| 1 | "use strict";
|
|---|
| 2 |
|
|---|
| 3 | Object.defineProperty(exports, "__esModule", {
|
|---|
| 4 | value: true
|
|---|
| 5 | });
|
|---|
| 6 | exports.default = getModuleName;
|
|---|
| 7 | const originalGetModuleName = getModuleName;
|
|---|
| 8 | exports.default = getModuleName = function getModuleName(rootOpts, pluginOpts) {
|
|---|
| 9 | var _pluginOpts$moduleId, _pluginOpts$moduleIds, _pluginOpts$getModule, _pluginOpts$moduleRoo;
|
|---|
| 10 | return originalGetModuleName(rootOpts, {
|
|---|
| 11 | moduleId: (_pluginOpts$moduleId = pluginOpts.moduleId) != null ? _pluginOpts$moduleId : rootOpts.moduleId,
|
|---|
| 12 | moduleIds: (_pluginOpts$moduleIds = pluginOpts.moduleIds) != null ? _pluginOpts$moduleIds : rootOpts.moduleIds,
|
|---|
| 13 | getModuleId: (_pluginOpts$getModule = pluginOpts.getModuleId) != null ? _pluginOpts$getModule : rootOpts.getModuleId,
|
|---|
| 14 | moduleRoot: (_pluginOpts$moduleRoo = pluginOpts.moduleRoot) != null ? _pluginOpts$moduleRoo : rootOpts.moduleRoot
|
|---|
| 15 | });
|
|---|
| 16 | };
|
|---|
| 17 | function getModuleName(rootOpts, pluginOpts) {
|
|---|
| 18 | const {
|
|---|
| 19 | filename,
|
|---|
| 20 | filenameRelative = filename,
|
|---|
| 21 | sourceRoot = pluginOpts.moduleRoot
|
|---|
| 22 | } = rootOpts;
|
|---|
| 23 | const {
|
|---|
| 24 | moduleId,
|
|---|
| 25 | moduleIds = !!moduleId,
|
|---|
| 26 | getModuleId,
|
|---|
| 27 | moduleRoot = sourceRoot
|
|---|
| 28 | } = pluginOpts;
|
|---|
| 29 | if (!moduleIds) return null;
|
|---|
| 30 | if (moduleId != null && !getModuleId) {
|
|---|
| 31 | return moduleId;
|
|---|
| 32 | }
|
|---|
| 33 | let moduleName = moduleRoot != null ? moduleRoot + "/" : "";
|
|---|
| 34 | if (filenameRelative) {
|
|---|
| 35 | const sourceRootReplacer = sourceRoot != null ? new RegExp("^" + sourceRoot + "/?") : "";
|
|---|
| 36 | moduleName += filenameRelative.replace(sourceRootReplacer, "").replace(/\.\w*$/, "");
|
|---|
| 37 | }
|
|---|
| 38 | moduleName = moduleName.replace(/\\/g, "/");
|
|---|
| 39 | if (getModuleId) {
|
|---|
| 40 | return getModuleId(moduleName) || moduleName;
|
|---|
| 41 | } else {
|
|---|
| 42 | return moduleName;
|
|---|
| 43 | }
|
|---|
| 44 | }
|
|---|
| 45 |
|
|---|
| 46 | //# sourceMappingURL=get-module-name.js.map
|
|---|