FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

fix renaming · webpack/webpack@82a0f2a · GitHub

Commit 82a0f2a

Browse files
committed
fix renaming
1 parent 261a73e commit 82a0f2a

2 files changed

Lines changed: 11 additions & 7 deletions

File tree

‎lib/NodeStuffPlugin.js‎

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -69,13 +69,16 @@ class NodeStuffPlugin {
6969
);
7070
}
7171
});
72-
parser.hooks.canRename.for("global").tap(
73-
{
74-
name: "NodeStuffPlugin",
75-
stage: -10
76-
},
77-
() => false
78-
);
72+
parser.hooks.rename.for("global").tap("NodeStuffPlugin", expr => {
73+
const dep = new ConstDependency(
74+
RuntimeGlobals.global,
75+
expr.range,
76+
[RuntimeGlobals.global]
77+
);
78+
dep.loc = expr.loc;
79+
parser.state.module.addPresentationalDependency(dep);
80+
return false;
81+
});
7982
}
8083

8184
const setModuleConstant = (expressionName, fn, warning) => {

‎test/configCases/web/node-source-global/index.js‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,6 @@ it("should disallow rename global", () => {
44
var method = shouldBeGlobal[String.fromCharCode(40, 40, 40)];
55
method && method();
66
eval("expect(shouldBeGlobal.value1).toBe('value1')");
7+
expect(shouldBeGlobal.test).toBe("test");
78
expect(global.test).toBe("test");
89
});

0 commit comments

Comments
 (0)

Back | FazBrowse Home | New Git URL