diff --git a/src/node/build/index.ts b/src/node/build/index.ts index 192b4101136149..7e9dd6c53324a9 100644 --- a/src/node/build/index.ts +++ b/src/node/build/index.ts @@ -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() + } } } @@ -220,7 +230,7 @@ export async function build(options: BuildConfig): Promise { input: path.resolve(root, 'index.html'), preserveEntrySignatures: false, treeshake: { moduleSideEffects: 'no-external' }, - onwarn: onRollupWarning, + onwarn: onRollupWarning(spinner), ...rollupInputOptions, plugins: [ ...basePlugins, diff --git a/src/node/depOptimizer.ts b/src/node/depOptimizer.ts index b942ed27dde0a5..ab4b72d19f2941 100644 --- a/src/node/depOptimizer.ts +++ b/src/node/depOptimizer.ts @@ -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)),