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