ProvideSharedModuleFactory.js 1.0 KB

1234567891011121314151617181920212223242526272829303132333435
  1. /*
  2. MIT License http://www.opensource.org/licenses/mit-license.php
  3. Author Tobias Koppers @sokra and Zackary Jackson @ScriptedAlchemy
  4. */
  5. "use strict";
  6. const ModuleFactory = require("../ModuleFactory");
  7. const ProvideSharedModule = require("./ProvideSharedModule");
  8. /** @typedef {import("../ModuleFactory").ModuleFactoryCreateData} ModuleFactoryCreateData */
  9. /** @typedef {import("../ModuleFactory").ModuleFactoryResult} ModuleFactoryResult */
  10. /** @typedef {import("./ProvideSharedDependency")} ProvideSharedDependency */
  11. class ProvideSharedModuleFactory extends ModuleFactory {
  12. /**
  13. * @param {ModuleFactoryCreateData} data data object
  14. * @param {function(Error=, ModuleFactoryResult=): void} callback callback
  15. * @returns {void}
  16. */
  17. create(data, callback) {
  18. const dep = /** @type {ProvideSharedDependency} */ (data.dependencies[0]);
  19. callback(null, {
  20. module: new ProvideSharedModule(
  21. dep.shareScope,
  22. dep.name,
  23. dep.version,
  24. dep.request,
  25. dep.eager
  26. )
  27. });
  28. }
  29. }
  30. module.exports = ProvideSharedModuleFactory;