Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/angry-goats-knock.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"microbundle": patch
---

Add friendly microbundle-specific errors when modules can't be resolved.
17 changes: 17 additions & 0 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -412,9 +412,26 @@ function createConfig(options, entry, format, writeMeta) {
}
return externalTest(id);
},

onwarn(warning, warn) {
// https://github.com/rollup/rollup/blob/0fa9758cb7b1976537ae0875d085669e3a21e918/src/utils/error.ts#L324
if (warning.code === 'UNRESOLVED_IMPORT') {
stdout(
`Failed to resolve the module ${warning.source} imported by ${warning.importer}` +
`\nIs the module installed? Note:` +
`\n ↳ to inline a module into your bundle, install it to "devDependencies".` +
`\n ↳ to depend on a module via import/require, install it to "dependencies".`,
);
return;
}

warn(warning);
},

treeshake: {
propertyReadSideEffects: false,
},

plugins: []
.concat(
postcss({
Expand Down