UI for Zipcoin Blue

HarmonyAcceptDependency.js 1.2KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  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. const makeHarmonyImportStatement = require("./HarmonyImportDependency").makeImportStatement;
  8. class HarmonyAcceptDependency extends NullDependency {
  9. constructor(range, dependencies, hasCallback) {
  10. super();
  11. this.range = range;
  12. this.dependencies = dependencies;
  13. this.hasCallback = hasCallback;
  14. }
  15. get type() {
  16. return "accepted harmony modules";
  17. }
  18. }
  19. HarmonyAcceptDependency.Template = class HarmonyAcceptDependencyTemplate {
  20. apply(dep, source, outputOptions, requestShortener) {
  21. const content = dep.dependencies
  22. .map(dependency => makeHarmonyImportStatement(
  23. false,
  24. dependency,
  25. outputOptions,
  26. requestShortener
  27. )).join("");
  28. if(dep.hasCallback) {
  29. source.insert(dep.range[0], `function(__WEBPACK_OUTDATED_DEPENDENCIES__) { ${content}(`);
  30. source.insert(dep.range[1], ")(__WEBPACK_OUTDATED_DEPENDENCIES__); }");
  31. return;
  32. }
  33. source.insert(dep.range[1] - 0.5, `, function() { ${content} }`);
  34. }
  35. };
  36. module.exports = HarmonyAcceptDependency;