Skip to content

Commit

Permalink
fix: ora swallow rollup warning (#269)
Browse files Browse the repository at this point in the history
  • Loading branch information
csr632 committed May 26, 2020
1 parent d71a06d commit 610a004
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
14 changes: 12 additions & 2 deletions src/node/build/index.ts
Expand Up @@ -45,9 +45,19 @@ const writeColors = {

const warningIgnoreList = [`CIRCULAR_DEPENDENCY`, `THIS_IS_UNDEFINED`]

export const onRollupWarning: InputOptions['onwarn'] = (warning, warn) => {
export const onRollupWarning: (
spinner: Ora | undefined
) => InputOptions['onwarn'] = (spinner) => (warning, warn) => {
if (!warningIgnoreList.includes(warning.code!)) {
// ora would swallow the console.warn if we let it keep running
// https://github.com/sindresorhus/ora/issues/90
if (spinner) {
spinner.stop()
}
warn(warning)
if (spinner) {
spinner.start()
}
}
}

Expand Down Expand Up @@ -220,7 +230,7 @@ export async function build(options: BuildConfig): Promise<BuildResult> {
input: path.resolve(root, 'index.html'),
preserveEntrySignatures: false,
treeshake: { moduleSideEffects: 'no-external' },
onwarn: onRollupWarning,
onwarn: onRollupWarning(spinner),
...rollupInputOptions,
plugins: [
...basePlugins,
Expand Down
2 changes: 1 addition & 1 deletion src/node/depOptimizer.ts
Expand Up @@ -223,7 +223,7 @@ export async function optimizeDeps(
input,
external: preservedDeps,
treeshake: { moduleSideEffects: 'no-external' },
onwarn: onRollupWarning,
onwarn: onRollupWarning(spinner),
...config.rollupInputOptions,
plugins: [
...(await createBaseRollupPlugins(root, resolver, config)),
Expand Down

0 comments on commit 610a004

Please sign in to comment.