AsyncDependencyToInitialChunkError.js 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. /*
  2. MIT License http://www.opensource.org/licenses/mit-license.php
  3. Author Sean Larkin @thelarkinn
  4. */
  5. "use strict";
  6. const WebpackError = require("./WebpackError");
  7. /** @typedef {import("./Dependency").DependencyLocation} DependencyLocation */
  8. /** @typedef {import("./Module")} Module */
  9. /**
  10. * Error raised when webpack detects an attempt to lazy-load a chunk name that
  11. * is already claimed by an entrypoint's initial chunk.
  12. */
  13. class AsyncDependencyToInitialChunkError extends WebpackError {
  14. /**
  15. * Captures the chunk name, originating module, and source location for an
  16. * invalid async dependency targeting an initial chunk.
  17. * @param {string} chunkName Name of Chunk
  18. * @param {Module} module module tied to dependency
  19. * @param {DependencyLocation} loc location of dependency
  20. */
  21. constructor(chunkName, module, loc) {
  22. super(
  23. `It's not allowed to load an initial chunk on demand. The chunk name "${chunkName}" is already used by an entrypoint.`
  24. );
  25. /** @type {string} */
  26. this.name = "AsyncDependencyToInitialChunkError";
  27. /** @type {Module} */
  28. this.module = module;
  29. /** @type {DependencyLocation} */
  30. this.loc = loc;
  31. }
  32. }
  33. module.exports = AsyncDependencyToInitialChunkError;