Fail build on deep requires in npm packages (#21063)
Dan Abramov committed
Mar 24, 2021 at 02:43 UTC
7b84dbd1697609d4df5931422c9591fe62022cb9
1 file changed
+11
scripts/rollup/build.js
+11
@@ -582,6 +582,17 @@ async function createBundle(bundle, bundleType) {
582
const containsThisModule = pkg => id === pkg || id.startsWith(pkg + '/');
583
const isProvidedByDependency = externals.some(containsThisModule);
584
if (!shouldBundleDependencies && isProvidedByDependency) {
585
+ if (id.indexOf('/src/') !== -1) {
586
+ throw Error(
587
+ 'You are trying to import ' +
588
+ id +
589
+ ' but ' +
590
+ externals.find(containsThisModule) +
591
+ ' is one of npm dependencies, ' +
592
+ 'so it will not contain that source file. You probably want ' +
593
+ 'to create a new bundle entry point for it instead.'
594
+ );
595
+ }
596
return true;
597
}
598
return !!peerGlobals[id];