bcd17bd2ba013c92afc2b375b343b1977b7fe09facdf5d8b409896884ec11c5e4d9321d3ba6d1a6ce857d1e13ae7d2e99361b3e1b144ac2e48c65350a0f27b 719 B

1234567891011121314151617181920212223242526
  1. /*
  2. MIT License http://www.opensource.org/licenses/mit-license.php
  3. Author Florent Cailhol @ooflorent
  4. */
  5. "use strict";
  6. const ConstDependency = require("./ConstDependency");
  7. class HarmonyTopLevelThisParserPlugin {
  8. apply(parser) {
  9. parser.hooks.expression
  10. .for("this")
  11. .tap("HarmonyTopLevelThisParserPlugin", node => {
  12. if (!parser.scope.topLevelScope) return;
  13. const module = parser.state.module;
  14. const isHarmony = !!(module.buildMeta && module.buildMeta.exportsType);
  15. if (isHarmony) {
  16. const dep = new ConstDependency("undefined", node.range, false);
  17. dep.loc = node.loc;
  18. parser.state.current.addDependency(dep);
  19. }
  20. });
  21. }
  22. }
  23. module.exports = HarmonyTopLevelThisParserPlugin;