Revert "Don't scan require calls in Browserify/Webpack bundles."

This reverts commit 99cb96fcf7.

Webpack already avoids this problem by transforming `require` to
`__webpack_require__`, and Browserify bundles can use something like
https://www.npmjs.com/package/derequire to rewrite ``require` calls to
avoid confusing other tools. False positives are acceptable, and we can
measure/mitigate the performance consequences in any number of ways.

Fixes #6427.
Fixes #6430.
This commit is contained in:
Ben Newman
2016-03-08 12:13:15 -05:00
parent d01e0be293
commit 62c41b2ef5

View File

@@ -83,10 +83,6 @@ export function findImportedModuleIdentifiers(source, hash) {
while (left < right && end < possibleIndexes[right - 1]) --right;
if (left < right) {
if (isFunctionWithParameter(node, "require")) {
return;
}
let id = getRequiredModuleId(node);
if (typeof id === "string") {
identifiers[id] = node;
@@ -129,18 +125,6 @@ function isNode(value) {
&& typeof value.end === "number";
}
function isFunctionWithParameter(node, name) {
if (node.type === "FunctionExpression" ||
node.type === "FunctionDeclaration" ||
node.type === "ArrowFunctionExpression") {
return node.params.some(
param =>
param.type === "Identifier" &&
param.name === name
);
}
}
function getRequiredModuleId(node) {
if (node.type === "CallExpression" &&
node.callee.type === "Identifier" &&