UI for Zipcoin Blue

ContextDependencyTemplateAsRequireCall.js 1.4KB

1234567891011121314151617181920212223242526272829303132333435
  1. /*
  2. MIT License http://www.opensource.org/licenses/mit-license.php
  3. Author Tobias Koppers @sokra
  4. */
  5. "use strict";
  6. class ContextDependencyTemplateAsRequireCall {
  7. apply(dep, source, outputOptions, requestShortener) {
  8. const comment = outputOptions.pathinfo ?
  9. "/*! " + requestShortener.shorten(dep.request) + " */ " : "";
  10. const containsDeps = dep.module && dep.module.dependencies && dep.module.dependencies.length > 0;
  11. const isAsync = dep.module && dep.module.async;
  12. if(dep.module && (isAsync || containsDeps)) {
  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. source.replace(dep.range[0], dep.valueRange[0] - 1, "__webpack_require__(" + comment + JSON.stringify(dep.module.id) + ")(" + (typeof dep.prepend === "string" ? JSON.stringify(dep.prepend) : "") + "");
  22. } else {
  23. source.replace(dep.range[0], dep.range[1] - 1, "__webpack_require__(" + comment + JSON.stringify(dep.module.id) + ")");
  24. }
  25. } else {
  26. const content = require("./WebpackMissingModule").module(dep.request);
  27. source.replace(dep.range[0], dep.range[1] - 1, content);
  28. }
  29. }
  30. }
  31. module.exports = ContextDependencyTemplateAsRequireCall;