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.

26 lines
682 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 RequireHeaderDependency extends NullDependency {
  8. constructor(range) {
  9. super();
  10. if (!Array.isArray(range)) throw new Error("range must be valid");
  11. this.range = range;
  12. }
  13. }
  14. RequireHeaderDependency.Template = class RequireHeaderDependencyTemplate {
  15. apply(dep, source) {
  16. source.replace(dep.range[0], dep.range[1] - 1, "__webpack_require__");
  17. }
  18. applyAsTemplateArgument(name, dep, source) {
  19. source.replace(dep.range[0], dep.range[1] - 1, "require");
  20. }
  21. };
  22. module.exports = RequireHeaderDependency;