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.

47 lines
1.2 KiB

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 AsyncDependenciesBlock = require("../AsyncDependenciesBlock");
  7. const AMDRequireDependency = require("./AMDRequireDependency");
  8. module.exports = class AMDRequireDependenciesBlock extends AsyncDependenciesBlock {
  9. constructor(
  10. expr,
  11. arrayRange,
  12. functionRange,
  13. errorCallbackRange,
  14. module,
  15. loc,
  16. request
  17. ) {
  18. super(null, module, loc, request);
  19. this.expr = expr;
  20. this.outerRange = expr.range;
  21. this.arrayRange = arrayRange;
  22. this.functionBindThis = false;
  23. this.functionRange = functionRange;
  24. this.errorCallbackBindThis = false;
  25. this.errorCallbackRange = errorCallbackRange;
  26. this.bindThis = true;
  27. if (arrayRange && functionRange && errorCallbackRange) {
  28. this.range = [arrayRange[0], errorCallbackRange[1]];
  29. } else if (arrayRange && functionRange) {
  30. this.range = [arrayRange[0], functionRange[1]];
  31. } else if (arrayRange) {
  32. this.range = arrayRange;
  33. } else if (functionRange) {
  34. this.range = functionRange;
  35. } else {
  36. this.range = expr.range;
  37. }
  38. const dep = this.newRequireDependency();
  39. dep.loc = loc;
  40. this.addDependency(dep);
  41. }
  42. newRequireDependency() {
  43. return new AMDRequireDependency(this);
  44. }
  45. };