@modern-js/utils 3.1.3 → 3.1.4

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.
@@ -33,6 +33,9 @@ var __webpack_modules__ = {
33
33
  "./logger" (module) {
34
34
  module.exports = require("./logger.js");
35
35
  },
36
+ "./modulePath" (module) {
37
+ module.exports = require("./modulePath.js");
38
+ },
36
39
  "./monorepo" (module) {
37
40
  module.exports = require("./monorepo.js");
38
41
  },
@@ -191,6 +194,10 @@ var __webpack_exports__ = {};
191
194
  var __rspack_reexport = {};
192
195
  for(const __rspack_import_key in _route__rspack_import_20)if ("default" !== __rspack_import_key) __rspack_reexport[__rspack_import_key] = ()=>_route__rspack_import_20[__rspack_import_key];
193
196
  __webpack_require__.d(__webpack_exports__, __rspack_reexport);
197
+ var _modulePath__rspack_import_21 = __webpack_require__("./modulePath");
198
+ var __rspack_reexport = {};
199
+ for(const __rspack_import_key in _modulePath__rspack_import_21)if ("default" !== __rspack_import_key) __rspack_reexport[__rspack_import_key] = ()=>_modulePath__rspack_import_21[__rspack_import_key];
200
+ __webpack_require__.d(__webpack_exports__, __rspack_reexport);
194
201
  })();
195
202
  for(var __rspack_i in __webpack_exports__)exports[__rspack_i] = __webpack_exports__[__rspack_i];
196
203
  Object.defineProperty(exports, '__esModule', {
@@ -0,0 +1,87 @@
1
+ "use strict";
2
+ var __webpack_require__ = {};
3
+ (()=>{
4
+ __webpack_require__.n = (module)=>{
5
+ var getter = module && module.__esModule ? ()=>module['default'] : ()=>module;
6
+ __webpack_require__.d(getter, {
7
+ a: getter
8
+ });
9
+ return getter;
10
+ };
11
+ })();
12
+ (()=>{
13
+ __webpack_require__.d = (exports1, definition)=>{
14
+ for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
15
+ enumerable: true,
16
+ get: definition[key]
17
+ });
18
+ };
19
+ })();
20
+ (()=>{
21
+ __webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
22
+ })();
23
+ (()=>{
24
+ __webpack_require__.r = (exports1)=>{
25
+ if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
26
+ value: 'Module'
27
+ });
28
+ Object.defineProperty(exports1, '__esModule', {
29
+ value: true
30
+ });
31
+ };
32
+ })();
33
+ var __webpack_exports__ = {};
34
+ __webpack_require__.r(__webpack_exports__);
35
+ __webpack_require__.d(__webpack_exports__, {
36
+ SOURCE_EXTENSIONS: ()=>SOURCE_EXTENSIONS,
37
+ findMatchedSourcePath: ()=>findMatchedSourcePath,
38
+ findSourceEntry: ()=>findSourceEntry,
39
+ JS_LIKE_EXTENSION_RE: ()=>JS_LIKE_EXTENSION_RE
40
+ });
41
+ const external_node_fs_namespaceObject = require("node:fs");
42
+ var external_node_fs_default = /*#__PURE__*/ __webpack_require__.n(external_node_fs_namespaceObject);
43
+ const external_node_path_namespaceObject = require("node:path");
44
+ var external_node_path_default = /*#__PURE__*/ __webpack_require__.n(external_node_path_namespaceObject);
45
+ const SOURCE_EXTENSIONS = [
46
+ '.ts',
47
+ '.js'
48
+ ];
49
+ const JS_LIKE_EXTENSION_RE = /\.(?:c|m)?js$/;
50
+ const isFile = (filepath)=>external_node_fs_default().existsSync(filepath) && external_node_fs_default().statSync(filepath).isFile();
51
+ const findSourceEntry = (resolvedPath)=>{
52
+ const ext = external_node_path_default().extname(resolvedPath);
53
+ if (ext) {
54
+ if (isFile(resolvedPath)) return resolvedPath;
55
+ if (JS_LIKE_EXTENSION_RE.test(resolvedPath)) {
56
+ const tsPath = `${resolvedPath.slice(0, -ext.length)}.ts`;
57
+ if (isFile(tsPath)) return tsPath;
58
+ }
59
+ return;
60
+ }
61
+ for (const candidateExt of SOURCE_EXTENSIONS){
62
+ const filePath = `${resolvedPath}${candidateExt}`;
63
+ if (isFile(filePath)) return filePath;
64
+ }
65
+ for (const candidateExt of SOURCE_EXTENSIONS){
66
+ const indexPath = external_node_path_default().join(resolvedPath, `index${candidateExt}`);
67
+ if (isFile(indexPath)) return indexPath;
68
+ }
69
+ };
70
+ const findMatchedSourcePath = (matchPath, specifier)=>{
71
+ let matchedPath = matchPath(specifier, void 0, void 0, SOURCE_EXTENSIONS);
72
+ if (!matchedPath && JS_LIKE_EXTENSION_RE.test(specifier)) matchedPath = matchPath(specifier.replace(JS_LIKE_EXTENSION_RE, ''), void 0, void 0, SOURCE_EXTENSIONS);
73
+ return matchedPath;
74
+ };
75
+ exports.JS_LIKE_EXTENSION_RE = __webpack_exports__.JS_LIKE_EXTENSION_RE;
76
+ exports.SOURCE_EXTENSIONS = __webpack_exports__.SOURCE_EXTENSIONS;
77
+ exports.findMatchedSourcePath = __webpack_exports__.findMatchedSourcePath;
78
+ exports.findSourceEntry = __webpack_exports__.findSourceEntry;
79
+ for(var __rspack_i in __webpack_exports__)if (-1 === [
80
+ "JS_LIKE_EXTENSION_RE",
81
+ "SOURCE_EXTENSIONS",
82
+ "findMatchedSourcePath",
83
+ "findSourceEntry"
84
+ ].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
85
+ Object.defineProperty(exports, '__esModule', {
86
+ value: true
87
+ });
@@ -19,3 +19,4 @@ export * from "./watch.mjs";
19
19
  export * from "./config.mjs";
20
20
  export * from "./version.mjs";
21
21
  export * from "./route.mjs";
22
+ export * from "./modulePath.mjs";
@@ -0,0 +1,33 @@
1
+ import node_fs from "node:fs";
2
+ import node_path from "node:path";
3
+ const SOURCE_EXTENSIONS = [
4
+ '.ts',
5
+ '.js'
6
+ ];
7
+ const JS_LIKE_EXTENSION_RE = /\.(?:c|m)?js$/;
8
+ const isFile = (filepath)=>node_fs.existsSync(filepath) && node_fs.statSync(filepath).isFile();
9
+ const findSourceEntry = (resolvedPath)=>{
10
+ const ext = node_path.extname(resolvedPath);
11
+ if (ext) {
12
+ if (isFile(resolvedPath)) return resolvedPath;
13
+ if (JS_LIKE_EXTENSION_RE.test(resolvedPath)) {
14
+ const tsPath = `${resolvedPath.slice(0, -ext.length)}.ts`;
15
+ if (isFile(tsPath)) return tsPath;
16
+ }
17
+ return;
18
+ }
19
+ for (const candidateExt of SOURCE_EXTENSIONS){
20
+ const filePath = `${resolvedPath}${candidateExt}`;
21
+ if (isFile(filePath)) return filePath;
22
+ }
23
+ for (const candidateExt of SOURCE_EXTENSIONS){
24
+ const indexPath = node_path.join(resolvedPath, `index${candidateExt}`);
25
+ if (isFile(indexPath)) return indexPath;
26
+ }
27
+ };
28
+ const findMatchedSourcePath = (matchPath, specifier)=>{
29
+ let matchedPath = matchPath(specifier, void 0, void 0, SOURCE_EXTENSIONS);
30
+ if (!matchedPath && JS_LIKE_EXTENSION_RE.test(specifier)) matchedPath = matchPath(specifier.replace(JS_LIKE_EXTENSION_RE, ''), void 0, void 0, SOURCE_EXTENSIONS);
31
+ return matchedPath;
32
+ };
33
+ export { JS_LIKE_EXTENSION_RE, SOURCE_EXTENSIONS, findMatchedSourcePath, findSourceEntry };
@@ -20,3 +20,4 @@ export * from "./watch.mjs";
20
20
  export * from "./config.mjs";
21
21
  export * from "./version.mjs";
22
22
  export * from "./route.mjs";
23
+ export * from "./modulePath.mjs";
@@ -0,0 +1,34 @@
1
+ import "node:module";
2
+ import node_fs from "node:fs";
3
+ import node_path from "node:path";
4
+ const SOURCE_EXTENSIONS = [
5
+ '.ts',
6
+ '.js'
7
+ ];
8
+ const JS_LIKE_EXTENSION_RE = /\.(?:c|m)?js$/;
9
+ const isFile = (filepath)=>node_fs.existsSync(filepath) && node_fs.statSync(filepath).isFile();
10
+ const findSourceEntry = (resolvedPath)=>{
11
+ const ext = node_path.extname(resolvedPath);
12
+ if (ext) {
13
+ if (isFile(resolvedPath)) return resolvedPath;
14
+ if (JS_LIKE_EXTENSION_RE.test(resolvedPath)) {
15
+ const tsPath = `${resolvedPath.slice(0, -ext.length)}.ts`;
16
+ if (isFile(tsPath)) return tsPath;
17
+ }
18
+ return;
19
+ }
20
+ for (const candidateExt of SOURCE_EXTENSIONS){
21
+ const filePath = `${resolvedPath}${candidateExt}`;
22
+ if (isFile(filePath)) return filePath;
23
+ }
24
+ for (const candidateExt of SOURCE_EXTENSIONS){
25
+ const indexPath = node_path.join(resolvedPath, `index${candidateExt}`);
26
+ if (isFile(indexPath)) return indexPath;
27
+ }
28
+ };
29
+ const findMatchedSourcePath = (matchPath, specifier)=>{
30
+ let matchedPath = matchPath(specifier, void 0, void 0, SOURCE_EXTENSIONS);
31
+ if (!matchedPath && JS_LIKE_EXTENSION_RE.test(specifier)) matchedPath = matchPath(specifier.replace(JS_LIKE_EXTENSION_RE, ''), void 0, void 0, SOURCE_EXTENSIONS);
32
+ return matchedPath;
33
+ };
34
+ export { JS_LIKE_EXTENSION_RE, SOURCE_EXTENSIONS, findMatchedSourcePath, findSourceEntry };
@@ -19,3 +19,4 @@ export * from './watch';
19
19
  export * from './config';
20
20
  export * from './version';
21
21
  export * from './route';
22
+ export * from './modulePath';
@@ -0,0 +1,5 @@
1
+ import type { MatchPath } from '../../compiled/tsconfig-paths';
2
+ export declare const SOURCE_EXTENSIONS: string[];
3
+ export declare const JS_LIKE_EXTENSION_RE: RegExp;
4
+ export declare const findSourceEntry: (resolvedPath: string) => string | undefined;
5
+ export declare const findMatchedSourcePath: (matchPath: MatchPath, specifier: string) => string | undefined;
package/package.json CHANGED
@@ -15,7 +15,7 @@
15
15
  "modern",
16
16
  "modern.js"
17
17
  ],
18
- "version": "3.1.3",
18
+ "version": "3.1.4",
19
19
  "types": "./dist/types/index.d.ts",
20
20
  "main": "./dist/cjs/index.js",
21
21
  "module": "./dist/esm/index.mjs",
@@ -147,7 +147,7 @@
147
147
  "happy-dom": "^20.8.9",
148
148
  "typescript": "^5",
149
149
  "@modern-js/rslib": "2.68.10",
150
- "@modern-js/types": "3.1.3",
150
+ "@modern-js/types": "3.1.4",
151
151
  "@scripts/rstest-config": "2.66.0"
152
152
  },
153
153
  "peerDependencies": {