Skip to content

Commit

Permalink
feat: exit build with error when fail to resolve module (#466)
Browse files Browse the repository at this point in the history
fix #459
  • Loading branch information
AlexandreBonaventure authored Jul 2, 2020
1 parent 046428c commit ebfeed2
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/node/build/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down

0 comments on commit ebfeed2

Please sign in to comment.