ts-swc-transform 2.11.11 → 2.11.12
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.js.map +1 -1
- package/dist/cjs/lib/patchESM.js.map +1 -1
- package/dist/cjs/lib/prepareSWCOptions.js +74 -2
- package/dist/cjs/lib/prepareSWCOptions.js.map +1 -1
- package/dist/cjs/workers/transformTypes.js +20 -2
- package/dist/cjs/workers/transformTypes.js.map +1 -1
- package/dist/esm/lib/patchCJS.js.map +1 -1
- package/dist/esm/lib/patchESM.js.map +1 -1
- package/dist/esm/lib/prepareSWCOptions.js +23 -2
- package/dist/esm/lib/prepareSWCOptions.js.map +1 -1
- package/dist/esm/workers/transformTypes.js +22 -2
- package/dist/esm/workers/transformTypes.js.map +1 -1
- package/package.json +3 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/typescript/ts-swc-transform/src/lib/patchCJS.ts"],"sourcesContent":["import path from 'path';\nimport { replaceExtension, rewriteExtensionsCJS } from './rewriteExtensions.ts';\n\n// https://github.com/vercel/next.js/blob/20b63e13ab2631d6043277895d373aa31a1b327c/packages/next/taskfile-swc.js#L118-L125\nexport const interop = \"/* CJS INTEROP */ if (exports.__esModule && exports.default) { try { Object.defineProperty(exports.default, '__esModule', { value: true }); for (var key in exports) { exports.default[key] = exports[key]; } } catch (_) {}; module.exports = exports.default; }\";\n\nimport type { Output } from '@swc/core';\nimport type { Entry } from 'fs-iterator';\nimport type {
|
|
1
|
+
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/typescript/ts-swc-transform/src/lib/patchCJS.ts"],"sourcesContent":["import path from 'path';\nimport { replaceExtension, rewriteExtensionsCJS } from './rewriteExtensions.ts';\n\n// https://github.com/vercel/next.js/blob/20b63e13ab2631d6043277895d373aa31a1b327c/packages/next/taskfile-swc.js#L118-L125\nexport const interop = \"/* CJS INTEROP */ if (exports.__esModule && exports.default) { try { Object.defineProperty(exports.default, '__esModule', { value: true }); for (var key in exports) { exports.default[key] = exports[key]; } } catch (_) {}; module.exports = exports.default; }\";\n\nimport type { Output } from '@swc/core';\nimport type { Entry } from 'fs-iterator';\nimport type { InternalConfigOptions } from '../types.ts';\n\n// Read straight off the parsed tsconfig JSON, which is arbitrary data rather\n// than typescript's own CompilerOptions.\ninterface InternalCompilerOptions {\n rewriteRelativeImportExtensions?: boolean;\n}\n\nexport default function patchCJS(entry: Entry, output: Output, options: InternalConfigOptions): string {\n const rewrite = ((options.tsconfig.config.compilerOptions || {}) as unknown as InternalCompilerOptions).rewriteRelativeImportExtensions;\n if (rewrite) output.code = rewriteExtensionsCJS(output.code);\n output.code += interop;\n\n return replaceExtension(path.extname(entry.basename));\n}\n"],"names":["patchCJS","interop","entry","output","options","rewrite","tsconfig","config","compilerOptions","rewriteRelativeImportExtensions","code","rewriteExtensionsCJS","replaceExtension","path","extname","basename"],"mappings":";;;;;;;;;;;QAgBA;eAAwBA;;QAZXC;eAAAA;;;2DAJI;mCACsC;;;;;;AAGhD,IAAMA,UAAU;AAYR,SAASD,SAASE,KAAY,EAAEC,MAAc,EAAEC,OAA8B;IAC3F,IAAMC,UAAU,AAAED,CAAAA,QAAQE,QAAQ,CAACC,MAAM,CAACC,eAAe,IAAI,CAAC,CAAA,EAA0CC,+BAA+B;IACvI,IAAIJ,SAASF,OAAOO,IAAI,GAAGC,IAAAA,yCAAoB,EAACR,OAAOO,IAAI;IAC3DP,OAAOO,IAAI,IAAIT;IAEf,OAAOW,IAAAA,qCAAgB,EAACC,aAAI,CAACC,OAAO,CAACZ,MAAMa,QAAQ;AACrD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/typescript/ts-swc-transform/src/lib/patchESM.ts"],"sourcesContent":["import type { Output } from '@swc/core';\nimport type { Entry } from 'fs-iterator';\nimport path from 'path';\nimport type {
|
|
1
|
+
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/typescript/ts-swc-transform/src/lib/patchESM.ts"],"sourcesContent":["import type { Output } from '@swc/core';\nimport type { Entry } from 'fs-iterator';\nimport path from 'path';\nimport type { InternalConfigOptions } from '../types.ts';\nimport { replaceExtension, rewriteExtensions } from './rewriteExtensions.ts';\n\n// Read straight off the parsed tsconfig JSON, which is arbitrary data rather\n// than typescript's own CompilerOptions.\ninterface InternalCompilerOptions {\n rewriteRelativeImportExtensions?: boolean;\n}\n\nexport default function patchESM(entry: Entry, output: Output, options: InternalConfigOptions): string {\n const rewrite = ((options.tsconfig.config.compilerOptions || {}) as unknown as InternalCompilerOptions).rewriteRelativeImportExtensions;\n if (rewrite) output.code = rewriteExtensions(output.code);\n\n return replaceExtension(path.extname(entry.basename));\n}\n"],"names":["patchESM","entry","output","options","rewrite","tsconfig","config","compilerOptions","rewriteRelativeImportExtensions","code","rewriteExtensions","replaceExtension","path","extname","basename"],"mappings":";;;;+BAYA;;;eAAwBA;;;2DAVP;mCAEmC;;;;;;AAQrC,SAASA,SAASC,KAAY,EAAEC,MAAc,EAAEC,OAA8B;IAC3F,IAAMC,UAAU,AAAED,CAAAA,QAAQE,QAAQ,CAACC,MAAM,CAACC,eAAe,IAAI,CAAC,CAAA,EAA0CC,+BAA+B;IACvI,IAAIJ,SAASF,OAAOO,IAAI,GAAGC,IAAAA,sCAAiB,EAACR,OAAOO,IAAI;IAExD,OAAOE,IAAAA,qCAAgB,EAACC,aAAI,CAACC,OAAO,CAACZ,MAAMa,QAAQ;AACrD"}
|
|
@@ -12,7 +12,21 @@ var _installoptional = require("install-optional");
|
|
|
12
12
|
var _lodashdebounce = /*#__PURE__*/ _interop_require_default(require("lodash.debounce"));
|
|
13
13
|
var _module = /*#__PURE__*/ _interop_require_default(require("module"));
|
|
14
14
|
var _path = /*#__PURE__*/ _interop_require_default(require("path"));
|
|
15
|
+
var _tsconstants = /*#__PURE__*/ _interop_require_default(require("ts-constants"));
|
|
15
16
|
var _url = /*#__PURE__*/ _interop_require_default(require("url"));
|
|
17
|
+
function _define_property(obj, key, value) {
|
|
18
|
+
if (key in obj) {
|
|
19
|
+
Object.defineProperty(obj, key, {
|
|
20
|
+
value: value,
|
|
21
|
+
enumerable: true,
|
|
22
|
+
configurable: true,
|
|
23
|
+
writable: true
|
|
24
|
+
});
|
|
25
|
+
} else {
|
|
26
|
+
obj[key] = value;
|
|
27
|
+
}
|
|
28
|
+
return obj;
|
|
29
|
+
}
|
|
16
30
|
function _instanceof(left, right) {
|
|
17
31
|
"@swc/helpers - instanceof";
|
|
18
32
|
if (right != null && typeof Symbol !== "undefined" && right[Symbol.hasInstance]) {
|
|
@@ -26,12 +40,68 @@ function _interop_require_default(obj) {
|
|
|
26
40
|
default: obj
|
|
27
41
|
};
|
|
28
42
|
}
|
|
43
|
+
function _object_spread(target) {
|
|
44
|
+
for(var i = 1; i < arguments.length; i++){
|
|
45
|
+
var source = arguments[i] != null ? arguments[i] : {};
|
|
46
|
+
var ownKeys = Object.keys(source);
|
|
47
|
+
if (typeof Object.getOwnPropertySymbols === "function") {
|
|
48
|
+
ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
|
|
49
|
+
return Object.getOwnPropertyDescriptor(source, sym).enumerable;
|
|
50
|
+
}));
|
|
51
|
+
}
|
|
52
|
+
ownKeys.forEach(function(key) {
|
|
53
|
+
_define_property(target, key, source[key]);
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
return target;
|
|
57
|
+
}
|
|
58
|
+
function ownKeys(object, enumerableOnly) {
|
|
59
|
+
var keys = Object.keys(object);
|
|
60
|
+
if (Object.getOwnPropertySymbols) {
|
|
61
|
+
var symbols = Object.getOwnPropertySymbols(object);
|
|
62
|
+
if (enumerableOnly) {
|
|
63
|
+
symbols = symbols.filter(function(sym) {
|
|
64
|
+
return Object.getOwnPropertyDescriptor(object, sym).enumerable;
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
keys.push.apply(keys, symbols);
|
|
68
|
+
}
|
|
69
|
+
return keys;
|
|
70
|
+
}
|
|
71
|
+
function _object_spread_props(target, source) {
|
|
72
|
+
source = source != null ? source : {};
|
|
73
|
+
if (Object.getOwnPropertyDescriptors) {
|
|
74
|
+
Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
|
|
75
|
+
} else {
|
|
76
|
+
ownKeys(Object(source)).forEach(function(key) {
|
|
77
|
+
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
return target;
|
|
81
|
+
}
|
|
29
82
|
var _require = typeof require === 'undefined' ? _module.default.createRequire(require("url").pathToFileURL(__filename).toString()) : require;
|
|
30
83
|
var __dirname = _path.default.dirname(typeof __filename !== 'undefined' ? __filename : _url.default.fileURLToPath(require("url").pathToFileURL(__filename).toString()));
|
|
31
84
|
var installSyncSWC = (0, _lodashdebounce.default)(_installoptional.installSync, 300, {
|
|
32
85
|
leading: true,
|
|
33
86
|
trailing: false
|
|
34
87
|
});
|
|
88
|
+
// tsconfig spells enums as strings ("es2019", "react-jsx"); swc needs the numbers.
|
|
89
|
+
function enumValue(map, value) {
|
|
90
|
+
if (typeof value !== 'string') return value;
|
|
91
|
+
var wanted = value.replace(/-/g, '').toLowerCase();
|
|
92
|
+
var names = Object.keys(map);
|
|
93
|
+
for(var i = 0; i < names.length; i++){
|
|
94
|
+
if (typeof map[names[i]] === 'number' && names[i].toLowerCase() === wanted) return map[names[i]];
|
|
95
|
+
}
|
|
96
|
+
return undefined;
|
|
97
|
+
}
|
|
98
|
+
function normalizeCompilerOptions(raw) {
|
|
99
|
+
return _object_spread_props(_object_spread({}, raw), {
|
|
100
|
+
target: enumValue(_tsconstants.default.ScriptTarget, raw.target),
|
|
101
|
+
module: enumValue(_tsconstants.default.ModuleKind, raw.module),
|
|
102
|
+
jsx: enumValue(_tsconstants.default.JsxEmit, raw.jsx)
|
|
103
|
+
});
|
|
104
|
+
}
|
|
35
105
|
function prepareSWCOptions(tsconfig) {
|
|
36
106
|
installSyncSWC('@swc/core', "".concat(process.platform, "-").concat(process.arch), {
|
|
37
107
|
cwd: __dirname,
|
|
@@ -41,8 +111,10 @@ function prepareSWCOptions(tsconfig) {
|
|
|
41
111
|
var ts = _require('typescript');
|
|
42
112
|
var swc = _require('@swc/core');
|
|
43
113
|
var transpiler = _require('ts-node/transpilers/swc');
|
|
44
|
-
|
|
45
|
-
|
|
114
|
+
// TypeScript 7 dropped the compiler API from the package root, so fall back
|
|
115
|
+
// to resolving the enum-valued fields directly.
|
|
116
|
+
var options = typeof ts.parseJsonConfigFileContent === 'function' ? ts.parseJsonConfigFileContent(tsconfig.config, ts.sys, _path.default.dirname(tsconfig.path)).options : normalizeCompilerOptions(tsconfig.config.compilerOptions || {});
|
|
117
|
+
return transpiler.createSwcOptions(options, undefined, swc, 'swc');
|
|
46
118
|
} catch (err) {
|
|
47
119
|
console.log("prepareSWCOptions failed: ".concat(_instanceof(err, Error) ? err.message : String(err)));
|
|
48
120
|
return {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/typescript/ts-swc-transform/src/lib/prepareSWCOptions.ts"],"sourcesContent":["import type { Options } from '@swc/core';\nimport { installSync, matchesLibc } from 'install-optional';\nimport debounce from 'lodash.debounce';\nimport Module from 'module';\nimport path from 'path';\nimport url from 'url';\n\nconst _require = typeof require === 'undefined' ? Module.createRequire(import.meta.url) : require;\nconst __dirname = path.dirname(typeof __filename !== 'undefined' ? __filename : url.fileURLToPath(import.meta.url));\n\nimport type { TSConfig } from '../types.ts';\n\nexport interface TranspilerOptions {\n tsxOptions: Options;\n nonTsxOptions: Options;\n}\n\nconst installSyncSWC = debounce(installSync, 300, { leading: true, trailing: false });\n\nexport default function prepareSWCOptions(tsconfig: TSConfig): TranspilerOptions {\n installSyncSWC('@swc/core', `${process.platform}-${process.arch}`, { cwd: __dirname, filter: matchesLibc });\n try {\n const ts = _require('typescript');\n const swc = _require('@swc/core');\n const transpiler = _require('ts-node/transpilers/swc');\n const
|
|
1
|
+
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/typescript/ts-swc-transform/src/lib/prepareSWCOptions.ts"],"sourcesContent":["import type { Options } from '@swc/core';\nimport { installSync, matchesLibc } from 'install-optional';\nimport debounce from 'lodash.debounce';\nimport Module from 'module';\nimport path from 'path';\nimport tsConstants from 'ts-constants';\nimport url from 'url';\n\nconst _require = typeof require === 'undefined' ? Module.createRequire(import.meta.url) : require;\nconst __dirname = path.dirname(typeof __filename !== 'undefined' ? __filename : url.fileURLToPath(import.meta.url));\n\nimport type { TSConfig } from '../types.ts';\n\nexport interface TranspilerOptions {\n tsxOptions: Options;\n nonTsxOptions: Options;\n}\n\nconst installSyncSWC = debounce(installSync, 300, { leading: true, trailing: false });\n\n// tsconfig spells enums as strings (\"es2019\", \"react-jsx\"); swc needs the numbers.\nfunction enumValue(map: Record<string, unknown>, value: unknown): unknown {\n if (typeof value !== 'string') return value;\n const wanted = value.replace(/-/g, '').toLowerCase();\n const names = Object.keys(map);\n for (let i = 0; i < names.length; i++) {\n if (typeof map[names[i]] === 'number' && names[i].toLowerCase() === wanted) return map[names[i]];\n }\n return undefined;\n}\n\nfunction normalizeCompilerOptions(raw: Record<string, unknown>): Record<string, unknown> {\n return {\n ...raw,\n target: enumValue(tsConstants.ScriptTarget as unknown as Record<string, unknown>, raw.target),\n module: enumValue(tsConstants.ModuleKind as unknown as Record<string, unknown>, raw.module),\n jsx: enumValue(tsConstants.JsxEmit as unknown as Record<string, unknown>, raw.jsx),\n };\n}\n\nexport default function prepareSWCOptions(tsconfig: TSConfig): TranspilerOptions {\n installSyncSWC('@swc/core', `${process.platform}-${process.arch}`, { cwd: __dirname, filter: matchesLibc });\n try {\n const ts = _require('typescript');\n const swc = _require('@swc/core');\n const transpiler = _require('ts-node/transpilers/swc');\n // TypeScript 7 dropped the compiler API from the package root, so fall back\n // to resolving the enum-valued fields directly.\n const options = typeof ts.parseJsonConfigFileContent === 'function' ? ts.parseJsonConfigFileContent(tsconfig.config, ts.sys, path.dirname(tsconfig.path)).options : normalizeCompilerOptions((tsconfig.config.compilerOptions || {}) as Record<string, unknown>);\n return transpiler.createSwcOptions(options, undefined, swc, 'swc');\n } catch (err) {\n console.log(`prepareSWCOptions failed: ${err instanceof Error ? err.message : String(err)}`);\n return {} as TranspilerOptions;\n }\n}\n"],"names":["prepareSWCOptions","_require","require","Module","createRequire","__dirname","path","dirname","__filename","url","fileURLToPath","installSyncSWC","debounce","installSync","leading","trailing","enumValue","map","value","wanted","replace","toLowerCase","names","Object","keys","i","length","undefined","normalizeCompilerOptions","raw","target","tsConstants","ScriptTarget","module","ModuleKind","jsx","JsxEmit","tsconfig","process","platform","arch","cwd","filter","matchesLibc","ts","swc","transpiler","options","parseJsonConfigFileContent","config","sys","compilerOptions","createSwcOptions","err","console","log","Error","message","String"],"mappings":";;;;+BAwCA;;;eAAwBA;;;+BAvCiB;qEACpB;6DACF;2DACF;kEACO;0DACR;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEhB,IAAMC,WAAW,OAAOC,YAAY,cAAcC,eAAM,CAACC,aAAa,CAAC,uDAAmBF;AAC1F,IAAMG,YAAYC,aAAI,CAACC,OAAO,CAAC,OAAOC,eAAe,cAAcA,aAAaC,YAAG,CAACC,aAAa,CAAC;AASlG,IAAMC,iBAAiBC,IAAAA,uBAAQ,EAACC,4BAAW,EAAE,KAAK;IAAEC,SAAS;IAAMC,UAAU;AAAM;AAEnF,mFAAmF;AACnF,SAASC,UAAUC,GAA4B,EAAEC,KAAc;IAC7D,IAAI,OAAOA,UAAU,UAAU,OAAOA;IACtC,IAAMC,SAASD,MAAME,OAAO,CAAC,MAAM,IAAIC,WAAW;IAClD,IAAMC,QAAQC,OAAOC,IAAI,CAACP;IAC1B,IAAK,IAAIQ,IAAI,GAAGA,IAAIH,MAAMI,MAAM,EAAED,IAAK;QAC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|
105
105
|
var concurrency = Math.min(64, Math.max(8, ((_ref = (_os_cpus = _os.default.cpus()) === null || _os_cpus === void 0 ? void 0 : _os_cpus.length) !== null && _ref !== void 0 ? _ref : 4) * 8));
|
|
106
106
|
var tscPath = (0, _resolvebinsync.default)('typescript', 'tsc');
|
|
107
|
+
function compilerMajor() {
|
|
108
|
+
try {
|
|
109
|
+
var pkg = JSON.parse(_fs.default.readFileSync(_path.default.join(_path.default.dirname(tscPath), '..', 'package.json'), 'utf8'));
|
|
110
|
+
return +String(pkg.version).split('.')[0] || 0;
|
|
111
|
+
} catch (unused) {
|
|
112
|
+
return 0;
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
// TypeScript 7 removed options that only ever affected JS emit, which swc handles.
|
|
116
|
+
// Older compilers still accept them, so only rewrite when the installed tsc would reject them.
|
|
117
|
+
function sanitizeForCompiler(options) {
|
|
118
|
+
if (compilerMajor() < 7) return options;
|
|
119
|
+
var sanitized = _object_spread({}, options);
|
|
120
|
+
delete sanitized.downlevelIteration;
|
|
121
|
+
if (sanitized.moduleResolution === 'node' || sanitized.moduleResolution === 'node10') sanitized.moduleResolution = 'bundler';
|
|
122
|
+
if (typeof sanitized.target === 'string' && /^es[35]$/i.test(sanitized.target)) sanitized.target = 'es2015';
|
|
123
|
+
return sanitized;
|
|
124
|
+
}
|
|
107
125
|
/* ---------------- root file filtering ---------------- */ function isAllowedRootFile(basename) {
|
|
108
126
|
return basename.endsWith('.d.ts') || basename.endsWith('.d.mts') || basename.endsWith('.d.cts') || basename.endsWith('.ts') || basename.endsWith('.tsx') || basename.endsWith('.mts') || basename.endsWith('.cts') || basename.endsWith('.js') || basename.endsWith('.jsx') || basename.endsWith('.mjs') || basename.endsWith('.cjs');
|
|
109
127
|
}
|
|
@@ -170,7 +188,7 @@ function transformTypesWorker(src, dest, options, callback) {
|
|
|
170
188
|
var _tsconfig_config_compilerOptions;
|
|
171
189
|
if (err1) return callback(err1);
|
|
172
190
|
if (rootFiles.length === 0) return callback(null, []);
|
|
173
|
-
var compilerOptions = _object_spread_props(_object_spread({}, tsconfig.config.compilerOptions), {
|
|
191
|
+
var compilerOptions = sanitizeForCompiler(_object_spread_props(_object_spread({}, tsconfig.config.compilerOptions), {
|
|
174
192
|
rootDir: src,
|
|
175
193
|
outDir: dest,
|
|
176
194
|
noEmit: false,
|
|
@@ -179,7 +197,7 @@ function transformTypesWorker(src, dest, options, callback) {
|
|
|
179
197
|
emitDeclarationOnly: true,
|
|
180
198
|
// Suppress TS6 deprecation warnings (TS5101/TS5107) for consumers still on legacy Node-targeted options.
|
|
181
199
|
ignoreDeprecations: '6.0'
|
|
182
|
-
});
|
|
200
|
+
}));
|
|
183
201
|
var rewrite = ((_tsconfig_config_compilerOptions = tsconfig.config.compilerOptions) === null || _tsconfig_config_compilerOptions === void 0 ? void 0 : _tsconfig_config_compilerOptions.rewriteRelativeImportExtensions) === true;
|
|
184
202
|
// Avoid collisions across concurrent runs.
|
|
185
203
|
var tempDir = _path.default.join(dest, '.ts-swc-transform-temp', String(process.pid), String(Date.now()));
|
|
@@ -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');\n\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 (!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));\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":["transformTypesWorker","os","concurrency","Math","min","max","cpus","length","tscPath","resolveBin","isAllowedRootFile","basename","endsWith","runCompiler","cmdPath","args","cb","spawn","process","execPath","encoding","parseEmittedFiles","res","dest","out","seen","Set","lines","stdout","stderr","split","line","trim","test","replace","path","isAbsolute","rel","relative","startsWith","has","add","push","src","options","callback","tsconfig","matcher","createMatcher","rootFiles","iterator","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","fs","mkdir","recursive","mkdirErr","writeFile","JSON","stringify","writeErr","safeRm","force","runErr","status","source","detail","slice","Error","emittedFiles","postQueue","Queue","file","defer","readFile","readErr","content","updated","rewriteExtensions","await","rmErr"],"mappings":";;;;+BAuEA;;;eAAwBA;;;mEAvEoC;yDAC7C;iEACsB;8BACd;yDACR;2DACE;8DACC;qEACK;sEAMG;mCACQ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IALYC;AAA9C,IAAMC,cAAcC,KAAKC,GAAG,CAAC,IAAID,KAAKE,GAAG,CAAC,GAAG,UAACJ,WAAAA,WAAE,CAACK,IAAI,gBAAPL,+BAAAA,SAAWM,MAAM,uCAAI,KAAK;AAExE,IAAMC,UAAUC,IAAAA,uBAAU,EAAC,cAAc;AAOzC,y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E,KAAK,CAAC,GAAG,SAAS,eAAqC,OAAxBlE,OAAOkE,KAAK,CAAC,GAAG;wBACjIN,IAAAA,sBAAM,EAACpB,SAAS;4BAAEc,WAAW;4BAAMO,OAAO;wBAAK,GAAG;mCAAM7C,SAAS,IAAImD,MAAMF;;wBAC3E;oBACF;oBAEA,IAAMG,eAAe5E,kBAAkBC,KAAKC;oBAC5C,IAAI0E,aAAa1F,MAAM,KAAK,GAAG;wBAC7BkF,IAAAA,sBAAM,EAACpB,SAAS;4BAAEc,WAAW;4BAAMO,OAAO;wBAAK,GAAG;mCAAM7C,SAAS,IAAImD,MAAM;;wBAC3E;oBACF;oBAEA,IAAME,YAAY,IAAIC,gBAAK;oBAE3B,IAAIhC,SAAS;4BACN,kCAAA,2BAAA;;;gCAAA,IAAMiC,OAAN;gCACHF,UAAUG,KAAK,CAAC,SAACrF;oCACfiE,WAAE,CAACqB,QAAQ,CAACF,MAAM,QAAQ,SAACG,SAASC;wCAClC,IAAID,SAAS,OAAOvF;wCACpB,IAAMyF,UAAUC,IAAAA,sCAAiB,EAACF;wCAClC,IAAIC,YAAYD,SAASxF;6CACpBiE,WAAE,CAACI,SAAS,CAACe,MAAMK,SAAS,QAAQ,SAAChD;mDAAQzC,GAAGyC;;oCACvD;gCACF;4BACF;4BATA,QAAK,YAAcwC,iCAAd,SAAA,6BAAA,QAAA,yBAAA;;4BAAA;4BAAA;;;qCAAA,6BAAA;oCAAA;;;oCAAA;0CAAA;;;;oBAUP;oBAEAC,UAAUS,KAAK,CAAC;wBACdlB,IAAAA,sBAAM,EAACpB,SAAS;4BAAEc,WAAW;4BAAMO,OAAO;wBAAK,GAAG,SAACkB;mCAAU/D,SAAS+D,SAAS,MAAMX;;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\nfunction compilerMajor(): number {\n try {\n const pkg = JSON.parse(fs.readFileSync(path.join(path.dirname(tscPath), '..', 'package.json'), 'utf8'));\n return +String(pkg.version).split('.')[0] || 0;\n } catch {\n return 0;\n }\n}\n\n// TypeScript 7 removed options that only ever affected JS emit, which swc handles.\n// Older compilers still accept them, so only rewrite when the installed tsc would reject them.\nfunction sanitizeForCompiler(options: Record<string, unknown>): Record<string, unknown> {\n if (compilerMajor() < 7) return options;\n const sanitized = { ...options };\n delete sanitized.downlevelIteration;\n if (sanitized.moduleResolution === 'node' || sanitized.moduleResolution === 'node10') sanitized.moduleResolution = 'bundler';\n if (typeof sanitized.target === 'string' && /^es[35]$/i.test(sanitized.target)) sanitized.target = 'es2015';\n return sanitized;\n}\n\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 (!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 = sanitizeForCompiler({\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));\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":["transformTypesWorker","os","concurrency","Math","min","max","cpus","length","tscPath","resolveBin","compilerMajor","pkg","JSON","parse","fs","readFileSync","path","join","dirname","String","version","split","sanitizeForCompiler","options","sanitized","downlevelIteration","moduleResolution","target","test","isAllowedRootFile","basename","endsWith","runCompiler","cmdPath","args","cb","spawn","process","execPath","encoding","parseEmittedFiles","res","dest","out","seen","Set","lines","stdout","stderr","line","trim","replace","isAbsolute","rel","relative","startsWith","has","add","push","src","callback","tsconfig","matcher","createMatcher","rootFiles","iterator","Iterator","forEach","entry","stats","isFile","fullPath","err","compilerOptions","config","rootDir","outDir","noEmit","allowJs","declaration","emitDeclarationOnly","ignoreDeprecations","rewrite","rewriteRelativeImportExtensions","tempDir","pid","Date","now","tempConfigPath","tempConfig","files","include","exclude","references","mkdir","recursive","mkdirErr","writeFile","stringify","writeErr","safeRm","force","runErr","status","source","detail","slice","Error","emittedFiles","postQueue","Queue","file","defer","readFile","readErr","content","updated","rewriteExtensions","await","rmErr"],"mappings":";;;;+BA2FA;;;eAAwBA;;;mEA3FoC;yDAC7C;iEACsB;8BACd;yDACR;2DACE;8DACC;qEACK;sEA0BG;mCACQ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAzBYC;AAA9C,IAAMC,cAAcC,KAAKC,GAAG,CAAC,IAAID,KAAKE,GAAG,CAAC,GAAG,UAACJ,WAAAA,WAAE,CAACK,IAAI,gBAAPL,+BAAAA,SAAWM,MAAM,uCAAI,KAAK;AAExE,IAAMC,UAAUC,IAAAA,uBAAU,EAAC,cAAc;AAEzC,SAASC;IACP,IAAI;QACF,IAAMC,MAAMC,KAAKC,KAAK,CAACC,WAAE,CAACC,YAAY,CAACC,aAAI,CAACC,IAAI,CAACD,aAAI,CAACE,OAAO,CAACV,UAAU,MAAM,iBAAiB;QAC/F,OAAO,CAACW,OAAOR,IAAIS,OAAO,EAAEC,KAAK,CAAC,IAAI,CAAC,EAAE,IAAI;IAC/C,EAAE,eAAM;QACN,OAAO;I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CAAd,SAAA,6BAAA,QAAA,yBAAA;;4BAAA;4BAAA;;;qCAAA,6BAAA;oCAAA;;;oCAAA;0CAAA;;;;oBAUP;oBAEAC,UAAUS,KAAK,CAAC;wBACdlB,IAAAA,sBAAM,EAAChB,SAAS;4BAAEW,WAAW;4BAAMM,OAAO;wBAAK,GAAG,SAACkB;mCAAU3D,SAAS2D,SAAS,MAAMX;;oBACvF;gBACF;YACF;QACF;IACF;AAEJ"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/typescript/ts-swc-transform/src/lib/patchCJS.ts"],"sourcesContent":["import path from 'path';\nimport { replaceExtension, rewriteExtensionsCJS } from './rewriteExtensions.ts';\n\n// https://github.com/vercel/next.js/blob/20b63e13ab2631d6043277895d373aa31a1b327c/packages/next/taskfile-swc.js#L118-L125\nexport const interop = \"/* CJS INTEROP */ if (exports.__esModule && exports.default) { try { Object.defineProperty(exports.default, '__esModule', { value: true }); for (var key in exports) { exports.default[key] = exports[key]; } } catch (_) {}; module.exports = exports.default; }\";\n\nimport type { Output } from '@swc/core';\nimport type { Entry } from 'fs-iterator';\nimport type {
|
|
1
|
+
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/typescript/ts-swc-transform/src/lib/patchCJS.ts"],"sourcesContent":["import path from 'path';\nimport { replaceExtension, rewriteExtensionsCJS } from './rewriteExtensions.ts';\n\n// https://github.com/vercel/next.js/blob/20b63e13ab2631d6043277895d373aa31a1b327c/packages/next/taskfile-swc.js#L118-L125\nexport const interop = \"/* CJS INTEROP */ if (exports.__esModule && exports.default) { try { Object.defineProperty(exports.default, '__esModule', { value: true }); for (var key in exports) { exports.default[key] = exports[key]; } } catch (_) {}; module.exports = exports.default; }\";\n\nimport type { Output } from '@swc/core';\nimport type { Entry } from 'fs-iterator';\nimport type { InternalConfigOptions } from '../types.ts';\n\n// Read straight off the parsed tsconfig JSON, which is arbitrary data rather\n// than typescript's own CompilerOptions.\ninterface InternalCompilerOptions {\n rewriteRelativeImportExtensions?: boolean;\n}\n\nexport default function patchCJS(entry: Entry, output: Output, options: InternalConfigOptions): string {\n const rewrite = ((options.tsconfig.config.compilerOptions || {}) as unknown as InternalCompilerOptions).rewriteRelativeImportExtensions;\n if (rewrite) output.code = rewriteExtensionsCJS(output.code);\n output.code += interop;\n\n return replaceExtension(path.extname(entry.basename));\n}\n"],"names":["path","replaceExtension","rewriteExtensionsCJS","interop","patchCJS","entry","output","options","rewrite","tsconfig","config","compilerOptions","rewriteRelativeImportExtensions","code","extname","basename"],"mappings":"AAAA,OAAOA,UAAU,OAAO;AACxB,SAASC,gBAAgB,EAAEC,oBAAoB,QAAQ,yBAAyB;AAEhF,0HAA0H;AAC1H,OAAO,MAAMC,UAAU,oQAAoQ;AAY3R,eAAe,SAASC,SAASC,KAAY,EAAEC,MAAc,EAAEC,OAA8B;IAC3F,MAAMC,UAAU,AAAED,CAAAA,QAAQE,QAAQ,CAACC,MAAM,CAACC,eAAe,IAAI,CAAC,CAAA,EAA0CC,+BAA+B;IACvI,IAAIJ,SAASF,OAAOO,IAAI,GAAGX,qBAAqBI,OAAOO,IAAI;IAC3DP,OAAOO,IAAI,IAAIV;IAEf,OAAOF,iBAAiBD,KAAKc,OAAO,CAACT,MAAMU,QAAQ;AACrD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/typescript/ts-swc-transform/src/lib/patchESM.ts"],"sourcesContent":["import type { Output } from '@swc/core';\nimport type { Entry } from 'fs-iterator';\nimport path from 'path';\nimport type {
|
|
1
|
+
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/typescript/ts-swc-transform/src/lib/patchESM.ts"],"sourcesContent":["import type { Output } from '@swc/core';\nimport type { Entry } from 'fs-iterator';\nimport path from 'path';\nimport type { InternalConfigOptions } from '../types.ts';\nimport { replaceExtension, rewriteExtensions } from './rewriteExtensions.ts';\n\n// Read straight off the parsed tsconfig JSON, which is arbitrary data rather\n// than typescript's own CompilerOptions.\ninterface InternalCompilerOptions {\n rewriteRelativeImportExtensions?: boolean;\n}\n\nexport default function patchESM(entry: Entry, output: Output, options: InternalConfigOptions): string {\n const rewrite = ((options.tsconfig.config.compilerOptions || {}) as unknown as InternalCompilerOptions).rewriteRelativeImportExtensions;\n if (rewrite) output.code = rewriteExtensions(output.code);\n\n return replaceExtension(path.extname(entry.basename));\n}\n"],"names":["path","replaceExtension","rewriteExtensions","patchESM","entry","output","options","rewrite","tsconfig","config","compilerOptions","rewriteRelativeImportExtensions","code","extname","basename"],"mappings":"AAEA,OAAOA,UAAU,OAAO;AAExB,SAASC,gBAAgB,EAAEC,iBAAiB,QAAQ,yBAAyB;AAQ7E,eAAe,SAASC,SAASC,KAAY,EAAEC,MAAc,EAAEC,OAA8B;IAC3F,MAAMC,UAAU,AAAED,CAAAA,QAAQE,QAAQ,CAACC,MAAM,CAACC,eAAe,IAAI,CAAC,CAAA,EAA0CC,+BAA+B;IACvI,IAAIJ,SAASF,OAAOO,IAAI,GAAGV,kBAAkBG,OAAOO,IAAI;IAExD,OAAOX,iBAAiBD,KAAKa,OAAO,CAACT,MAAMU,QAAQ;AACrD"}
|
|
@@ -2,6 +2,7 @@ import { installSync, matchesLibc } from 'install-optional';
|
|
|
2
2
|
import debounce from 'lodash.debounce';
|
|
3
3
|
import Module from 'module';
|
|
4
4
|
import path from 'path';
|
|
5
|
+
import tsConstants from 'ts-constants';
|
|
5
6
|
import url from 'url';
|
|
6
7
|
const _require = typeof require === 'undefined' ? Module.createRequire(import.meta.url) : require;
|
|
7
8
|
const __dirname = path.dirname(typeof __filename !== 'undefined' ? __filename : url.fileURLToPath(import.meta.url));
|
|
@@ -9,6 +10,24 @@ const installSyncSWC = debounce(installSync, 300, {
|
|
|
9
10
|
leading: true,
|
|
10
11
|
trailing: false
|
|
11
12
|
});
|
|
13
|
+
// tsconfig spells enums as strings ("es2019", "react-jsx"); swc needs the numbers.
|
|
14
|
+
function enumValue(map, value) {
|
|
15
|
+
if (typeof value !== 'string') return value;
|
|
16
|
+
const wanted = value.replace(/-/g, '').toLowerCase();
|
|
17
|
+
const names = Object.keys(map);
|
|
18
|
+
for(let i = 0; i < names.length; i++){
|
|
19
|
+
if (typeof map[names[i]] === 'number' && names[i].toLowerCase() === wanted) return map[names[i]];
|
|
20
|
+
}
|
|
21
|
+
return undefined;
|
|
22
|
+
}
|
|
23
|
+
function normalizeCompilerOptions(raw) {
|
|
24
|
+
return {
|
|
25
|
+
...raw,
|
|
26
|
+
target: enumValue(tsConstants.ScriptTarget, raw.target),
|
|
27
|
+
module: enumValue(tsConstants.ModuleKind, raw.module),
|
|
28
|
+
jsx: enumValue(tsConstants.JsxEmit, raw.jsx)
|
|
29
|
+
};
|
|
30
|
+
}
|
|
12
31
|
export default function prepareSWCOptions(tsconfig) {
|
|
13
32
|
installSyncSWC('@swc/core', `${process.platform}-${process.arch}`, {
|
|
14
33
|
cwd: __dirname,
|
|
@@ -18,8 +37,10 @@ export default function prepareSWCOptions(tsconfig) {
|
|
|
18
37
|
const ts = _require('typescript');
|
|
19
38
|
const swc = _require('@swc/core');
|
|
20
39
|
const transpiler = _require('ts-node/transpilers/swc');
|
|
21
|
-
|
|
22
|
-
|
|
40
|
+
// TypeScript 7 dropped the compiler API from the package root, so fall back
|
|
41
|
+
// to resolving the enum-valued fields directly.
|
|
42
|
+
const options = typeof ts.parseJsonConfigFileContent === 'function' ? ts.parseJsonConfigFileContent(tsconfig.config, ts.sys, path.dirname(tsconfig.path)).options : normalizeCompilerOptions(tsconfig.config.compilerOptions || {});
|
|
43
|
+
return transpiler.createSwcOptions(options, undefined, swc, 'swc');
|
|
23
44
|
} catch (err) {
|
|
24
45
|
console.log(`prepareSWCOptions failed: ${err instanceof Error ? err.message : String(err)}`);
|
|
25
46
|
return {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/typescript/ts-swc-transform/src/lib/prepareSWCOptions.ts"],"sourcesContent":["import type { Options } from '@swc/core';\nimport { installSync, matchesLibc } from 'install-optional';\nimport debounce from 'lodash.debounce';\nimport Module from 'module';\nimport path from 'path';\nimport url from 'url';\n\nconst _require = typeof require === 'undefined' ? Module.createRequire(import.meta.url) : require;\nconst __dirname = path.dirname(typeof __filename !== 'undefined' ? __filename : url.fileURLToPath(import.meta.url));\n\nimport type { TSConfig } from '../types.ts';\n\nexport interface TranspilerOptions {\n tsxOptions: Options;\n nonTsxOptions: Options;\n}\n\nconst installSyncSWC = debounce(installSync, 300, { leading: true, trailing: false });\n\nexport default function prepareSWCOptions(tsconfig: TSConfig): TranspilerOptions {\n installSyncSWC('@swc/core', `${process.platform}-${process.arch}`, { cwd: __dirname, filter: matchesLibc });\n try {\n const ts = _require('typescript');\n const swc = _require('@swc/core');\n const transpiler = _require('ts-node/transpilers/swc');\n const
|
|
1
|
+
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/typescript/ts-swc-transform/src/lib/prepareSWCOptions.ts"],"sourcesContent":["import type { Options } from '@swc/core';\nimport { installSync, matchesLibc } from 'install-optional';\nimport debounce from 'lodash.debounce';\nimport Module from 'module';\nimport path from 'path';\nimport tsConstants from 'ts-constants';\nimport url from 'url';\n\nconst _require = typeof require === 'undefined' ? Module.createRequire(import.meta.url) : require;\nconst __dirname = path.dirname(typeof __filename !== 'undefined' ? __filename : url.fileURLToPath(import.meta.url));\n\nimport type { TSConfig } from '../types.ts';\n\nexport interface TranspilerOptions {\n tsxOptions: Options;\n nonTsxOptions: Options;\n}\n\nconst installSyncSWC = debounce(installSync, 300, { leading: true, trailing: false });\n\n// tsconfig spells enums as strings (\"es2019\", \"react-jsx\"); swc needs the numbers.\nfunction enumValue(map: Record<string, unknown>, value: unknown): unknown {\n if (typeof value !== 'string') return value;\n const wanted = value.replace(/-/g, '').toLowerCase();\n const names = Object.keys(map);\n for (let i = 0; i < names.length; i++) {\n if (typeof map[names[i]] === 'number' && names[i].toLowerCase() === wanted) return map[names[i]];\n }\n return undefined;\n}\n\nfunction normalizeCompilerOptions(raw: Record<string, unknown>): Record<string, unknown> {\n return {\n ...raw,\n target: enumValue(tsConstants.ScriptTarget as unknown as Record<string, unknown>, raw.target),\n module: enumValue(tsConstants.ModuleKind as unknown as Record<string, unknown>, raw.module),\n jsx: enumValue(tsConstants.JsxEmit as unknown as Record<string, unknown>, raw.jsx),\n };\n}\n\nexport default function prepareSWCOptions(tsconfig: TSConfig): TranspilerOptions {\n installSyncSWC('@swc/core', `${process.platform}-${process.arch}`, { cwd: __dirname, filter: matchesLibc });\n try {\n const ts = _require('typescript');\n const swc = _require('@swc/core');\n const transpiler = _require('ts-node/transpilers/swc');\n // TypeScript 7 dropped the compiler API from the package root, so fall back\n // to resolving the enum-valued fields directly.\n const options = typeof ts.parseJsonConfigFileContent === 'function' ? ts.parseJsonConfigFileContent(tsconfig.config, ts.sys, path.dirname(tsconfig.path)).options : normalizeCompilerOptions((tsconfig.config.compilerOptions || {}) as Record<string, unknown>);\n return transpiler.createSwcOptions(options, undefined, swc, 'swc');\n } catch (err) {\n console.log(`prepareSWCOptions failed: ${err instanceof Error ? err.message : String(err)}`);\n return {} as TranspilerOptions;\n }\n}\n"],"names":["installSync","matchesLibc","debounce","Module","path","tsConstants","url","_require","require","createRequire","__dirname","dirname","__filename","fileURLToPath","installSyncSWC","leading","trailing","enumValue","map","value","wanted","replace","toLowerCase","names","Object","keys","i","length","undefined","normalizeCompilerOptions","raw","target","ScriptTarget","module","ModuleKind","jsx","JsxEmit","prepareSWCOptions","tsconfig","process","platform","arch","cwd","filter","ts","swc","transpiler","options","parseJsonConfigFileContent","config","sys","compilerOptions","createSwcOptions","err","console","log","Error","message","String"],"mappings":"AACA,SAASA,WAAW,EAAEC,WAAW,QAAQ,mBAAmB;AAC5D,OAAOC,cAAc,kBAAkB;AACvC,OAAOC,YAAY,SAAS;AAC5B,OAAOC,UAAU,OAAO;AACxB,OAAOC,iBAAiB,eAAe;AACvC,OAAOC,SAAS,MAAM;AAEtB,M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ChD,MAAMwC,UAAU,OAAOH,GAAGI,0BAA0B,KAAK,aAAaJ,GAAGI,0BAA0B,CAACV,SAASW,MAAM,EAAEL,GAAGM,GAAG,EAAE9C,KAAKO,OAAO,CAAC2B,SAASlC,IAAI,GAAG2C,OAAO,GAAGlB,yBAA0BS,SAASW,MAAM,CAACE,eAAe,IAAI,CAAC;QAClO,OAAOL,WAAWM,gBAAgB,CAACL,SAASnB,WAAWiB,KAAK;IAC9D,EAAE,OAAOQ,KAAK;QACZC,QAAQC,GAAG,CAAC,CAAC,0BAA0B,EAAEF,eAAeG,QAAQH,IAAII,OAAO,GAAGC,OAAOL,MAAM;QAC3F,OAAO,CAAC;IACV;AACF"}
|
|
@@ -10,6 +10,26 @@ 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
|
+
function compilerMajor() {
|
|
14
|
+
try {
|
|
15
|
+
const pkg = JSON.parse(fs.readFileSync(path.join(path.dirname(tscPath), '..', 'package.json'), 'utf8'));
|
|
16
|
+
return +String(pkg.version).split('.')[0] || 0;
|
|
17
|
+
} catch {
|
|
18
|
+
return 0;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
// TypeScript 7 removed options that only ever affected JS emit, which swc handles.
|
|
22
|
+
// Older compilers still accept them, so only rewrite when the installed tsc would reject them.
|
|
23
|
+
function sanitizeForCompiler(options) {
|
|
24
|
+
if (compilerMajor() < 7) return options;
|
|
25
|
+
const sanitized = {
|
|
26
|
+
...options
|
|
27
|
+
};
|
|
28
|
+
delete sanitized.downlevelIteration;
|
|
29
|
+
if (sanitized.moduleResolution === 'node' || sanitized.moduleResolution === 'node10') sanitized.moduleResolution = 'bundler';
|
|
30
|
+
if (typeof sanitized.target === 'string' && /^es[35]$/i.test(sanitized.target)) sanitized.target = 'es2015';
|
|
31
|
+
return sanitized;
|
|
32
|
+
}
|
|
13
33
|
import createMatcher from '../createMatcher.js';
|
|
14
34
|
import { rewriteExtensions } from '../lib/rewriteExtensions.js';
|
|
15
35
|
/* ---------------- root file filtering ---------------- */ function isAllowedRootFile(basename) {
|
|
@@ -62,7 +82,7 @@ export default function transformTypesWorker(src, dest, options, callback) {
|
|
|
62
82
|
var _tsconfig_config_compilerOptions;
|
|
63
83
|
if (err) return callback(err);
|
|
64
84
|
if (rootFiles.length === 0) return callback(null, []);
|
|
65
|
-
const compilerOptions = {
|
|
85
|
+
const compilerOptions = sanitizeForCompiler({
|
|
66
86
|
...tsconfig.config.compilerOptions,
|
|
67
87
|
rootDir: src,
|
|
68
88
|
outDir: dest,
|
|
@@ -72,7 +92,7 @@ export default function transformTypesWorker(src, dest, options, callback) {
|
|
|
72
92
|
emitDeclarationOnly: true,
|
|
73
93
|
// Suppress TS6 deprecation warnings (TS5101/TS5107) for consumers still on legacy Node-targeted options.
|
|
74
94
|
ignoreDeprecations: '6.0'
|
|
75
|
-
};
|
|
95
|
+
});
|
|
76
96
|
const rewrite = ((_tsconfig_config_compilerOptions = tsconfig.config.compilerOptions) === null || _tsconfig_config_compilerOptions === void 0 ? void 0 : _tsconfig_config_compilerOptions.rewriteRelativeImportExtensions) === true;
|
|
77
97
|
// Avoid collisions across concurrent runs.
|
|
78
98
|
const tempDir = path.join(dest, '.ts-swc-transform-temp', String(process.pid), String(Date.now()));
|
|
@@ -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');\n\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 (!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));\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","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","await","rmErr"],"mappings":";IAS8CA;AAT9C,OAAOC,WAAqD,iBAAiB;AAC7E,OAAOC,QAAQ,KAAK;AACpB,OAAOC,cAA8B,cAAc;AACnD,S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AA,OAAQ7D,MAAM,uCAAI;wBACxC,MAAMC,SAASwC,gBAAOoB,mBAAAA,6BAAAA,OAAQ5D,MAAM,yCAAI;wBACxC,MAAM6D,SAAS,CAAC,mCAAmC,EAAEF,OAAO,aAAa,EAAE5D,OAAO+D,KAAK,CAAC,GAAG,QAAS,WAAW,EAAE9D,OAAO8D,KAAK,CAAC,GAAG,QAAS;wBAC1I7F,OAAOqE,SAAS;4BAAEa,WAAW;4BAAMM,OAAO;wBAAK,GAAG,IAAMzC,SAAS,IAAI+C,MAAMF;wBAC3E;oBACF;oBAEA,MAAMG,eAAexE,kBAAkBC,KAAKC;oBAC5C,IAAIsE,aAAatF,MAAM,KAAK,GAAG;wBAC7BT,OAAOqE,SAAS;4BAAEa,WAAW;4BAAMM,OAAO;wBAAK,GAAG,IAAMzC,SAAS,IAAI+C,MAAM;wBAC3E;oBACF;oBAEA,MAAME,YAAY,IAAI9F;oBAEtB,IAAIiE,SAAS;wBACX,KAAK,MAAM8B,QAAQF,aAAc;4BAC/BC,UAAUE,KAAK,CAAC,CAAC/E;gCACfrB,GAAGqG,QAAQ,CAACF,MAAM,QAAQ,CAACG,SAASC;oCAClC,IAAID,SAAS,OAAOjF;oCACpB,MAAMmF,UAAU1F,kBAAkByF;oCAClC,IAAIC,YAAYD,SAASlF;yCACpBrB,GAAGsF,SAAS,CAACa,MAAMK,SAAS,QAAQ,CAAC7C,MAAQtC,GAAGsC;gCACvD;4BACF;wBACF;oBACF;oBAEAuC,UAAUO,KAAK,CAAC;wBACdvG,OAAOqE,SAAS;4BAAEa,WAAW;4BAAMM,OAAO;wBAAK,GAAG,CAACgB,QAAUzD,SAASyD,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\nfunction compilerMajor(): number {\n try {\n const pkg = JSON.parse(fs.readFileSync(path.join(path.dirname(tscPath), '..', 'package.json'), 'utf8'));\n return +String(pkg.version).split('.')[0] || 0;\n } catch {\n return 0;\n }\n}\n\n// TypeScript 7 removed options that only ever affected JS emit, which swc handles.\n// Older compilers still accept them, so only rewrite when the installed tsc would reject them.\nfunction sanitizeForCompiler(options: Record<string, unknown>): Record<string, unknown> {\n if (compilerMajor() < 7) return options;\n const sanitized = { ...options };\n delete sanitized.downlevelIteration;\n if (sanitized.moduleResolution === 'node' || sanitized.moduleResolution === 'node10') sanitized.moduleResolution = 'bundler';\n if (typeof sanitized.target === 'string' && /^es[35]$/i.test(sanitized.target)) sanitized.target = 'es2015';\n return sanitized;\n}\n\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 (!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 = sanitizeForCompiler({\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));\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","compilerMajor","pkg","JSON","parse","readFileSync","join","dirname","String","version","split","sanitizeForCompiler","options","sanitized","downlevelIteration","moduleResolution","target","test","createMatcher","rewriteExtensions","isAllowedRootFile","basename","endsWith","runCompiler","cmdPath","args","cb","process","execPath","encoding","parseEmittedFiles","res","dest","out","seen","Set","lines","stdout","stderr","line","trim","replace","isAbsolute","rel","relative","startsWith","has","add","push","transformTypesWorker","src","callback","tsconfig","matcher","rootFiles","iterator","forEach","entry","stats","isFile","fullPath","err","compilerOptions","config","rootDir","outDir","noEmit","allowJs","declaration","emitDeclarationOnly","ignoreDeprecations","rewrite","rewriteRelativeImportExtensions","tempDir","pid","Date","now","tempConfigPath","tempConfig","files","include","exclude","references","mkdir","recursive","mkdirErr","writeFile","stringify","writeErr","force","runErr","status","source","detail","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,UAACX,WAAAA,GAAGY,IAAI,gBAAPZ,+BAAAA,SAAWa,MAAM,uCAAI,KAAK;AAExE,MAAMC,UAAUP,WAAW,cAAc;AAEzC,SAASQ;IACP,IAAI;QACF,MAAMC,MAAMC,KAAKC,KAAK,CAAChB,GAAGiB,YAAY,CAACd,KAAKe,IAAI,CAACf,KAAKgB,OAAO,CAACP,UAAU,MAAM,iBAAiB;QAC/F,OAAO,CAACQ,OAAON,IAAIO,OAAO,EAAEC,KAAK,CAAC,IAAI,CAAC,EAAE,IAAI;IAC/C,EAAE,OAAM;QACN,OAAO;IACT;AACF;AAEA,mFAAm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transform",
|
|
3
|
-
"version": "2.11.
|
|
3
|
+
"version": "2.11.12",
|
|
4
4
|
"description": "Typescript transformers for swc. Supports Node >= 0.8",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"matcher",
|
|
@@ -60,8 +60,9 @@
|
|
|
60
60
|
"resolve-bin-sync": "^1.0.13",
|
|
61
61
|
"resolve.exports": "^2.0.3",
|
|
62
62
|
"test-match": "^1.0.0",
|
|
63
|
+
"ts-constants": "^1.1.13",
|
|
63
64
|
"ts-node": "^10.9.0",
|
|
64
|
-
"typescript": "^
|
|
65
|
+
"typescript": "^7.0.2"
|
|
65
66
|
},
|
|
66
67
|
"devDependencies": {
|
|
67
68
|
"@types/is-absolute": "^1.0.2",
|