SelfModuleFactory.js 844 B

123456789101112131415161718192021222324252627282930313233
  1. /*
  2. MIT License http://www.opensource.org/licenses/mit-license.php
  3. Author Tobias Koppers @sokra
  4. */
  5. "use strict";
  6. /** @typedef {import("./ModuleFactory").ModuleFactoryCreateData} ModuleFactoryCreateData */
  7. /** @typedef {import("./ModuleFactory").ModuleFactoryResult} ModuleFactoryResult */
  8. /** @typedef {import("./ModuleGraph")} ModuleGraph */
  9. class SelfModuleFactory {
  10. /**
  11. * @param {ModuleGraph} moduleGraph module graph
  12. */
  13. constructor(moduleGraph) {
  14. this.moduleGraph = moduleGraph;
  15. }
  16. /**
  17. * @param {ModuleFactoryCreateData} data data object
  18. * @param {function((Error | null)=, ModuleFactoryResult=): void} callback callback
  19. * @returns {void}
  20. */
  21. create(data, callback) {
  22. const module = this.moduleGraph.getParentModule(data.dependencies[0]);
  23. callback(null, {
  24. module
  25. });
  26. }
  27. }
  28. module.exports = SelfModuleFactory;