mirror of https://github.com/webpack/webpack.git
fix incorrect parsing of define functions
fix invalid code when using declaring local modules and arrow functions are supported
This commit is contained in:
parent
1b463f9820
commit
0c4e157196
|
|
@ -68,7 +68,7 @@ const DEFINITIONS = {
|
|||
lf: {
|
||||
definition: "var XXX, XXXmodule;",
|
||||
content:
|
||||
"!(XXXmodule = { id: YYY, exports: {}, loaded: false }, XXX = #.call(XXXmodule.exports, __webpack_require__, XXXmodule.exports, XXXmodule), XXXmodule.loaded = true, XXX === undefined && (XXX = XXXmodule.exports))",
|
||||
"!(XXXmodule = { id: YYY, exports: {}, loaded: false }, XXX = (#).call(XXXmodule.exports, __webpack_require__, XXXmodule.exports, XXXmodule), XXXmodule.loaded = true, XXX === undefined && (XXX = XXXmodule.exports))",
|
||||
requests: [RuntimeGlobals.require, RuntimeGlobals.module]
|
||||
},
|
||||
lo: {
|
||||
|
|
|
|||
|
|
@ -276,6 +276,10 @@ class AMDDefineDependencyParserPlugin {
|
|||
}
|
||||
parser.scope.inTry = inTry;
|
||||
if (fn.body.type === "BlockStatement") {
|
||||
parser.detectMode(fn.body.body);
|
||||
const prev = parser.prevStatement;
|
||||
parser.preWalkStatement(fn.body);
|
||||
parser.prevStatement = prev;
|
||||
parser.walkStatement(fn.body);
|
||||
} else {
|
||||
parser.walkExpression(fn.body);
|
||||
|
|
@ -293,6 +297,10 @@ class AMDDefineDependencyParserPlugin {
|
|||
}
|
||||
parser.scope.inTry = inTry;
|
||||
if (fn.callee.object.body.type === "BlockStatement") {
|
||||
parser.detectMode(fn.callee.object.body.body);
|
||||
const prev = parser.prevStatement;
|
||||
parser.preWalkStatement(fn.callee.object.body);
|
||||
parser.prevStatement = prev;
|
||||
parser.walkStatement(fn.callee.object.body);
|
||||
} else {
|
||||
parser.walkExpression(fn.callee.object.body);
|
||||
|
|
|
|||
|
|
@ -0,0 +1,3 @@
|
|||
it("should not replace declared variables", () => {
|
||||
expect(require("./module")).toBe(42 + 42);
|
||||
});
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
define("local", () => {
|
||||
var __webpack_modules__ = 42;
|
||||
|
||||
return __webpack_modules__;
|
||||
});
|
||||
|
||||
define(["local"], l => {
|
||||
var __webpack_modules__ = 42 + l;
|
||||
|
||||
return __webpack_modules__;
|
||||
});
|
||||
Loading…
Reference in New Issue