UI for Zipcoin Blue

RequireIncludeDependency.js 922B

12345678910111213141516171819202122232425262728293031323334
  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 RequireIncludeDependency extends ModuleDependency {
  8. constructor(request, range) {
  9. super(request);
  10. this.range = range;
  11. }
  12. get type() {
  13. return "require.include";
  14. }
  15. }
  16. RequireIncludeDependency.Template = class RequireIncludeDependencyTemplate {
  17. apply(dep, source, outputOptions, requestShortener) {
  18. const comment = this.getOptionalComment(outputOptions.pathinfo && dep.module, requestShortener.shorten(dep.request));
  19. source.replace(dep.range[0], dep.range[1] - 1, `undefined${comment}`);
  20. }
  21. getOptionalComment(shouldHaveComment, shortenedRequest) {
  22. if(shouldHaveComment) {
  23. return "";
  24. }
  25. return `/*! require.include ${shortenedRequest} */`;
  26. }
  27. };
  28. module.exports = RequireIncludeDependency;