Skip to content

Commit

Permalink
Fail build on deep requires in npm packages (#21063)
Browse files Browse the repository at this point in the history
  • Loading branch information
gaearon authored Mar 24, 2021
1 parent 2c9d8ef commit 7b84dbd
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions scripts/rollup/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -582,6 +582,17 @@ async function createBundle(bundle, bundleType) {
const containsThisModule = pkg => id === pkg || id.startsWith(pkg + '/');
const isProvidedByDependency = externals.some(containsThisModule);
if (!shouldBundleDependencies && isProvidedByDependency) {
if (id.indexOf('/src/') !== -1) {
throw Error(
'You are trying to import ' +
id +
' but ' +
externals.find(containsThisModule) +
' is one of npm dependencies, ' +
'so it will not contain that source file. You probably want ' +
'to create a new bundle entry point for it instead.'
);
}
return true;
}
return !!peerGlobals[id];
Expand Down

0 comments on commit 7b84dbd

Please sign in to comment.