a zip code crypto-currency system good for red ONLY

HarmonyExportExpressionDependency.js 1.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. /*
  2. MIT License http://www.opensource.org/licenses/mit-license.php
  3. Author Tobias Koppers @sokra
  4. */
  5. "use strict";
  6. const NullDependency = require("./NullDependency");
  7. class HarmonyExportExpressionDependency extends NullDependency {
  8. constructor(originModule, range, rangeStatement) {
  9. super();
  10. this.originModule = originModule;
  11. this.range = range;
  12. this.rangeStatement = rangeStatement;
  13. }
  14. get type() {
  15. return "harmony export expression";
  16. }
  17. getExports() {
  18. return {
  19. exports: ["default"]
  20. };
  21. }
  22. }
  23. HarmonyExportExpressionDependency.Template = class HarmonyExportDependencyTemplate {
  24. apply(dep, source) {
  25. const used = dep.originModule.isUsed("default");
  26. const content = this.getContent(dep.originModule, used);
  27. if(dep.range) {
  28. source.replace(dep.rangeStatement[0], dep.range[0] - 1, content + "(");
  29. source.replace(dep.range[1], dep.rangeStatement[1] - 1, ");");
  30. return;
  31. }
  32. source.replace(dep.rangeStatement[0], dep.rangeStatement[1] - 1, content);
  33. }
  34. getContent(module, used) {
  35. const exportsName = module.exportsArgument || "exports";
  36. if(used) {
  37. return `/* harmony default export */ ${exportsName}[${JSON.stringify(used)}] = `;
  38. }
  39. return "/* unused harmony default export */ var _unused_webpack_default_export = ";
  40. }
  41. };
  42. module.exports = HarmonyExportExpressionDependency;