LocalModuleDependency.js 625 B

123456789101112131415161718192021222324
  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 LocalModuleDependency extends NullDependency {
  8. constructor(localModule, range) {
  9. super();
  10. localModule.flagUsed();
  11. this.localModule = localModule;
  12. this.range = range;
  13. }
  14. }
  15. LocalModuleDependency.Template = class LocalModuleDependencyTemplate {
  16. apply(dep, source) {
  17. if(!dep.range) return;
  18. source.replace(dep.range[0], dep.range[1] - 1, dep.localModule.variableName());
  19. }
  20. };
  21. module.exports = LocalModuleDependency;