From 14abfe70237a1bc0bf08c5c47edde5d7c37a072e Mon Sep 17 00:00:00 2001 From: Alexandre Bonaventure Geissmann Date: Thu, 2 Jul 2020 15:37:09 -0400 Subject: [PATCH] feat: exit build with error when fail to resolve module (#466) 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 f8bb3eddf6c435..81941ff7f0ad41 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))