ts-swc-transform 2.11.5 → 2.11.7
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/lib/patchCJS.d.cts +2 -2
- package/dist/cjs/lib/patchCJS.d.ts +2 -2
- package/dist/cjs/lib/patchCJS.js.map +1 -1
- package/dist/cjs/lib/patchESM.d.cts +2 -2
- package/dist/cjs/lib/patchESM.d.ts +2 -2
- package/dist/cjs/lib/patchESM.js.map +1 -1
- package/dist/cjs/lib/prepareSWCOptions.js +8 -1
- package/dist/cjs/lib/prepareSWCOptions.js.map +1 -1
- package/dist/cjs/lib/rewriteExtensions.d.cts +1 -6
- package/dist/cjs/lib/rewriteExtensions.d.ts +1 -6
- package/dist/cjs/lib/rewriteExtensions.js.map +1 -1
- package/dist/cjs/lib/transformFile.d.cts +2 -2
- package/dist/cjs/lib/transformFile.d.ts +2 -2
- package/dist/cjs/lib/transformFile.js +22 -9
- package/dist/cjs/lib/transformFile.js.map +1 -1
- package/dist/cjs/lib/urlFileUrl.js +2 -1
- package/dist/cjs/lib/urlFileUrl.js.map +1 -1
- package/dist/cjs/resolveFileSync.d.cts +1 -1
- package/dist/cjs/resolveFileSync.d.ts +1 -1
- package/dist/cjs/resolveFileSync.js.map +1 -1
- package/dist/cjs/transformDirectory.js +27 -3
- package/dist/cjs/transformDirectory.js.map +1 -1
- package/dist/cjs/transformTypes.js +27 -3
- package/dist/cjs/transformTypes.js.map +1 -1
- package/dist/cjs/types.d.cts +6 -3
- package/dist/cjs/types.d.ts +6 -3
- package/dist/cjs/workers/transformDirectory.d.cts +2 -2
- package/dist/cjs/workers/transformDirectory.d.ts +2 -2
- package/dist/cjs/workers/transformDirectory.js +12 -9
- package/dist/cjs/workers/transformDirectory.js.map +1 -1
- package/dist/cjs/workers/transformTypes.d.cts +2 -2
- package/dist/cjs/workers/transformTypes.d.ts +2 -2
- package/dist/cjs/workers/transformTypes.js +25 -28
- package/dist/cjs/workers/transformTypes.js.map +1 -1
- package/dist/esm/lib/patchCJS.d.ts +2 -2
- package/dist/esm/lib/patchCJS.js.map +1 -1
- package/dist/esm/lib/patchESM.d.ts +2 -2
- package/dist/esm/lib/patchESM.js.map +1 -1
- package/dist/esm/lib/prepareSWCOptions.js +1 -1
- package/dist/esm/lib/prepareSWCOptions.js.map +1 -1
- package/dist/esm/lib/rewriteExtensions.d.ts +1 -6
- package/dist/esm/lib/rewriteExtensions.js.map +1 -1
- package/dist/esm/lib/transformFile.d.ts +2 -2
- package/dist/esm/lib/transformFile.js +14 -12
- package/dist/esm/lib/transformFile.js.map +1 -1
- package/dist/esm/lib/urlFileUrl.js +2 -1
- package/dist/esm/lib/urlFileUrl.js.map +1 -1
- package/dist/esm/resolveFileSync.d.ts +1 -1
- package/dist/esm/resolveFileSync.js.map +1 -1
- package/dist/esm/transformDirectory.js +3 -3
- package/dist/esm/transformDirectory.js.map +1 -1
- package/dist/esm/transformTypes.js +3 -3
- package/dist/esm/transformTypes.js.map +1 -1
- package/dist/esm/types.d.ts +6 -3
- package/dist/esm/types.js.map +1 -1
- package/dist/esm/workers/transformDirectory.d.ts +2 -2
- package/dist/esm/workers/transformDirectory.js +12 -9
- package/dist/esm/workers/transformDirectory.js.map +1 -1
- package/dist/esm/workers/transformTypes.d.ts +2 -2
- package/dist/esm/workers/transformTypes.js +23 -28
- package/dist/esm/workers/transformTypes.js.map +1 -1
- package/package.json +5 -2
package/dist/esm/types.d.ts
CHANGED
|
@@ -9,8 +9,11 @@ export interface ConfigOptions {
|
|
|
9
9
|
cwd?: string;
|
|
10
10
|
sourceMaps?: boolean;
|
|
11
11
|
}
|
|
12
|
-
export
|
|
13
|
-
|
|
14
|
-
|
|
12
|
+
export interface InternalConfigOptions extends ConfigOptions {
|
|
13
|
+
tsconfig: TSConfig;
|
|
14
|
+
}
|
|
15
|
+
export type TransformDirectoryCallback = (err?: Error | null, filePaths?: string[]) => void;
|
|
16
|
+
export type TransformFileCallback = (err?: Error | null, destFilePath?: string) => void;
|
|
17
|
+
export type TransformTypesCallback = (err?: Error | null, filePaths?: string[]) => void;
|
|
15
18
|
export type Matcher = (filePath: string) => boolean;
|
|
16
19
|
export type TargetType = 'cjs' | 'esm';
|
package/dist/esm/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/typescript/ts-swc-transform/src/types.ts"],"sourcesContent":["import type { TSConfig } from 'read-tsconfig-sync';\n\nexport interface Context {\n parentURL?: string;\n parentPath?: string;\n}\n\nexport type { TSConfig, TSConfigSchema } from 'read-tsconfig-sync';\nexport interface ConfigOptions {\n tsconfig?: TSConfig;\n cwd?: string;\n sourceMaps?: boolean;\n}\n\nexport type TransformDirectoryCallback = (err?: Error, filePaths?: string[]) => void;\nexport type TransformFileCallback = (err?: Error, destFilePath?: string) => void;\nexport type TransformTypesCallback = (err?: Error, filePaths?: string[]) => void;\n\nexport type Matcher = (filePath: string) => boolean;\n\nexport type TargetType = 'cjs' | 'esm';\n"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/typescript/ts-swc-transform/src/types.ts"],"sourcesContent":["import type { TSConfig } from 'read-tsconfig-sync';\n\nexport interface Context {\n parentURL?: string;\n parentPath?: string;\n}\n\nexport type { TSConfig, TSConfigSchema } from 'read-tsconfig-sync';\nexport interface ConfigOptions {\n tsconfig?: TSConfig;\n cwd?: string;\n sourceMaps?: boolean;\n}\n\n// Workers receive options after tsconfig has been resolved by the public entry points.\nexport interface InternalConfigOptions extends ConfigOptions {\n tsconfig: TSConfig;\n}\n\nexport type TransformDirectoryCallback = (err?: Error | null, filePaths?: string[]) => void;\nexport type TransformFileCallback = (err?: Error | null, destFilePath?: string) => void;\nexport type TransformTypesCallback = (err?: Error | null, filePaths?: string[]) => void;\n\nexport type Matcher = (filePath: string) => boolean;\n\nexport type TargetType = 'cjs' | 'esm';\n"],"names":[],"mappings":"AAyBA,WAAuC"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
export default function transformDirectoryWorker(src: string, dest: string, type: TargetType, options:
|
|
1
|
+
import type { InternalConfigOptions, TargetType, TransformDirectoryCallback } from '../types.js';
|
|
2
|
+
export default function transformDirectoryWorker(src: string, dest: string, type: TargetType, options: InternalConfigOptions, callback: TransformDirectoryCallback): void;
|
|
@@ -13,31 +13,34 @@ export default function transformDirectoryWorker(src, dest, type, options, callb
|
|
|
13
13
|
alwaysStat: true
|
|
14
14
|
});
|
|
15
15
|
iterator.forEach((entry)=>{
|
|
16
|
-
|
|
17
|
-
if (
|
|
18
|
-
|
|
16
|
+
const stats = entry.stats;
|
|
17
|
+
if (!stats || !stats.isFile()) return;
|
|
18
|
+
const basename = entry.basename;
|
|
19
|
+
if (basename[0] === '.') return;
|
|
20
|
+
if (typeFileRegEx.test(basename)) return;
|
|
19
21
|
if (!matcher(entry.fullPath)) return;
|
|
20
|
-
const ext = path.extname(
|
|
22
|
+
const ext = path.extname(basename);
|
|
21
23
|
if (ext && extensions.indexOf(ext) < 0) return;
|
|
22
24
|
entries.push(entry);
|
|
23
|
-
const stats = entry.stats;
|
|
24
25
|
if (stats.mode) {
|
|
25
26
|
modeByPath.set(entry.fullPath, stats.mode);
|
|
26
27
|
}
|
|
27
28
|
}, (err)=>{
|
|
28
29
|
if (err) return callback(err);
|
|
29
30
|
const results = [];
|
|
30
|
-
|
|
31
|
+
const opts = {
|
|
31
32
|
...options,
|
|
32
33
|
tsconfig
|
|
33
34
|
};
|
|
34
35
|
const queue = new Queue();
|
|
35
36
|
entries.forEach((entry)=>{
|
|
36
37
|
const mode = modeByPath.get(entry.fullPath);
|
|
37
|
-
queue.defer((cb)=>transformFile(entry, dest, type,
|
|
38
|
+
queue.defer((cb)=>transformFile(entry, dest, type, opts, mode, (err, outPath)=>{
|
|
38
39
|
if (err) return cb(err);
|
|
39
|
-
|
|
40
|
-
|
|
40
|
+
if (outPath) {
|
|
41
|
+
results.push(path.normalize(outPath));
|
|
42
|
+
if (opts.sourceMaps) results.push(`${path.normalize(outPath)}.map`);
|
|
43
|
+
}
|
|
41
44
|
cb();
|
|
42
45
|
}));
|
|
43
46
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/typescript/ts-swc-transform/src/workers/transformDirectory.ts"],"sourcesContent":["import type fs from 'fs';\nimport Iterator, { type Entry } from 'fs-iterator';\nimport path from 'path';\nimport Queue from 'queue-cb';\n\nimport { extensions, typeFileRegEx } from '../constants.ts';\nimport createMatcher from '../createMatcher.ts';\nimport transformFile from '../lib/transformFile.ts';\n\nimport type {
|
|
1
|
+
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/typescript/ts-swc-transform/src/workers/transformDirectory.ts"],"sourcesContent":["import type fs from 'fs';\nimport Iterator, { type Entry } from 'fs-iterator';\nimport path from 'path';\nimport Queue from 'queue-cb';\n\nimport { extensions, typeFileRegEx } from '../constants.ts';\nimport createMatcher from '../createMatcher.ts';\nimport transformFile from '../lib/transformFile.ts';\n\nimport type { InternalConfigOptions, TargetType, TransformDirectoryCallback } from '../types.ts';\n\nexport default function transformDirectoryWorker(src: string, dest: string, type: TargetType, options: InternalConfigOptions, callback: TransformDirectoryCallback) {\n const tsconfig = options.tsconfig;\n const matcher = createMatcher(tsconfig);\n\n const entries: Entry[] = [];\n const modeByPath = new Map<string, number>();\n const iterator = new Iterator(src, { alwaysStat: true });\n iterator.forEach(\n (entry: Entry): void => {\n const stats = entry.stats as fs.Stats | undefined;\n if (!stats || !stats.isFile()) return;\n const basename = entry.basename as string;\n if (basename[0] === '.') return;\n if (typeFileRegEx.test(basename)) return;\n if (!matcher(entry.fullPath)) return;\n const ext = path.extname(basename);\n if (ext && extensions.indexOf(ext) < 0) return;\n entries.push(entry);\n\n if (stats.mode) {\n modeByPath.set(entry.fullPath, stats.mode);\n }\n },\n (err) => {\n if (err) return callback(err);\n const results: string[] = [];\n const opts: InternalConfigOptions = { ...options, tsconfig };\n\n const queue = new Queue();\n entries.forEach((entry: Entry) => {\n const mode = modeByPath.get(entry.fullPath);\n queue.defer((cb) =>\n transformFile(entry, dest, type, opts, mode, (err, outPath) => {\n if (err) return cb(err);\n if (outPath) {\n results.push(path.normalize(outPath));\n if (opts.sourceMaps) results.push(`${path.normalize(outPath)}.map`);\n }\n cb();\n })\n );\n });\n queue.await((err) => (err ? callback(err) : callback(null, results)));\n }\n );\n}\n"],"names":["Iterator","path","Queue","extensions","typeFileRegEx","createMatcher","transformFile","transformDirectoryWorker","src","dest","type","options","callback","tsconfig","matcher","entries","modeByPath","Map","iterator","alwaysStat","forEach","entry","stats","isFile","basename","test","fullPath","ext","extname","indexOf","push","mode","set","err","results","opts","queue","get","defer","cb","outPath","normalize","sourceMaps","await"],"mappings":"AACA,OAAOA,cAA8B,cAAc;AACnD,OAAOC,UAAU,OAAO;AACxB,OAAOC,WAAW,WAAW;AAE7B,SAASC,UAAU,EAAEC,aAAa,QAAQ,kBAAkB;AAC5D,OAAOC,mBAAmB,sBAAsB;AAChD,OAAOC,mBAAmB,0BAA0B;AAIpD,eAAe,SAASC,yBAAyBC,GAAW,EAAEC,IAAY,EAAEC,IAAgB,EAAEC,OAA8B,EAAEC,QAAoC;IAChK,MAAMC,WAAWF,QAAQE,QAAQ;IACjC,MAAMC,UAAUT,cAAcQ;IAE9B,MAAME,UAAmB,EAAE;IAC3B,MAAMC,aAAa,IAAIC;IACvB,MAAMC,WAAW,IAAIlB,SAASQ,KAAK;QAAEW,YAAY;IAAK;IACtDD,SAASE,OAAO,CACd,CAACC;QACC,MAAMC,QAAQD,MAAMC,KAAK;QACzB,IAAI,CAACA,SAAS,CAACA,MAAMC,MAAM,IAAI;QAC/B,MAAMC,WAAWH,MAAMG,QAAQ;QAC/B,IAAIA,QAAQ,CAAC,EAAE,KAAK,KAAK;QACzB,IAAIpB,cAAcqB,IAAI,CAACD,WAAW;QAClC,IAAI,CAACV,QAAQO,MAAMK,QAAQ,GAAG;QAC9B,MAAMC,MAAM1B,KAAK2B,OAAO,CAACJ;QACzB,IAAIG,OAAOxB,WAAW0B,OAAO,CAACF,OAAO,GAAG;QACxCZ,QAAQe,IAAI,CAACT;QAEb,IAAIC,MAAMS,IAAI,EAAE;YACdf,WAAWgB,GAAG,CAACX,MAAMK,QAAQ,EAAEJ,MAAMS,IAAI;QAC3C;IACF,GACA,CAACE;QACC,IAAIA,KAAK,OAAOrB,SAASqB;QACzB,MAAMC,UAAoB,EAAE;QAC5B,MAAMC,OAA8B;YAAE,GAAGxB,OAAO;YAAEE;QAAS;QAE3D,MAAMuB,QAAQ,IAAIlC;QAClBa,QAAQK,OAAO,CAAC,CAACC;YACf,MAAMU,OAAOf,WAAWqB,GAAG,CAAChB,MAAMK,QAAQ;YAC1CU,MAAME,KAAK,CAAC,CAACC,KACXjC,cAAce,OAAOZ,MAAMC,MAAMyB,MAAMJ,MAAM,CAACE,KAAKO;oBACjD,IAAIP,KAAK,OAAOM,GAAGN;oBACnB,IAAIO,SAAS;wBACXN,QAAQJ,IAAI,CAAC7B,KAAKwC,SAAS,CAACD;wBAC5B,IAAIL,KAAKO,UAAU,EAAER,QAAQJ,IAAI,CAAC,GAAG7B,KAAKwC,SAAS,CAACD,SAAS,IAAI,CAAC;oBACpE;oBACAD;gBACF;QAEJ;QACAH,MAAMO,KAAK,CAAC,CAACV,MAASA,MAAMrB,SAASqB,OAAOrB,SAAS,MAAMsB;IAC7D;AAEJ"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
export default function transformTypesWorker(src: string, dest: string, options:
|
|
1
|
+
import type { InternalConfigOptions, TransformTypesCallback } from '../types.js';
|
|
2
|
+
export default function transformTypesWorker(src: string, dest: string, options: InternalConfigOptions, callback: TransformTypesCallback): void;
|
|
@@ -10,12 +10,6 @@ import Queue from 'queue-cb';
|
|
|
10
10
|
import resolveBin from 'resolve-bin-sync';
|
|
11
11
|
const concurrency = Math.min(64, Math.max(8, ((_ref = (_os_cpus = os.cpus()) === null || _os_cpus === void 0 ? void 0 : _os_cpus.length) !== null && _ref !== void 0 ? _ref : 4) * 8));
|
|
12
12
|
const tscPath = resolveBin('typescript', 'tsc');
|
|
13
|
-
let tsgoPath = null;
|
|
14
|
-
try {
|
|
15
|
-
tsgoPath = resolveBin('@typescript/native-preview', 'tsgo');
|
|
16
|
-
} catch {
|
|
17
|
-
tsgoPath = null;
|
|
18
|
-
}
|
|
19
13
|
import { typeFileRegEx } from '../constants.js';
|
|
20
14
|
import createMatcher from '../createMatcher.js';
|
|
21
15
|
import { rewriteExtensions } from '../lib/rewriteExtensions.js';
|
|
@@ -30,17 +24,6 @@ import { rewriteExtensions } from '../lib/rewriteExtensions.js';
|
|
|
30
24
|
encoding: 'utf8'
|
|
31
25
|
}, cb);
|
|
32
26
|
}
|
|
33
|
-
function runTsgoThenTsc(args, cb) {
|
|
34
|
-
if (tsgoPath) {
|
|
35
|
-
runCompiler(tsgoPath, args, (err, res)=>{
|
|
36
|
-
// Prefer status code over "err" for deciding success/fallback
|
|
37
|
-
if (!err && res.status === 0) return cb(null, res);
|
|
38
|
-
runCompiler(tscPath, args, cb);
|
|
39
|
-
});
|
|
40
|
-
} else {
|
|
41
|
-
runCompiler(tscPath, args, cb);
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
27
|
/* ---------------- emitted file parsing ---------------- */ function parseEmittedFiles(res, dest) {
|
|
45
28
|
const out = [];
|
|
46
29
|
const seen = new Set();
|
|
@@ -67,10 +50,12 @@ export default function transformTypesWorker(src, dest, options, callback) {
|
|
|
67
50
|
const rootFiles = [];
|
|
68
51
|
const iterator = new Iterator(src);
|
|
69
52
|
iterator.forEach((entry)=>{
|
|
70
|
-
|
|
71
|
-
if (
|
|
72
|
-
|
|
73
|
-
if (
|
|
53
|
+
const stats = entry.stats;
|
|
54
|
+
if (!stats || !stats.isFile()) return;
|
|
55
|
+
const basename = entry.basename;
|
|
56
|
+
if (basename[0] === '.') return;
|
|
57
|
+
if (typeFileRegEx.test(basename)) return;
|
|
58
|
+
if (!isAllowedRootFile(basename)) return;
|
|
74
59
|
if (!matcher(entry.fullPath)) return;
|
|
75
60
|
rootFiles.push(entry.fullPath);
|
|
76
61
|
}, {
|
|
@@ -81,11 +66,14 @@ export default function transformTypesWorker(src, dest, options, callback) {
|
|
|
81
66
|
if (rootFiles.length === 0) return callback(null, []);
|
|
82
67
|
const compilerOptions = {
|
|
83
68
|
...tsconfig.config.compilerOptions,
|
|
69
|
+
rootDir: src,
|
|
84
70
|
outDir: dest,
|
|
85
71
|
noEmit: false,
|
|
86
72
|
allowJs: true,
|
|
87
73
|
declaration: true,
|
|
88
|
-
emitDeclarationOnly: true
|
|
74
|
+
emitDeclarationOnly: true,
|
|
75
|
+
// Suppress TS6 deprecation warnings (TS5101/TS5107) for consumers still on legacy Node-targeted options.
|
|
76
|
+
ignoreDeprecations: '6.0'
|
|
89
77
|
};
|
|
90
78
|
const rewrite = ((_tsconfig_config_compilerOptions = tsconfig.config.compilerOptions) === null || _tsconfig_config_compilerOptions === void 0 ? void 0 : _tsconfig_config_compilerOptions.rewriteRelativeImportExtensions) === true;
|
|
91
79
|
// Avoid collisions across concurrent runs.
|
|
@@ -119,14 +107,20 @@ export default function transformTypesWorker(src, dest, options, callback) {
|
|
|
119
107
|
'--pretty',
|
|
120
108
|
'false'
|
|
121
109
|
];
|
|
122
|
-
|
|
123
|
-
if (runErr || res.status !== 0) {
|
|
124
|
-
var _ref;
|
|
125
|
-
|
|
110
|
+
runCompiler(tscPath, args, (runErr, res)=>{
|
|
111
|
+
if (runErr || !res || res.status !== 0) {
|
|
112
|
+
var _ref, _ref1;
|
|
113
|
+
// cross-spawn-cb sets runErr (with stdout/stderr/status copied onto it) on non-zero exit
|
|
114
|
+
// and does NOT pass res — read from runErr first, then fall back to res.
|
|
115
|
+
const source = runErr !== null && runErr !== void 0 ? runErr : res;
|
|
116
|
+
const status = source === null || source === void 0 ? void 0 : source.status;
|
|
117
|
+
const stdout = String((_ref = source === null || source === void 0 ? void 0 : source.stdout) !== null && _ref !== void 0 ? _ref : '');
|
|
118
|
+
const stderr = String((_ref1 = source === null || source === void 0 ? void 0 : source.stderr) !== null && _ref1 !== void 0 ? _ref1 : '');
|
|
119
|
+
const detail = `TypeScript compiler failed (status=${status}).\nstdout:\n${stdout.slice(0, 100000)}\nstderr:\n${stderr.slice(0, 20000)}`;
|
|
126
120
|
safeRm(tempDir, {
|
|
127
121
|
recursive: true,
|
|
128
122
|
force: true
|
|
129
|
-
}, ()=>callback(
|
|
123
|
+
}, ()=>callback(new Error(detail)));
|
|
130
124
|
return;
|
|
131
125
|
}
|
|
132
126
|
const emittedFiles = parseEmittedFiles(res, dest);
|
|
@@ -144,7 +138,8 @@ export default function transformTypesWorker(src, dest, options, callback) {
|
|
|
144
138
|
fs.readFile(file, 'utf8', (readErr, content)=>{
|
|
145
139
|
if (readErr) return cb();
|
|
146
140
|
const updated = rewriteExtensions(content);
|
|
147
|
-
updated === content
|
|
141
|
+
if (updated === content) cb();
|
|
142
|
+
else fs.writeFile(file, updated, 'utf8', (err)=>cb(err !== null && err !== void 0 ? err : undefined));
|
|
148
143
|
});
|
|
149
144
|
});
|
|
150
145
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/typescript/ts-swc-transform/src/workers/transformTypes.ts"],"sourcesContent":["import spawn, { type SpawnCallback, type SpawnResult } from 'cross-spawn-cb';\nimport fs from 'fs';\nimport Iterator, { type Entry } from 'fs-iterator';\nimport { safeRm } from 'fs-remove-compat';\nimport os from 'os';\nimport path from 'path';\nimport Queue from 'queue-cb';\nimport resolveBin from 'resolve-bin-sync';\n\nconst concurrency = Math.min(64, Math.max(8, (os.cpus()?.length ?? 4) * 8));\n\nconst tscPath = resolveBin('typescript', 'tsc');\nlet tsgoPath: string | null = null;\ntry {\n tsgoPath = resolveBin('@typescript/native-preview', 'tsgo');\n} catch {\n tsgoPath = null;\n}\n\nimport { typeFileRegEx } from '../constants.ts';\nimport createMatcher from '../createMatcher.ts';\nimport { rewriteExtensions } from '../lib/rewriteExtensions.ts';\n\nimport type { ConfigOptions, TransformTypesCallback } from '../types.ts';\n\n/* ---------------- root file filtering ---------------- */\n\nfunction isAllowedRootFile(basename: string): boolean {\n return (\n basename.endsWith('.d.ts') ||\n basename.endsWith('.d.mts') ||\n basename.endsWith('.d.cts') ||\n basename.endsWith('.ts') ||\n basename.endsWith('.tsx') ||\n basename.endsWith('.mts') ||\n basename.endsWith('.cts') ||\n basename.endsWith('.js') ||\n basename.endsWith('.jsx') ||\n basename.endsWith('.mjs') ||\n basename.endsWith('.cjs')\n );\n}\n\n/* ---------------- compiler execution ---------------- */\n\nfunction runCompiler(cmdPath: string, args: string[], cb: SpawnCallback): void {\n spawn(process.execPath, [cmdPath, ...args], { encoding: 'utf8' }, cb);\n}\n\nfunction runTsgoThenTsc(args: string[], cb: SpawnCallback): void {\n if (tsgoPath) {\n runCompiler(tsgoPath, args, (err, res) => {\n // Prefer status code over \"err\" for deciding success/fallback\n if (!err && res.status === 0) return cb(null, res);\n runCompiler(tscPath, args, cb);\n });\n } else {\n runCompiler(tscPath, args, cb);\n }\n}\n\n/* ---------------- emitted file parsing ---------------- */\n\nfunction parseEmittedFiles(res: SpawnResult, dest: string): string[] {\n const out: string[] = [];\n const seen = new Set<string>();\n const lines = `${res.stdout}\\n${res.stderr}`.split(/\\r?\\n/);\n\n for (let line of lines) {\n line = line.trim();\n if (!line) continue;\n\n if (/^TSFILE:\\s+/i.test(line)) line = line.replace(/^TSFILE:\\s+/i, '').trim();\n\n if (!path.isAbsolute(line)) continue;\n if (!(line.endsWith('.d.ts') || line.endsWith('.d.mts') || line.endsWith('.d.cts'))) continue;\n\n // Optional safety: only accept outputs under dest\n const rel = path.relative(dest, line);\n if (rel.startsWith('..') || path.isAbsolute(rel)) continue;\n\n if (!seen.has(line)) {\n seen.add(line);\n out.push(line);\n }\n }\n\n return out;\n}\n\nexport default function transformTypesWorker(src: string, dest: string, options: ConfigOptions, callback: TransformTypesCallback) {\n const tsconfig = options.tsconfig;\n const matcher = createMatcher(tsconfig);\n\n const rootFiles: string[] = [];\n const iterator = new Iterator(src);\n\n iterator.forEach(\n (entry: Entry): void => {\n if (!entry.stats.isFile()) return;\n if (entry.basename[0] === '.') return;\n if (typeFileRegEx.test(entry.basename)) return;\n if (!isAllowedRootFile(entry.basename)) return;\n if (!matcher(entry.fullPath)) return;\n\n rootFiles.push(entry.fullPath);\n },\n { concurrency },\n (err) => {\n if (err) return callback(err);\n if (rootFiles.length === 0) return callback(null, []);\n\n const compilerOptions = {\n ...tsconfig.config.compilerOptions,\n outDir: dest,\n noEmit: false,\n allowJs: true,\n declaration: true,\n emitDeclarationOnly: true,\n };\n\n const rewrite = tsconfig.config.compilerOptions?.rewriteRelativeImportExtensions === true;\n\n // Avoid collisions across concurrent runs.\n const tempDir = path.join(dest, '.ts-swc-transform-temp', String(process.pid), String(Date.now()));\n const tempConfigPath = path.join(tempDir, 'tsconfig.json');\n\n const tempConfig = {\n compilerOptions,\n files: rootFiles,\n include: [],\n exclude: [],\n ...(tsconfig.config.references && { references: tsconfig.config.references }),\n };\n\n fs.mkdir(tempDir, { recursive: true }, (mkdirErr) => {\n if (mkdirErr) return callback(mkdirErr);\n\n fs.writeFile(tempConfigPath, JSON.stringify(tempConfig, null, 2), 'utf8', (writeErr) => {\n if (writeErr) {\n safeRm(tempDir, { recursive: true, force: true }, () => callback(writeErr));\n return;\n }\n\n const args = ['--project', tempConfigPath, '--listEmittedFiles', '--pretty', 'false'];\n\n runTsgoThenTsc(args, (runErr, res) => {\n if (runErr || res.status !== 0) {\n const msg = `TypeScript compiler failed (status=${res?.status}).\\n${`stderr:\\n${String(res?.stderr ?? '')}`.slice(0, 20_000)}`;\n safeRm(tempDir, { recursive: true, force: true }, () => callback(runErr ?? new Error(msg)));\n return;\n }\n\n const emittedFiles = parseEmittedFiles(res, dest);\n if (emittedFiles.length === 0) {\n safeRm(tempDir, { recursive: true, force: true }, () => callback(new Error('TypeScript compiler produced no emitted declaration files')));\n return;\n }\n\n const postQueue = new Queue();\n\n if (rewrite) {\n for (const file of emittedFiles) {\n postQueue.defer((cb) => {\n fs.readFile(file, 'utf8', (readErr, content) => {\n if (readErr) return cb();\n const updated = rewriteExtensions(content);\n updated === content ? cb() : fs.writeFile(file, updated, 'utf8', cb);\n });\n });\n }\n }\n\n postQueue.await(() => {\n safeRm(tempDir, { recursive: true, force: true }, (rmErr) => callback(rmErr || null, emittedFiles));\n });\n });\n });\n });\n }\n );\n}\n"],"names":["os","spawn","fs","Iterator","safeRm","path","Queue","resolveBin","concurrency","Math","min","max","cpus","length","tscPath","tsgoPath","typeFileRegEx","createMatcher","rewriteExtensions","isAllowedRootFile","basename","endsWith","runCompiler","cmdPath","args","cb","process","execPath","encoding","runTsgoThenTsc","err","res","status","parseEmittedFiles","dest","out","seen","Set","lines","stdout","stderr","split","line","trim","test","replace","isAbsolute","rel","relative","startsWith","has","add","push","transformTypesWorker","src","options","callback","tsconfig","matcher","rootFiles","iterator","forEach","entry","stats","isFile","fullPath","compilerOptions","config","outDir","noEmit","allowJs","declaration","emitDeclarationOnly","rewrite","rewriteRelativeImportExtensions","tempDir","join","String","pid","Date","now","tempConfigPath","tempConfig","files","include","exclude","references","mkdir","recursive","mkdirErr","writeFile","JSON","stringify","writeErr","force","runErr","msg","slice","Error","emittedFiles","postQueue","file","defer","readFile","readErr","content","updated","await","rmErr"],"mappings":";IAS8CA;AAT9C,OAAOC,WAAqD,iBAAiB;AAC7E,OAAOC,QAAQ,KAAK;AACpB,OAAOC,cAA8B,cAAc;AACnD,SAASC,MAAM,QAAQ,mBAAmB;AAC1C,OAAOJ,QAAQ,KAAK;AACpB,OAAOK,UAAU,OAAO;AACxB,OAAOC,WAAW,WAAW;AAC7B,OAAOC,gBAAgB,mBAAmB;AAE1C,MAAMC,cAAcC,KAAKC,GAAG,CAAC,IAAID,KAAKE,GAAG,CAAC,GAAG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mC,EAAEjE,gBAAAA,0BAAAA,IAAKC,MAAM,CAAC,IAAI,EAAE,CAAC,SAAS,EAAE6C,eAAO9C,gBAAAA,0BAAAA,IAAKS,MAAM,uCAAI,KAAK,CAACyD,KAAK,CAAC,GAAG,QAAS;wBAC9H7F,OAAOuE,SAAS;4BAAEa,WAAW;4BAAMM,OAAO;wBAAK,GAAG,IAAMtC,SAASuC,mBAAAA,oBAAAA,SAAU,IAAIG,MAAMF;wBACrF;oBACF;oBAEA,MAAMG,eAAelE,kBAAkBF,KAAKG;oBAC5C,IAAIiE,aAAatF,MAAM,KAAK,GAAG;wBAC7BT,OAAOuE,SAAS;4BAAEa,WAAW;4BAAMM,OAAO;wBAAK,GAAG,IAAMtC,SAAS,IAAI0C,MAAM;wBAC3E;oBACF;oBAEA,MAAME,YAAY,IAAI9F;oBAEtB,IAAImE,SAAS;wBACX,KAAK,MAAM4B,QAAQF,aAAc;4BAC/BC,UAAUE,KAAK,CAAC,CAAC7E;gCACfvB,GAAGqG,QAAQ,CAACF,MAAM,QAAQ,CAACG,SAASC;oCAClC,IAAID,SAAS,OAAO/E;oCACpB,MAAMiF,UAAUxF,kBAAkBuF;oCAClCC,YAAYD,UAAUhF,OAAOvB,GAAGwF,SAAS,CAACW,MAAMK,SAAS,QAAQjF;gCACnE;4BACF;wBACF;oBACF;oBAEA2E,UAAUO,KAAK,CAAC;wBACdvG,OAAOuE,SAAS;4BAAEa,WAAW;4BAAMM,OAAO;wBAAK,GAAG,CAACc,QAAUpD,SAASoD,SAAS,MAAMT;oBACvF;gBACF;YACF;QACF;IACF;AAEJ"}
|
|
1
|
+
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/typescript/ts-swc-transform/src/workers/transformTypes.ts"],"sourcesContent":["import spawn, { type SpawnCallback, type SpawnResult } from 'cross-spawn-cb';\nimport fs from 'fs';\nimport Iterator, { type Entry } from 'fs-iterator';\nimport { safeRm } from 'fs-remove-compat';\nimport os from 'os';\nimport path from 'path';\nimport Queue from 'queue-cb';\nimport resolveBin from 'resolve-bin-sync';\n\nconst concurrency = Math.min(64, Math.max(8, (os.cpus()?.length ?? 4) * 8));\n\nconst tscPath = resolveBin('typescript', 'tsc');\n\nimport { typeFileRegEx } from '../constants.ts';\nimport createMatcher from '../createMatcher.ts';\nimport { rewriteExtensions } from '../lib/rewriteExtensions.ts';\n\nimport type { InternalConfigOptions, TransformTypesCallback } from '../types.ts';\n\n/* ---------------- root file filtering ---------------- */\n\nfunction isAllowedRootFile(basename: string): boolean {\n return (\n basename.endsWith('.d.ts') ||\n basename.endsWith('.d.mts') ||\n basename.endsWith('.d.cts') ||\n basename.endsWith('.ts') ||\n basename.endsWith('.tsx') ||\n basename.endsWith('.mts') ||\n basename.endsWith('.cts') ||\n basename.endsWith('.js') ||\n basename.endsWith('.jsx') ||\n basename.endsWith('.mjs') ||\n basename.endsWith('.cjs')\n );\n}\n\n/* ---------------- compiler execution ---------------- */\n\nfunction runCompiler(cmdPath: string, args: string[], cb: SpawnCallback): void {\n spawn(process.execPath, [cmdPath, ...args], { encoding: 'utf8' }, cb);\n}\n\n/* ---------------- emitted file parsing ---------------- */\n\nfunction parseEmittedFiles(res: SpawnResult, dest: string): string[] {\n const out: string[] = [];\n const seen = new Set<string>();\n const lines = `${res.stdout}\\n${res.stderr}`.split(/\\r?\\n/);\n\n for (let line of lines) {\n line = line.trim();\n if (!line) continue;\n\n if (/^TSFILE:\\s+/i.test(line)) line = line.replace(/^TSFILE:\\s+/i, '').trim();\n\n if (!path.isAbsolute(line)) continue;\n if (!(line.endsWith('.d.ts') || line.endsWith('.d.mts') || line.endsWith('.d.cts'))) continue;\n\n // Optional safety: only accept outputs under dest\n const rel = path.relative(dest, line);\n if (rel.startsWith('..') || path.isAbsolute(rel)) continue;\n\n if (!seen.has(line)) {\n seen.add(line);\n out.push(line);\n }\n }\n\n return out;\n}\n\nexport default function transformTypesWorker(src: string, dest: string, options: InternalConfigOptions, callback: TransformTypesCallback) {\n const tsconfig = options.tsconfig;\n const matcher = createMatcher(tsconfig);\n\n const rootFiles: string[] = [];\n const iterator = new Iterator(src);\n\n iterator.forEach(\n (entry: Entry): void => {\n const stats = entry.stats as fs.Stats | undefined;\n if (!stats || !stats.isFile()) return;\n const basename = entry.basename as string;\n if (basename[0] === '.') return;\n if (typeFileRegEx.test(basename)) return;\n if (!isAllowedRootFile(basename)) return;\n if (!matcher(entry.fullPath)) return;\n\n rootFiles.push(entry.fullPath);\n },\n { concurrency },\n (err) => {\n if (err) return callback(err);\n if (rootFiles.length === 0) return callback(null, []);\n\n const compilerOptions = {\n ...tsconfig.config.compilerOptions,\n rootDir: src,\n outDir: dest,\n noEmit: false,\n allowJs: true,\n declaration: true,\n emitDeclarationOnly: true,\n // Suppress TS6 deprecation warnings (TS5101/TS5107) for consumers still on legacy Node-targeted options.\n ignoreDeprecations: '6.0',\n };\n\n const rewrite = (tsconfig.config.compilerOptions as { rewriteRelativeImportExtensions?: boolean } | undefined)?.rewriteRelativeImportExtensions === true;\n\n // Avoid collisions across concurrent runs.\n const tempDir = path.join(dest, '.ts-swc-transform-temp', String(process.pid), String(Date.now()));\n const tempConfigPath = path.join(tempDir, 'tsconfig.json');\n\n const tempConfig = {\n compilerOptions,\n files: rootFiles,\n include: [],\n exclude: [],\n ...(tsconfig.config.references && { references: tsconfig.config.references }),\n };\n\n fs.mkdir(tempDir, { recursive: true }, (mkdirErr) => {\n if (mkdirErr) return callback(mkdirErr);\n\n fs.writeFile(tempConfigPath, JSON.stringify(tempConfig, null, 2), 'utf8', (writeErr) => {\n if (writeErr) {\n safeRm(tempDir, { recursive: true, force: true }, () => callback(writeErr));\n return;\n }\n\n const args = ['--project', tempConfigPath, '--listEmittedFiles', '--pretty', 'false'];\n\n runCompiler(tscPath, args, (runErr, res) => {\n if (runErr || !res || res.status !== 0) {\n // cross-spawn-cb sets runErr (with stdout/stderr/status copied onto it) on non-zero exit\n // and does NOT pass res — read from runErr first, then fall back to res.\n const source = (runErr as unknown as SpawnResult | undefined) ?? res;\n const status = source?.status;\n const stdout = String(source?.stdout ?? '');\n const stderr = String(source?.stderr ?? '');\n const detail = `TypeScript compiler failed (status=${status}).\\nstdout:\\n${stdout.slice(0, 100_000)}\\nstderr:\\n${stderr.slice(0, 20_000)}`;\n safeRm(tempDir, { recursive: true, force: true }, () => callback(new Error(detail)));\n return;\n }\n\n const emittedFiles = parseEmittedFiles(res, dest);\n if (emittedFiles.length === 0) {\n safeRm(tempDir, { recursive: true, force: true }, () => callback(new Error('TypeScript compiler produced no emitted declaration files')));\n return;\n }\n\n const postQueue = new Queue();\n\n if (rewrite) {\n for (const file of emittedFiles) {\n postQueue.defer((cb) => {\n fs.readFile(file, 'utf8', (readErr, content) => {\n if (readErr) return cb();\n const updated = rewriteExtensions(content);\n if (updated === content) cb();\n else fs.writeFile(file, updated, 'utf8', (err) => cb(err ?? undefined));\n });\n });\n }\n }\n\n postQueue.await(() => {\n safeRm(tempDir, { recursive: true, force: true }, (rmErr) => callback(rmErr || null, emittedFiles));\n });\n });\n });\n });\n }\n );\n}\n"],"names":["os","spawn","fs","Iterator","safeRm","path","Queue","resolveBin","concurrency","Math","min","max","cpus","length","tscPath","typeFileRegEx","createMatcher","rewriteExtensions","isAllowedRootFile","basename","endsWith","runCompiler","cmdPath","args","cb","process","execPath","encoding","parseEmittedFiles","res","dest","out","seen","Set","lines","stdout","stderr","split","line","trim","test","replace","isAbsolute","rel","relative","startsWith","has","add","push","transformTypesWorker","src","options","callback","tsconfig","matcher","rootFiles","iterator","forEach","entry","stats","isFile","fullPath","err","compilerOptions","config","rootDir","outDir","noEmit","allowJs","declaration","emitDeclarationOnly","ignoreDeprecations","rewrite","rewriteRelativeImportExtensions","tempDir","join","String","pid","Date","now","tempConfigPath","tempConfig","files","include","exclude","references","mkdir","recursive","mkdirErr","writeFile","JSON","stringify","writeErr","force","runErr","status","source","detail","slice","Error","emittedFiles","postQueue","file","defer","readFile","readErr","content","updated","undefined","await","rmErr"],"mappings":";IAS8CA;AAT9C,OAA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F;YACF;QACF;IACF;AAEJ"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ts-swc-transform",
|
|
3
|
-
"version": "2.11.
|
|
3
|
+
"version": "2.11.7",
|
|
4
4
|
"description": "Typescript transformers for swc. Supports Node >= 0.8",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"matcher",
|
|
@@ -45,7 +45,6 @@
|
|
|
45
45
|
},
|
|
46
46
|
"dependencies": {
|
|
47
47
|
"@swc/core": "^1.15.5",
|
|
48
|
-
"@typescript/native-preview": "^7.0.0-dev.20260108.1",
|
|
49
48
|
"core-js-pure": "^3.20.0",
|
|
50
49
|
"exit-compat": "^1.0.0",
|
|
51
50
|
"fs-iterator": "^7.0.0",
|
|
@@ -65,8 +64,12 @@
|
|
|
65
64
|
"typescript": "^6.0.0"
|
|
66
65
|
},
|
|
67
66
|
"devDependencies": {
|
|
67
|
+
"@types/is-absolute": "^1.0.2",
|
|
68
|
+
"@types/lodash.debounce": "^4.0.9",
|
|
68
69
|
"@types/mocha": "*",
|
|
69
70
|
"@types/node": "*",
|
|
71
|
+
"@types/react": "*",
|
|
72
|
+
"@types/resolve": "^1.20.6",
|
|
70
73
|
"cr": "^0.1.0",
|
|
71
74
|
"cross-spawn-cb": "^3.0.0",
|
|
72
75
|
"fs-remove-compat": "^1.0.0",
|