ts-swc-transform 2.11.10 → 2.11.11
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/transformFile.js +2 -2
- package/dist/cjs/lib/transformFile.js.map +1 -1
- package/dist/cjs/transformDirectory.js +3 -1
- package/dist/cjs/transformDirectory.js.map +1 -1
- package/dist/cjs/transformSync.js +3 -1
- package/dist/cjs/transformSync.js.map +1 -1
- package/dist/cjs/transformTypes.js +3 -1
- package/dist/cjs/transformTypes.js.map +1 -1
- package/dist/cjs/workers/transformTypes.js +1 -1
- package/dist/cjs/workers/transformTypes.js.map +1 -1
- package/dist/esm/lib/transformFile.js +2 -2
- package/dist/esm/lib/transformFile.js.map +1 -1
- package/dist/esm/transformDirectory.js +3 -1
- package/dist/esm/transformDirectory.js.map +1 -1
- package/dist/esm/transformSync.js +3 -1
- package/dist/esm/transformSync.js.map +1 -1
- package/dist/esm/transformTypes.js +3 -1
- package/dist/esm/transformTypes.js.map +1 -1
- package/dist/esm/workers/transformTypes.js +1 -1
- package/dist/esm/workers/transformTypes.js.map +1 -1
- package/package.json +1 -1
|
@@ -101,12 +101,12 @@ function transformFile(entry, dest, type, options, mode, callback) {
|
|
|
101
101
|
var queue = new _queuecb.default();
|
|
102
102
|
queue.defer(function(cb) {
|
|
103
103
|
return _fs.default.writeFile(outPath, output.code, 'utf8', function(err) {
|
|
104
|
-
return cb(err
|
|
104
|
+
return cb(err);
|
|
105
105
|
});
|
|
106
106
|
});
|
|
107
107
|
if (output.map && options.sourceMaps) queue.defer(function(cb) {
|
|
108
108
|
return _fs.default.writeFile("".concat(outPath, ".map"), output.map, 'utf8', function(err) {
|
|
109
|
-
return cb(err
|
|
109
|
+
return cb(err);
|
|
110
110
|
});
|
|
111
111
|
});
|
|
112
112
|
queue.await(function(err) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/typescript/ts-swc-transform/src/lib/transformFile.ts"],"sourcesContent":["import type { Output } from '@swc/core';\nimport fs from 'fs';\nimport type { Entry } from 'fs-iterator';\nimport mkdirp from 'mkdirp-classic';\nimport Module from 'module';\nimport path from 'path';\nimport Queue from 'queue-cb';\n\nimport patchCJS from '../lib/patchCJS.ts';\nimport patchESM from '../lib/patchESM.ts';\nimport prepareSWCOptions from '../lib/prepareSWCOptions.ts';\n\nconst _require = typeof require === 'undefined' ? Module.createRequire(import.meta.url) : require;\n\nimport type { InternalConfigOptions, TargetType, TransformFileCallback } from '../types.ts';\n\nexport default function transformFile(entry: Entry, dest: string, type: TargetType, options: InternalConfigOptions, mode: number | undefined, callback: TransformFileCallback): void {\n let tsconfig = options.tsconfig;\n\n // overrides for cjs\n if (type === 'cjs') {\n const compilerOptions = { ...(tsconfig.config.compilerOptions || {}), module: 'commonjs' as const, target: 'es5' as const };\n tsconfig = { ...tsconfig, config: { ...tsconfig.config, compilerOptions } };\n }\n\n const swcOptions = prepareSWCOptions(tsconfig);\n const swc = _require('@swc/core');\n const ext = path.extname(entry.basename as string);\n\n swc\n .transformFile(entry.fullPath, {\n ...(ext === '.tsx' || ext === '.jsx' ? swcOptions.tsxOptions : swcOptions.nonTsxOptions),\n filename: entry.basename,\n })\n .then((output: Output) => {\n const extTarget = type === 'esm' ? patchESM(entry, output, options) : patchCJS(entry, output, options);\n const ext = path.extname(entry.path);\n const outPath = path.join(dest, (ext ? entry.path.slice(0, -ext.length) : entry.path) + extTarget);\n\n mkdirp(path.dirname(outPath), () => {\n const queue = new Queue();\n queue.defer((cb) => fs.writeFile(outPath, output.code, 'utf8', (err) => cb(err
|
|
1
|
+
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/typescript/ts-swc-transform/src/lib/transformFile.ts"],"sourcesContent":["import type { Output } from '@swc/core';\nimport fs from 'fs';\nimport type { Entry } from 'fs-iterator';\nimport mkdirp from 'mkdirp-classic';\nimport Module from 'module';\nimport path from 'path';\nimport Queue from 'queue-cb';\n\nimport patchCJS from '../lib/patchCJS.ts';\nimport patchESM from '../lib/patchESM.ts';\nimport prepareSWCOptions from '../lib/prepareSWCOptions.ts';\n\nconst _require = typeof require === 'undefined' ? Module.createRequire(import.meta.url) : require;\n\nimport type { InternalConfigOptions, TargetType, TransformFileCallback } from '../types.ts';\n\nexport default function transformFile(entry: Entry, dest: string, type: TargetType, options: InternalConfigOptions, mode: number | undefined, callback: TransformFileCallback): void {\n let tsconfig = options.tsconfig;\n\n // overrides for cjs\n if (type === 'cjs') {\n const compilerOptions = { ...(tsconfig.config.compilerOptions || {}), module: 'commonjs' as const, target: 'es5' as const };\n tsconfig = { ...tsconfig, config: { ...tsconfig.config, compilerOptions } };\n }\n\n const swcOptions = prepareSWCOptions(tsconfig);\n const swc = _require('@swc/core');\n const ext = path.extname(entry.basename as string);\n\n swc\n .transformFile(entry.fullPath, {\n ...(ext === '.tsx' || ext === '.jsx' ? swcOptions.tsxOptions : swcOptions.nonTsxOptions),\n filename: entry.basename,\n })\n .then((output: Output) => {\n const extTarget = type === 'esm' ? patchESM(entry, output, options) : patchCJS(entry, output, options);\n const ext = path.extname(entry.path);\n const outPath = path.join(dest, (ext ? entry.path.slice(0, -ext.length) : entry.path) + extTarget);\n\n mkdirp(path.dirname(outPath), () => {\n const queue = new Queue();\n queue.defer((cb) => fs.writeFile(outPath, output.code, 'utf8', (err) => cb(err)));\n if (output.map && options.sourceMaps) queue.defer((cb) => fs.writeFile(`${outPath}.map`, output.map as string, 'utf8', (err) => cb(err)));\n queue.await((err) => {\n if (err) return callback(err);\n\n if (mode) {\n const execBits = mode & 0o111;\n if (execBits) {\n fs.chmod(outPath, 0o644 | execBits, (_chmodErr) => {\n callback(null, outPath);\n });\n return;\n }\n }\n callback(null, outPath);\n });\n });\n })\n .catch(callback);\n}\n"],"names":["transformFile","_require","require","Module","createRequire","entry","dest","type","options","mode","callback","tsconfig","compilerOptions","config","module","target","swcOptions","prepareSWCOptions","swc","ext","path","extname","basename","fullPath","tsxOptions","nonTsxOptions","filename","then","output","extTarget","patchESM","patchCJS","outPath","join","slice","length","mkdirp","dirname","queue","Queue","defer","cb","fs","writeFile","code","err","map","sourceMaps","await","execBits","chmod","_chmodErr","catch"],"mappings":";;;;+BAgBA;;;eAAwBA;;;yDAfT;oEAEI;6DACA;2DACF;8DACC;iEAEG;iEACA;0EACS;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAE9B,IAAMC,WAAW,OAAOC,YAAY,cAAcC,eAAM,CAACC,aAAa,CAAC,uDAAmBF;AAI3E,SAASF,cAAcK,KAAY,EAAEC,IAAY,EAAEC,IAAgB,EAAEC,OAA8B,EAAEC,IAAwB,EAAEC,QAA+B;IAC3K,IAAIC,WAAWH,QAAQG,QAAQ;IAE/B,oBAAoB;IACpB,IAAIJ,SAAS,OAAO;QAClB,IAAMK,kBAAkB,wCAAMD,SAASE,MAAM,CAACD,eAAe,IAAI,CAAC;YAAIE,QAAQ;YAAqBC,QAAQ;;QAC3GJ,WAAW,wCAAKA;YAAUE,QAAQ,wCAAKF,SAASE,MAAM;gBAAED,iBAAAA;;;IAC1D;IAEA,IAAMI,aAAaC,IAAAA,4BAAiB,EAACN;IACrC,IAAMO,MAAMjB,SAAS;IACrB,IAAMkB,MAAMC,aAAI,CAACC,OAAO,CAAChB,MAAMiB,QAAQ;IAEvCJ,IACGlB,aAAa,CAACK,MAAMkB,QAAQ,EAAE,wCACzBJ,QAAQ,UAAUA,QAAQ,SAASH,WAAWQ,UAAU,GAAGR,WAAWS,aAAa;QACvFC,UAAUrB,MAAMiB,QAAQ;QAEzBK,IAAI,CAAC,SAACC;QACL,IAAMC,YAAYtB,SAAS,QAAQuB,IAAAA,mBAAQ,EAACzB,OAAOuB,QAAQpB,WAAWuB,IAAAA,mBAAQ,EAAC1B,OAAOuB,QAAQpB;QAC9F,IAAMW,MAAMC,aAAI,CAACC,OAAO,CAAChB,MAAMe,IAAI;QACnC,IAAMY,UAAUZ,aAAI,CAACa,IAAI,CAAC3B,MAAM,AAACa,CAAAA,MAAMd,MAAMe,IAAI,CAACc,KAAK,CAAC,GAAG,CAACf,IAAIgB,MAAM,IAAI9B,MAAMe,IAAI,AAAD,IAAKS;QAExFO,IAAAA,sBAAM,EAAChB,aAAI,CAACiB,OAAO,CAACL,UAAU;YAC5B,IAAMM,QAAQ,IAAIC,gBAAK;YACvBD,MAAME,KAAK,CAAC,SAACC;uBAAOC,WAAE,CAACC,SAAS,CAACX,SAASJ,OAAOgB,IAAI,EAAE,QAAQ,SAACC;2BAAQJ,GAAGI;;;YAC3E,IAAIjB,OAAOkB,GAAG,IAAItC,QAAQuC,UAAU,EAAET,MAAME,KAAK,CAAC,SAACC;uBAAOC,WAAE,CAACC,SAAS,CAAC,AAAC,GAAU,OAARX,SAAQ,SAAOJ,OAAOkB,GAAG,EAAY,QAAQ,SAACD;2BAAQJ,GAAGI;;;YACnIP,MAAMU,KAAK,CAAC,SAACH;gBACX,IAAIA,KAAK,OAAOnC,SAASmC;gBAEzB,IAAIpC,MAAM;oBACR,IAAMwC,WAAWxC,OAAO;oBACxB,IAAIwC,UAAU;wBACZP,WAAE,CAACQ,KAAK,CAAClB,SAAS,MAAQiB,UAAU,SAACE;4BACnCzC,SAAS,MAAMsB;wBACjB;wBACA;oBACF;gBACF;gBACAtB,SAAS,MAAMsB;YACjB;QACF;IACF,GACCoB,KAAK,CAAC1C;AACX"}
|
|
@@ -84,12 +84,14 @@ var worker = major >= 20 ? run : (0, _nodeversioncall.bind)('>=20', workerPath,
|
|
|
84
84
|
});
|
|
85
85
|
function transformDirectory(src, dest, type, options, callback) {
|
|
86
86
|
try {
|
|
87
|
+
var _loadConfigSync;
|
|
87
88
|
if (typeof src !== 'string') throw new Error('transformDirectory: unexpected source');
|
|
88
89
|
if (typeof dest !== 'string') throw new Error('transformDirectory: unexpected destination directory');
|
|
89
90
|
if (typeof type !== 'string') throw new Error('transformDirectory: unexpected type');
|
|
90
91
|
callback = typeof options === 'function' ? options : callback;
|
|
91
92
|
options = typeof options === 'function' ? {} : options || {};
|
|
92
|
-
var tsconfig = options.tsconfig ? options.tsconfig : (0, _readtsconfigsync.default)(src);
|
|
93
|
+
var tsconfig = options.tsconfig ? options.tsconfig : (_loadConfigSync = (0, _readtsconfigsync.default)(src)) !== null && _loadConfigSync !== void 0 ? _loadConfigSync : undefined;
|
|
94
|
+
if (!tsconfig) throw new Error('transformDirectory: failed to load tsconfig');
|
|
93
95
|
var opts = _object_spread_props(_object_spread({}, options), {
|
|
94
96
|
tsconfig: tsconfig
|
|
95
97
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/typescript/ts-swc-transform/src/transformDirectory.ts"],"sourcesContent":["import Module from 'module';\nimport { bind } from 'node-version-call';\nimport path from 'path';\nimport loadConfigSync from 'read-tsconfig-sync';\nimport url from 'url';\n\nimport type { ConfigOptions, InternalConfigOptions, TargetType, TransformDirectoryCallback } from './types.ts';\n\nconst major = +process.versions.node.split('.')[0];\nconst _require = typeof require === 'undefined' ? Module.createRequire(import.meta.url) : require;\nconst __dirname = path.dirname(typeof __filename === 'undefined' ? url.fileURLToPath(import.meta.url) : __filename);\nconst workerPath = path.join(__dirname, '..', 'cjs', 'workers', 'transformDirectory.js');\n\nfunction run(src: string, dest: string, type: TargetType, options: ConfigOptions, callback: TransformDirectoryCallback) {\n return _require(workerPath)(src, dest, type, options, callback);\n}\n\n// spawnOptions: false - no node/npm spawn (library call only)\nconst worker = major >= 20 ? run : bind('>=20', workerPath, { callbacks: true, spawnOptions: false });\n\nexport default function transformDirectory(src: string, dest: string, type: TargetType, callback: TransformDirectoryCallback): void;\nexport default function transformDirectory(src: string, dest: string, type: TargetType, options: ConfigOptions, callback: TransformDirectoryCallback): void;\nexport default function transformDirectory(src: string, dest: string, type: TargetType): Promise<string[]>;\nexport default function transformDirectory(src: string, dest: string, type: TargetType, options: ConfigOptions): Promise<string[]>;\nexport default function transformDirectory(src: string, dest: string, type: TargetType, options?: ConfigOptions | TransformDirectoryCallback, callback?: TransformDirectoryCallback): void | Promise<string[]> {\n try {\n if (typeof src !== 'string') throw new Error('transformDirectory: unexpected source');\n if (typeof dest !== 'string') throw new Error('transformDirectory: unexpected destination directory');\n if (typeof type !== 'string') throw new Error('transformDirectory: unexpected type');\n\n callback = typeof options === 'function' ? options : callback;\n options = typeof options === 'function' ? {} : ((options || {}) as ConfigOptions);\n const tsconfig = options.tsconfig ? options.tsconfig : loadConfigSync(src);\n const opts: InternalConfigOptions = { ...options, tsconfig };\n\n if (typeof callback === 'function') return worker(src, dest, type, opts, callback);\n return new Promise<string[]>((resolve, reject) => worker(src, dest, type, opts, (err, result) => (err ? reject(err) : resolve(result ?? []))));\n } catch (err) {\n if (typeof callback === 'function') return callback(err as Error);\n return Promise.reject(err);\n }\n}\n"],"names":["transformDirectory","major","process","versions","node","split","_require","require","Module","createRequire","__dirname","path","dirname","__filename","url","fileURLToPath","workerPath","join","run","src","dest","type","options","callback","worker","bind","callbacks","spawnOptions","Error","tsconfig","
|
|
1
|
+
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/typescript/ts-swc-transform/src/transformDirectory.ts"],"sourcesContent":["import Module from 'module';\nimport { bind } from 'node-version-call';\nimport path from 'path';\nimport loadConfigSync from 'read-tsconfig-sync';\nimport url from 'url';\n\nimport type { ConfigOptions, InternalConfigOptions, TargetType, TransformDirectoryCallback } from './types.ts';\n\nconst major = +process.versions.node.split('.')[0];\nconst _require = typeof require === 'undefined' ? Module.createRequire(import.meta.url) : require;\nconst __dirname = path.dirname(typeof __filename === 'undefined' ? url.fileURLToPath(import.meta.url) : __filename);\nconst workerPath = path.join(__dirname, '..', 'cjs', 'workers', 'transformDirectory.js');\n\nfunction run(src: string, dest: string, type: TargetType, options: ConfigOptions, callback: TransformDirectoryCallback) {\n return _require(workerPath)(src, dest, type, options, callback);\n}\n\n// spawnOptions: false - no node/npm spawn (library call only)\nconst worker = major >= 20 ? run : bind('>=20', workerPath, { callbacks: true, spawnOptions: false });\n\nexport default function transformDirectory(src: string, dest: string, type: TargetType, callback: TransformDirectoryCallback): void;\nexport default function transformDirectory(src: string, dest: string, type: TargetType, options: ConfigOptions, callback: TransformDirectoryCallback): void;\nexport default function transformDirectory(src: string, dest: string, type: TargetType): Promise<string[]>;\nexport default function transformDirectory(src: string, dest: string, type: TargetType, options: ConfigOptions): Promise<string[]>;\nexport default function transformDirectory(src: string, dest: string, type: TargetType, options?: ConfigOptions | TransformDirectoryCallback, callback?: TransformDirectoryCallback): void | Promise<string[]> {\n try {\n if (typeof src !== 'string') throw new Error('transformDirectory: unexpected source');\n if (typeof dest !== 'string') throw new Error('transformDirectory: unexpected destination directory');\n if (typeof type !== 'string') throw new Error('transformDirectory: unexpected type');\n\n callback = typeof options === 'function' ? options : callback;\n options = typeof options === 'function' ? {} : ((options || {}) as ConfigOptions);\n const tsconfig = options.tsconfig ? options.tsconfig : (loadConfigSync(src) ?? undefined);\n if (!tsconfig) throw new Error('transformDirectory: failed to load tsconfig');\n const opts: InternalConfigOptions = { ...options, tsconfig };\n\n if (typeof callback === 'function') return worker(src, dest, type, opts, callback);\n return new Promise<string[]>((resolve, reject) => worker(src, dest, type, opts, (err, result) => (err ? reject(err) : resolve(result ?? []))));\n } catch (err) {\n if (typeof callback === 'function') return callback(err as Error);\n return Promise.reject(err);\n }\n}\n"],"names":["transformDirectory","major","process","versions","node","split","_require","require","Module","createRequire","__dirname","path","dirname","__filename","url","fileURLToPath","workerPath","join","run","src","dest","type","options","callback","worker","bind","callbacks","spawnOptions","loadConfigSync","Error","tsconfig","undefined","opts","Promise","resolve","reject","err","result"],"mappings":";;;;+BAwBA;;;eAAwBA;;;6DAxBL;+BACE;2DACJ;uEACU;0DACX;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAIhB,IAAMC,QAAQ,CAACC,QAAQC,QAAQ,CAACC,IAAI,CAACC,KAAK,CAAC,IAAI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KAAKC,MAAMC,MAAMW,MAAM,SAACI,KAAKC;uBAAYD,MAAMD,OAAOC,OAAOF,QAAQG,mBAAAA,oBAAAA,SAAU,EAAE;;;IAC5I,EAAE,OAAOD,KAAK;QACZ,IAAI,OAAOb,aAAa,YAAY,OAAOA,SAASa;QACpD,OAAOH,QAAQE,MAAM,CAACC;IACxB;AACF"}
|
|
@@ -30,9 +30,11 @@ var worker = major >= 20 ? run : (0, _nodeversioncall.bindSync)('>=20', workerPa
|
|
|
30
30
|
spawnOptions: false
|
|
31
31
|
});
|
|
32
32
|
function transformSync(contents, fileName, tsconfig) {
|
|
33
|
+
var _loadConfigSync;
|
|
33
34
|
if (typeof contents !== 'string') throw new Error('transformSync: unexpected contents');
|
|
34
35
|
if (typeof fileName !== 'string') throw new Error('transformSync: unexpected fileName');
|
|
35
|
-
if (!tsconfig) tsconfig = (0, _readtsconfigsync.default)(process.cwd());
|
|
36
|
+
if (!tsconfig) tsconfig = (_loadConfigSync = (0, _readtsconfigsync.default)(process.cwd())) !== null && _loadConfigSync !== void 0 ? _loadConfigSync : undefined;
|
|
37
|
+
if (!tsconfig) throw new Error('transformSync: failed to load tsconfig');
|
|
36
38
|
return worker(contents, fileName, tsconfig);
|
|
37
39
|
}
|
|
38
40
|
/* 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; }
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/typescript/ts-swc-transform/src/transformSync.ts"],"sourcesContent":["import Module from 'module';\nimport { bindSync } from 'node-version-call';\nimport path from 'path';\nimport loadConfigSync from 'read-tsconfig-sync';\nimport url from 'url';\n\nimport type { TSConfig } from './types.ts';\n\nconst major = +process.versions.node.split('.')[0];\nconst _require = typeof require === 'undefined' ? Module.createRequire(import.meta.url) : require;\nconst __dirname = path.dirname(typeof __filename === 'undefined' ? url.fileURLToPath(import.meta.url) : __filename);\nconst workerPath = path.join(__dirname, '..', 'cjs', 'workers', 'transformSync.js');\n\nfunction run(contents: string, fileName: string, tsconfig: TSConfig) {\n return _require(workerPath)(contents, fileName, tsconfig);\n}\n\n// spawnOptions: false - no node/npm spawn (library call only)\nconst worker = major >= 20 ? run : bindSync('>=20', workerPath, { spawnOptions: false });\n\nimport type { Output } from '@swc/core';\nexport default function transformSync(contents: string, fileName: string, tsconfig?: TSConfig): Output {\n if (typeof contents !== 'string') throw new Error('transformSync: unexpected contents');\n if (typeof fileName !== 'string') throw new Error('transformSync: unexpected fileName');\n if (!tsconfig) tsconfig = loadConfigSync(process.cwd());\n return worker(contents, fileName, tsconfig) as Output;\n}\n"],"names":["transformSync","major","process","versions","node","split","_require","require","Module","createRequire","__dirname","path","dirname","__filename","url","fileURLToPath","workerPath","join","run","contents","fileName","tsconfig","worker","bindSync","spawnOptions","
|
|
1
|
+
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/typescript/ts-swc-transform/src/transformSync.ts"],"sourcesContent":["import Module from 'module';\nimport { bindSync } from 'node-version-call';\nimport path from 'path';\nimport loadConfigSync from 'read-tsconfig-sync';\nimport url from 'url';\n\nimport type { TSConfig } from './types.ts';\n\nconst major = +process.versions.node.split('.')[0];\nconst _require = typeof require === 'undefined' ? Module.createRequire(import.meta.url) : require;\nconst __dirname = path.dirname(typeof __filename === 'undefined' ? url.fileURLToPath(import.meta.url) : __filename);\nconst workerPath = path.join(__dirname, '..', 'cjs', 'workers', 'transformSync.js');\n\nfunction run(contents: string, fileName: string, tsconfig: TSConfig) {\n return _require(workerPath)(contents, fileName, tsconfig);\n}\n\n// spawnOptions: false - no node/npm spawn (library call only)\nconst worker = major >= 20 ? run : bindSync('>=20', workerPath, { spawnOptions: false });\n\nimport type { Output } from '@swc/core';\nexport default function transformSync(contents: string, fileName: string, tsconfig?: TSConfig): Output {\n if (typeof contents !== 'string') throw new Error('transformSync: unexpected contents');\n if (typeof fileName !== 'string') throw new Error('transformSync: unexpected fileName');\n if (!tsconfig) tsconfig = loadConfigSync(process.cwd()) ?? undefined;\n if (!tsconfig) throw new Error('transformSync: failed to load tsconfig');\n return worker(contents, fileName, tsconfig) as Output;\n}\n"],"names":["transformSync","major","process","versions","node","split","_require","require","Module","createRequire","__dirname","path","dirname","__filename","url","fileURLToPath","workerPath","join","run","contents","fileName","tsconfig","worker","bindSync","spawnOptions","loadConfigSync","Error","cwd","undefined"],"mappings":";;;;+BAqBA;;;eAAwBA;;;6DArBL;+BACM;2DACR;uEACU;0DACX;;;;;;AAIhB,IAAMC,QAAQ,CAACC,QAAQC,QAAQ,CAACC,IAAI,CAACC,KAAK,CAAC,IAAI,CAAC,EAAE;AAClD,IAAMC,WAAW,OAAOC,YAAY,cAAcC,eAAM,CAACC,aAAa,CAAC,uDAAmBF;AAC1F,IAAMG,YAAYC,aAAI,CAACC,OAAO,CAAC,OAAOC,eAAe,cAAcC,YAAG,CAACC,aAAa,CAAC,uDAAmBF;AACxG,IAAMG,aAAaL,aAAI,CAACM,IAAI,CAACP,WAAW,MAAM,OAAO,WAAW;AAEhE,SAASQ,IAAIC,QAAgB,EAAEC,QAAgB,EAAEC,QAAkB;IACjE,OAAOf,SAASU,YAAYG,UAAUC,UAAUC;AAClD;AAEA,8DAA8D;AAC9D,IAAMC,SAASrB,SAAS,KAAKiB,MAAMK,IAAAA,yBAAQ,EAAC,QAAQP,YAAY;IAAEQ,cAAc;AAAM;AAGvE,SAASxB,cAAcmB,QAAgB,EAAEC,QAAgB,EAAEC,QAAmB;QAGjEI;IAF1B,IAAI,OAAON,aAAa,UAAU,MAAM,IAAIO,MAAM;IAClD,IAAI,OAAON,aAAa,UAAU,MAAM,IAAIM,MAAM;IAClD,IAAI,CAACL,UAAUA,YAAWI,kBAAAA,IAAAA,yBAAc,EAACvB,QAAQyB,GAAG,iBAA1BF,6BAAAA,kBAAiCG;IAC3D,IAAI,CAACP,UAAU,MAAM,IAAIK,MAAM;IAC/B,OAAOJ,OAAOH,UAAUC,UAAUC;AACpC"}
|
|
@@ -84,11 +84,13 @@ var worker = major >= 20 ? run : (0, _nodeversioncall.bind)('>=20', workerPath,
|
|
|
84
84
|
});
|
|
85
85
|
function transformTypes(src, dest, options, callback) {
|
|
86
86
|
try {
|
|
87
|
+
var _loadConfigSync;
|
|
87
88
|
if (typeof src !== 'string') throw new Error('transformTypes: unexpected source');
|
|
88
89
|
if (typeof dest !== 'string') throw new Error('transformTypes: unexpected destination directory');
|
|
89
90
|
callback = typeof options === 'function' ? options : callback;
|
|
90
91
|
options = typeof options === 'function' ? {} : options || {};
|
|
91
|
-
var tsconfig = options.tsconfig ? options.tsconfig : (0, _readtsconfigsync.default)(src);
|
|
92
|
+
var tsconfig = options.tsconfig ? options.tsconfig : (_loadConfigSync = (0, _readtsconfigsync.default)(src)) !== null && _loadConfigSync !== void 0 ? _loadConfigSync : undefined;
|
|
93
|
+
if (!tsconfig) throw new Error('transformTypes: failed to load tsconfig');
|
|
92
94
|
var opts = _object_spread_props(_object_spread({}, options), {
|
|
93
95
|
tsconfig: tsconfig
|
|
94
96
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/typescript/ts-swc-transform/src/transformTypes.ts"],"sourcesContent":["import Module from 'module';\nimport { bind } from 'node-version-call';\nimport path from 'path';\nimport loadConfigSync from 'read-tsconfig-sync';\nimport url from 'url';\n\nimport type { ConfigOptions, InternalConfigOptions, TransformTypesCallback } from './types.ts';\n\nconst major = +process.versions.node.split('.')[0];\nconst _require = typeof require === 'undefined' ? Module.createRequire(import.meta.url) : require;\nconst __dirname = path.dirname(typeof __filename === 'undefined' ? url.fileURLToPath(import.meta.url) : __filename);\nconst workerPath = path.join(__dirname, '..', 'cjs', 'workers', 'transformTypes.js');\n\nfunction run(src: string, dest: string, options: ConfigOptions, callback: TransformTypesCallback) {\n return _require(workerPath)(src, dest, options, callback);\n}\n\n// spawnOptions: false - no node/npm spawn (library call only)\nconst worker = major >= 20 ? run : bind('>=20', workerPath, { callbacks: true, spawnOptions: false });\n\nexport default function transformTypes(src: string, dest: string, callback: TransformTypesCallback): void;\nexport default function transformTypes(src: string, dest: string, options: ConfigOptions, callback: TransformTypesCallback): void;\nexport default function transformTypes(src: string, dest: string): Promise<string[]>;\nexport default function transformTypes(src: string, dest: string, options: ConfigOptions): Promise<string[]>;\nexport default function transformTypes(src: string, dest: string, options?: ConfigOptions | TransformTypesCallback, callback?: TransformTypesCallback): void | Promise<string[]> {\n try {\n if (typeof src !== 'string') throw new Error('transformTypes: unexpected source');\n if (typeof dest !== 'string') throw new Error('transformTypes: unexpected destination directory');\n\n callback = typeof options === 'function' ? options : callback;\n options = typeof options === 'function' ? {} : ((options || {}) as ConfigOptions);\n const tsconfig = options.tsconfig ? options.tsconfig : loadConfigSync(src);\n const opts: InternalConfigOptions = { ...options, tsconfig };\n\n if (typeof callback === 'function') return worker(src, dest, opts, callback);\n return new Promise<string[]>((resolve, reject) => worker(src, dest, opts, (err, result) => (err ? reject(err) : resolve(result ?? []))));\n } catch (err) {\n if (typeof callback === 'function') return callback(err as Error);\n return Promise.reject(err);\n }\n}\n"],"names":["transformTypes","major","process","versions","node","split","_require","require","Module","createRequire","__dirname","path","dirname","__filename","url","fileURLToPath","workerPath","join","run","src","dest","options","callback","worker","bind","callbacks","spawnOptions","Error","tsconfig","
|
|
1
|
+
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/typescript/ts-swc-transform/src/transformTypes.ts"],"sourcesContent":["import Module from 'module';\nimport { bind } from 'node-version-call';\nimport path from 'path';\nimport loadConfigSync from 'read-tsconfig-sync';\nimport url from 'url';\n\nimport type { ConfigOptions, InternalConfigOptions, TransformTypesCallback } from './types.ts';\n\nconst major = +process.versions.node.split('.')[0];\nconst _require = typeof require === 'undefined' ? Module.createRequire(import.meta.url) : require;\nconst __dirname = path.dirname(typeof __filename === 'undefined' ? url.fileURLToPath(import.meta.url) : __filename);\nconst workerPath = path.join(__dirname, '..', 'cjs', 'workers', 'transformTypes.js');\n\nfunction run(src: string, dest: string, options: ConfigOptions, callback: TransformTypesCallback) {\n return _require(workerPath)(src, dest, options, callback);\n}\n\n// spawnOptions: false - no node/npm spawn (library call only)\nconst worker = major >= 20 ? run : bind('>=20', workerPath, { callbacks: true, spawnOptions: false });\n\nexport default function transformTypes(src: string, dest: string, callback: TransformTypesCallback): void;\nexport default function transformTypes(src: string, dest: string, options: ConfigOptions, callback: TransformTypesCallback): void;\nexport default function transformTypes(src: string, dest: string): Promise<string[]>;\nexport default function transformTypes(src: string, dest: string, options: ConfigOptions): Promise<string[]>;\nexport default function transformTypes(src: string, dest: string, options?: ConfigOptions | TransformTypesCallback, callback?: TransformTypesCallback): void | Promise<string[]> {\n try {\n if (typeof src !== 'string') throw new Error('transformTypes: unexpected source');\n if (typeof dest !== 'string') throw new Error('transformTypes: unexpected destination directory');\n\n callback = typeof options === 'function' ? options : callback;\n options = typeof options === 'function' ? {} : ((options || {}) as ConfigOptions);\n const tsconfig = options.tsconfig ? options.tsconfig : (loadConfigSync(src) ?? undefined);\n if (!tsconfig) throw new Error('transformTypes: failed to load tsconfig');\n const opts: InternalConfigOptions = { ...options, tsconfig };\n\n if (typeof callback === 'function') return worker(src, dest, opts, callback);\n return new Promise<string[]>((resolve, reject) => worker(src, dest, opts, (err, result) => (err ? reject(err) : resolve(result ?? []))));\n } catch (err) {\n if (typeof callback === 'function') return callback(err as Error);\n return Promise.reject(err);\n }\n}\n"],"names":["transformTypes","major","process","versions","node","split","_require","require","Module","createRequire","__dirname","path","dirname","__filename","url","fileURLToPath","workerPath","join","run","src","dest","options","callback","worker","bind","callbacks","spawnOptions","loadConfigSync","Error","tsconfig","undefined","opts","Promise","resolve","reject","err","result"],"mappings":";;;;+BAwBA;;;eAAwBA;;;6DAxBL;+BACE;2DACJ;uEACU;0DACX;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAIhB,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I,KAAKC;uBAAYD,MAAMD,OAAOC,OAAOF,QAAQG,mBAAAA,oBAAAA,SAAU,EAAE;;;IACtI,EAAE,OAAOD,KAAK;QACZ,IAAI,OAAOb,aAAa,YAAY,OAAOA,SAASa;QACpD,OAAOH,QAAQE,MAAM,CAACC;IACxB;AACF"}
|
|
@@ -253,7 +253,7 @@ function transformTypesWorker(src, dest, options, callback) {
|
|
|
253
253
|
var updated = (0, _rewriteExtensionsts.rewriteExtensions)(content);
|
|
254
254
|
if (updated === content) cb();
|
|
255
255
|
else _fs.default.writeFile(file, updated, 'utf8', function(err) {
|
|
256
|
-
return cb(err
|
|
256
|
+
return cb(err);
|
|
257
257
|
});
|
|
258
258
|
});
|
|
259
259
|
});
|
|
@@ -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 ?? 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":["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","undefined","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,yDAAyD,GAEzD,SAASC,kBAAkBC,QAAgB;IACzC,OACEA,SAASC,QAAQ,CAAC,YAClBD,SAASC,QAAQ,CAAC,aAClBD,SAASC,QAAQ,CAAC,aAClBD,SAASC,QAAQ,CAAC,UAClBD,SAASC,QAAQ,CAAC,WAClBD,SAASC,QAAQ,C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AEA,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,gBAAAA,iBAAAA,MAAOkD;;oCAC9D;gCACF;4BACF;4BATA,QAAK,YAAcV,iCAAd,SAAA,6BAAA,QAAA,yBAAA;;4BAAA;4BAAA;;;qCAAA,6BAAA;oCAAA;;;oCAAA;0CAAA;;;;oBAUP;oBAEAC,UAAUU,KAAK,CAAC;wBACdnB,IAAAA,sBAAM,EAACpB,SAAS;4BAAEc,WAAW;4BAAMO,OAAO;wBAAK,GAAG,SAACmB;mCAAUhE,SAASgE,SAAS,MAAMZ;;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 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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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4BAAEc,WAAW;4BAAMO,OAAO;wBAAK,GAAG,SAACkB;mCAAU/D,SAAS+D,SAAS,MAAMX;;oBACvF;gBACF;YACF;QACF;IACF;AAEJ"}
|
|
@@ -36,8 +36,8 @@ export default function transformFile(entry, dest, type, options, mode, callback
|
|
|
36
36
|
const outPath = path.join(dest, (ext ? entry.path.slice(0, -ext.length) : entry.path) + extTarget);
|
|
37
37
|
mkdirp(path.dirname(outPath), ()=>{
|
|
38
38
|
const queue = new Queue();
|
|
39
|
-
queue.defer((cb)=>fs.writeFile(outPath, output.code, 'utf8', (err)=>cb(err
|
|
40
|
-
if (output.map && options.sourceMaps) queue.defer((cb)=>fs.writeFile(`${outPath}.map`, output.map, 'utf8', (err)=>cb(err
|
|
39
|
+
queue.defer((cb)=>fs.writeFile(outPath, output.code, 'utf8', (err)=>cb(err)));
|
|
40
|
+
if (output.map && options.sourceMaps) queue.defer((cb)=>fs.writeFile(`${outPath}.map`, output.map, 'utf8', (err)=>cb(err)));
|
|
41
41
|
queue.await((err)=>{
|
|
42
42
|
if (err) return callback(err);
|
|
43
43
|
if (mode) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/typescript/ts-swc-transform/src/lib/transformFile.ts"],"sourcesContent":["import type { Output } from '@swc/core';\nimport fs from 'fs';\nimport type { Entry } from 'fs-iterator';\nimport mkdirp from 'mkdirp-classic';\nimport Module from 'module';\nimport path from 'path';\nimport Queue from 'queue-cb';\n\nimport patchCJS from '../lib/patchCJS.ts';\nimport patchESM from '../lib/patchESM.ts';\nimport prepareSWCOptions from '../lib/prepareSWCOptions.ts';\n\nconst _require = typeof require === 'undefined' ? Module.createRequire(import.meta.url) : require;\n\nimport type { InternalConfigOptions, TargetType, TransformFileCallback } from '../types.ts';\n\nexport default function transformFile(entry: Entry, dest: string, type: TargetType, options: InternalConfigOptions, mode: number | undefined, callback: TransformFileCallback): void {\n let tsconfig = options.tsconfig;\n\n // overrides for cjs\n if (type === 'cjs') {\n const compilerOptions = { ...(tsconfig.config.compilerOptions || {}), module: 'commonjs' as const, target: 'es5' as const };\n tsconfig = { ...tsconfig, config: { ...tsconfig.config, compilerOptions } };\n }\n\n const swcOptions = prepareSWCOptions(tsconfig);\n const swc = _require('@swc/core');\n const ext = path.extname(entry.basename as string);\n\n swc\n .transformFile(entry.fullPath, {\n ...(ext === '.tsx' || ext === '.jsx' ? swcOptions.tsxOptions : swcOptions.nonTsxOptions),\n filename: entry.basename,\n })\n .then((output: Output) => {\n const extTarget = type === 'esm' ? patchESM(entry, output, options) : patchCJS(entry, output, options);\n const ext = path.extname(entry.path);\n const outPath = path.join(dest, (ext ? entry.path.slice(0, -ext.length) : entry.path) + extTarget);\n\n mkdirp(path.dirname(outPath), () => {\n const queue = new Queue();\n queue.defer((cb) => fs.writeFile(outPath, output.code, 'utf8', (err) => cb(err
|
|
1
|
+
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/typescript/ts-swc-transform/src/lib/transformFile.ts"],"sourcesContent":["import type { Output } from '@swc/core';\nimport fs from 'fs';\nimport type { Entry } from 'fs-iterator';\nimport mkdirp from 'mkdirp-classic';\nimport Module from 'module';\nimport path from 'path';\nimport Queue from 'queue-cb';\n\nimport patchCJS from '../lib/patchCJS.ts';\nimport patchESM from '../lib/patchESM.ts';\nimport prepareSWCOptions from '../lib/prepareSWCOptions.ts';\n\nconst _require = typeof require === 'undefined' ? Module.createRequire(import.meta.url) : require;\n\nimport type { InternalConfigOptions, TargetType, TransformFileCallback } from '../types.ts';\n\nexport default function transformFile(entry: Entry, dest: string, type: TargetType, options: InternalConfigOptions, mode: number | undefined, callback: TransformFileCallback): void {\n let tsconfig = options.tsconfig;\n\n // overrides for cjs\n if (type === 'cjs') {\n const compilerOptions = { ...(tsconfig.config.compilerOptions || {}), module: 'commonjs' as const, target: 'es5' as const };\n tsconfig = { ...tsconfig, config: { ...tsconfig.config, compilerOptions } };\n }\n\n const swcOptions = prepareSWCOptions(tsconfig);\n const swc = _require('@swc/core');\n const ext = path.extname(entry.basename as string);\n\n swc\n .transformFile(entry.fullPath, {\n ...(ext === '.tsx' || ext === '.jsx' ? swcOptions.tsxOptions : swcOptions.nonTsxOptions),\n filename: entry.basename,\n })\n .then((output: Output) => {\n const extTarget = type === 'esm' ? patchESM(entry, output, options) : patchCJS(entry, output, options);\n const ext = path.extname(entry.path);\n const outPath = path.join(dest, (ext ? entry.path.slice(0, -ext.length) : entry.path) + extTarget);\n\n mkdirp(path.dirname(outPath), () => {\n const queue = new Queue();\n queue.defer((cb) => fs.writeFile(outPath, output.code, 'utf8', (err) => cb(err)));\n if (output.map && options.sourceMaps) queue.defer((cb) => fs.writeFile(`${outPath}.map`, output.map as string, 'utf8', (err) => cb(err)));\n queue.await((err) => {\n if (err) return callback(err);\n\n if (mode) {\n const execBits = mode & 0o111;\n if (execBits) {\n fs.chmod(outPath, 0o644 | execBits, (_chmodErr) => {\n callback(null, outPath);\n });\n return;\n }\n }\n callback(null, outPath);\n });\n });\n })\n .catch(callback);\n}\n"],"names":["fs","mkdirp","Module","path","Queue","patchCJS","patchESM","prepareSWCOptions","_require","require","createRequire","url","transformFile","entry","dest","type","options","mode","callback","tsconfig","compilerOptions","config","module","target","swcOptions","swc","ext","extname","basename","fullPath","tsxOptions","nonTsxOptions","filename","then","output","extTarget","outPath","join","slice","length","dirname","queue","defer","cb","writeFile","code","err","map","sourceMaps","await","execBits","chmod","_chmodErr","catch"],"mappings":"AACA,OAAOA,QAAQ,KAAK;AAEpB,OAAOC,YAAY,iBAAiB;AACpC,OAAOC,YAAY,SAAS;AAC5B,OAAOC,UAAU,OAAO;AACxB,OAAOC,WAAW,WAAW;AAE7B,OAAOC,cAAc,qBAAqB;AAC1C,OAAOC,cAAc,qBAAqB;AAC1C,OAAOC,uBAAuB,8BAA8B;AAE5D,MAAMC,WAAW,OAAOC,YAAY,cAAcP,OAAOQ,aAAa,CAAC,YAAYC,GAAG,IAAIF;AAI1F,eAAe,SAASG,cAAc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,MAAMC,KAAK,CAAC,CAACC,KAAO3C,GAAG4C,SAAS,CAAC,GAAGR,QAAQ,IAAI,CAAC,EAAEF,OAAOa,GAAG,EAAY,QAAQ,CAACD,MAAQH,GAAGG;YACnIL,MAAMQ,KAAK,CAAC,CAACH;gBACX,IAAIA,KAAK,OAAO5B,SAAS4B;gBAEzB,IAAI7B,MAAM;oBACR,MAAMiC,WAAWjC,OAAO;oBACxB,IAAIiC,UAAU;wBACZlD,GAAGmD,KAAK,CAACf,SAAS,QAAQc,UAAU,CAACE;4BACnClC,SAAS,MAAMkB;wBACjB;wBACA;oBACF;gBACF;gBACAlB,SAAS,MAAMkB;YACjB;QACF;IACF,GACCiB,KAAK,CAACnC;AACX"}
|
|
@@ -17,12 +17,14 @@ const worker = major >= 20 ? run : bind('>=20', workerPath, {
|
|
|
17
17
|
});
|
|
18
18
|
export default function transformDirectory(src, dest, type, options, callback) {
|
|
19
19
|
try {
|
|
20
|
+
var _loadConfigSync;
|
|
20
21
|
if (typeof src !== 'string') throw new Error('transformDirectory: unexpected source');
|
|
21
22
|
if (typeof dest !== 'string') throw new Error('transformDirectory: unexpected destination directory');
|
|
22
23
|
if (typeof type !== 'string') throw new Error('transformDirectory: unexpected type');
|
|
23
24
|
callback = typeof options === 'function' ? options : callback;
|
|
24
25
|
options = typeof options === 'function' ? {} : options || {};
|
|
25
|
-
const tsconfig = options.tsconfig ? options.tsconfig : loadConfigSync(src);
|
|
26
|
+
const tsconfig = options.tsconfig ? options.tsconfig : (_loadConfigSync = loadConfigSync(src)) !== null && _loadConfigSync !== void 0 ? _loadConfigSync : undefined;
|
|
27
|
+
if (!tsconfig) throw new Error('transformDirectory: failed to load tsconfig');
|
|
26
28
|
const opts = {
|
|
27
29
|
...options,
|
|
28
30
|
tsconfig
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/typescript/ts-swc-transform/src/transformDirectory.ts"],"sourcesContent":["import Module from 'module';\nimport { bind } from 'node-version-call';\nimport path from 'path';\nimport loadConfigSync from 'read-tsconfig-sync';\nimport url from 'url';\n\nimport type { ConfigOptions, InternalConfigOptions, TargetType, TransformDirectoryCallback } from './types.ts';\n\nconst major = +process.versions.node.split('.')[0];\nconst _require = typeof require === 'undefined' ? Module.createRequire(import.meta.url) : require;\nconst __dirname = path.dirname(typeof __filename === 'undefined' ? url.fileURLToPath(import.meta.url) : __filename);\nconst workerPath = path.join(__dirname, '..', 'cjs', 'workers', 'transformDirectory.js');\n\nfunction run(src: string, dest: string, type: TargetType, options: ConfigOptions, callback: TransformDirectoryCallback) {\n return _require(workerPath)(src, dest, type, options, callback);\n}\n\n// spawnOptions: false - no node/npm spawn (library call only)\nconst worker = major >= 20 ? run : bind('>=20', workerPath, { callbacks: true, spawnOptions: false });\n\nexport default function transformDirectory(src: string, dest: string, type: TargetType, callback: TransformDirectoryCallback): void;\nexport default function transformDirectory(src: string, dest: string, type: TargetType, options: ConfigOptions, callback: TransformDirectoryCallback): void;\nexport default function transformDirectory(src: string, dest: string, type: TargetType): Promise<string[]>;\nexport default function transformDirectory(src: string, dest: string, type: TargetType, options: ConfigOptions): Promise<string[]>;\nexport default function transformDirectory(src: string, dest: string, type: TargetType, options?: ConfigOptions | TransformDirectoryCallback, callback?: TransformDirectoryCallback): void | Promise<string[]> {\n try {\n if (typeof src !== 'string') throw new Error('transformDirectory: unexpected source');\n if (typeof dest !== 'string') throw new Error('transformDirectory: unexpected destination directory');\n if (typeof type !== 'string') throw new Error('transformDirectory: unexpected type');\n\n callback = typeof options === 'function' ? options : callback;\n options = typeof options === 'function' ? {} : ((options || {}) as ConfigOptions);\n const tsconfig = options.tsconfig ? options.tsconfig : loadConfigSync(src);\n const opts: InternalConfigOptions = { ...options, tsconfig };\n\n if (typeof callback === 'function') return worker(src, dest, type, opts, callback);\n return new Promise<string[]>((resolve, reject) => worker(src, dest, type, opts, (err, result) => (err ? reject(err) : resolve(result ?? []))));\n } catch (err) {\n if (typeof callback === 'function') return callback(err as Error);\n return Promise.reject(err);\n }\n}\n"],"names":["Module","bind","path","loadConfigSync","url","major","process","versions","node","split","_require","require","createRequire","__dirname","dirname","__filename","fileURLToPath","workerPath","join","run","src","dest","type","options","callback","worker","callbacks","spawnOptions","transformDirectory","Error","tsconfig","opts","Promise","resolve","reject","err","result"],"mappings":"AAAA,OAAOA,YAAY,SAAS;AAC5B,SAASC,IAAI,QAAQ,oBAAoB;AACzC,OAAOC,UAAU,OAAO;AACxB,OAAOC,oBAAoB,qBAAqB;AAChD,OAAOC,SAAS,MAAM;AAItB,MAAMC,QAAQ,CAACC,QAAQC,QAAQ,CAACC,IAAI,CAACC,KAAK,CAAC,IAAI,CAAC,EAAE;AAClD,MAAMC,WAAW,OAAOC,YAAY,cAAcX,OAAOY,aAAa,CAAC,YAAYR,GAAG,IAAIO;AAC1F,MAAME,YAAYX,KAAKY,OAAO,CAAC,OAAOC,eAAe,cAAcX,IAAIY,aAAa,CAAC,YAAYZ,GAAG,IAAIW;AACxG,MAAME,aAAaf,KAAKgB,IAAI,CAACL,WAAW,MAAM,OAAO,WAAW;AAEhE,SAASM,IAAIC,GAAW,EAAEC,IAAY,EAAEC,IAAgB,EAAEC,OAAsB,EAAEC,QAAoC;IACpH,OAAOd,SAASO,YAAYG,KAAKC,MAAMC,MAAMC,SAASC;AACxD;AAEA,8DAA8D;AAC9D,MAAMC,SAASpB,SAAS,KAAKc,MAAMlB,KAAK,QAAQgB,YAAY;IAAES,WAAW;IAAMC,cAAc;AAAM;AAMnG,eAAe,SAASC,mBAAmBR,GAAW,EAAEC,IAAY,EAAEC,IAAgB,EAAEC,OAAoD,EAAEC,QAAqC;IACjL,IAAI;
|
|
1
|
+
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/typescript/ts-swc-transform/src/transformDirectory.ts"],"sourcesContent":["import Module from 'module';\nimport { bind } from 'node-version-call';\nimport path from 'path';\nimport loadConfigSync from 'read-tsconfig-sync';\nimport url from 'url';\n\nimport type { ConfigOptions, InternalConfigOptions, TargetType, TransformDirectoryCallback } from './types.ts';\n\nconst major = +process.versions.node.split('.')[0];\nconst _require = typeof require === 'undefined' ? Module.createRequire(import.meta.url) : require;\nconst __dirname = path.dirname(typeof __filename === 'undefined' ? url.fileURLToPath(import.meta.url) : __filename);\nconst workerPath = path.join(__dirname, '..', 'cjs', 'workers', 'transformDirectory.js');\n\nfunction run(src: string, dest: string, type: TargetType, options: ConfigOptions, callback: TransformDirectoryCallback) {\n return _require(workerPath)(src, dest, type, options, callback);\n}\n\n// spawnOptions: false - no node/npm spawn (library call only)\nconst worker = major >= 20 ? run : bind('>=20', workerPath, { callbacks: true, spawnOptions: false });\n\nexport default function transformDirectory(src: string, dest: string, type: TargetType, callback: TransformDirectoryCallback): void;\nexport default function transformDirectory(src: string, dest: string, type: TargetType, options: ConfigOptions, callback: TransformDirectoryCallback): void;\nexport default function transformDirectory(src: string, dest: string, type: TargetType): Promise<string[]>;\nexport default function transformDirectory(src: string, dest: string, type: TargetType, options: ConfigOptions): Promise<string[]>;\nexport default function transformDirectory(src: string, dest: string, type: TargetType, options?: ConfigOptions | TransformDirectoryCallback, callback?: TransformDirectoryCallback): void | Promise<string[]> {\n try {\n if (typeof src !== 'string') throw new Error('transformDirectory: unexpected source');\n if (typeof dest !== 'string') throw new Error('transformDirectory: unexpected destination directory');\n if (typeof type !== 'string') throw new Error('transformDirectory: unexpected type');\n\n callback = typeof options === 'function' ? options : callback;\n options = typeof options === 'function' ? {} : ((options || {}) as ConfigOptions);\n const tsconfig = options.tsconfig ? options.tsconfig : (loadConfigSync(src) ?? undefined);\n if (!tsconfig) throw new Error('transformDirectory: failed to load tsconfig');\n const opts: InternalConfigOptions = { ...options, tsconfig };\n\n if (typeof callback === 'function') return worker(src, dest, type, opts, callback);\n return new Promise<string[]>((resolve, reject) => worker(src, dest, type, opts, (err, result) => (err ? reject(err) : resolve(result ?? []))));\n } catch (err) {\n if (typeof callback === 'function') return callback(err as Error);\n return Promise.reject(err);\n }\n}\n"],"names":["Module","bind","path","loadConfigSync","url","major","process","versions","node","split","_require","require","createRequire","__dirname","dirname","__filename","fileURLToPath","workerPath","join","run","src","dest","type","options","callback","worker","callbacks","spawnOptions","transformDirectory","Error","tsconfig","undefined","opts","Promise","resolve","reject","err","result"],"mappings":"AAAA,OAAOA,YAAY,SAAS;AAC5B,SAASC,IAAI,QAAQ,oBAAoB;AACzC,OAAOC,UAAU,OAAO;AACxB,OAAOC,oBAAoB,qBAAqB;AAChD,OAAOC,SAAS,MAAM;AAItB,MAAMC,QAAQ,CAACC,QAAQC,QAAQ,CAACC,IAAI,CAACC,KAAK,CAAC,IAAI,CAAC,EAAE;AAClD,MAAMC,WAAW,OAAOC,YAAY,cAAcX,OAAOY,aAAa,CAAC,YAAYR,GAAG,IAAIO;AAC1F,MAAME,YAAYX,KAAKY,OAAO,CAAC,OAAOC,eAAe,cAAcX,IAAIY,aAAa,CAAC,YAAYZ,GAAG,IAAIW;AACxG,MAAME,aAAaf,KAAKgB,IAAI,CAACL,WAAW,MAAM,OAAO,WAAW;AAEhE,SAASM,IAAIC,GAAW,EAAEC,IAAY,EAAEC,IAAgB,EAAEC,OAAsB,EAAEC,QAAoC;IACpH,OAAOd,SAASO,YAAYG,KAAKC,MAAMC,MAAMC,SAASC;AACxD;AAEA,8DAA8D;AAC9D,MAAMC,SAASpB,SAAS,KAAKc,MAAMlB,KAAK,QAAQgB,YAAY;IAAES,WAAW;IAAMC,cAAc;AAAM;AAMnG,eAAe,SAASC,mBAAmBR,GAAW,EAAEC,IAAY,EAAEC,IAAgB,EAAEC,OAAoD,EAAEC,QAAqC;IACjL,IAAI;YAOsDrB;QANxD,IAAI,OAAOiB,QAAQ,UAAU,MAAM,IAAIS,MAAM;QAC7C,IAAI,OAAOR,SAAS,UAAU,MAAM,IAAIQ,MAAM;QAC9C,IAAI,OAAOP,SAAS,UAAU,MAAM,IAAIO,MAAM;QAE9CL,WAAW,OAAOD,YAAY,aAAaA,UAAUC;QACrDD,UAAU,OAAOA,YAAY,aAAa,CAAC,IAAMA,WAAW,CAAC;QAC7D,MAAMO,WAAWP,QAAQO,QAAQ,GAAGP,QAAQO,QAAQ,IAAI3B,kBAAAA,eAAeiB,kBAAfjB,6BAAAA,kBAAuB4B;QAC/E,IAAI,CAACD,UAAU,MAAM,IAAID,MAAM;QAC/B,MAAMG,OAA8B;YAAE,GAAGT,OAAO;YAAEO;QAAS;QAE3D,IAAI,OAAON,aAAa,YAAY,OAAOC,OAAOL,KAAKC,MAAMC,MAAMU,MAAMR;QACzE,OAAO,IAAIS,QAAkB,CAACC,SAASC,SAAWV,OAAOL,KAAKC,MAAMC,MAAMU,MAAM,CAACI,KAAKC,SAAYD,MAAMD,OAAOC,OAAOF,QAAQG,mBAAAA,oBAAAA,SAAU,EAAE;IAC5I,EAAE,OAAOD,KAAK;QACZ,IAAI,OAAOZ,aAAa,YAAY,OAAOA,SAASY;QACpD,OAAOH,QAAQE,MAAM,CAACC;IACxB;AACF"}
|
|
@@ -15,8 +15,10 @@ const worker = major >= 20 ? run : bindSync('>=20', workerPath, {
|
|
|
15
15
|
spawnOptions: false
|
|
16
16
|
});
|
|
17
17
|
export default function transformSync(contents, fileName, tsconfig) {
|
|
18
|
+
var _loadConfigSync;
|
|
18
19
|
if (typeof contents !== 'string') throw new Error('transformSync: unexpected contents');
|
|
19
20
|
if (typeof fileName !== 'string') throw new Error('transformSync: unexpected fileName');
|
|
20
|
-
if (!tsconfig) tsconfig = loadConfigSync(process.cwd());
|
|
21
|
+
if (!tsconfig) tsconfig = (_loadConfigSync = loadConfigSync(process.cwd())) !== null && _loadConfigSync !== void 0 ? _loadConfigSync : undefined;
|
|
22
|
+
if (!tsconfig) throw new Error('transformSync: failed to load tsconfig');
|
|
21
23
|
return worker(contents, fileName, tsconfig);
|
|
22
24
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/typescript/ts-swc-transform/src/transformSync.ts"],"sourcesContent":["import Module from 'module';\nimport { bindSync } from 'node-version-call';\nimport path from 'path';\nimport loadConfigSync from 'read-tsconfig-sync';\nimport url from 'url';\n\nimport type { TSConfig } from './types.ts';\n\nconst major = +process.versions.node.split('.')[0];\nconst _require = typeof require === 'undefined' ? Module.createRequire(import.meta.url) : require;\nconst __dirname = path.dirname(typeof __filename === 'undefined' ? url.fileURLToPath(import.meta.url) : __filename);\nconst workerPath = path.join(__dirname, '..', 'cjs', 'workers', 'transformSync.js');\n\nfunction run(contents: string, fileName: string, tsconfig: TSConfig) {\n return _require(workerPath)(contents, fileName, tsconfig);\n}\n\n// spawnOptions: false - no node/npm spawn (library call only)\nconst worker = major >= 20 ? run : bindSync('>=20', workerPath, { spawnOptions: false });\n\nimport type { Output } from '@swc/core';\nexport default function transformSync(contents: string, fileName: string, tsconfig?: TSConfig): Output {\n if (typeof contents !== 'string') throw new Error('transformSync: unexpected contents');\n if (typeof fileName !== 'string') throw new Error('transformSync: unexpected fileName');\n if (!tsconfig) tsconfig = loadConfigSync(process.cwd());\n return worker(contents, fileName, tsconfig) as Output;\n}\n"],"names":["Module","bindSync","path","loadConfigSync","url","major","process","versions","node","split","_require","require","createRequire","__dirname","dirname","__filename","fileURLToPath","workerPath","join","run","contents","fileName","tsconfig","worker","spawnOptions","transformSync","Error","cwd"],"mappings":"AAAA,OAAOA,YAAY,SAAS;AAC5B,SAASC,QAAQ,QAAQ,oBAAoB;AAC7C,OAAOC,UAAU,OAAO;AACxB,OAAOC,oBAAoB,qBAAqB;AAChD,OAAOC,SAAS,MAAM;AAItB,MAAMC,QAAQ,CAACC,QAAQC,QAAQ,CAACC,IAAI,CAACC,KAAK,CAAC,IAAI,CAAC,EAAE;AAClD,MAAMC,WAAW,OAAOC,YAAY,cAAcX,OAAOY,aAAa,CAAC,YAAYR,GAAG,IAAIO;AAC1F,MAAME,YAAYX,KAAKY,OAAO,CAAC,OAAOC,eAAe,cAAcX,IAAIY,aAAa,CAAC,YAAYZ,GAAG,IAAIW;AACxG,MAAME,aAAaf,KAAKgB,IAAI,CAACL,WAAW,MAAM,OAAO,WAAW;AAEhE,SAASM,IAAIC,QAAgB,EAAEC,QAAgB,EAAEC,QAAkB;IACjE,OAAOZ,SAASO,YAAYG,UAAUC,UAAUC;AAClD;AAEA,8DAA8D;AAC9D,MAAMC,SAASlB,SAAS,KAAKc,MAAMlB,SAAS,QAAQgB,YAAY;IAAEO,cAAc;AAAM;AAGtF,eAAe,SAASC,cAAcL,QAAgB,EAAEC,QAAgB,EAAEC,QAAmB;
|
|
1
|
+
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/typescript/ts-swc-transform/src/transformSync.ts"],"sourcesContent":["import Module from 'module';\nimport { bindSync } from 'node-version-call';\nimport path from 'path';\nimport loadConfigSync from 'read-tsconfig-sync';\nimport url from 'url';\n\nimport type { TSConfig } from './types.ts';\n\nconst major = +process.versions.node.split('.')[0];\nconst _require = typeof require === 'undefined' ? Module.createRequire(import.meta.url) : require;\nconst __dirname = path.dirname(typeof __filename === 'undefined' ? url.fileURLToPath(import.meta.url) : __filename);\nconst workerPath = path.join(__dirname, '..', 'cjs', 'workers', 'transformSync.js');\n\nfunction run(contents: string, fileName: string, tsconfig: TSConfig) {\n return _require(workerPath)(contents, fileName, tsconfig);\n}\n\n// spawnOptions: false - no node/npm spawn (library call only)\nconst worker = major >= 20 ? run : bindSync('>=20', workerPath, { spawnOptions: false });\n\nimport type { Output } from '@swc/core';\nexport default function transformSync(contents: string, fileName: string, tsconfig?: TSConfig): Output {\n if (typeof contents !== 'string') throw new Error('transformSync: unexpected contents');\n if (typeof fileName !== 'string') throw new Error('transformSync: unexpected fileName');\n if (!tsconfig) tsconfig = loadConfigSync(process.cwd()) ?? undefined;\n if (!tsconfig) throw new Error('transformSync: failed to load tsconfig');\n return worker(contents, fileName, tsconfig) as Output;\n}\n"],"names":["Module","bindSync","path","loadConfigSync","url","major","process","versions","node","split","_require","require","createRequire","__dirname","dirname","__filename","fileURLToPath","workerPath","join","run","contents","fileName","tsconfig","worker","spawnOptions","transformSync","Error","cwd","undefined"],"mappings":"AAAA,OAAOA,YAAY,SAAS;AAC5B,SAASC,QAAQ,QAAQ,oBAAoB;AAC7C,OAAOC,UAAU,OAAO;AACxB,OAAOC,oBAAoB,qBAAqB;AAChD,OAAOC,SAAS,MAAM;AAItB,MAAMC,QAAQ,CAACC,QAAQC,QAAQ,CAACC,IAAI,CAACC,KAAK,CAAC,IAAI,CAAC,EAAE;AAClD,MAAMC,WAAW,OAAOC,YAAY,cAAcX,OAAOY,aAAa,CAAC,YAAYR,GAAG,IAAIO;AAC1F,MAAME,YAAYX,KAAKY,OAAO,CAAC,OAAOC,eAAe,cAAcX,IAAIY,aAAa,CAAC,YAAYZ,GAAG,IAAIW;AACxG,MAAME,aAAaf,KAAKgB,IAAI,CAACL,WAAW,MAAM,OAAO,WAAW;AAEhE,SAASM,IAAIC,QAAgB,EAAEC,QAAgB,EAAEC,QAAkB;IACjE,OAAOZ,SAASO,YAAYG,UAAUC,UAAUC;AAClD;AAEA,8DAA8D;AAC9D,MAAMC,SAASlB,SAAS,KAAKc,MAAMlB,SAAS,QAAQgB,YAAY;IAAEO,cAAc;AAAM;AAGtF,eAAe,SAASC,cAAcL,QAAgB,EAAEC,QAAgB,EAAEC,QAAmB;QAGjEnB;IAF1B,IAAI,OAAOiB,aAAa,UAAU,MAAM,IAAIM,MAAM;IAClD,IAAI,OAAOL,aAAa,UAAU,MAAM,IAAIK,MAAM;IAClD,IAAI,CAACJ,UAAUA,YAAWnB,kBAAAA,eAAeG,QAAQqB,GAAG,iBAA1BxB,6BAAAA,kBAAiCyB;IAC3D,IAAI,CAACN,UAAU,MAAM,IAAII,MAAM;IAC/B,OAAOH,OAAOH,UAAUC,UAAUC;AACpC"}
|
|
@@ -17,11 +17,13 @@ const worker = major >= 20 ? run : bind('>=20', workerPath, {
|
|
|
17
17
|
});
|
|
18
18
|
export default function transformTypes(src, dest, options, callback) {
|
|
19
19
|
try {
|
|
20
|
+
var _loadConfigSync;
|
|
20
21
|
if (typeof src !== 'string') throw new Error('transformTypes: unexpected source');
|
|
21
22
|
if (typeof dest !== 'string') throw new Error('transformTypes: unexpected destination directory');
|
|
22
23
|
callback = typeof options === 'function' ? options : callback;
|
|
23
24
|
options = typeof options === 'function' ? {} : options || {};
|
|
24
|
-
const tsconfig = options.tsconfig ? options.tsconfig : loadConfigSync(src);
|
|
25
|
+
const tsconfig = options.tsconfig ? options.tsconfig : (_loadConfigSync = loadConfigSync(src)) !== null && _loadConfigSync !== void 0 ? _loadConfigSync : undefined;
|
|
26
|
+
if (!tsconfig) throw new Error('transformTypes: failed to load tsconfig');
|
|
25
27
|
const opts = {
|
|
26
28
|
...options,
|
|
27
29
|
tsconfig
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/typescript/ts-swc-transform/src/transformTypes.ts"],"sourcesContent":["import Module from 'module';\nimport { bind } from 'node-version-call';\nimport path from 'path';\nimport loadConfigSync from 'read-tsconfig-sync';\nimport url from 'url';\n\nimport type { ConfigOptions, InternalConfigOptions, TransformTypesCallback } from './types.ts';\n\nconst major = +process.versions.node.split('.')[0];\nconst _require = typeof require === 'undefined' ? Module.createRequire(import.meta.url) : require;\nconst __dirname = path.dirname(typeof __filename === 'undefined' ? url.fileURLToPath(import.meta.url) : __filename);\nconst workerPath = path.join(__dirname, '..', 'cjs', 'workers', 'transformTypes.js');\n\nfunction run(src: string, dest: string, options: ConfigOptions, callback: TransformTypesCallback) {\n return _require(workerPath)(src, dest, options, callback);\n}\n\n// spawnOptions: false - no node/npm spawn (library call only)\nconst worker = major >= 20 ? run : bind('>=20', workerPath, { callbacks: true, spawnOptions: false });\n\nexport default function transformTypes(src: string, dest: string, callback: TransformTypesCallback): void;\nexport default function transformTypes(src: string, dest: string, options: ConfigOptions, callback: TransformTypesCallback): void;\nexport default function transformTypes(src: string, dest: string): Promise<string[]>;\nexport default function transformTypes(src: string, dest: string, options: ConfigOptions): Promise<string[]>;\nexport default function transformTypes(src: string, dest: string, options?: ConfigOptions | TransformTypesCallback, callback?: TransformTypesCallback): void | Promise<string[]> {\n try {\n if (typeof src !== 'string') throw new Error('transformTypes: unexpected source');\n if (typeof dest !== 'string') throw new Error('transformTypes: unexpected destination directory');\n\n callback = typeof options === 'function' ? options : callback;\n options = typeof options === 'function' ? {} : ((options || {}) as ConfigOptions);\n const tsconfig = options.tsconfig ? options.tsconfig : loadConfigSync(src);\n const opts: InternalConfigOptions = { ...options, tsconfig };\n\n if (typeof callback === 'function') return worker(src, dest, opts, callback);\n return new Promise<string[]>((resolve, reject) => worker(src, dest, opts, (err, result) => (err ? reject(err) : resolve(result ?? []))));\n } catch (err) {\n if (typeof callback === 'function') return callback(err as Error);\n return Promise.reject(err);\n }\n}\n"],"names":["Module","bind","path","loadConfigSync","url","major","process","versions","node","split","_require","require","createRequire","__dirname","dirname","__filename","fileURLToPath","workerPath","join","run","src","dest","options","callback","worker","callbacks","spawnOptions","transformTypes","Error","tsconfig","opts","Promise","resolve","reject","err","result"],"mappings":"AAAA,OAAOA,YAAY,SAAS;AAC5B,SAASC,IAAI,QAAQ,oBAAoB;AACzC,OAAOC,UAAU,OAAO;AACxB,OAAOC,oBAAoB,qBAAqB;AAChD,OAAOC,SAAS,MAAM;AAItB,MAAMC,QAAQ,CAACC,QAAQC,QAAQ,CAACC,IAAI,CAACC,KAAK,CAAC,IAAI,CAAC,EAAE;AAClD,MAAMC,WAAW,OAAOC,YAAY,cAAcX,OAAOY,aAAa,CAAC,YAAYR,GAAG,IAAIO;AAC1F,MAAME,YAAYX,KAAKY,OAAO,CAAC,OAAOC,eAAe,cAAcX,IAAIY,aAAa,CAAC,YAAYZ,GAAG,IAAIW;AACxG,MAAME,aAAaf,KAAKgB,IAAI,CAACL,WAAW,MAAM,OAAO,WAAW;AAEhE,SAASM,IAAIC,GAAW,EAAEC,IAAY,EAAEC,OAAsB,EAAEC,QAAgC;IAC9F,OAAOb,SAASO,YAAYG,KAAKC,MAAMC,SAASC;AAClD;AAEA,8DAA8D;AAC9D,MAAMC,SAASnB,SAAS,KAAKc,MAAMlB,KAAK,QAAQgB,YAAY;IAAEQ,WAAW;IAAMC,cAAc;AAAM;AAMnG,eAAe,SAASC,eAAeP,GAAW,EAAEC,IAAY,EAAEC,OAAgD,EAAEC,QAAiC;IACnJ,IAAI;
|
|
1
|
+
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/typescript/ts-swc-transform/src/transformTypes.ts"],"sourcesContent":["import Module from 'module';\nimport { bind } from 'node-version-call';\nimport path from 'path';\nimport loadConfigSync from 'read-tsconfig-sync';\nimport url from 'url';\n\nimport type { ConfigOptions, InternalConfigOptions, TransformTypesCallback } from './types.ts';\n\nconst major = +process.versions.node.split('.')[0];\nconst _require = typeof require === 'undefined' ? Module.createRequire(import.meta.url) : require;\nconst __dirname = path.dirname(typeof __filename === 'undefined' ? url.fileURLToPath(import.meta.url) : __filename);\nconst workerPath = path.join(__dirname, '..', 'cjs', 'workers', 'transformTypes.js');\n\nfunction run(src: string, dest: string, options: ConfigOptions, callback: TransformTypesCallback) {\n return _require(workerPath)(src, dest, options, callback);\n}\n\n// spawnOptions: false - no node/npm spawn (library call only)\nconst worker = major >= 20 ? run : bind('>=20', workerPath, { callbacks: true, spawnOptions: false });\n\nexport default function transformTypes(src: string, dest: string, callback: TransformTypesCallback): void;\nexport default function transformTypes(src: string, dest: string, options: ConfigOptions, callback: TransformTypesCallback): void;\nexport default function transformTypes(src: string, dest: string): Promise<string[]>;\nexport default function transformTypes(src: string, dest: string, options: ConfigOptions): Promise<string[]>;\nexport default function transformTypes(src: string, dest: string, options?: ConfigOptions | TransformTypesCallback, callback?: TransformTypesCallback): void | Promise<string[]> {\n try {\n if (typeof src !== 'string') throw new Error('transformTypes: unexpected source');\n if (typeof dest !== 'string') throw new Error('transformTypes: unexpected destination directory');\n\n callback = typeof options === 'function' ? options : callback;\n options = typeof options === 'function' ? {} : ((options || {}) as ConfigOptions);\n const tsconfig = options.tsconfig ? options.tsconfig : (loadConfigSync(src) ?? undefined);\n if (!tsconfig) throw new Error('transformTypes: failed to load tsconfig');\n const opts: InternalConfigOptions = { ...options, tsconfig };\n\n if (typeof callback === 'function') return worker(src, dest, opts, callback);\n return new Promise<string[]>((resolve, reject) => worker(src, dest, opts, (err, result) => (err ? reject(err) : resolve(result ?? []))));\n } catch (err) {\n if (typeof callback === 'function') return callback(err as Error);\n return Promise.reject(err);\n }\n}\n"],"names":["Module","bind","path","loadConfigSync","url","major","process","versions","node","split","_require","require","createRequire","__dirname","dirname","__filename","fileURLToPath","workerPath","join","run","src","dest","options","callback","worker","callbacks","spawnOptions","transformTypes","Error","tsconfig","undefined","opts","Promise","resolve","reject","err","result"],"mappings":"AAAA,OAAOA,YAAY,SAAS;AAC5B,SAASC,IAAI,QAAQ,oBAAoB;AACzC,OAAOC,UAAU,OAAO;AACxB,OAAOC,oBAAoB,qBAAqB;AAChD,OAAOC,SAAS,MAAM;AAItB,MAAMC,QAAQ,CAACC,QAAQC,QAAQ,CAACC,IAAI,CAACC,KAAK,CAAC,IAAI,CAAC,EAAE;AAClD,MAAMC,WAAW,OAAOC,YAAY,cAAcX,OAAOY,aAAa,CAAC,YAAYR,GAAG,IAAIO;AAC1F,MAAME,YAAYX,KAAKY,OAAO,CAAC,OAAOC,eAAe,cAAcX,IAAIY,aAAa,CAAC,YAAYZ,GAAG,IAAIW;AACxG,MAAME,aAAaf,KAAKgB,IAAI,CAACL,WAAW,MAAM,OAAO,WAAW;AAEhE,SAASM,IAAIC,GAAW,EAAEC,IAAY,EAAEC,OAAsB,EAAEC,QAAgC;IAC9F,OAAOb,SAASO,YAAYG,KAAKC,MAAMC,SAASC;AAClD;AAEA,8DAA8D;AAC9D,MAAMC,SAASnB,SAAS,KAAKc,MAAMlB,KAAK,QAAQgB,YAAY;IAAEQ,WAAW;IAAMC,cAAc;AAAM;AAMnG,eAAe,SAASC,eAAeP,GAAW,EAAEC,IAAY,EAAEC,OAAgD,EAAEC,QAAiC;IACnJ,IAAI;YAMsDpB;QALxD,IAAI,OAAOiB,QAAQ,UAAU,MAAM,IAAIQ,MAAM;QAC7C,IAAI,OAAOP,SAAS,UAAU,MAAM,IAAIO,MAAM;QAE9CL,WAAW,OAAOD,YAAY,aAAaA,UAAUC;QACrDD,UAAU,OAAOA,YAAY,aAAa,CAAC,IAAMA,WAAW,CAAC;QAC7D,MAAMO,WAAWP,QAAQO,QAAQ,GAAGP,QAAQO,QAAQ,IAAI1B,kBAAAA,eAAeiB,kBAAfjB,6BAAAA,kBAAuB2B;QAC/E,IAAI,CAACD,UAAU,MAAM,IAAID,MAAM;QAC/B,MAAMG,OAA8B;YAAE,GAAGT,OAAO;YAAEO;QAAS;QAE3D,IAAI,OAAON,aAAa,YAAY,OAAOC,OAAOJ,KAAKC,MAAMU,MAAMR;QACnE,OAAO,IAAIS,QAAkB,CAACC,SAASC,SAAWV,OAAOJ,KAAKC,MAAMU,MAAM,CAACI,KAAKC,SAAYD,MAAMD,OAAOC,OAAOF,QAAQG,mBAAAA,oBAAAA,SAAU,EAAE;IACtI,EAAE,OAAOD,KAAK;QACZ,IAAI,OAAOZ,aAAa,YAAY,OAAOA,SAASY;QACpD,OAAOH,QAAQE,MAAM,CAACC;IACxB;AACF"}
|
|
@@ -137,7 +137,7 @@ export default function transformTypesWorker(src, dest, options, callback) {
|
|
|
137
137
|
if (readErr) return cb();
|
|
138
138
|
const updated = rewriteExtensions(content);
|
|
139
139
|
if (updated === content) cb();
|
|
140
|
-
else fs.writeFile(file, updated, 'utf8', (err)=>cb(err
|
|
140
|
+
else fs.writeFile(file, updated, 'utf8', (err)=>cb(err));
|
|
141
141
|
});
|
|
142
142
|
});
|
|
143
143
|
}
|
|
@@ -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 ?? 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","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"],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"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,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,OAAOQ,mBAAmB,sBAAsB;AAChD,SAASC,iBAAiB,QAAQ,8BAA8B;AAIhE,yDAAyD,GAEzD,SAASC,kBAAkBC,QAAgB;IACzC,OACEA,SAASC,QAAQ,CAAC,YAClBD,SAASC,QAAQ,CAAC,aAClBD,SAASC,QAAQ,CAAC,aAClBD,SAASC,QAAQ,CAAC,UAClBD,SAASC,QAAQ,CAAC,WAClBD,SAASC,QAAQ,CAAC,WAClBD,SAASC,QAAQ,CAAC,WAClBD,SAASC,QAAQ,CAAC,UAClBD,SAASC,QAAQ,CAAC,WAClBD,SAASC,QAAQ,CAAC,WAClBD,SAASC,QAAQ,CAAC;AAEtB;AAEA,wDAAwD,GAExD,SAASC,YAAYC,OAAe,EAAEC,IAAc,EAAEC,EAAiB;IACrEtB,MAAMuB,QAAQC,QAAQ,EAAE;QAACJ;WAAYC;KAAK,EAAE;QAAEI,UAAU;IAAO,GAAGH;AACpE;AAEA,0DAA0D,GAE1D,SAASI,kBAAkBC,GAAgB,EAAEC,IAAY;IACvD,MAAMC,MAAgB,EAAE;IACxB,MAAMC,OAAO,IAAIC;I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