InvalidDependenciesModuleWarning.js 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. /*
  2. MIT License http://www.opensource.org/licenses/mit-license.php
  3. Author Tobias Koppers @sokra
  4. */
  5. "use strict";
  6. const WebpackError = require("./WebpackError");
  7. const makeSerializable = require("./util/makeSerializable");
  8. /** @typedef {import("./Dependency").DependencyLocation} DependencyLocation */
  9. /** @typedef {import("./Module")} Module */
  10. class InvalidDependenciesModuleWarning extends WebpackError {
  11. /**
  12. * @param {Module} module module tied to dependency
  13. * @param {Iterable<string>} deps invalid dependencies
  14. */
  15. constructor(module, deps) {
  16. const orderedDeps = deps ? Array.from(deps).sort() : [];
  17. const depsList = orderedDeps.map(dep => ` * ${JSON.stringify(dep)}`);
  18. super(`Invalid dependencies have been reported by plugins or loaders for this module. All reported dependencies need to be absolute paths.
  19. Invalid dependencies may lead to broken watching and caching.
  20. As best effort we try to convert all invalid values to absolute paths and converting globs into context dependencies, but this is deprecated behavior.
  21. Loaders: Pass absolute paths to this.addDependency (existing files), this.addMissingDependency (not existing files), and this.addContextDependency (directories).
  22. Plugins: Pass absolute paths to fileDependencies (existing files), missingDependencies (not existing files), and contextDependencies (directories).
  23. Globs: They are not supported. Pass absolute path to the directory as context dependencies.
  24. The following invalid values have been reported:
  25. ${depsList.slice(0, 3).join("\n")}${
  26. depsList.length > 3 ? "\n * and more ..." : ""
  27. }`);
  28. this.name = "InvalidDependenciesModuleWarning";
  29. this.details = depsList.slice(3).join("\n");
  30. this.module = module;
  31. }
  32. }
  33. makeSerializable(
  34. InvalidDependenciesModuleWarning,
  35. "webpack/lib/InvalidDependenciesModuleWarning"
  36. );
  37. module.exports = InvalidDependenciesModuleWarning;