fix: add --pure flag

closes #349
This commit is contained in:
EGOIST 2021-07-06 16:39:43 +08:00
parent 3ca80afe32
commit 17ac44cd2f
2 changed files with 6 additions and 0 deletions

View File

@ -67,6 +67,7 @@ export async function main(options: Options = {}) {
'--silent',
'Supress non-error logs (excluding "onSuccess" process output)'
)
.option('--pure <express>', 'Mark specific expressions as pure')
.action(async (files: string[], flags) => {
const { build } = await import('.')
Object.assign(options, {

View File

@ -101,6 +101,10 @@ export type Options = {
* Skip node_modules bundling
*/
skipNodeModulesBundle?: boolean
/**
* @see https://esbuild.github.io/api/#pure
*/
pure?: string | string[]
}
export type NormalizedOptions = MarkRequired<
@ -204,6 +208,7 @@ export async function runEsbuild(
minifySyntax: options.minifySyntax,
keepNames: options.keepNames,
incremental: !!options.watch,
pure: typeof options.pure === 'string' ? [options.pure] : options.pure,
})
} catch (error) {
log(format, 'error', 'Build failed')