AMDRequireDependenciesBlock.js 1.1 KB

123456789101112131415161718192021222324252627282930313233
  1. /*
  2. MIT License http://www.opensource.org/licenses/mit-license.php
  3. Author Tobias Koppers @sokra
  4. */
  5. "use strict";
  6. const AsyncDependenciesBlock = require("../AsyncDependenciesBlock");
  7. const AMDRequireDependency = require("./AMDRequireDependency");
  8. module.exports = class AMDRequireDependenciesBlock extends AsyncDependenciesBlock {
  9. constructor(expr, arrayRange, functionRange, errorCallbackRange, module, loc) {
  10. super(null, module, loc);
  11. this.expr = expr;
  12. this.outerRange = expr.range;
  13. this.arrayRange = arrayRange;
  14. this.functionRange = functionRange;
  15. this.errorCallbackRange = errorCallbackRange;
  16. this.bindThis = true;
  17. if(arrayRange && functionRange && errorCallbackRange) {
  18. this.range = [arrayRange[0], errorCallbackRange[1]];
  19. } else if(arrayRange && functionRange) {
  20. this.range = [arrayRange[0], functionRange[1]];
  21. } else if(arrayRange) {
  22. this.range = arrayRange;
  23. } else if(functionRange) {
  24. this.range = functionRange;
  25. } else {
  26. this.range = expr.range;
  27. }
  28. const dep = new AMDRequireDependency(this);
  29. dep.loc = loc;
  30. this.addDependency(dep);
  31. }
  32. };