ImportMetaContextDependency.js 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. /*
  2. MIT License http://www.opensource.org/licenses/mit-license.php
  3. Author Ivan Kopeykin @vankop
  4. */
  5. "use strict";
  6. const makeSerializable = require("../util/makeSerializable");
  7. const ContextDependency = require("./ContextDependency");
  8. const ModuleDependencyTemplateAsRequireId = require("./ModuleDependencyTemplateAsRequireId");
  9. /** @typedef {import("../javascript/JavascriptParser").Range} Range */
  10. /** @typedef {import("./ContextDependency").ContextDependencyOptions} ContextDependencyOptions */
  11. class ImportMetaContextDependency extends ContextDependency {
  12. /**
  13. * @param {ContextDependencyOptions} options options
  14. * @param {Range} range range
  15. */
  16. constructor(options, range) {
  17. super(options);
  18. this.range = range;
  19. }
  20. get category() {
  21. return "esm";
  22. }
  23. get type() {
  24. return `import.meta.webpackContext ${this.options.mode}`;
  25. }
  26. }
  27. makeSerializable(
  28. ImportMetaContextDependency,
  29. "webpack/lib/dependencies/ImportMetaContextDependency"
  30. );
  31. ImportMetaContextDependency.Template = ModuleDependencyTemplateAsRequireId;
  32. module.exports = ImportMetaContextDependency;