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.

RequireEnsureDependenciesBlock.js 864B

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 RequireEnsureDependency = require("./RequireEnsureDependency");
  8. module.exports = class RequireEnsureDependenciesBlock extends AsyncDependenciesBlock {
  9. constructor(
  10. expr,
  11. successExpression,
  12. errorExpression,
  13. chunkName,
  14. chunkNameRange,
  15. module,
  16. loc
  17. ) {
  18. super(chunkName, module, loc, null);
  19. this.expr = expr;
  20. const successBodyRange =
  21. successExpression &&
  22. successExpression.body &&
  23. successExpression.body.range;
  24. if (successBodyRange) {
  25. this.range = [successBodyRange[0] + 1, successBodyRange[1] - 1];
  26. }
  27. this.chunkNameRange = chunkNameRange;
  28. const dep = new RequireEnsureDependency(this);
  29. dep.loc = loc;
  30. this.addDependency(dep);
  31. }
  32. };