utils.js 863 B

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