@bleedingdev/modern-js-server-utils 3.4.0-ultramodern.1 → 3.4.0-ultramodern.3
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/compilers/typescript/index.js +2 -1
- package/dist/cjs/compilers/typescript/tsconfigPathsPlugin.js +12 -7
- package/dist/esm/compilers/typescript/index.mjs +2 -1
- package/dist/esm/compilers/typescript/tsconfigPathsPlugin.mjs +13 -8
- package/dist/esm-node/compilers/typescript/index.mjs +2 -1
- package/dist/esm-node/compilers/typescript/tsconfigPathsPlugin.mjs +13 -8
- package/dist/types/compilers/typescript/index.d.ts +1 -0
- package/package.json +4 -4
|
@@ -74,6 +74,7 @@ const createResolvedTsgoConfig = async (appDirectory, tsconfigPath, distDir, sou
|
|
|
74
74
|
config.compilerOptions ??= {};
|
|
75
75
|
config.compilerOptions.rootDir = appDirectory;
|
|
76
76
|
config.compilerOptions.outDir = distDir;
|
|
77
|
+
config.compilerOptions.noEmit = false;
|
|
77
78
|
config.files = filterSourceFiles(tsconfigDir, sourceDirs, config.files);
|
|
78
79
|
delete config.include;
|
|
79
80
|
delete config.compilerOptions.baseUrl;
|
|
@@ -237,6 +238,7 @@ const compileByTs = async (appDirectory, config, compileOptions)=>{
|
|
|
237
238
|
}
|
|
238
239
|
if (result.stderr) utils_namespaceObject.logger.error(result.stderr);
|
|
239
240
|
if (result.stdout) utils_namespaceObject.logger.info(result.stdout);
|
|
241
|
+
await rewriteOutputSpecifiers(appDirectory, distDir, absoluteBaseUrl, paths, compileOptions.moduleType);
|
|
240
242
|
if (0 !== result.code) {
|
|
241
243
|
const noEmitOnError = tsgoConfig.compilerOptions?.noEmitOnError;
|
|
242
244
|
if (void 0 === noEmitOnError || true === noEmitOnError) if (compileOptions.throwErrorInsteadOfExit) {
|
|
@@ -247,7 +249,6 @@ const compileByTs = async (appDirectory, config, compileOptions)=>{
|
|
|
247
249
|
].filter(Boolean).join('\n'));
|
|
248
250
|
} else process.exit(1);
|
|
249
251
|
}
|
|
250
|
-
await rewriteOutputSpecifiers(appDirectory, distDir, absoluteBaseUrl, paths, compileOptions.moduleType);
|
|
251
252
|
for (const source of sourceDirs)await copyFiles(source, distDir, appDirectory);
|
|
252
253
|
utils_namespaceObject.logger.info("TS-Go compile succeed");
|
|
253
254
|
};
|
|
@@ -42,9 +42,16 @@ __webpack_require__.d(__webpack_exports__, {
|
|
|
42
42
|
});
|
|
43
43
|
const utils_namespaceObject = require("@modern-js/utils");
|
|
44
44
|
const tsconfig_paths_namespaceObject = require("@modern-js/utils/tsconfig-paths");
|
|
45
|
-
const external_os_namespaceObject = require("os");
|
|
46
45
|
const external_path_namespaceObject = require("path");
|
|
47
46
|
var external_path_default = /*#__PURE__*/ __webpack_require__.n(external_path_namespaceObject);
|
|
47
|
+
const windowsAbsolutePathRE = /^[A-Za-z]:[\\/]/u;
|
|
48
|
+
const isAbsolutePath = (input)=>external_path_default().isAbsolute(input) || external_path_default().win32.isAbsolute(input);
|
|
49
|
+
const pathApiFor = (...inputs)=>inputs.some((input)=>windowsAbsolutePathRE.test(input)) ? external_path_default().win32 : external_path_default();
|
|
50
|
+
const toImportSpecifier = (sourceFile, resolvedPath)=>{
|
|
51
|
+
const pathApi = pathApiFor(sourceFile, resolvedPath);
|
|
52
|
+
const relativePath = pathApi.relative(pathApi.dirname(sourceFile), resolvedPath).split(pathApi.sep).join(external_path_default().posix.sep);
|
|
53
|
+
return '.' === relativePath[0] ? relativePath : `./${relativePath}`;
|
|
54
|
+
};
|
|
48
55
|
const toEsmOutputPath = (resolvedPath)=>{
|
|
49
56
|
const sourcePath = (0, utils_namespaceObject.findSourceEntry)(resolvedPath) || resolvedPath;
|
|
50
57
|
const ext = external_path_default().extname(sourcePath);
|
|
@@ -52,8 +59,8 @@ const toEsmOutputPath = (resolvedPath)=>{
|
|
|
52
59
|
};
|
|
53
60
|
const resolveRelativeEsmSpecifier = (sourceFile, text)=>{
|
|
54
61
|
if (!text.startsWith('./') && !text.startsWith('../')) return;
|
|
55
|
-
const
|
|
56
|
-
return
|
|
62
|
+
const pathApi = pathApiFor(sourceFile);
|
|
63
|
+
return pathApi.resolve(pathApi.dirname(sourceFile), text);
|
|
57
64
|
};
|
|
58
65
|
const isRegExpKey = (str)=>str.startsWith('^') || str.endsWith('$');
|
|
59
66
|
const resolveAliasPath = (baseUrl, filePath)=>{
|
|
@@ -116,8 +123,7 @@ function getNotAliasedPath(sourceFile, matcher, text, moduleType) {
|
|
|
116
123
|
let result = (0, utils_namespaceObject.findMatchedSourcePath)(matcher, text);
|
|
117
124
|
if (!result && 'module' === moduleType) result = resolveRelativeEsmSpecifier(sourceFile, text);
|
|
118
125
|
if (!result) return;
|
|
119
|
-
if (
|
|
120
|
-
if (!external_path_default().isAbsolute(result)) {
|
|
126
|
+
if (!isAbsolutePath(result)) {
|
|
121
127
|
if (!result.startsWith('.') && !result.startsWith('..')) try {
|
|
122
128
|
const packagePath = require.resolve(result, {
|
|
123
129
|
paths: [
|
|
@@ -138,8 +144,7 @@ function getNotAliasedPath(sourceFile, matcher, text, moduleType) {
|
|
|
138
144
|
} catch {}
|
|
139
145
|
}
|
|
140
146
|
if ('module' === moduleType) result = toEsmOutputPath(result);
|
|
141
|
-
|
|
142
|
-
return '.' === resolvedPath[0] ? resolvedPath : `./${resolvedPath}`;
|
|
147
|
+
return toImportSpecifier(sourceFile, result) || './';
|
|
143
148
|
}
|
|
144
149
|
exports.createTsconfigPathsMatcher = __webpack_exports__.createTsconfigPathsMatcher;
|
|
145
150
|
exports.getNotAliasedPath = __webpack_exports__.getNotAliasedPath;
|
|
@@ -29,6 +29,7 @@ const createResolvedTsgoConfig = async (appDirectory, tsconfigPath, distDir, sou
|
|
|
29
29
|
config.compilerOptions ??= {};
|
|
30
30
|
config.compilerOptions.rootDir = appDirectory;
|
|
31
31
|
config.compilerOptions.outDir = distDir;
|
|
32
|
+
config.compilerOptions.noEmit = false;
|
|
32
33
|
config.files = filterSourceFiles(tsconfigDir, sourceDirs, config.files);
|
|
33
34
|
delete config.include;
|
|
34
35
|
delete config.compilerOptions.baseUrl;
|
|
@@ -192,6 +193,7 @@ const compileByTs = async (appDirectory, config, compileOptions)=>{
|
|
|
192
193
|
}
|
|
193
194
|
if (result.stderr) logger.error(result.stderr);
|
|
194
195
|
if (result.stdout) logger.info(result.stdout);
|
|
196
|
+
await rewriteOutputSpecifiers(appDirectory, distDir, absoluteBaseUrl, paths, compileOptions.moduleType);
|
|
195
197
|
if (0 !== result.code) {
|
|
196
198
|
const noEmitOnError = tsgoConfig.compilerOptions?.noEmitOnError;
|
|
197
199
|
if (void 0 === noEmitOnError || true === noEmitOnError) if (compileOptions.throwErrorInsteadOfExit) {
|
|
@@ -202,7 +204,6 @@ const compileByTs = async (appDirectory, config, compileOptions)=>{
|
|
|
202
204
|
].filter(Boolean).join('\n'));
|
|
203
205
|
} else process.exit(1);
|
|
204
206
|
}
|
|
205
|
-
await rewriteOutputSpecifiers(appDirectory, distDir, absoluteBaseUrl, paths, compileOptions.moduleType);
|
|
206
207
|
for (const source of sourceDirs)await copyFiles(source, distDir, appDirectory);
|
|
207
208
|
logger.info("TS-Go compile succeed");
|
|
208
209
|
};
|
|
@@ -1,7 +1,14 @@
|
|
|
1
1
|
import { findMatchedSourcePath, findSourceEntry } from "@modern-js/utils";
|
|
2
2
|
import { createMatchPath } from "@modern-js/utils/tsconfig-paths";
|
|
3
|
-
import path
|
|
4
|
-
|
|
3
|
+
import path from "path";
|
|
4
|
+
const windowsAbsolutePathRE = /^[A-Za-z]:[\\/]/u;
|
|
5
|
+
const isAbsolutePath = (input)=>path.isAbsolute(input) || path.win32.isAbsolute(input);
|
|
6
|
+
const pathApiFor = (...inputs)=>inputs.some((input)=>windowsAbsolutePathRE.test(input)) ? path.win32 : path;
|
|
7
|
+
const toImportSpecifier = (sourceFile, resolvedPath)=>{
|
|
8
|
+
const pathApi = pathApiFor(sourceFile, resolvedPath);
|
|
9
|
+
const relativePath = pathApi.relative(pathApi.dirname(sourceFile), resolvedPath).split(pathApi.sep).join(path.posix.sep);
|
|
10
|
+
return '.' === relativePath[0] ? relativePath : `./${relativePath}`;
|
|
11
|
+
};
|
|
5
12
|
const toEsmOutputPath = (resolvedPath)=>{
|
|
6
13
|
const sourcePath = findSourceEntry(resolvedPath) || resolvedPath;
|
|
7
14
|
const ext = path.extname(sourcePath);
|
|
@@ -9,8 +16,8 @@ const toEsmOutputPath = (resolvedPath)=>{
|
|
|
9
16
|
};
|
|
10
17
|
const resolveRelativeEsmSpecifier = (sourceFile, text)=>{
|
|
11
18
|
if (!text.startsWith('./') && !text.startsWith('../')) return;
|
|
12
|
-
const
|
|
13
|
-
return
|
|
19
|
+
const pathApi = pathApiFor(sourceFile);
|
|
20
|
+
return pathApi.resolve(pathApi.dirname(sourceFile), text);
|
|
14
21
|
};
|
|
15
22
|
const isRegExpKey = (str)=>str.startsWith('^') || str.endsWith('$');
|
|
16
23
|
const resolveAliasPath = (baseUrl, filePath)=>{
|
|
@@ -73,8 +80,7 @@ function getNotAliasedPath(sourceFile, matcher, text, moduleType) {
|
|
|
73
80
|
let result = findMatchedSourcePath(matcher, text);
|
|
74
81
|
if (!result && 'module' === moduleType) result = resolveRelativeEsmSpecifier(sourceFile, text);
|
|
75
82
|
if (!result) return;
|
|
76
|
-
if (
|
|
77
|
-
if (!path.isAbsolute(result)) {
|
|
83
|
+
if (!isAbsolutePath(result)) {
|
|
78
84
|
if (!result.startsWith('.') && !result.startsWith('..')) try {
|
|
79
85
|
const packagePath = require.resolve(result, {
|
|
80
86
|
paths: [
|
|
@@ -95,7 +101,6 @@ function getNotAliasedPath(sourceFile, matcher, text, moduleType) {
|
|
|
95
101
|
} catch {}
|
|
96
102
|
}
|
|
97
103
|
if ('module' === moduleType) result = toEsmOutputPath(result);
|
|
98
|
-
|
|
99
|
-
return '.' === resolvedPath[0] ? resolvedPath : `./${resolvedPath}`;
|
|
104
|
+
return toImportSpecifier(sourceFile, result) || './';
|
|
100
105
|
}
|
|
101
106
|
export { createTsconfigPathsMatcher, getNotAliasedPath };
|
|
@@ -34,6 +34,7 @@ const createResolvedTsgoConfig = async (appDirectory, tsconfigPath, distDir, sou
|
|
|
34
34
|
config.compilerOptions ??= {};
|
|
35
35
|
config.compilerOptions.rootDir = appDirectory;
|
|
36
36
|
config.compilerOptions.outDir = distDir;
|
|
37
|
+
config.compilerOptions.noEmit = false;
|
|
37
38
|
config.files = filterSourceFiles(tsconfigDir, sourceDirs, config.files);
|
|
38
39
|
delete config.include;
|
|
39
40
|
delete config.compilerOptions.baseUrl;
|
|
@@ -197,6 +198,7 @@ const compileByTs = async (appDirectory, config, compileOptions)=>{
|
|
|
197
198
|
}
|
|
198
199
|
if (result.stderr) logger.error(result.stderr);
|
|
199
200
|
if (result.stdout) logger.info(result.stdout);
|
|
201
|
+
await rewriteOutputSpecifiers(appDirectory, distDir, absoluteBaseUrl, paths, compileOptions.moduleType);
|
|
200
202
|
if (0 !== result.code) {
|
|
201
203
|
const noEmitOnError = tsgoConfig.compilerOptions?.noEmitOnError;
|
|
202
204
|
if (void 0 === noEmitOnError || true === noEmitOnError) if (compileOptions.throwErrorInsteadOfExit) {
|
|
@@ -207,7 +209,6 @@ const compileByTs = async (appDirectory, config, compileOptions)=>{
|
|
|
207
209
|
].filter(Boolean).join('\n'));
|
|
208
210
|
} else process.exit(1);
|
|
209
211
|
}
|
|
210
|
-
await rewriteOutputSpecifiers(appDirectory, distDir, absoluteBaseUrl, paths, compileOptions.moduleType);
|
|
211
212
|
for (const source of sourceDirs)await copyFiles(source, distDir, appDirectory);
|
|
212
213
|
logger.info("TS-Go compile succeed");
|
|
213
214
|
};
|
|
@@ -2,8 +2,15 @@ import __rslib_shim_module__ from "node:module";
|
|
|
2
2
|
const require = /*#__PURE__*/ __rslib_shim_module__.createRequire(/*#__PURE__*/ (()=>import.meta.url)());
|
|
3
3
|
import { findMatchedSourcePath, findSourceEntry } from "@modern-js/utils";
|
|
4
4
|
import { createMatchPath } from "@modern-js/utils/tsconfig-paths";
|
|
5
|
-
import path
|
|
6
|
-
|
|
5
|
+
import path from "path";
|
|
6
|
+
const windowsAbsolutePathRE = /^[A-Za-z]:[\\/]/u;
|
|
7
|
+
const isAbsolutePath = (input)=>path.isAbsolute(input) || path.win32.isAbsolute(input);
|
|
8
|
+
const pathApiFor = (...inputs)=>inputs.some((input)=>windowsAbsolutePathRE.test(input)) ? path.win32 : path;
|
|
9
|
+
const toImportSpecifier = (sourceFile, resolvedPath)=>{
|
|
10
|
+
const pathApi = pathApiFor(sourceFile, resolvedPath);
|
|
11
|
+
const relativePath = pathApi.relative(pathApi.dirname(sourceFile), resolvedPath).split(pathApi.sep).join(path.posix.sep);
|
|
12
|
+
return '.' === relativePath[0] ? relativePath : `./${relativePath}`;
|
|
13
|
+
};
|
|
7
14
|
const toEsmOutputPath = (resolvedPath)=>{
|
|
8
15
|
const sourcePath = findSourceEntry(resolvedPath) || resolvedPath;
|
|
9
16
|
const ext = path.extname(sourcePath);
|
|
@@ -11,8 +18,8 @@ const toEsmOutputPath = (resolvedPath)=>{
|
|
|
11
18
|
};
|
|
12
19
|
const resolveRelativeEsmSpecifier = (sourceFile, text)=>{
|
|
13
20
|
if (!text.startsWith('./') && !text.startsWith('../')) return;
|
|
14
|
-
const
|
|
15
|
-
return
|
|
21
|
+
const pathApi = pathApiFor(sourceFile);
|
|
22
|
+
return pathApi.resolve(pathApi.dirname(sourceFile), text);
|
|
16
23
|
};
|
|
17
24
|
const isRegExpKey = (str)=>str.startsWith('^') || str.endsWith('$');
|
|
18
25
|
const resolveAliasPath = (baseUrl, filePath)=>{
|
|
@@ -75,8 +82,7 @@ function getNotAliasedPath(sourceFile, matcher, text, moduleType) {
|
|
|
75
82
|
let result = findMatchedSourcePath(matcher, text);
|
|
76
83
|
if (!result && 'module' === moduleType) result = resolveRelativeEsmSpecifier(sourceFile, text);
|
|
77
84
|
if (!result) return;
|
|
78
|
-
if (
|
|
79
|
-
if (!path.isAbsolute(result)) {
|
|
85
|
+
if (!isAbsolutePath(result)) {
|
|
80
86
|
if (!result.startsWith('.') && !result.startsWith('..')) try {
|
|
81
87
|
const packagePath = require.resolve(result, {
|
|
82
88
|
paths: [
|
|
@@ -97,7 +103,6 @@ function getNotAliasedPath(sourceFile, matcher, text, moduleType) {
|
|
|
97
103
|
} catch {}
|
|
98
104
|
}
|
|
99
105
|
if ('module' === moduleType) result = toEsmOutputPath(result);
|
|
100
|
-
|
|
101
|
-
return '.' === resolvedPath[0] ? resolvedPath : `./${resolvedPath}`;
|
|
106
|
+
return toImportSpecifier(sourceFile, result) || './';
|
|
102
107
|
}
|
|
103
108
|
export { createTsconfigPathsMatcher, getNotAliasedPath };
|
package/package.json
CHANGED
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
"modern",
|
|
18
18
|
"modern.js"
|
|
19
19
|
],
|
|
20
|
-
"version": "3.4.0-ultramodern.
|
|
20
|
+
"version": "3.4.0-ultramodern.3",
|
|
21
21
|
"types": "./dist/types/index.d.ts",
|
|
22
22
|
"main": "./dist/cjs/index.js",
|
|
23
23
|
"exports": {
|
|
@@ -40,13 +40,13 @@
|
|
|
40
40
|
},
|
|
41
41
|
"dependencies": {
|
|
42
42
|
"@swc/helpers": "^0.5.23",
|
|
43
|
-
"@modern-js/utils": "npm:@bleedingdev/modern-js-utils@3.4.0-ultramodern.
|
|
43
|
+
"@modern-js/utils": "npm:@bleedingdev/modern-js-utils@3.4.0-ultramodern.3"
|
|
44
44
|
},
|
|
45
45
|
"devDependencies": {
|
|
46
46
|
"@rslib/core": "0.23.0",
|
|
47
|
-
"@types/node": "^26.0.
|
|
47
|
+
"@types/node": "^26.0.1",
|
|
48
48
|
"@typescript/native-preview": "7.0.0-dev.20260624.1",
|
|
49
|
-
"@modern-js/server-core": "npm:@bleedingdev/modern-js-server-core@3.4.0-ultramodern.
|
|
49
|
+
"@modern-js/server-core": "npm:@bleedingdev/modern-js-server-core@3.4.0-ultramodern.3",
|
|
50
50
|
"@scripts/rstest-config": "2.66.0"
|
|
51
51
|
},
|
|
52
52
|
"peerDependencies": {
|