From 8b6ce9f880d9ec695698936bcec7e43dc9ac04ca Mon Sep 17 00:00:00 2001 From: Alexandre Geissmann Date: Thu, 25 Jun 2020 19:12:35 -0400 Subject: [PATCH] feat: exit build with error when fail to resolve module (fix #459) --- src/node/build/index.ts | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/node/build/index.ts b/src/node/build/index.ts index d8d41710fc2af1..1eed860d65d83d 100644 --- a/src/node/build/index.ts +++ b/src/node/build/index.ts @@ -59,6 +59,13 @@ const dynamicImportWarningIgnoreList = [ export const onRollupWarning: ( spinner: Ora | undefined ) => InputOptions['onwarn'] = (spinner) => (warning, warn) => { + if (warning.code === 'UNRESOLVED_IMPORT') { + console.error( + chalk.red(`[vite]: Rollup failed to resolve a module, this is most likely unintended because it can break your application at runtime. +If you do want to externalize this module explicitly add it to \`rollupInputOptions.external\``) + ) + throw new Error(warning.message) + } if ( warning.plugin === 'rollup-plugin-dynamic-import-variables' && dynamicImportWarningIgnoreList.some((msg) => warning.message.includes(msg))