Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

ContextDependencyTemplateAsId.js 1.1KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. /*
  2. MIT License http://www.opensource.org/licenses/mit-license.php
  3. Author Tobias Koppers @sokra
  4. */
  5. "use strict";
  6. class ContextDependencyTemplateAsId {
  7. apply(dep, source, runtime) {
  8. const moduleExports = runtime.moduleExports({
  9. module: dep.module,
  10. request: dep.request
  11. });
  12. if (dep.module) {
  13. if (dep.valueRange) {
  14. if (Array.isArray(dep.replaces)) {
  15. for (let i = 0; i < dep.replaces.length; i++) {
  16. const rep = dep.replaces[i];
  17. source.replace(rep.range[0], rep.range[1] - 1, rep.value);
  18. }
  19. }
  20. source.replace(dep.valueRange[1], dep.range[1] - 1, ")");
  21. // TODO webpack 5 remove `prepend` it's no longer used
  22. source.replace(
  23. dep.range[0],
  24. dep.valueRange[0] - 1,
  25. `${moduleExports}.resolve(${
  26. typeof dep.prepend === "string" ? JSON.stringify(dep.prepend) : ""
  27. }`
  28. );
  29. } else {
  30. source.replace(
  31. dep.range[0],
  32. dep.range[1] - 1,
  33. `${moduleExports}.resolve`
  34. );
  35. }
  36. } else {
  37. source.replace(dep.range[0], dep.range[1] - 1, moduleExports);
  38. }
  39. }
  40. }
  41. module.exports = ContextDependencyTemplateAsId;