Non puoi selezionare più di 25 argomenti Gli argomenti devono iniziare con una lettera o un numero, possono includere trattini ('-') e possono essere lunghi fino a 35 caratteri.
 
 
 
 

27 righe
719 B

  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;