source: trip-planner-front/node_modules/@babel/helper-module-transforms/lib/get-module-name.js@ fa375fe

Last change on this file since fa375fe was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 1.7 KB
Line 
1"use strict";
2
3Object.defineProperty(exports, "__esModule", {
4 value: true
5});
6exports.default = getModuleName;
7{
8 const originalGetModuleName = getModuleName;
9
10 exports.default = getModuleName = function getModuleName(rootOpts, pluginOpts) {
11 var _pluginOpts$moduleId, _pluginOpts$moduleIds, _pluginOpts$getModule, _pluginOpts$moduleRoo;
12
13 return originalGetModuleName(rootOpts, {
14 moduleId: (_pluginOpts$moduleId = pluginOpts.moduleId) != null ? _pluginOpts$moduleId : rootOpts.moduleId,
15 moduleIds: (_pluginOpts$moduleIds = pluginOpts.moduleIds) != null ? _pluginOpts$moduleIds : rootOpts.moduleIds,
16 getModuleId: (_pluginOpts$getModule = pluginOpts.getModuleId) != null ? _pluginOpts$getModule : rootOpts.getModuleId,
17 moduleRoot: (_pluginOpts$moduleRoo = pluginOpts.moduleRoot) != null ? _pluginOpts$moduleRoo : rootOpts.moduleRoot
18 });
19 };
20}
21
22function getModuleName(rootOpts, pluginOpts) {
23 const {
24 filename,
25 filenameRelative = filename,
26 sourceRoot = pluginOpts.moduleRoot
27 } = rootOpts;
28 const {
29 moduleId,
30 moduleIds = !!moduleId,
31 getModuleId,
32 moduleRoot = sourceRoot
33 } = pluginOpts;
34 if (!moduleIds) return null;
35
36 if (moduleId != null && !getModuleId) {
37 return moduleId;
38 }
39
40 let moduleName = moduleRoot != null ? moduleRoot + "/" : "";
41
42 if (filenameRelative) {
43 const sourceRootReplacer = sourceRoot != null ? new RegExp("^" + sourceRoot + "/?") : "";
44 moduleName += filenameRelative.replace(sourceRootReplacer, "").replace(/\.(\w*?)$/, "");
45 }
46
47 moduleName = moduleName.replace(/\\/g, "/");
48
49 if (getModuleId) {
50 return getModuleId(moduleName) || moduleName;
51 } else {
52 return moduleName;
53 }
54}
Note: See TracBrowser for help on using the repository browser.