mirror of
https://github.com/zebrajr/react.git
synced 2025-12-06 12:20:20 +01:00
Fail build on deep requires in npm packages (#21063)
This commit is contained in:
parent
2c9d8efc8e
commit
7b84dbd169
|
|
@ -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];
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user