You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

34 lines
824 B

4 years ago
  1. /*
  2. MIT License http://www.opensource.org/licenses/mit-license.php
  3. Author Tobias Koppers @sokra
  4. */
  5. "use strict";
  6. const ModuleDependency = require("./ModuleDependency");
  7. class ImportWeakDependency extends ModuleDependency {
  8. constructor(request, originModule, range) {
  9. super(request);
  10. this.originModule = originModule;
  11. this.range = range;
  12. this.weak = true;
  13. }
  14. get type() {
  15. return "import() weak";
  16. }
  17. }
  18. ImportWeakDependency.Template = class ImportDependencyTemplate {
  19. apply(dep, source, runtime) {
  20. const content = runtime.moduleNamespacePromise({
  21. module: dep.module,
  22. request: dep.request,
  23. strict: dep.originModule.buildMeta.strictHarmonyModule,
  24. message: "import() weak",
  25. weak: true
  26. });
  27. source.replace(dep.range[0], dep.range[1] - 1, content);
  28. }
  29. };
  30. module.exports = ImportWeakDependency;