getSourceModules.js 726 B

12345678910111213141516171819202122
  1. /*
  2. MIT License http://www.opensource.org/licenses/mit-license.php
  3. Author Alexander Akait @alexander-akait
  4. */
  5. "use strict";
  6. const ConcatenatedModule = require("../optimize/ConcatenatedModule");
  7. /** @import Module from "../Module" */
  8. /**
  9. * Yields the modules a user wrote, looking through scope hoisting: a
  10. * concatenation is one module in the chunk graph but several on disk, and a
  11. * hint about bytes or duplication has to name the ones on disk.
  12. * @param {Module} module a module from the chunk graph
  13. * @returns {Iterable<Module>} the modules it was built from, or itself
  14. */
  15. const getSourceModules = (module) =>
  16. module instanceof ConcatenatedModule ? module.modules : [module];
  17. module.exports = getSourceModules;