@modern-js/utils 3.6.0 → 3.8.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.
@@ -48,7 +48,13 @@ const external_node_path_namespaceObject = require("node:path");
48
48
  var external_node_path_default = /*#__PURE__*/ __webpack_require__.n(external_node_path_namespaceObject);
49
49
  const SOURCE_EXTENSIONS = [
50
50
  '.ts',
51
- '.js'
51
+ '.tsx',
52
+ '.js',
53
+ '.jsx'
54
+ ];
55
+ const TS_EXTENSIONS = [
56
+ '.ts',
57
+ '.tsx'
52
58
  ];
53
59
  const JS_LIKE_EXTENSION_RE = /\.(?:c|m)?js$/;
54
60
  const isFile = (filepath)=>external_node_fs_default().existsSync(filepath) && external_node_fs_default().statSync(filepath).isFile();
@@ -57,8 +63,11 @@ const findSourceEntry = (resolvedPath)=>{
57
63
  if (ext) {
58
64
  if (isFile(resolvedPath)) return resolvedPath;
59
65
  if (JS_LIKE_EXTENSION_RE.test(resolvedPath)) {
60
- const tsPath = `${resolvedPath.slice(0, -ext.length)}.ts`;
61
- if (isFile(tsPath)) return tsPath;
66
+ const withoutExt = resolvedPath.slice(0, -ext.length);
67
+ for (const candidateExt of TS_EXTENSIONS){
68
+ const tsPath = `${withoutExt}${candidateExt}`;
69
+ if (isFile(tsPath)) return tsPath;
70
+ }
62
71
  }
63
72
  return;
64
73
  }
@@ -2,7 +2,13 @@ import node_fs from "node:fs";
2
2
  import node_path from "node:path";
3
3
  const SOURCE_EXTENSIONS = [
4
4
  '.ts',
5
- '.js'
5
+ '.tsx',
6
+ '.js',
7
+ '.jsx'
8
+ ];
9
+ const TS_EXTENSIONS = [
10
+ '.ts',
11
+ '.tsx'
6
12
  ];
7
13
  const JS_LIKE_EXTENSION_RE = /\.(?:c|m)?js$/;
8
14
  const isFile = (filepath)=>node_fs.existsSync(filepath) && node_fs.statSync(filepath).isFile();
@@ -11,8 +17,11 @@ const findSourceEntry = (resolvedPath)=>{
11
17
  if (ext) {
12
18
  if (isFile(resolvedPath)) return resolvedPath;
13
19
  if (JS_LIKE_EXTENSION_RE.test(resolvedPath)) {
14
- const tsPath = `${resolvedPath.slice(0, -ext.length)}.ts`;
15
- if (isFile(tsPath)) return tsPath;
20
+ const withoutExt = resolvedPath.slice(0, -ext.length);
21
+ for (const candidateExt of TS_EXTENSIONS){
22
+ const tsPath = `${withoutExt}${candidateExt}`;
23
+ if (isFile(tsPath)) return tsPath;
24
+ }
16
25
  }
17
26
  return;
18
27
  }
@@ -3,7 +3,13 @@ import node_fs from "node:fs";
3
3
  import node_path from "node:path";
4
4
  const SOURCE_EXTENSIONS = [
5
5
  '.ts',
6
- '.js'
6
+ '.tsx',
7
+ '.js',
8
+ '.jsx'
9
+ ];
10
+ const TS_EXTENSIONS = [
11
+ '.ts',
12
+ '.tsx'
7
13
  ];
8
14
  const JS_LIKE_EXTENSION_RE = /\.(?:c|m)?js$/;
9
15
  const isFile = (filepath)=>node_fs.existsSync(filepath) && node_fs.statSync(filepath).isFile();
@@ -12,8 +18,11 @@ const findSourceEntry = (resolvedPath)=>{
12
18
  if (ext) {
13
19
  if (isFile(resolvedPath)) return resolvedPath;
14
20
  if (JS_LIKE_EXTENSION_RE.test(resolvedPath)) {
15
- const tsPath = `${resolvedPath.slice(0, -ext.length)}.ts`;
16
- if (isFile(tsPath)) return tsPath;
21
+ const withoutExt = resolvedPath.slice(0, -ext.length);
22
+ for (const candidateExt of TS_EXTENSIONS){
23
+ const tsPath = `${withoutExt}${candidateExt}`;
24
+ if (isFile(tsPath)) return tsPath;
25
+ }
17
26
  }
18
27
  return;
19
28
  }
package/package.json CHANGED
@@ -15,7 +15,7 @@
15
15
  "modern",
16
16
  "modern.js"
17
17
  ],
18
- "version": "3.6.0",
18
+ "version": "3.8.0",
19
19
  "types": "./dist/types/index.d.ts",
20
20
  "main": "./dist/cjs/index.js",
21
21
  "module": "./dist/esm/index.mjs",
@@ -147,8 +147,8 @@
147
147
  "happy-dom": "^20.9.0",
148
148
  "typescript": "^5",
149
149
  "@modern-js/rslib": "2.68.10",
150
- "@modern-js/types": "3.6.0",
151
- "@scripts/rstest-config": "2.66.0"
150
+ "@scripts/rstest-config": "2.66.0",
151
+ "@modern-js/types": "3.8.0"
152
152
  },
153
153
  "peerDependencies": {
154
154
  "react": "^19.2.7",