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.

33 lines
777 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 NullDependency = require("./NullDependency");
  7. class ConstDependency extends NullDependency {
  8. constructor(expression, range, requireWebpackRequire) {
  9. super();
  10. this.expression = expression;
  11. this.range = range;
  12. this.requireWebpackRequire = requireWebpackRequire;
  13. }
  14. updateHash(hash) {
  15. hash.update(this.range + "");
  16. hash.update(this.expression + "");
  17. }
  18. }
  19. ConstDependency.Template = class ConstDependencyTemplate {
  20. apply(dep, source) {
  21. if (typeof dep.range === "number") {
  22. source.insert(dep.range, dep.expression);
  23. return;
  24. }
  25. source.replace(dep.range[0], dep.range[1] - 1, dep.expression);
  26. }
  27. };
  28. module.exports = ConstDependency;