mirror of https://github.com/webpack/webpack.git
fix renaming
This commit is contained in:
parent
261a73e18e
commit
82a0f2add6
|
|
@ -69,13 +69,16 @@ class NodeStuffPlugin {
|
|||
);
|
||||
}
|
||||
});
|
||||
parser.hooks.canRename.for("global").tap(
|
||||
{
|
||||
name: "NodeStuffPlugin",
|
||||
stage: -10
|
||||
},
|
||||
() => false
|
||||
);
|
||||
parser.hooks.rename.for("global").tap("NodeStuffPlugin", expr => {
|
||||
const dep = new ConstDependency(
|
||||
RuntimeGlobals.global,
|
||||
expr.range,
|
||||
[RuntimeGlobals.global]
|
||||
);
|
||||
dep.loc = expr.loc;
|
||||
parser.state.module.addPresentationalDependency(dep);
|
||||
return false;
|
||||
});
|
||||
}
|
||||
|
||||
const setModuleConstant = (expressionName, fn, warning) => {
|
||||
|
|
|
|||
|
|
@ -4,5 +4,6 @@ it("should disallow rename global", () => {
|
|||
var method = shouldBeGlobal[String.fromCharCode(40, 40, 40)];
|
||||
method && method();
|
||||
eval("expect(shouldBeGlobal.value1).toBe('value1')");
|
||||
expect(shouldBeGlobal.test).toBe("test");
|
||||
expect(global.test).toBe("test");
|
||||
});
|
||||
|
|
|
|||
Loading…
Reference in New Issue