1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 | "use strict";
|
7 |
|
8 | const ConstDependency = require("./ConstDependency");
|
9 | const HarmonyExports = require("./HarmonyExports");
|
10 |
|
11 | class HarmonyTopLevelThisParserPlugin {
|
12 | apply(parser) {
|
13 | parser.hooks.expression
|
14 | .for("this")
|
15 | .tap("HarmonyTopLevelThisParserPlugin", node => {
|
16 | if (!parser.scope.topLevelScope) return;
|
17 | if (HarmonyExports.isEnabled(parser.state)) {
|
18 | const dep = new ConstDependency("undefined", node.range, null);
|
19 | dep.loc = node.loc;
|
20 | parser.state.module.addPresentationalDependency(dep);
|
21 | return this;
|
22 | }
|
23 | });
|
24 | }
|
25 | }
|
26 |
|
27 | module.exports = HarmonyTopLevelThisParserPlugin;
|