| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -69,13 +69,16 @@ class NodeStuffPlugin { | |||
| 69 | 69 | ); | |
| 70 | 70 | } | |
| 71 | 71 | }); | |
| 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 | + }); | ||
| 79 | 82 | } | |
| 80 | 83 | ||
| 81 | 84 | const setModuleConstant = (expressionName, fn, warning) => { | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -4,5 +4,6 @@ it("should disallow rename global", () => { | |||
| 4 | 4 | var method = shouldBeGlobal[String.fromCharCode(40, 40, 40)]; | |
| 5 | 5 | method && method(); | |
| 6 | 6 | eval("expect(shouldBeGlobal.value1).toBe('value1')"); | |
| 7 | + expect(shouldBeGlobal.test).toBe("test"); | ||
| 7 | 8 | expect(global.test).toBe("test"); | |
| 8 | 9 | }); | |
| Back | FazBrowse Home | New Git URL |
0 commit comments