@modern-js/babel-plugin-module-resolver 2.35.0 → 2.36.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cjs/index.js CHANGED
@@ -1,30 +1,43 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", {
3
- value: true
4
- });
5
- function _export(target, all) {
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __export = (target, all) => {
6
8
  for (var name in all)
7
- Object.defineProperty(target, name, {
8
- enumerable: true,
9
- get: all[name]
10
- });
11
- }
12
- _export(exports, {
13
- resolvePath: function() {
14
- return _resolvePath.default;
15
- },
16
- default: function() {
17
- return _default;
9
+ __defProp(target, name, { get: all[name], enumerable: true });
10
+ };
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from))
14
+ if (!__hasOwnProp.call(to, key) && key !== except)
15
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
18
16
  }
17
+ return to;
18
+ };
19
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
20
+ // If the importer is in node compatibility mode or this is not an ESM
21
+ // file that has been converted to a CommonJS file using a Babel-
22
+ // compatible transform (i.e. "__esModule" has not been set), then set
23
+ // "default" to the CommonJS "module.exports" for node compatibility.
24
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
25
+ mod
26
+ ));
27
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
28
+ var src_exports = {};
29
+ __export(src_exports, {
30
+ default: () => src_default,
31
+ resolvePath: () => import_resolvePath.default
19
32
  });
20
- const _interop_require_default = require("@swc/helpers/_/_interop_require_default");
21
- const _normalizeOptions = /* @__PURE__ */ _interop_require_default._(require("./normalizeOptions"));
22
- const _resolvePath = /* @__PURE__ */ _interop_require_default._(require("./resolvePath"));
23
- const _call = /* @__PURE__ */ _interop_require_default._(require("./transformers/call"));
24
- const _import = /* @__PURE__ */ _interop_require_default._(require("./transformers/import"));
33
+ module.exports = __toCommonJS(src_exports);
34
+ var import_normalizeOptions = __toESM(require("./normalizeOptions"));
35
+ var import_resolvePath = __toESM(require("./resolvePath"));
36
+ var import_call = __toESM(require("./transformers/call"));
37
+ var import_import = __toESM(require("./transformers/import"));
25
38
  const importVisitors = {
26
- CallExpression: _call.default,
27
- "ImportDeclaration|ExportDeclaration": _import.default
39
+ CallExpression: import_call.default,
40
+ "ImportDeclaration|ExportDeclaration": import_import.default
28
41
  };
29
42
  const visitor = {
30
43
  Program: {
@@ -36,7 +49,7 @@ const visitor = {
36
49
  }
37
50
  }
38
51
  };
39
- const _default = ({ types }) => ({
52
+ var src_default = ({ types }) => ({
40
53
  name: "module-resolver",
41
54
  manipulateOptions(opts) {
42
55
  if (opts.filename === void 0) {
@@ -46,7 +59,7 @@ const _default = ({ types }) => ({
46
59
  pre(file) {
47
60
  this.types = types;
48
61
  const currentFile = file.opts.filename;
49
- this.normalizedOpts = (0, _normalizeOptions.default)(currentFile, this.opts);
62
+ this.normalizedOpts = (0, import_normalizeOptions.default)(currentFile, this.opts);
50
63
  this.moduleResolverVisited = /* @__PURE__ */ new Set();
51
64
  },
52
65
  visitor,
@@ -54,3 +67,7 @@ const _default = ({ types }) => ({
54
67
  this.moduleResolverVisited.clear();
55
68
  }
56
69
  });
70
+ // Annotate the CommonJS export names for ESM import in node:
71
+ 0 && (module.exports = {
72
+ resolvePath
73
+ });
package/dist/cjs/log.js CHANGED
@@ -1,13 +1,29 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", {
3
- value: true
4
- });
5
- Object.defineProperty(exports, "warn", {
6
- enumerable: true,
7
- get: function() {
8
- return warn;
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all)
7
+ __defProp(target, name, { get: all[name], enumerable: true });
8
+ };
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
9
14
  }
15
+ return to;
16
+ };
17
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
+ var log_exports = {};
19
+ __export(log_exports, {
20
+ warn: () => warn
10
21
  });
22
+ module.exports = __toCommonJS(log_exports);
11
23
  function warn(...args) {
12
24
  console.warn(...args);
13
25
  }
26
+ // Annotate the CommonJS export names for ESM import in node:
27
+ 0 && (module.exports = {
28
+ warn
29
+ });
@@ -1,22 +1,43 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", {
3
- value: true
4
- });
5
- Object.defineProperty(exports, "default", {
6
- enumerable: true,
7
- get: function() {
8
- return mapPathString;
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __export = (target, all) => {
8
+ for (var name in all)
9
+ __defProp(target, name, { get: all[name], enumerable: true });
10
+ };
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from))
14
+ if (!__hasOwnProp.call(to, key) && key !== except)
15
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
9
16
  }
17
+ return to;
18
+ };
19
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
20
+ // If the importer is in node compatibility mode or this is not an ESM
21
+ // file that has been converted to a CommonJS file using a Babel-
22
+ // compatible transform (i.e. "__esModule" has not been set), then set
23
+ // "default" to the CommonJS "module.exports" for node compatibility.
24
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
25
+ mod
26
+ ));
27
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
28
+ var mapPath_exports = {};
29
+ __export(mapPath_exports, {
30
+ default: () => mapPathString
10
31
  });
11
- const _interop_require_default = require("@swc/helpers/_/_interop_require_default");
12
- const _resolvePath = /* @__PURE__ */ _interop_require_default._(require("./resolvePath"));
32
+ module.exports = __toCommonJS(mapPath_exports);
33
+ var import_resolvePath = __toESM(require("./resolvePath"));
13
34
  function mapPathString(nodePath, state) {
14
35
  if (!state.types.isStringLiteral(nodePath)) {
15
36
  return;
16
37
  }
17
38
  const sourcePath = nodePath.node.value;
18
39
  const currentFile = state.file.opts.filename;
19
- const resolvePath = state.normalizedOpts.customResolvePath || _resolvePath.default;
40
+ const resolvePath = state.normalizedOpts.customResolvePath || import_resolvePath.default;
20
41
  const modulePath = resolvePath(sourcePath, currentFile, state.opts);
21
42
  if (modulePath) {
22
43
  if (nodePath.node.pathResolved) {
@@ -1,21 +1,42 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", {
3
- value: true
4
- });
5
- Object.defineProperty(exports, "default", {
6
- enumerable: true,
7
- get: function() {
8
- return mapToRelative;
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __export = (target, all) => {
8
+ for (var name in all)
9
+ __defProp(target, name, { get: all[name], enumerable: true });
10
+ };
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from))
14
+ if (!__hasOwnProp.call(to, key) && key !== except)
15
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
9
16
  }
17
+ return to;
18
+ };
19
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
20
+ // If the importer is in node compatibility mode or this is not an ESM
21
+ // file that has been converted to a CommonJS file using a Babel-
22
+ // compatible transform (i.e. "__esModule" has not been set), then set
23
+ // "default" to the CommonJS "module.exports" for node compatibility.
24
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
25
+ mod
26
+ ));
27
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
28
+ var mapToRelative_exports = {};
29
+ __export(mapToRelative_exports, {
30
+ default: () => mapToRelative
10
31
  });
11
- const _interop_require_default = require("@swc/helpers/_/_interop_require_default");
12
- const _path = /* @__PURE__ */ _interop_require_default._(require("path"));
13
- const _utils = require("./utils");
14
- function mapToRelative(cwd, currentFile, module) {
15
- let from = _path.default.dirname(currentFile);
16
- let to = _path.default.normalize(module);
17
- from = _path.default.resolve(cwd, from);
18
- to = _path.default.resolve(cwd, to);
19
- const moduleMapped = _path.default.relative(from, to);
20
- return (0, _utils.toPosixPath)(moduleMapped);
32
+ module.exports = __toCommonJS(mapToRelative_exports);
33
+ var import_path = __toESM(require("path"));
34
+ var import_utils = require("./utils");
35
+ function mapToRelative(cwd, currentFile, module2) {
36
+ let from = import_path.default.dirname(currentFile);
37
+ let to = import_path.default.normalize(module2);
38
+ from = import_path.default.resolve(cwd, from);
39
+ to = import_path.default.resolve(cwd, to);
40
+ const moduleMapped = import_path.default.relative(from, to);
41
+ return (0, import_utils.toPosixPath)(moduleMapped);
21
42
  }
@@ -1,20 +1,41 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", {
3
- value: true
4
- });
5
- Object.defineProperty(exports, "default", {
6
- enumerable: true,
7
- get: function() {
8
- return _default;
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __export = (target, all) => {
8
+ for (var name in all)
9
+ __defProp(target, name, { get: all[name], enumerable: true });
10
+ };
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from))
14
+ if (!__hasOwnProp.call(to, key) && key !== except)
15
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
9
16
  }
17
+ return to;
18
+ };
19
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
20
+ // If the importer is in node compatibility mode or this is not an ESM
21
+ // file that has been converted to a CommonJS file using a Babel-
22
+ // compatible transform (i.e. "__esModule" has not been set), then set
23
+ // "default" to the CommonJS "module.exports" for node compatibility.
24
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
25
+ mod
26
+ ));
27
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
28
+ var normalizeOptions_exports = {};
29
+ __export(normalizeOptions_exports, {
30
+ default: () => normalizeOptions_default
10
31
  });
11
- const _interop_require_default = require("@swc/helpers/_/_interop_require_default");
12
- const _fs = /* @__PURE__ */ _interop_require_default._(require("fs"));
13
- const _path = /* @__PURE__ */ _interop_require_default._(require("path"));
14
- const _reselect = require("reselect");
15
- const _glob = /* @__PURE__ */ _interop_require_default._(require("glob"));
16
- const _pkgup = /* @__PURE__ */ _interop_require_default._(require("pkg-up"));
17
- const _utils = require("./utils");
32
+ module.exports = __toCommonJS(normalizeOptions_exports);
33
+ var import_fs = __toESM(require("fs"));
34
+ var import_path = __toESM(require("path"));
35
+ var import_reselect = require("reselect");
36
+ var import_glob = __toESM(require("glob"));
37
+ var import_pkg_up = __toESM(require("pkg-up"));
38
+ var import_utils = require("./utils");
18
39
  const defaultExtensions = [
19
40
  ".js",
20
41
  ".jsx",
@@ -44,7 +65,7 @@ function isRegExp(string) {
44
65
  }
45
66
  const specialCwd = {
46
67
  babelrc: () => null,
47
- packagejson: (startPath) => _pkgup.default.sync({
68
+ packagejson: (startPath) => import_pkg_up.default.sync({
48
69
  cwd: startPath
49
70
  })
50
71
  };
@@ -53,7 +74,7 @@ function normalizeCwd(optsCwd, currentFile) {
53
74
  if (optsCwd in specialCwd) {
54
75
  const startPath = currentFile === "unknown" ? "./" : currentFile;
55
76
  const computedCwd = specialCwd[optsCwd](startPath);
56
- cwd = computedCwd ? _path.default.dirname(computedCwd) : null;
77
+ cwd = computedCwd ? import_path.default.dirname(computedCwd) : null;
57
78
  } else {
58
79
  cwd = optsCwd;
59
80
  }
@@ -66,9 +87,9 @@ function normalizeRoot(optsRoot, cwd) {
66
87
  const rootArray = Array.isArray(optsRoot) ? optsRoot : [
67
88
  optsRoot
68
89
  ];
69
- return rootArray.map((dirPath) => _path.default.resolve(cwd, dirPath)).reduce((resolvedDirs, absDirPath) => {
70
- if (_glob.default.hasMagic(absDirPath)) {
71
- const roots = _glob.default.sync(absDirPath).filter((resolvedPath) => _fs.default.lstatSync(resolvedPath).isDirectory());
90
+ return rootArray.map((dirPath) => import_path.default.resolve(cwd, dirPath)).reduce((resolvedDirs, absDirPath) => {
91
+ if (import_glob.default.hasMagic(absDirPath)) {
92
+ const roots = import_glob.default.sync(absDirPath).filter((resolvedPath) => import_fs.default.lstatSync(resolvedPath).isDirectory());
72
93
  return [
73
94
  ...resolvedDirs,
74
95
  ...roots
@@ -81,7 +102,7 @@ function normalizeRoot(optsRoot, cwd) {
81
102
  }, []);
82
103
  }
83
104
  function getAliasTarget(key, isKeyRegExp) {
84
- const regExpPattern = isKeyRegExp ? key : `^${(0, _utils.escapeRegExp)(key)}(/.*|)$`;
105
+ const regExpPattern = isKeyRegExp ? key : `^${(0, import_utils.escapeRegExp)(key)}(/.*|)$`;
85
106
  return new RegExp(regExpPattern);
86
107
  }
87
108
  function getAliasSubstitute(value, isKeyRegExp) {
@@ -130,9 +151,9 @@ function normalizeTransformedFunctions(optsTransformFunctions) {
130
151
  function normalizeLoglevel(optsLoglevel) {
131
152
  return optsLoglevel || "warn";
132
153
  }
133
- const _default = (0, _reselect.createSelector)(
154
+ var normalizeOptions_default = (0, import_reselect.createSelector)(
134
155
  // The currentFile should have an extension; otherwise it's considered a special value
135
- (currentFile) => currentFile.includes(".") ? _path.default.dirname(currentFile) : currentFile,
156
+ (currentFile) => currentFile.includes(".") ? import_path.default.dirname(currentFile) : currentFile,
136
157
  (_, opts) => opts,
137
158
  (currentFile, opts) => {
138
159
  const cwd = normalizeCwd(opts.cwd, currentFile);
@@ -1,32 +1,53 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", {
3
- value: true
4
- });
5
- Object.defineProperty(exports, "default", {
6
- enumerable: true,
7
- get: function() {
8
- return resolvePath;
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __export = (target, all) => {
8
+ for (var name in all)
9
+ __defProp(target, name, { get: all[name], enumerable: true });
10
+ };
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from))
14
+ if (!__hasOwnProp.call(to, key) && key !== except)
15
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
9
16
  }
17
+ return to;
18
+ };
19
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
20
+ // If the importer is in node compatibility mode or this is not an ESM
21
+ // file that has been converted to a CommonJS file using a Babel-
22
+ // compatible transform (i.e. "__esModule" has not been set), then set
23
+ // "default" to the CommonJS "module.exports" for node compatibility.
24
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
25
+ mod
26
+ ));
27
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
28
+ var resolvePath_exports = {};
29
+ __export(resolvePath_exports, {
30
+ default: () => resolvePath
10
31
  });
11
- const _interop_require_default = require("@swc/helpers/_/_interop_require_default");
12
- const _path = /* @__PURE__ */ _interop_require_default._(require("path"));
13
- const _log = require("./log");
14
- const _mapToRelative = /* @__PURE__ */ _interop_require_default._(require("./mapToRelative"));
15
- const _normalizeOptions = /* @__PURE__ */ _interop_require_default._(require("./normalizeOptions"));
16
- const _utils = require("./utils");
32
+ module.exports = __toCommonJS(resolvePath_exports);
33
+ var import_path = __toESM(require("path"));
34
+ var import_log = require("./log");
35
+ var import_mapToRelative = __toESM(require("./mapToRelative"));
36
+ var import_normalizeOptions = __toESM(require("./normalizeOptions"));
37
+ var import_utils = require("./utils");
17
38
  function getRelativePath(sourcePath, currentFile, absFileInRoot, opts) {
18
- const realSourceFileExtension = _path.default.extname(absFileInRoot);
19
- const sourceFileExtension = _path.default.extname(sourcePath);
20
- let relativePath = (0, _mapToRelative.default)(opts.cwd, currentFile, absFileInRoot);
39
+ const realSourceFileExtension = import_path.default.extname(absFileInRoot);
40
+ const sourceFileExtension = import_path.default.extname(sourcePath);
41
+ let relativePath = (0, import_mapToRelative.default)(opts.cwd, currentFile, absFileInRoot);
21
42
  if (realSourceFileExtension !== sourceFileExtension) {
22
- relativePath = (0, _utils.replaceExtension)(relativePath, opts);
43
+ relativePath = (0, import_utils.replaceExtension)(relativePath, opts);
23
44
  }
24
- return (0, _utils.toLocalPath)((0, _utils.toPosixPath)(relativePath));
45
+ return (0, import_utils.toLocalPath)((0, import_utils.toPosixPath)(relativePath));
25
46
  }
26
47
  function findPathInRoots(sourcePath, { extensions, root }) {
27
48
  let resolvedSourceFile;
28
49
  root.some((basedir) => {
29
- resolvedSourceFile = (0, _utils.nodeResolvePath)(`./${sourcePath}`, basedir, extensions);
50
+ resolvedSourceFile = (0, import_utils.nodeResolvePath)(`./${sourcePath}`, basedir, extensions);
30
51
  return resolvedSourceFile !== null;
31
52
  });
32
53
  return resolvedSourceFile;
@@ -39,9 +60,9 @@ function resolvePathFromRootConfig(sourcePath, currentFile, opts) {
39
60
  return getRelativePath(sourcePath, currentFile, absFileInRoot, opts);
40
61
  }
41
62
  function checkIfPackageExists(modulePath, currentFile, extensions, loglevel) {
42
- const resolvedPath = (0, _utils.nodeResolvePath)(modulePath, currentFile, extensions);
63
+ const resolvedPath = (0, import_utils.nodeResolvePath)(modulePath, currentFile, extensions);
43
64
  if (resolvedPath === null && loglevel !== "silent") {
44
- (0, _log.warn)(`Could not resolve "${modulePath}" in file ${currentFile}.`);
65
+ (0, import_log.warn)(`Could not resolve "${modulePath}" in file ${currentFile}.`);
45
66
  }
46
67
  }
47
68
  function resolvePathFromAliasConfig(sourcePath, currentFile, opts) {
@@ -59,14 +80,14 @@ function resolvePathFromAliasConfig(sourcePath, currentFile, opts) {
59
80
  }
60
81
  if (Array.isArray(aliasedSourceFile)) {
61
82
  return aliasedSourceFile.map((asf) => {
62
- if ((0, _utils.isRelativePath)(asf)) {
63
- return (0, _utils.toLocalPath)((0, _utils.toPosixPath)((0, _mapToRelative.default)(opts.cwd, currentFile, asf)));
83
+ if ((0, import_utils.isRelativePath)(asf)) {
84
+ return (0, import_utils.toLocalPath)((0, import_utils.toPosixPath)((0, import_mapToRelative.default)(opts.cwd, currentFile, asf)));
64
85
  }
65
86
  return asf;
66
- }).find((src) => (0, _utils.nodeResolvePath)(src, _path.default.dirname(currentFile), opts.extensions));
87
+ }).find((src) => (0, import_utils.nodeResolvePath)(src, import_path.default.dirname(currentFile), opts.extensions));
67
88
  }
68
- if ((0, _utils.isRelativePath)(aliasedSourceFile)) {
69
- return (0, _utils.toLocalPath)((0, _utils.toPosixPath)((0, _mapToRelative.default)(opts.cwd, currentFile, aliasedSourceFile)));
89
+ if ((0, import_utils.isRelativePath)(aliasedSourceFile)) {
90
+ return (0, import_utils.toLocalPath)((0, import_utils.toPosixPath)((0, import_mapToRelative.default)(opts.cwd, currentFile, aliasedSourceFile)));
70
91
  }
71
92
  if (process.env.NODE_ENV !== "production") {
72
93
  checkIfPackageExists(aliasedSourceFile, currentFile, opts.extensions, opts.loglevel);
@@ -78,11 +99,11 @@ const resolvers = [
78
99
  resolvePathFromRootConfig
79
100
  ];
80
101
  function resolvePath(sourcePath, currentFile, opts) {
81
- if ((0, _utils.isRelativePath)(sourcePath)) {
102
+ if ((0, import_utils.isRelativePath)(sourcePath)) {
82
103
  return sourcePath;
83
104
  }
84
- const normalizedOpts = (0, _normalizeOptions.default)(currentFile, opts);
85
- const absoluteCurrentFile = _path.default.resolve(currentFile);
105
+ const normalizedOpts = (0, import_normalizeOptions.default)(currentFile, opts);
106
+ const absoluteCurrentFile = import_path.default.resolve(currentFile);
86
107
  let resolvedPath = null;
87
108
  resolvers.some((resolver) => {
88
109
  resolvedPath = resolver(sourcePath, absoluteCurrentFile, normalizedOpts);
@@ -1,24 +1,45 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", {
3
- value: true
4
- });
5
- Object.defineProperty(exports, "default", {
6
- enumerable: true,
7
- get: function() {
8
- return transformCall;
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __export = (target, all) => {
8
+ for (var name in all)
9
+ __defProp(target, name, { get: all[name], enumerable: true });
10
+ };
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from))
14
+ if (!__hasOwnProp.call(to, key) && key !== except)
15
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
9
16
  }
17
+ return to;
18
+ };
19
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
20
+ // If the importer is in node compatibility mode or this is not an ESM
21
+ // file that has been converted to a CommonJS file using a Babel-
22
+ // compatible transform (i.e. "__esModule" has not been set), then set
23
+ // "default" to the CommonJS "module.exports" for node compatibility.
24
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
25
+ mod
26
+ ));
27
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
28
+ var call_exports = {};
29
+ __export(call_exports, {
30
+ default: () => transformCall
10
31
  });
11
- const _interop_require_default = require("@swc/helpers/_/_interop_require_default");
12
- const _utils = require("../utils");
13
- const _mapPath = /* @__PURE__ */ _interop_require_default._(require("../mapPath"));
32
+ module.exports = __toCommonJS(call_exports);
33
+ var import_utils = require("../utils");
34
+ var import_mapPath = __toESM(require("../mapPath"));
14
35
  function transformCall(nodePath, state) {
15
36
  if (state.moduleResolverVisited.has(nodePath)) {
16
37
  return;
17
38
  }
18
39
  const calleePath = nodePath.get("callee");
19
- const isNormalCall = state.normalizedOpts.transformFunctions.some((pattern) => (0, _utils.matchesPattern)(state.types, calleePath, pattern));
20
- if (isNormalCall || (0, _utils.isImportCall)(state.types, nodePath)) {
40
+ const isNormalCall = state.normalizedOpts.transformFunctions.some((pattern) => (0, import_utils.matchesPattern)(state.types, calleePath, pattern));
41
+ if (isNormalCall || (0, import_utils.isImportCall)(state.types, nodePath)) {
21
42
  state.moduleResolverVisited.add(nodePath);
22
- (0, _mapPath.default)(nodePath.get("arguments.0"), state);
43
+ (0, import_mapPath.default)(nodePath.get("arguments.0"), state);
23
44
  }
24
45
  }
@@ -1,19 +1,40 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", {
3
- value: true
4
- });
5
- Object.defineProperty(exports, "default", {
6
- enumerable: true,
7
- get: function() {
8
- return transformImport;
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __export = (target, all) => {
8
+ for (var name in all)
9
+ __defProp(target, name, { get: all[name], enumerable: true });
10
+ };
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from))
14
+ if (!__hasOwnProp.call(to, key) && key !== except)
15
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
9
16
  }
17
+ return to;
18
+ };
19
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
20
+ // If the importer is in node compatibility mode or this is not an ESM
21
+ // file that has been converted to a CommonJS file using a Babel-
22
+ // compatible transform (i.e. "__esModule" has not been set), then set
23
+ // "default" to the CommonJS "module.exports" for node compatibility.
24
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
25
+ mod
26
+ ));
27
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
28
+ var import_exports = {};
29
+ __export(import_exports, {
30
+ default: () => transformImport
10
31
  });
11
- const _interop_require_default = require("@swc/helpers/_/_interop_require_default");
12
- const _mapPath = /* @__PURE__ */ _interop_require_default._(require("../mapPath"));
32
+ module.exports = __toCommonJS(import_exports);
33
+ var import_mapPath = __toESM(require("../mapPath"));
13
34
  function transformImport(nodePath, state) {
14
35
  if (state.moduleResolverVisited.has(nodePath)) {
15
36
  return;
16
37
  }
17
38
  state.moduleResolverVisited.add(nodePath);
18
- (0, _mapPath.default)(nodePath.get("source"), state);
39
+ (0, import_mapPath.default)(nodePath.get("source"), state);
19
40
  }
package/dist/cjs/utils.js CHANGED
@@ -1,49 +1,48 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", {
3
- value: true
4
- });
5
- function _export(target, all) {
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __export = (target, all) => {
6
8
  for (var name in all)
7
- Object.defineProperty(target, name, {
8
- enumerable: true,
9
- get: all[name]
10
- });
11
- }
12
- _export(exports, {
13
- nodeResolvePath: function() {
14
- return nodeResolvePath;
15
- },
16
- isRelativePath: function() {
17
- return isRelativePath;
18
- },
19
- toPosixPath: function() {
20
- return toPosixPath;
21
- },
22
- toLocalPath: function() {
23
- return toLocalPath;
24
- },
25
- stripExtension: function() {
26
- return stripExtension;
27
- },
28
- replaceExtension: function() {
29
- return replaceExtension;
30
- },
31
- matchesPattern: function() {
32
- return matchesPattern;
33
- },
34
- isImportCall: function() {
35
- return isImportCall;
36
- },
37
- escapeRegExp: function() {
38
- return escapeRegExp;
9
+ __defProp(target, name, { get: all[name], enumerable: true });
10
+ };
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from))
14
+ if (!__hasOwnProp.call(to, key) && key !== except)
15
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
39
16
  }
17
+ return to;
18
+ };
19
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
20
+ // If the importer is in node compatibility mode or this is not an ESM
21
+ // file that has been converted to a CommonJS file using a Babel-
22
+ // compatible transform (i.e. "__esModule" has not been set), then set
23
+ // "default" to the CommonJS "module.exports" for node compatibility.
24
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
25
+ mod
26
+ ));
27
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
28
+ var utils_exports = {};
29
+ __export(utils_exports, {
30
+ escapeRegExp: () => escapeRegExp,
31
+ isImportCall: () => isImportCall,
32
+ isRelativePath: () => isRelativePath,
33
+ matchesPattern: () => matchesPattern,
34
+ nodeResolvePath: () => nodeResolvePath,
35
+ replaceExtension: () => replaceExtension,
36
+ stripExtension: () => stripExtension,
37
+ toLocalPath: () => toLocalPath,
38
+ toPosixPath: () => toPosixPath
40
39
  });
41
- const _interop_require_default = require("@swc/helpers/_/_interop_require_default");
42
- const _path = /* @__PURE__ */ _interop_require_default._(require("path"));
43
- const _resolve = /* @__PURE__ */ _interop_require_default._(require("resolve"));
40
+ module.exports = __toCommonJS(utils_exports);
41
+ var import_path = __toESM(require("path"));
42
+ var import_resolve = __toESM(require("resolve"));
44
43
  function nodeResolvePath(modulePath, basedir, extensions) {
45
44
  try {
46
- return _resolve.default.sync(modulePath, {
45
+ return import_resolve.default.sync(modulePath, {
47
46
  basedir,
48
47
  extensions
49
48
  });
@@ -65,7 +64,7 @@ function toLocalPath(modulePath) {
65
64
  return localPath;
66
65
  }
67
66
  function stripExtension(modulePath, stripExtensions) {
68
- let name = _path.default.basename(modulePath);
67
+ let name = import_path.default.basename(modulePath);
69
68
  stripExtensions.some((extension) => {
70
69
  if (name.endsWith(extension)) {
71
70
  name = name.slice(0, name.length - extension.length);
@@ -77,7 +76,7 @@ function stripExtension(modulePath, stripExtensions) {
77
76
  }
78
77
  function replaceExtension(modulePath, opts) {
79
78
  const filename = stripExtension(modulePath, opts.stripExtensions);
80
- return _path.default.join(_path.default.dirname(modulePath), filename);
79
+ return import_path.default.join(import_path.default.dirname(modulePath), filename);
81
80
  }
82
81
  function matchesPattern(types, calleePath, pattern) {
83
82
  const { node } = calleePath;
@@ -96,3 +95,15 @@ function isImportCall(types, calleePath) {
96
95
  function escapeRegExp(string) {
97
96
  return string.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
98
97
  }
98
+ // Annotate the CommonJS export names for ESM import in node:
99
+ 0 && (module.exports = {
100
+ escapeRegExp,
101
+ isImportCall,
102
+ isRelativePath,
103
+ matchesPattern,
104
+ nodeResolvePath,
105
+ replaceExtension,
106
+ stripExtension,
107
+ toLocalPath,
108
+ toPosixPath
109
+ });
package/dist/esm/index.js CHANGED
@@ -2,7 +2,6 @@ import normalizeOptions from "./normalizeOptions";
2
2
  import resolvePath from "./resolvePath";
3
3
  import transformCall from "./transformers/call";
4
4
  import transformImport from "./transformers/import";
5
- export { resolvePath };
6
5
  var importVisitors = {
7
6
  CallExpression: transformCall,
8
7
  "ImportDeclaration|ExportDeclaration": transformImport
@@ -17,7 +16,7 @@ var visitor = {
17
16
  }
18
17
  }
19
18
  };
20
- export default function(param) {
19
+ function src_default(param) {
21
20
  var types = param.types;
22
21
  return {
23
22
  name: "module-resolver",
@@ -32,10 +31,14 @@ export default function(param) {
32
31
  this.normalizedOpts = normalizeOptions(currentFile, this.opts);
33
32
  this.moduleResolverVisited = /* @__PURE__ */ new Set();
34
33
  },
35
- visitor: visitor,
34
+ visitor,
36
35
  post: function post() {
37
36
  this.moduleResolverVisited.clear();
38
37
  }
39
38
  };
40
39
  }
41
40
  ;
41
+ export {
42
+ src_default as default,
43
+ resolvePath
44
+ };
package/dist/esm/log.js CHANGED
@@ -1,8 +1,11 @@
1
1
  import { _ as _to_consumable_array } from "@swc/helpers/_/_to_consumable_array";
2
- export function warn() {
2
+ function warn() {
3
3
  for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
4
4
  args[_key] = arguments[_key];
5
5
  }
6
6
  var _console;
7
7
  (_console = console).warn.apply(_console, _to_consumable_array(args));
8
8
  }
9
+ export {
10
+ warn
11
+ };
@@ -1,5 +1,5 @@
1
1
  import defaultResolvePath from "./resolvePath";
2
- export default function mapPathString(nodePath, state) {
2
+ function mapPathString(nodePath, state) {
3
3
  if (!state.types.isStringLiteral(nodePath)) {
4
4
  return;
5
5
  }
@@ -15,3 +15,6 @@ export default function mapPathString(nodePath, state) {
15
15
  nodePath.node.pathResolved = true;
16
16
  }
17
17
  }
18
+ export {
19
+ mapPathString as default
20
+ };
@@ -1,6 +1,6 @@
1
1
  import path from "path";
2
2
  import { toPosixPath } from "./utils";
3
- export default function mapToRelative(cwd, currentFile, module) {
3
+ function mapToRelative(cwd, currentFile, module) {
4
4
  var from = path.dirname(currentFile);
5
5
  var to = path.normalize(module);
6
6
  from = path.resolve(cwd, from);
@@ -8,3 +8,6 @@ export default function mapToRelative(cwd, currentFile, module) {
8
8
  var moduleMapped = path.relative(from, to);
9
9
  return toPosixPath(moduleMapped);
10
10
  }
11
+ export {
12
+ mapToRelative as default
13
+ };
@@ -131,7 +131,7 @@ function normalizeTransformedFunctions(optsTransformFunctions) {
131
131
  function normalizeLoglevel(optsLoglevel) {
132
132
  return optsLoglevel || "warn";
133
133
  }
134
- export default createSelector(
134
+ var normalizeOptions_default = createSelector(
135
135
  // The currentFile should have an extension; otherwise it's considered a special value
136
136
  function(currentFile) {
137
137
  return currentFile.includes(".") ? path.dirname(currentFile) : currentFile;
@@ -148,14 +148,17 @@ export default createSelector(
148
148
  var extensions = opts.extensions || defaultExtensions;
149
149
  var stripExtensions = opts.stripExtensions || extensions;
150
150
  return {
151
- cwd: cwd,
152
- root: root,
153
- alias: alias,
154
- loglevel: loglevel,
155
- transformFunctions: transformFunctions,
156
- extensions: extensions,
157
- stripExtensions: stripExtensions,
151
+ cwd,
152
+ root,
153
+ alias,
154
+ loglevel,
155
+ transformFunctions,
156
+ extensions,
157
+ stripExtensions,
158
158
  customResolvePath: opts.resolvePath
159
159
  };
160
160
  }
161
161
  );
162
+ export {
163
+ normalizeOptions_default as default
164
+ };
@@ -71,7 +71,7 @@ var resolvers = [
71
71
  resolvePathFromAliasConfig,
72
72
  resolvePathFromRootConfig
73
73
  ];
74
- export default function resolvePath(sourcePath, currentFile, opts) {
74
+ function resolvePath(sourcePath, currentFile, opts) {
75
75
  if (isRelativePath(sourcePath)) {
76
76
  return sourcePath;
77
77
  }
@@ -84,3 +84,6 @@ export default function resolvePath(sourcePath, currentFile, opts) {
84
84
  });
85
85
  return resolvedPath;
86
86
  }
87
+ export {
88
+ resolvePath as default
89
+ };
@@ -1,6 +1,6 @@
1
1
  import { matchesPattern, isImportCall } from "../utils";
2
2
  import mapPathString from "../mapPath";
3
- export default function transformCall(nodePath, state) {
3
+ function transformCall(nodePath, state) {
4
4
  if (state.moduleResolverVisited.has(nodePath)) {
5
5
  return;
6
6
  }
@@ -13,3 +13,6 @@ export default function transformCall(nodePath, state) {
13
13
  mapPathString(nodePath.get("arguments.0"), state);
14
14
  }
15
15
  }
16
+ export {
17
+ transformCall as default
18
+ };
@@ -1,8 +1,11 @@
1
1
  import mapPathString from "../mapPath";
2
- export default function transformImport(nodePath, state) {
2
+ function transformImport(nodePath, state) {
3
3
  if (state.moduleResolverVisited.has(nodePath)) {
4
4
  return;
5
5
  }
6
6
  state.moduleResolverVisited.add(nodePath);
7
7
  mapPathString(nodePath.get("source"), state);
8
8
  }
9
+ export {
10
+ transformImport as default
11
+ };
package/dist/esm/utils.js CHANGED
@@ -1,29 +1,29 @@
1
1
  import path from "path";
2
2
  import resolve from "resolve";
3
- export function nodeResolvePath(modulePath, basedir, extensions) {
3
+ function nodeResolvePath(modulePath, basedir, extensions) {
4
4
  try {
5
5
  return resolve.sync(modulePath, {
6
- basedir: basedir,
7
- extensions: extensions
6
+ basedir,
7
+ extensions
8
8
  });
9
9
  } catch (e) {
10
10
  return null;
11
11
  }
12
12
  }
13
- export function isRelativePath(nodePath) {
13
+ function isRelativePath(nodePath) {
14
14
  return nodePath.match(/^\.?\.\//);
15
15
  }
16
- export function toPosixPath(modulePath) {
16
+ function toPosixPath(modulePath) {
17
17
  return modulePath.replace(/\\/g, "/");
18
18
  }
19
- export function toLocalPath(modulePath) {
19
+ function toLocalPath(modulePath) {
20
20
  var localPath = modulePath.replace(/\/index$/, "");
21
21
  if (!isRelativePath(localPath)) {
22
22
  localPath = "./".concat(localPath);
23
23
  }
24
24
  return localPath;
25
25
  }
26
- export function stripExtension(modulePath, stripExtensions) {
26
+ function stripExtension(modulePath, stripExtensions) {
27
27
  var name = path.basename(modulePath);
28
28
  stripExtensions.some(function(extension) {
29
29
  if (name.endsWith(extension)) {
@@ -34,11 +34,11 @@ export function stripExtension(modulePath, stripExtensions) {
34
34
  });
35
35
  return name;
36
36
  }
37
- export function replaceExtension(modulePath, opts) {
37
+ function replaceExtension(modulePath, opts) {
38
38
  var filename = stripExtension(modulePath, opts.stripExtensions);
39
39
  return path.join(path.dirname(modulePath), filename);
40
40
  }
41
- export function matchesPattern(types, calleePath, pattern) {
41
+ function matchesPattern(types, calleePath, pattern) {
42
42
  var node = calleePath.node;
43
43
  if (types.isMemberExpression(node)) {
44
44
  return calleePath.matchesPattern(pattern);
@@ -49,9 +49,20 @@ export function matchesPattern(types, calleePath, pattern) {
49
49
  var name = pattern.split(".")[0];
50
50
  return node.name === name;
51
51
  }
52
- export function isImportCall(types, calleePath) {
52
+ function isImportCall(types, calleePath) {
53
53
  return types.isImport(calleePath.node.callee);
54
54
  }
55
- export function escapeRegExp(string) {
55
+ function escapeRegExp(string) {
56
56
  return string.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
57
57
  }
58
+ export {
59
+ escapeRegExp,
60
+ isImportCall,
61
+ isRelativePath,
62
+ matchesPattern,
63
+ nodeResolvePath,
64
+ replaceExtension,
65
+ stripExtension,
66
+ toLocalPath,
67
+ toPosixPath
68
+ };
@@ -2,7 +2,6 @@ import normalizeOptions from "./normalizeOptions";
2
2
  import resolvePath from "./resolvePath";
3
3
  import transformCall from "./transformers/call";
4
4
  import transformImport from "./transformers/import";
5
- export { resolvePath };
6
5
  const importVisitors = {
7
6
  CallExpression: transformCall,
8
7
  "ImportDeclaration|ExportDeclaration": transformImport
@@ -17,7 +16,7 @@ const visitor = {
17
16
  }
18
17
  }
19
18
  };
20
- export default ({ types }) => ({
19
+ var src_default = ({ types }) => ({
21
20
  name: "module-resolver",
22
21
  manipulateOptions(opts) {
23
22
  if (opts.filename === void 0) {
@@ -35,3 +34,7 @@ export default ({ types }) => ({
35
34
  this.moduleResolverVisited.clear();
36
35
  }
37
36
  });
37
+ export {
38
+ src_default as default,
39
+ resolvePath
40
+ };
@@ -1,3 +1,6 @@
1
- export function warn(...args) {
1
+ function warn(...args) {
2
2
  console.warn(...args);
3
3
  }
4
+ export {
5
+ warn
6
+ };
@@ -1,5 +1,5 @@
1
1
  import defaultResolvePath from "./resolvePath";
2
- export default function mapPathString(nodePath, state) {
2
+ function mapPathString(nodePath, state) {
3
3
  if (!state.types.isStringLiteral(nodePath)) {
4
4
  return;
5
5
  }
@@ -15,3 +15,6 @@ export default function mapPathString(nodePath, state) {
15
15
  nodePath.node.pathResolved = true;
16
16
  }
17
17
  }
18
+ export {
19
+ mapPathString as default
20
+ };
@@ -1,6 +1,6 @@
1
1
  import path from "path";
2
2
  import { toPosixPath } from "./utils";
3
- export default function mapToRelative(cwd, currentFile, module) {
3
+ function mapToRelative(cwd, currentFile, module) {
4
4
  let from = path.dirname(currentFile);
5
5
  let to = path.normalize(module);
6
6
  from = path.resolve(cwd, from);
@@ -8,3 +8,6 @@ export default function mapToRelative(cwd, currentFile, module) {
8
8
  const moduleMapped = path.relative(from, to);
9
9
  return toPosixPath(moduleMapped);
10
10
  }
11
+ export {
12
+ mapToRelative as default
13
+ };
@@ -119,7 +119,7 @@ function normalizeTransformedFunctions(optsTransformFunctions) {
119
119
  function normalizeLoglevel(optsLoglevel) {
120
120
  return optsLoglevel || "warn";
121
121
  }
122
- export default createSelector(
122
+ var normalizeOptions_default = createSelector(
123
123
  // The currentFile should have an extension; otherwise it's considered a special value
124
124
  (currentFile) => currentFile.includes(".") ? path.dirname(currentFile) : currentFile,
125
125
  (_, opts) => opts,
@@ -143,3 +143,6 @@ export default createSelector(
143
143
  };
144
144
  }
145
145
  );
146
+ export {
147
+ normalizeOptions_default as default
148
+ };
@@ -66,7 +66,7 @@ const resolvers = [
66
66
  resolvePathFromAliasConfig,
67
67
  resolvePathFromRootConfig
68
68
  ];
69
- export default function resolvePath(sourcePath, currentFile, opts) {
69
+ function resolvePath(sourcePath, currentFile, opts) {
70
70
  if (isRelativePath(sourcePath)) {
71
71
  return sourcePath;
72
72
  }
@@ -79,3 +79,6 @@ export default function resolvePath(sourcePath, currentFile, opts) {
79
79
  });
80
80
  return resolvedPath;
81
81
  }
82
+ export {
83
+ resolvePath as default
84
+ };
@@ -1,6 +1,6 @@
1
1
  import { matchesPattern, isImportCall } from "../utils";
2
2
  import mapPathString from "../mapPath";
3
- export default function transformCall(nodePath, state) {
3
+ function transformCall(nodePath, state) {
4
4
  if (state.moduleResolverVisited.has(nodePath)) {
5
5
  return;
6
6
  }
@@ -11,3 +11,6 @@ export default function transformCall(nodePath, state) {
11
11
  mapPathString(nodePath.get("arguments.0"), state);
12
12
  }
13
13
  }
14
+ export {
15
+ transformCall as default
16
+ };
@@ -1,8 +1,11 @@
1
1
  import mapPathString from "../mapPath";
2
- export default function transformImport(nodePath, state) {
2
+ function transformImport(nodePath, state) {
3
3
  if (state.moduleResolverVisited.has(nodePath)) {
4
4
  return;
5
5
  }
6
6
  state.moduleResolverVisited.add(nodePath);
7
7
  mapPathString(nodePath.get("source"), state);
8
8
  }
9
+ export {
10
+ transformImport as default
11
+ };
@@ -1,6 +1,6 @@
1
1
  import path from "path";
2
2
  import resolve from "resolve";
3
- export function nodeResolvePath(modulePath, basedir, extensions) {
3
+ function nodeResolvePath(modulePath, basedir, extensions) {
4
4
  try {
5
5
  return resolve.sync(modulePath, {
6
6
  basedir,
@@ -10,20 +10,20 @@ export function nodeResolvePath(modulePath, basedir, extensions) {
10
10
  return null;
11
11
  }
12
12
  }
13
- export function isRelativePath(nodePath) {
13
+ function isRelativePath(nodePath) {
14
14
  return nodePath.match(/^\.?\.\//);
15
15
  }
16
- export function toPosixPath(modulePath) {
16
+ function toPosixPath(modulePath) {
17
17
  return modulePath.replace(/\\/g, "/");
18
18
  }
19
- export function toLocalPath(modulePath) {
19
+ function toLocalPath(modulePath) {
20
20
  let localPath = modulePath.replace(/\/index$/, "");
21
21
  if (!isRelativePath(localPath)) {
22
22
  localPath = `./${localPath}`;
23
23
  }
24
24
  return localPath;
25
25
  }
26
- export function stripExtension(modulePath, stripExtensions) {
26
+ function stripExtension(modulePath, stripExtensions) {
27
27
  let name = path.basename(modulePath);
28
28
  stripExtensions.some((extension) => {
29
29
  if (name.endsWith(extension)) {
@@ -34,11 +34,11 @@ export function stripExtension(modulePath, stripExtensions) {
34
34
  });
35
35
  return name;
36
36
  }
37
- export function replaceExtension(modulePath, opts) {
37
+ function replaceExtension(modulePath, opts) {
38
38
  const filename = stripExtension(modulePath, opts.stripExtensions);
39
39
  return path.join(path.dirname(modulePath), filename);
40
40
  }
41
- export function matchesPattern(types, calleePath, pattern) {
41
+ function matchesPattern(types, calleePath, pattern) {
42
42
  const { node } = calleePath;
43
43
  if (types.isMemberExpression(node)) {
44
44
  return calleePath.matchesPattern(pattern);
@@ -49,9 +49,20 @@ export function matchesPattern(types, calleePath, pattern) {
49
49
  const name = pattern.split(".")[0];
50
50
  return node.name === name;
51
51
  }
52
- export function isImportCall(types, calleePath) {
52
+ function isImportCall(types, calleePath) {
53
53
  return types.isImport(calleePath.node.callee);
54
54
  }
55
- export function escapeRegExp(string) {
55
+ function escapeRegExp(string) {
56
56
  return string.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
57
57
  }
58
+ export {
59
+ escapeRegExp,
60
+ isImportCall,
61
+ isRelativePath,
62
+ matchesPattern,
63
+ nodeResolvePath,
64
+ replaceExtension,
65
+ stripExtension,
66
+ toLocalPath,
67
+ toPosixPath
68
+ };
package/package.json CHANGED
@@ -15,7 +15,7 @@
15
15
  "modern",
16
16
  "modern.js"
17
17
  ],
18
- "version": "2.35.0",
18
+ "version": "2.36.0",
19
19
  "jsnext:source": "./src/index.js",
20
20
  "types": "./dist/types/index.d.ts",
21
21
  "main": "./dist/cjs/index.js",
@@ -44,8 +44,8 @@
44
44
  "@babel/preset-env": "^7.22.15",
45
45
  "common-tags": "^1.8.2",
46
46
  "jest": "^29.3.1",
47
- "@scripts/jest-config": "2.35.0",
48
- "@scripts/build": "2.35.0"
47
+ "@scripts/build": "2.36.0",
48
+ "@scripts/jest-config": "2.36.0"
49
49
  },
50
50
  "sideEffects": false,
51
51
  "publishConfig": {