You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

20 lines
729 B

3 months ago
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", {
  3. value: true
  4. });
  5. exports.getModulePathParts = getModulePathParts;
  6. const MULTI_MODULE_REGEXP = /^multi /u;
  7. function getModulePathParts(moduleData) {
  8. if (MULTI_MODULE_REGEXP.test(moduleData.identifier)) {
  9. return [moduleData.identifier];
  10. }
  11. const loaders = moduleData.name.split('!'); // Removing loaders from module path: they're joined by `!` and the last part is a raw module path
  12. const parsedPath = loaders[loaders.length - 1] // Splitting module path into parts
  13. .split('/') // Removing first `.`
  14. .slice(1) // Replacing `~` with `node_modules`
  15. .map(part => part === '~' ? 'node_modules' : part);
  16. return parsedPath.length ? parsedPath : null;
  17. }