From 62c41b2ef579cc3a301aabb660eeae77cb227e4c Mon Sep 17 00:00:00 2001 From: Ben Newman Date: Tue, 8 Mar 2016 12:13:15 -0500 Subject: [PATCH] Revert "Don't scan require calls in Browserify/Webpack bundles." This reverts commit 99cb96fcf76cb08cc389d354ec8ed42ef74e8ae9. 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. --- tools/isobuild/js-analyze.js | 16 ---------------- 1 file changed, 16 deletions(-) diff --git a/tools/isobuild/js-analyze.js b/tools/isobuild/js-analyze.js index 171fb072c1..97b0c8f0ff 100644 --- a/tools/isobuild/js-analyze.js +++ b/tools/isobuild/js-analyze.js @@ -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" &&