15989596284dffee63c8b62277ba1d9e9c3e14756dd4e02a3f19f05c6676fdee61d69cf2a4dc336f4f6977f4a2b7e676a41ced6fd772de7792bf8223dfed9a 621 B

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