@bleedingdev/modern-js-server-utils 3.4.0-ultramodern.0 → 3.4.0-ultramodern.10
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 +18 -11
- package/dist/cjs/compilers/typescript/tsconfigPathsPlugin.js +12 -7
- package/dist/esm/compilers/typescript/index.mjs +18 -11
- package/dist/esm/compilers/typescript/tsconfigPathsPlugin.mjs +13 -8
- package/dist/esm-node/compilers/typescript/index.mjs +18 -11
- package/dist/esm-node/compilers/typescript/tsconfigPathsPlugin.mjs +13 -8
- package/dist/types/compilers/typescript/index.d.ts +4 -0
- package/package.json +5 -5
|
@@ -74,6 +74,8 @@ 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;
|
|
78
|
+
if (true === config.compilerOptions.allowImportingTsExtensions) config.compilerOptions.rewriteRelativeImportExtensions = true;
|
|
77
79
|
config.files = filterSourceFiles(tsconfigDir, sourceDirs, config.files);
|
|
78
80
|
delete config.include;
|
|
79
81
|
delete config.compilerOptions.baseUrl;
|
|
@@ -81,16 +83,19 @@ const createResolvedTsgoConfig = async (appDirectory, tsconfigPath, distDir, sou
|
|
|
81
83
|
'node',
|
|
82
84
|
'node10'
|
|
83
85
|
].includes(String(config.compilerOptions.moduleResolution).toLowerCase())) delete config.compilerOptions.moduleResolution;
|
|
84
|
-
if ('module' !== moduleType
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
config.compilerOptions.module
|
|
93
|
-
|
|
86
|
+
if ('module' !== moduleType) {
|
|
87
|
+
if ([
|
|
88
|
+
'preserve',
|
|
89
|
+
'esnext',
|
|
90
|
+
'es2015',
|
|
91
|
+
'es2020',
|
|
92
|
+
'es2022',
|
|
93
|
+
'es6'
|
|
94
|
+
].includes(String(config.compilerOptions.module).toLowerCase())) {
|
|
95
|
+
config.compilerOptions.module = 'commonjs';
|
|
96
|
+
delete config.compilerOptions.moduleResolution;
|
|
97
|
+
}
|
|
98
|
+
config.compilerOptions.verbatimModuleSyntax = false;
|
|
94
99
|
}
|
|
95
100
|
const resolvedConfigPath = external_path_default().join(tsconfigDir, `.tsgo.${process.pid}.${resolvedConfigCount++}.resolved.json`);
|
|
96
101
|
await utils_namespaceObject.fs.writeFile(resolvedConfigPath, JSON.stringify(config, null, 2));
|
|
@@ -103,9 +108,11 @@ const filterSourceFiles = (tsconfigDir, sourceDirs, files = [])=>{
|
|
|
103
108
|
const sourcePosixPaths = sourceDirs.map((sourceDir)=>sourceDir.split(external_path_default().sep).join(external_path_default().posix.sep));
|
|
104
109
|
return files.filter((fileName)=>{
|
|
105
110
|
const absoluteFileName = external_path_default().resolve(tsconfigDir, fileName).split(external_path_default().sep).join(external_path_default().posix.sep);
|
|
111
|
+
if (isAppRouterGeneratedDeclaration(absoluteFileName)) return false;
|
|
106
112
|
return fileName.endsWith('.d.ts') || sourcePosixPaths.some((sourceDir)=>absoluteFileName.includes(sourceDir));
|
|
107
113
|
});
|
|
108
114
|
};
|
|
115
|
+
const isAppRouterGeneratedDeclaration = (absoluteFileName)=>/\/src\/modern-tanstack\/.*\.gen\.d\.ts$/u.test(absoluteFileName);
|
|
109
116
|
const runTsgo = (tsgoBinPath, args, options)=>new Promise((resolve, reject)=>{
|
|
110
117
|
const child = (0, external_child_process_namespaceObject.spawn)(process.execPath, [
|
|
111
118
|
tsgoBinPath,
|
|
@@ -234,6 +241,7 @@ const compileByTs = async (appDirectory, config, compileOptions)=>{
|
|
|
234
241
|
}
|
|
235
242
|
if (result.stderr) utils_namespaceObject.logger.error(result.stderr);
|
|
236
243
|
if (result.stdout) utils_namespaceObject.logger.info(result.stdout);
|
|
244
|
+
await rewriteOutputSpecifiers(appDirectory, distDir, absoluteBaseUrl, paths, compileOptions.moduleType);
|
|
237
245
|
if (0 !== result.code) {
|
|
238
246
|
const noEmitOnError = tsgoConfig.compilerOptions?.noEmitOnError;
|
|
239
247
|
if (void 0 === noEmitOnError || true === noEmitOnError) if (compileOptions.throwErrorInsteadOfExit) {
|
|
@@ -244,7 +252,6 @@ const compileByTs = async (appDirectory, config, compileOptions)=>{
|
|
|
244
252
|
].filter(Boolean).join('\n'));
|
|
245
253
|
} else process.exit(1);
|
|
246
254
|
}
|
|
247
|
-
await rewriteOutputSpecifiers(appDirectory, distDir, absoluteBaseUrl, paths, compileOptions.moduleType);
|
|
248
255
|
for (const source of sourceDirs)await copyFiles(source, distDir, appDirectory);
|
|
249
256
|
utils_namespaceObject.logger.info("TS-Go compile succeed");
|
|
250
257
|
};
|
|
@@ -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,8 @@ 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;
|
|
33
|
+
if (true === config.compilerOptions.allowImportingTsExtensions) config.compilerOptions.rewriteRelativeImportExtensions = true;
|
|
32
34
|
config.files = filterSourceFiles(tsconfigDir, sourceDirs, config.files);
|
|
33
35
|
delete config.include;
|
|
34
36
|
delete config.compilerOptions.baseUrl;
|
|
@@ -36,16 +38,19 @@ const createResolvedTsgoConfig = async (appDirectory, tsconfigPath, distDir, sou
|
|
|
36
38
|
'node',
|
|
37
39
|
'node10'
|
|
38
40
|
].includes(String(config.compilerOptions.moduleResolution).toLowerCase())) delete config.compilerOptions.moduleResolution;
|
|
39
|
-
if ('module' !== moduleType
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
config.compilerOptions.module
|
|
48
|
-
|
|
41
|
+
if ('module' !== moduleType) {
|
|
42
|
+
if ([
|
|
43
|
+
'preserve',
|
|
44
|
+
'esnext',
|
|
45
|
+
'es2015',
|
|
46
|
+
'es2020',
|
|
47
|
+
'es2022',
|
|
48
|
+
'es6'
|
|
49
|
+
].includes(String(config.compilerOptions.module).toLowerCase())) {
|
|
50
|
+
config.compilerOptions.module = 'commonjs';
|
|
51
|
+
delete config.compilerOptions.moduleResolution;
|
|
52
|
+
}
|
|
53
|
+
config.compilerOptions.verbatimModuleSyntax = false;
|
|
49
54
|
}
|
|
50
55
|
const resolvedConfigPath = path.join(tsconfigDir, `.tsgo.${process.pid}.${resolvedConfigCount++}.resolved.json`);
|
|
51
56
|
await fs.writeFile(resolvedConfigPath, JSON.stringify(config, null, 2));
|
|
@@ -58,9 +63,11 @@ const filterSourceFiles = (tsconfigDir, sourceDirs, files = [])=>{
|
|
|
58
63
|
const sourcePosixPaths = sourceDirs.map((sourceDir)=>sourceDir.split(path.sep).join(path.posix.sep));
|
|
59
64
|
return files.filter((fileName)=>{
|
|
60
65
|
const absoluteFileName = path.resolve(tsconfigDir, fileName).split(path.sep).join(path.posix.sep);
|
|
66
|
+
if (isAppRouterGeneratedDeclaration(absoluteFileName)) return false;
|
|
61
67
|
return fileName.endsWith('.d.ts') || sourcePosixPaths.some((sourceDir)=>absoluteFileName.includes(sourceDir));
|
|
62
68
|
});
|
|
63
69
|
};
|
|
70
|
+
const isAppRouterGeneratedDeclaration = (absoluteFileName)=>/\/src\/modern-tanstack\/.*\.gen\.d\.ts$/u.test(absoluteFileName);
|
|
64
71
|
const runTsgo = (tsgoBinPath, args, options)=>new Promise((resolve, reject)=>{
|
|
65
72
|
const child = spawn(process.execPath, [
|
|
66
73
|
tsgoBinPath,
|
|
@@ -189,6 +196,7 @@ const compileByTs = async (appDirectory, config, compileOptions)=>{
|
|
|
189
196
|
}
|
|
190
197
|
if (result.stderr) logger.error(result.stderr);
|
|
191
198
|
if (result.stdout) logger.info(result.stdout);
|
|
199
|
+
await rewriteOutputSpecifiers(appDirectory, distDir, absoluteBaseUrl, paths, compileOptions.moduleType);
|
|
192
200
|
if (0 !== result.code) {
|
|
193
201
|
const noEmitOnError = tsgoConfig.compilerOptions?.noEmitOnError;
|
|
194
202
|
if (void 0 === noEmitOnError || true === noEmitOnError) if (compileOptions.throwErrorInsteadOfExit) {
|
|
@@ -199,7 +207,6 @@ const compileByTs = async (appDirectory, config, compileOptions)=>{
|
|
|
199
207
|
].filter(Boolean).join('\n'));
|
|
200
208
|
} else process.exit(1);
|
|
201
209
|
}
|
|
202
|
-
await rewriteOutputSpecifiers(appDirectory, distDir, absoluteBaseUrl, paths, compileOptions.moduleType);
|
|
203
210
|
for (const source of sourceDirs)await copyFiles(source, distDir, appDirectory);
|
|
204
211
|
logger.info("TS-Go compile succeed");
|
|
205
212
|
};
|
|
@@ -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,8 @@ 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;
|
|
38
|
+
if (true === config.compilerOptions.allowImportingTsExtensions) config.compilerOptions.rewriteRelativeImportExtensions = true;
|
|
37
39
|
config.files = filterSourceFiles(tsconfigDir, sourceDirs, config.files);
|
|
38
40
|
delete config.include;
|
|
39
41
|
delete config.compilerOptions.baseUrl;
|
|
@@ -41,16 +43,19 @@ const createResolvedTsgoConfig = async (appDirectory, tsconfigPath, distDir, sou
|
|
|
41
43
|
'node',
|
|
42
44
|
'node10'
|
|
43
45
|
].includes(String(config.compilerOptions.moduleResolution).toLowerCase())) delete config.compilerOptions.moduleResolution;
|
|
44
|
-
if ('module' !== moduleType
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
config.compilerOptions.module
|
|
53
|
-
|
|
46
|
+
if ('module' !== moduleType) {
|
|
47
|
+
if ([
|
|
48
|
+
'preserve',
|
|
49
|
+
'esnext',
|
|
50
|
+
'es2015',
|
|
51
|
+
'es2020',
|
|
52
|
+
'es2022',
|
|
53
|
+
'es6'
|
|
54
|
+
].includes(String(config.compilerOptions.module).toLowerCase())) {
|
|
55
|
+
config.compilerOptions.module = 'commonjs';
|
|
56
|
+
delete config.compilerOptions.moduleResolution;
|
|
57
|
+
}
|
|
58
|
+
config.compilerOptions.verbatimModuleSyntax = false;
|
|
54
59
|
}
|
|
55
60
|
const resolvedConfigPath = path.join(tsconfigDir, `.tsgo.${process.pid}.${resolvedConfigCount++}.resolved.json`);
|
|
56
61
|
await fs.writeFile(resolvedConfigPath, JSON.stringify(config, null, 2));
|
|
@@ -63,9 +68,11 @@ const filterSourceFiles = (tsconfigDir, sourceDirs, files = [])=>{
|
|
|
63
68
|
const sourcePosixPaths = sourceDirs.map((sourceDir)=>sourceDir.split(path.sep).join(path.posix.sep));
|
|
64
69
|
return files.filter((fileName)=>{
|
|
65
70
|
const absoluteFileName = path.resolve(tsconfigDir, fileName).split(path.sep).join(path.posix.sep);
|
|
71
|
+
if (isAppRouterGeneratedDeclaration(absoluteFileName)) return false;
|
|
66
72
|
return fileName.endsWith('.d.ts') || sourcePosixPaths.some((sourceDir)=>absoluteFileName.includes(sourceDir));
|
|
67
73
|
});
|
|
68
74
|
};
|
|
75
|
+
const isAppRouterGeneratedDeclaration = (absoluteFileName)=>/\/src\/modern-tanstack\/.*\.gen\.d\.ts$/u.test(absoluteFileName);
|
|
69
76
|
const runTsgo = (tsgoBinPath, args, options)=>new Promise((resolve, reject)=>{
|
|
70
77
|
const child = spawn(process.execPath, [
|
|
71
78
|
tsgoBinPath,
|
|
@@ -194,6 +201,7 @@ const compileByTs = async (appDirectory, config, compileOptions)=>{
|
|
|
194
201
|
}
|
|
195
202
|
if (result.stderr) logger.error(result.stderr);
|
|
196
203
|
if (result.stdout) logger.info(result.stdout);
|
|
204
|
+
await rewriteOutputSpecifiers(appDirectory, distDir, absoluteBaseUrl, paths, compileOptions.moduleType);
|
|
197
205
|
if (0 !== result.code) {
|
|
198
206
|
const noEmitOnError = tsgoConfig.compilerOptions?.noEmitOnError;
|
|
199
207
|
if (void 0 === noEmitOnError || true === noEmitOnError) if (compileOptions.throwErrorInsteadOfExit) {
|
|
@@ -204,7 +212,6 @@ const compileByTs = async (appDirectory, config, compileOptions)=>{
|
|
|
204
212
|
].filter(Boolean).join('\n'));
|
|
205
213
|
} else process.exit(1);
|
|
206
214
|
}
|
|
207
|
-
await rewriteOutputSpecifiers(appDirectory, distDir, absoluteBaseUrl, paths, compileOptions.moduleType);
|
|
208
215
|
for (const source of sourceDirs)await copyFiles(source, distDir, appDirectory);
|
|
209
216
|
logger.info("TS-Go compile succeed");
|
|
210
217
|
};
|
|
@@ -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 };
|
|
@@ -1,12 +1,16 @@
|
|
|
1
1
|
import type { CompileFunc } from '../../common';
|
|
2
2
|
type TsgoConfig = {
|
|
3
3
|
compilerOptions?: {
|
|
4
|
+
allowImportingTsExtensions?: boolean;
|
|
4
5
|
baseUrl?: unknown;
|
|
5
6
|
module?: string;
|
|
6
7
|
moduleResolution?: string;
|
|
8
|
+
noEmit?: boolean;
|
|
7
9
|
noEmitOnError?: boolean;
|
|
8
10
|
outDir?: string;
|
|
9
11
|
rootDir?: string;
|
|
12
|
+
rewriteRelativeImportExtensions?: boolean;
|
|
13
|
+
verbatimModuleSyntax?: boolean;
|
|
10
14
|
};
|
|
11
15
|
files?: string[];
|
|
12
16
|
include?: string[];
|
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.10",
|
|
21
21
|
"types": "./dist/types/index.d.ts",
|
|
22
22
|
"main": "./dist/cjs/index.js",
|
|
23
23
|
"exports": {
|
|
@@ -40,14 +40,14 @@
|
|
|
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.10"
|
|
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
|
-
"@
|
|
50
|
-
"@
|
|
49
|
+
"@modern-js/server-core": "npm:@bleedingdev/modern-js-server-core@3.4.0-ultramodern.10",
|
|
50
|
+
"@scripts/rstest-config": "2.66.0"
|
|
51
51
|
},
|
|
52
52
|
"peerDependencies": {
|
|
53
53
|
"@typescript/native-preview": ">=7.0.0-dev.20260624.1"
|