ts-swc-transform 2.11.1 → 2.11.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/lib/transformFile.d.cts +1 -1
- package/dist/cjs/lib/transformFile.d.ts +1 -1
- package/dist/cjs/lib/transformFile.js +15 -19
- package/dist/cjs/lib/transformFile.js.map +1 -1
- package/dist/cjs/transformDirectory.js +3 -3
- package/dist/cjs/transformDirectory.js.map +1 -1
- package/dist/cjs/transformTypes.js +3 -3
- package/dist/cjs/transformTypes.js.map +1 -1
- package/dist/cjs/workers/transformDirectory.js +10 -2
- package/dist/cjs/workers/transformDirectory.js.map +1 -1
- package/dist/cjs/workers/transformTypes.js +56 -156
- package/dist/cjs/workers/transformTypes.js.map +1 -1
- package/dist/esm/lib/transformFile.d.ts +1 -1
- package/dist/esm/lib/transformFile.js +15 -19
- package/dist/esm/lib/transformFile.js.map +1 -1
- package/dist/esm/transformDirectory.js +3 -5
- package/dist/esm/transformDirectory.js.map +1 -1
- package/dist/esm/transformTypes.js +3 -5
- package/dist/esm/transformTypes.js.map +1 -1
- package/dist/esm/workers/transformDirectory.js +10 -2
- package/dist/esm/workers/transformDirectory.js.map +1 -1
- package/dist/esm/workers/transformTypes.js +53 -84
- package/dist/esm/workers/transformTypes.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import type { Entry } from 'fs-iterator';
|
|
2
2
|
import type { ConfigOptions, TargetType, TransformFileCallback } from '../types.js';
|
|
3
|
-
export default function transformFile(entry: Entry, dest: string, type: TargetType, options: ConfigOptions, callback: TransformFileCallback): void;
|
|
3
|
+
export default function transformFile(entry: Entry, dest: string, type: TargetType, options: ConfigOptions, mode: number | undefined, callback: TransformFileCallback): void;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import type { Entry } from 'fs-iterator';
|
|
2
2
|
import type { ConfigOptions, TargetType, TransformFileCallback } from '../types.js';
|
|
3
|
-
export default function transformFile(entry: Entry, dest: string, type: TargetType, options: ConfigOptions, callback: TransformFileCallback): void;
|
|
3
|
+
export default function transformFile(entry: Entry, dest: string, type: TargetType, options: ConfigOptions, mode: number | undefined, callback: TransformFileCallback): void;
|
|
@@ -74,7 +74,7 @@ function _object_spread_props(target, source) {
|
|
|
74
74
|
return target;
|
|
75
75
|
}
|
|
76
76
|
var _require = typeof require === 'undefined' ? _module.default.createRequire(require("url").pathToFileURL(__filename).toString()) : require;
|
|
77
|
-
function transformFile(entry, dest, type, options, callback) {
|
|
77
|
+
function transformFile(entry, dest, type, options, mode, callback) {
|
|
78
78
|
var tsconfig = options.tsconfig;
|
|
79
79
|
// overrides for cjs
|
|
80
80
|
if (type === 'cjs') {
|
|
@@ -90,29 +90,25 @@ function transformFile(entry, dest, type, options, callback) {
|
|
|
90
90
|
swc.transformFile(entry.fullPath, _object_spread_props(_object_spread({}, ext === '.tsx' || ext === '.jsx' ? swcOptions.tsxOptions : swcOptions.nonTsxOptions), {
|
|
91
91
|
filename: entry.basename
|
|
92
92
|
})).then(function(output) {
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
var
|
|
98
|
-
|
|
99
|
-
(
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
if (
|
|
103
|
-
|
|
104
|
-
if (err) return callback(err);
|
|
105
|
-
// Preserve executable permissions from source (only +x bits, not full mode)
|
|
106
|
-
var execBits = stats.mode & 73;
|
|
93
|
+
var extTarget = type === 'esm' ? (0, _patchESMts.default)(entry, output, options) : (0, _patchCJSts.default)(entry, output, options);
|
|
94
|
+
var ext = _path.default.extname(entry.path);
|
|
95
|
+
var outPath = _path.default.join(dest, (ext ? entry.path.slice(0, -ext.length) : entry.path) + extTarget);
|
|
96
|
+
(0, _mkdirpclassic.default)(_path.default.dirname(outPath), function() {
|
|
97
|
+
var queue = new _queuecb.default();
|
|
98
|
+
queue.defer(_fs.default.writeFile.bind(null, outPath, output.code, 'utf8'));
|
|
99
|
+
if (output.map && options.sourceMaps) queue.defer(_fs.default.writeFile.bind(null, "".concat(outPath, ".map"), output.map, 'utf8'));
|
|
100
|
+
queue.await(function(err) {
|
|
101
|
+
if (err) return callback(err);
|
|
102
|
+
if (mode) {
|
|
103
|
+
var execBits = mode & 73;
|
|
107
104
|
if (execBits) {
|
|
108
105
|
_fs.default.chmod(outPath, 420 | execBits, function(_chmodErr) {
|
|
109
|
-
// Ignore chmod errors (e.g., on Windows)
|
|
110
106
|
callback(null, outPath);
|
|
111
107
|
});
|
|
112
|
-
|
|
113
|
-
callback(null, outPath);
|
|
108
|
+
return;
|
|
114
109
|
}
|
|
115
|
-
}
|
|
110
|
+
}
|
|
111
|
+
callback(null, outPath);
|
|
116
112
|
});
|
|
117
113
|
});
|
|
118
114
|
}).catch(callback);
|
|
@@ -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';\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 { ConfigOptions, TargetType, TransformFileCallback } from '../types.ts';\n\nexport default function transformFile(entry: Entry, dest: string, type: TargetType, options: ConfigOptions, callback: TransformFileCallback): void {\n let tsconfig = options.tsconfig;\n\n // overrides for cjs\n if (type === 'cjs') {\n tsconfig = { ...tsconfig };\n tsconfig.config = { ...tsconfig.config };\n tsconfig.config.compilerOptions = { ...(tsconfig.config.compilerOptions || {}) };\n tsconfig.config.compilerOptions.module = 'commonjs';\n tsconfig.config.compilerOptions.target = 'es5';\n }\n\n const swcOptions = prepareSWCOptions(tsconfig);\n const swc = _require('@swc/core');\n const ext = path.extname(entry.basename);\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
|
|
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';\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 { ConfigOptions, TargetType, TransformFileCallback } from '../types.ts';\n\nexport default function transformFile(entry: Entry, dest: string, type: TargetType, options: ConfigOptions, mode: number | undefined, callback: TransformFileCallback): void {\n let tsconfig = options.tsconfig;\n\n // overrides for cjs\n if (type === 'cjs') {\n tsconfig = { ...tsconfig };\n tsconfig.config = { ...tsconfig.config };\n tsconfig.config.compilerOptions = { ...(tsconfig.config.compilerOptions || {}) };\n tsconfig.config.compilerOptions.module = 'commonjs';\n tsconfig.config.compilerOptions.target = 'es5';\n }\n\n const swcOptions = prepareSWCOptions(tsconfig);\n const swc = _require('@swc/core');\n const ext = path.extname(entry.basename);\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(fs.writeFile.bind(null, outPath, output.code, 'utf8'));\n if (output.map && options.sourceMaps) queue.defer(fs.writeFile.bind(null, `${outPath}.map`, output.map, 'utf8'));\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","config","compilerOptions","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","fs","writeFile","bind","code","map","sourceMaps","await","err","execBits","chmod","_chmodErr","catch"],"mappings":";;;;+BAeA;;;eAAwBA;;;yDAdT;oEAEI;6DACA;2DACF;8DACC;iEACG;iEACA;0EACS;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAE9B,IAAMC,WAAW,OAAOC,YAAY,cAAcC,eAAM,CAACC,aAAa,CAAC,uDAAmBF;AAI3E,SAASF,cAAcK,KAAY,EAAEC,IAAY,EAAEC,IAAgB,EAAEC,OAAsB,EAAEC,IAAwB,EAAEC,QAA+B;IACnK,IAAIC,WAAWH,QAAQG,QAAQ;IAE/B,oBAAoB;IACpB,IAAIJ,SAAS,OAAO;QAClBI,WAAW,mBAAKA;QAChBA,SAASC,MAAM,GAAG,mBAAKD,SAASC,MAAM;QACtCD,SAASC,MAAM,CAACC,eAAe,GAAG,mBAAMF,SAASC,MAAM,CAACC,eAAe,IAAI,CAAC;QAC5EF,SAASC,MAAM,CAACC,eAAe,CAACC,MAAM,GAAG;QACzCH,SAASC,MAAM,CAACC,eAAe,CAACE,MAAM,GAAG;IAC3C;IAEA,IAAMC,aAAaC,IAAAA,4BAAiB,EAACN;IAC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F;gBACAtB,SAAS,MAAMsB;YACjB;QACF;IACF,GACCoB,KAAK,CAAC1C;AACX"}
|
|
@@ -72,12 +72,12 @@ function transformDirectory(src, dest, type, options, callback) {
|
|
|
72
72
|
if (typeof callback === 'function') return worker(src, dest, type, opts, callback);
|
|
73
73
|
return new Promise(function(resolve, reject) {
|
|
74
74
|
return worker(src, dest, type, opts, function(err, result) {
|
|
75
|
-
err ? reject(err) : resolve(result);
|
|
75
|
+
return err ? reject(err) : resolve(result);
|
|
76
76
|
});
|
|
77
77
|
});
|
|
78
78
|
} catch (err) {
|
|
79
|
-
if (callback) callback(err);
|
|
80
|
-
|
|
79
|
+
if (typeof callback === 'function') return callback(err);
|
|
80
|
+
return Promise.reject(err);
|
|
81
81
|
}
|
|
82
82
|
}
|
|
83
83
|
/* 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/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, 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: ConfigOptions = { tsconfig, ...options };\n\n if (typeof callback === 'function') return worker(src, dest, type, opts, callback);\n return new Promise((resolve, reject)
|
|
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, 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: ConfigOptions = { tsconfig, ...options };\n\n if (typeof callback === 'function') return worker(src, dest, type, opts, callback);\n return new Promise((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);\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","loadConfigSync","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,CAAC,EAAE;AAClD,IAAMC,WAAW,OAAOC,YAAY,cAAcC,eAAM,CAACC,aAAa,CAAC,uDAAmBF;AAC1F,IAAMG,YAAYC,aAAI,CAACC,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71,12 @@ function transformTypes(src, dest, options, callback) {
|
|
|
71
71
|
if (typeof callback === 'function') return worker(src, dest, opts, callback);
|
|
72
72
|
return new Promise(function(resolve, reject) {
|
|
73
73
|
return worker(src, dest, opts, function(err, result) {
|
|
74
|
-
err ? reject(err) : resolve(result);
|
|
74
|
+
return err ? reject(err) : resolve(result);
|
|
75
75
|
});
|
|
76
76
|
});
|
|
77
77
|
} catch (err) {
|
|
78
|
-
if (callback) callback(err);
|
|
79
|
-
|
|
78
|
+
if (typeof callback === 'function') return callback(err);
|
|
79
|
+
return Promise.reject(err);
|
|
80
80
|
}
|
|
81
81
|
}
|
|
82
82
|
/* 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/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, 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: ConfigOptions = { tsconfig, ...options };\n\n if (typeof callback === 'function') return worker(src, dest, opts, callback);\n return new Promise((resolve, reject)
|
|
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, 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: ConfigOptions = { tsconfig, ...options };\n\n if (typeof callback === 'function') return worker(src, dest, opts, callback);\n return new Promise((resolve, reject) => worker(src, dest, opts, (err, result) => (err ? reject(err) : resolve(result))));\n } catch (err) {\n if (typeof callback === 'function') return callback(err);\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","loadConfigSync","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,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,GAAW,EAAEC,IAAY,EAAEC,OAAsB,EAAEC,QAAgC;IAC9F,OAAOhB,SAASU,YAAYG,KAAKC,MAAMC,SAASC;AAClD;AAEA,8DAA8D;AAC9D,IAAMC,SAAStB,SAAS,KAAKiB,MAAMM,IAAAA,qBAAI,EAAC,QAAQR,YAAY;IAAES,WAAW;IAAMC,cAAc;AAAM;AAMpF,SAAS1B,eAAemB,GAAW,EAAEC,IAAY,EAAEC,OAAgD,EAAEC,QAAiC;IACnJ,IAAI;QACF,IAAI,OAAOH,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,IAAMO,WAAWP,QAAQO,QAAQ,GAAGP,QAAQO,QAAQ,GAAGC,IAAAA,yBAAc,EAACV;QACtE,IAAMW,OAAsB;YAAEF,UAAAA;WAAaP;QAE3C,IAAI,OAAOC,aAAa,YAAY,OAAOC,OAAOJ,KAAKC,MAAMU,MAAMR;QACnE,OAAO,IAAIS,QAAQ,SAACC,SAASC;mBAAWV,OAAOJ,KAAKC,MAAMU,MAAM,SAACI,KAAKC;uBAAYD,MAAMD,OAAOC,OAAOF,QAAQG;;;IAChH,EAAE,OAAOD,KAAK;QACZ,IAAI,OAAOZ,aAAa,YAAY,OAAOA,SAASY;QACpD,OAAOH,QAAQE,MAAM,CAACC;IACxB;AACF"}
|
|
@@ -75,7 +75,10 @@ function transformDirectoryWorker(src, dest, type, options, callback) {
|
|
|
75
75
|
var tsconfig = options.tsconfig;
|
|
76
76
|
var matcher = (0, _createMatcherts.default)(tsconfig);
|
|
77
77
|
var entries = [];
|
|
78
|
-
var
|
|
78
|
+
var modeByPath = new Map();
|
|
79
|
+
var iterator = new _fsiterator.default(src, {
|
|
80
|
+
alwaysStat: true
|
|
81
|
+
});
|
|
79
82
|
iterator.forEach(function(entry) {
|
|
80
83
|
if (!entry.stats.isFile()) return;
|
|
81
84
|
if (entry.basename[0] === '.') return;
|
|
@@ -84,6 +87,10 @@ function transformDirectoryWorker(src, dest, type, options, callback) {
|
|
|
84
87
|
var ext = _path.default.extname(entry.basename);
|
|
85
88
|
if (ext && _constantsts.extensions.indexOf(ext) < 0) return;
|
|
86
89
|
entries.push(entry);
|
|
90
|
+
var stats = entry.stats;
|
|
91
|
+
if (stats.mode) {
|
|
92
|
+
modeByPath.set(entry.fullPath, stats.mode);
|
|
93
|
+
}
|
|
87
94
|
}, function(err) {
|
|
88
95
|
if (err) return callback(err);
|
|
89
96
|
var results = [];
|
|
@@ -92,8 +99,9 @@ function transformDirectoryWorker(src, dest, type, options, callback) {
|
|
|
92
99
|
});
|
|
93
100
|
var queue = new _queuecb.default();
|
|
94
101
|
entries.forEach(function(entry) {
|
|
102
|
+
var mode = modeByPath.get(entry.fullPath);
|
|
95
103
|
queue.defer(function(cb) {
|
|
96
|
-
return (0, _transformFilets.default)(entry, dest, type, options, function(err, outPath) {
|
|
104
|
+
return (0, _transformFilets.default)(entry, dest, type, options, mode, function(err, outPath) {
|
|
97
105
|
if (err) return cb(err);
|
|
98
106
|
results.push(_path.default.normalize(outPath));
|
|
99
107
|
if (options.sourceMaps) results.push("".concat(_path.default.normalize(outPath), ".map"));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/typescript/ts-swc-transform/src/workers/transformDirectory.ts"],"sourcesContent":["import Iterator, { type Entry } from 'fs-iterator';\nimport path from 'path';\nimport Queue from 'queue-cb';\n\nimport { extensions, typeFileRegEx } from '../constants.ts';\nimport createMatcher from '../createMatcher.ts';\nimport transformFile from '../lib/transformFile.ts';\n\nimport type { ConfigOptions, TargetType, TransformDirectoryCallback } from '../types.ts';\n\nexport default function transformDirectoryWorker(src: string, dest: string, type: TargetType, options: ConfigOptions, callback: TransformDirectoryCallback) {\n const tsconfig = options.tsconfig;\n const matcher = createMatcher(tsconfig);\n\n const entries: Entry[] = [];\n const iterator = new Iterator(src);\n iterator.forEach(\n (entry: Entry): void => {\n if (!entry.stats.isFile()) return;\n if (entry.basename[0] === '.') return;\n if (typeFileRegEx.test(entry.basename)) return;\n if (!matcher(entry.fullPath)) return;\n const ext = path.extname(entry.basename);\n if (ext && extensions.indexOf(ext) < 0) return;\n entries.push(entry);\n },\n (err) => {\n if (err) return callback(err);\n const results = [];\n options = { ...options, tsconfig };\n\n const queue = new Queue();\n entries.forEach((entry: Entry) => {\n queue.defer((cb) =>\n transformFile(entry, dest, type, options, (err, outPath) => {\n if (err) return cb(err);\n results.push(path.normalize(outPath));\n if (options.sourceMaps) results.push(`${path.normalize(outPath)}.map`);\n cb();\n })\n );\n });\n queue.await((err) => (err ? callback(err) : callback(null, results)));\n }\n );\n}\n"],"names":["transformDirectoryWorker","src","dest","type","options","callback","tsconfig","matcher","createMatcher","entries","iterator","Iterator","forEach","entry","stats","isFile","basename","typeFileRegEx","test","fullPath","ext","path","extname","extensions","indexOf","push","err","results","queue","Queue","defer","cb","transformFile","outPath","normalize","sourceMaps","await"],"mappings":";;;;+
|
|
1
|
+
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/typescript/ts-swc-transform/src/workers/transformDirectory.ts"],"sourcesContent":["import type fs from 'fs';\nimport Iterator, { type Entry } from 'fs-iterator';\nimport path from 'path';\nimport Queue from 'queue-cb';\n\nimport { extensions, typeFileRegEx } from '../constants.ts';\nimport createMatcher from '../createMatcher.ts';\nimport transformFile from '../lib/transformFile.ts';\n\nimport type { ConfigOptions, TargetType, TransformDirectoryCallback } from '../types.ts';\n\nexport default function transformDirectoryWorker(src: string, dest: string, type: TargetType, options: ConfigOptions, callback: TransformDirectoryCallback) {\n const tsconfig = options.tsconfig;\n const matcher = createMatcher(tsconfig);\n\n const entries: Entry[] = [];\n const modeByPath = new Map<string, number>();\n const iterator = new Iterator(src, { alwaysStat: true });\n iterator.forEach(\n (entry: Entry): void => {\n if (!entry.stats.isFile()) return;\n if (entry.basename[0] === '.') return;\n if (typeFileRegEx.test(entry.basename)) return;\n if (!matcher(entry.fullPath)) return;\n const ext = path.extname(entry.basename);\n if (ext && extensions.indexOf(ext) < 0) return;\n entries.push(entry);\n\n const stats = entry.stats as fs.Stats;\n if (stats.mode) {\n modeByPath.set(entry.fullPath, stats.mode);\n }\n },\n (err) => {\n if (err) return callback(err);\n const results = [];\n options = { ...options, tsconfig };\n\n const queue = new Queue();\n entries.forEach((entry: Entry) => {\n const mode = modeByPath.get(entry.fullPath);\n queue.defer((cb) =>\n transformFile(entry, dest, type, options, mode, (err, outPath) => {\n if (err) return cb(err);\n results.push(path.normalize(outPath));\n if (options.sourceMaps) results.push(`${path.normalize(outPath)}.map`);\n cb();\n })\n );\n });\n queue.await((err) => (err ? callback(err) : callback(null, results)));\n }\n );\n}\n"],"names":["transformDirectoryWorker","src","dest","type","options","callback","tsconfig","matcher","createMatcher","entries","modeByPath","Map","iterator","Iterator","alwaysStat","forEach","entry","stats","isFile","basename","typeFileRegEx","test","fullPath","ext","path","extname","extensions","indexOf","push","mode","set","err","results","queue","Queue","get","defer","cb","transformFile","outPath","normalize","sourceMaps","await"],"mappings":";;;;+BAWA;;;eAAwBA;;;iEAVa;2DACpB;8DACC;2BAEwB;sEAChB;sEACA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAIX,SAASA,yBAAyBC,GAAW,EAAEC,IAAY,EAAEC,IAAgB,EAAEC,OAAsB,EAAEC,QAAoC;IACxJ,IAAMC,WAAWF,QAAQE,QAAQ;IACjC,IAAMC,UAAUC,IAAAA,wBAAa,EAACF;IAE9B,IAAMG,UAAmB,EAAE;IAC3B,IAAMC,aAAa,IAAIC;IACvB,IAAMC,WAAW,IAAIC,mBAAQ,CAACZ,KAAK;QAAEa,YAAY;IAAK;IACtDF,SAASG,OAAO,CACd,SAACC;QACC,IAAI,CAACA,MAAMC,KAAK,CAACC,MAAM,IAAI;QAC3B,IAAIF,MAAMG,QAAQ,CAAC,EAAE,KAAK,KAAK;QAC/B,IAAIC,0BAAa,CAACC,IAAI,CAACL,MAAMG,QAAQ,GAAG;QACxC,IAAI,CAACZ,QAAQS,MAAMM,QAAQ,GAAG;QAC9B,IAAMC,MAAMC,aAAI,CAACC,OAAO,CAACT,MAAMG,QAAQ;QACvC,IAAII,OAAOG,uBAAU,CAACC,OAAO,CAACJ,OAAO,GAAG;QACxCd,QAAQmB,IAAI,CAACZ;QAEb,IAAMC,QAAQD,MAAMC,KAAK;QACzB,IAAIA,MAAMY,IAAI,EAAE;YACdnB,WAAWoB,GAAG,CAACd,MAAMM,QAAQ,EAAEL,MAAMY,IAAI;QAC3C;IACF,GACA,SAACE;QACC,IAAIA,KAAK,OAAO1B,SAAS0B;QACzB,IAAMC,UAAU,EAAE;QAClB5B,UAAU,wCAAKA;YAASE,UAAAA;;QAExB,IAAM2B,QAAQ,IAAIC,gBAAK;QACvBzB,QAAQM,OAAO,CAAC,SAACC;YACf,IAAMa,OAAOnB,WAAWyB,GAAG,CAACnB,MAAMM,QAAQ;YAC1CW,MAAMG,KAAK,CAAC,SAACC;uBACXC,IAAAA,wBAAa,EAACtB,OAAOd,MAAMC,MAAMC,SAASyB,MAAM,SAACE,KAAKQ;oBACpD,IAAIR,KAAK,OAAOM,GAAGN;oBACnBC,QAAQJ,IAAI,CAACJ,aAAI,CAACgB,SAAS,CAACD;oBAC5B,IAAInC,QAAQqC,UAAU,EAAET,QAAQJ,IAAI,CAAC,AAAC,GAA0B,OAAxBJ,aAAI,CAACgB,SAAS,CAACD,UAAS;oBAChEF;gBACF;;QAEJ;QACAJ,MAAMS,KAAK,CAAC,SAACX;mBAASA,MAAM1B,SAAS0B,OAAO1B,SAAS,MAAM2B;;IAC7D;AAEJ"}
|
|
@@ -11,20 +11,12 @@ Object.defineProperty(exports, "default", {
|
|
|
11
11
|
var _fs = /*#__PURE__*/ _interop_require_default(require("fs"));
|
|
12
12
|
var _fsiterator = /*#__PURE__*/ _interop_require_default(require("fs-iterator"));
|
|
13
13
|
var _module = /*#__PURE__*/ _interop_require_default(require("module"));
|
|
14
|
-
var
|
|
14
|
+
var _os = /*#__PURE__*/ _interop_require_default(require("os"));
|
|
15
15
|
var _queuecb = /*#__PURE__*/ _interop_require_default(require("queue-cb"));
|
|
16
16
|
var _compatts = require("../compat.js");
|
|
17
17
|
var _constantsts = require("../constants.js");
|
|
18
18
|
var _createMatcherts = /*#__PURE__*/ _interop_require_default(require("../createMatcher.js"));
|
|
19
19
|
var _rewriteExtensionsts = require("../lib/rewriteExtensions.js");
|
|
20
|
-
function _array_like_to_array(arr, len) {
|
|
21
|
-
if (len == null || len > arr.length) len = arr.length;
|
|
22
|
-
for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
|
|
23
|
-
return arr2;
|
|
24
|
-
}
|
|
25
|
-
function _array_with_holes(arr) {
|
|
26
|
-
if (Array.isArray(arr)) return arr;
|
|
27
|
-
}
|
|
28
20
|
function _define_property(obj, key, value) {
|
|
29
21
|
if (key in obj) {
|
|
30
22
|
Object.defineProperty(obj, key, {
|
|
@@ -43,33 +35,6 @@ function _interop_require_default(obj) {
|
|
|
43
35
|
default: obj
|
|
44
36
|
};
|
|
45
37
|
}
|
|
46
|
-
function _iterable_to_array_limit(arr, i) {
|
|
47
|
-
var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
|
|
48
|
-
if (_i == null) return;
|
|
49
|
-
var _arr = [];
|
|
50
|
-
var _n = true;
|
|
51
|
-
var _d = false;
|
|
52
|
-
var _s, _e;
|
|
53
|
-
try {
|
|
54
|
-
for(_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true){
|
|
55
|
-
_arr.push(_s.value);
|
|
56
|
-
if (i && _arr.length === i) break;
|
|
57
|
-
}
|
|
58
|
-
} catch (err) {
|
|
59
|
-
_d = true;
|
|
60
|
-
_e = err;
|
|
61
|
-
} finally{
|
|
62
|
-
try {
|
|
63
|
-
if (!_n && _i["return"] != null) _i["return"]();
|
|
64
|
-
} finally{
|
|
65
|
-
if (_d) throw _e;
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
return _arr;
|
|
69
|
-
}
|
|
70
|
-
function _non_iterable_rest() {
|
|
71
|
-
throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
72
|
-
}
|
|
73
38
|
function _object_spread(target) {
|
|
74
39
|
for(var i = 1; i < arguments.length; i++){
|
|
75
40
|
var source = arguments[i] != null ? arguments[i] : {};
|
|
@@ -109,17 +74,9 @@ function _object_spread_props(target, source) {
|
|
|
109
74
|
}
|
|
110
75
|
return target;
|
|
111
76
|
}
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
function _unsupported_iterable_to_array(o, minLen) {
|
|
116
|
-
if (!o) return;
|
|
117
|
-
if (typeof o === "string") return _array_like_to_array(o, minLen);
|
|
118
|
-
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
119
|
-
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
120
|
-
if (n === "Map" || n === "Set") return Array.from(n);
|
|
121
|
-
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
|
|
122
|
-
}
|
|
77
|
+
var _ref;
|
|
78
|
+
var _os_cpus;
|
|
79
|
+
var concurrency = Math.min(64, Math.max(8, ((_ref = (_os_cpus = _os.default.cpus()) === null || _os_cpus === void 0 ? void 0 : _os_cpus.length) !== null && _ref !== void 0 ? _ref : 4) * 8));
|
|
123
80
|
var _require = typeof require === 'undefined' ? _module.default.createRequire(require("url").pathToFileURL(__filename).toString()) : require;
|
|
124
81
|
function transformTypesWorker(src, dest, options, callback) {
|
|
125
82
|
var tsconfig = options.tsconfig;
|
|
@@ -134,121 +91,64 @@ function transformTypesWorker(src, dest, options, callback) {
|
|
|
134
91
|
if (!matcher(entry.fullPath)) return;
|
|
135
92
|
entries.push(entry);
|
|
136
93
|
}, {
|
|
137
|
-
concurrency:
|
|
94
|
+
concurrency: concurrency
|
|
138
95
|
}, function(err) {
|
|
139
96
|
if (err) return callback(err);
|
|
140
|
-
// Step
|
|
141
|
-
var
|
|
142
|
-
var
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
host: host,
|
|
176
|
-
configFileParsingDiagnostics: ts.getConfigFileParsingDiagnostics({
|
|
177
|
-
fileNames: fileNames,
|
|
178
|
-
options: _$options
|
|
179
|
-
})
|
|
180
|
-
};
|
|
181
|
-
var program = ts.createProgram(programOptions);
|
|
182
|
-
var res = program.emit();
|
|
183
|
-
// Step 3: Post-process emitted files (async)
|
|
184
|
-
var postQueue = new _queuecb.default();
|
|
185
|
-
if (res.emittedFiles) {
|
|
186
|
-
res.emittedFiles.forEach(function(file) {
|
|
187
|
-
// 3a: Rewrite extensions (convert from sync to async)
|
|
188
|
-
// TODO: remove patch for https://github.com/microsoft/TypeScript/issues/61037
|
|
189
|
-
if (compilerOptions.options.rewriteRelativeImportExtensions) {
|
|
190
|
-
if ((0, _compatts.stringEndsWith)(file, '.d.ts') || (0, _compatts.stringEndsWith)(file, '.d.cts') || (0, _compatts.stringEndsWith)(file, '.d.mts')) {
|
|
191
|
-
postQueue.defer(function(cb) {
|
|
192
|
-
_fs.default.readFile(file, 'utf8', function(readErr, content) {
|
|
193
|
-
if (readErr) return cb(); // Ignore errors, continue
|
|
194
|
-
var updated = (0, _rewriteExtensionsts.rewriteExtensions)(content);
|
|
195
|
-
if (updated !== content) {
|
|
196
|
-
_fs.default.writeFile(file, updated, 'utf8', function() {
|
|
197
|
-
return cb();
|
|
198
|
-
}); // Ignore write errors
|
|
199
|
-
} else {
|
|
200
|
-
cb();
|
|
201
|
-
}
|
|
202
|
-
});
|
|
203
|
-
});
|
|
204
|
-
}
|
|
205
|
-
}
|
|
206
|
-
// 3b: Apply executable permissions from source files
|
|
97
|
+
// Step 2: TypeScript emit (inherently sync - cannot change)
|
|
98
|
+
var compilerOptions = ts.convertCompilerOptionsFromJson(tsconfig.config.compilerOptions, '');
|
|
99
|
+
var config = {
|
|
100
|
+
fileNames: entries.map(function(entry) {
|
|
101
|
+
return entry.fullPath;
|
|
102
|
+
}),
|
|
103
|
+
options: _object_spread_props(_object_spread({}, compilerOptions.options), {
|
|
104
|
+
outDir: dest,
|
|
105
|
+
noEmit: false,
|
|
106
|
+
allowJs: true,
|
|
107
|
+
declaration: true,
|
|
108
|
+
emitDeclarationOnly: true,
|
|
109
|
+
listEmittedFiles: true
|
|
110
|
+
}),
|
|
111
|
+
projectReferences: tsconfig.config.references
|
|
112
|
+
};
|
|
113
|
+
var fileNames = config.fileNames, _$options = config.options, projectReferences = config.projectReferences;
|
|
114
|
+
var host = ts.createCompilerHostWorker(_$options, /*setParentNodes*/ undefined, ts.sys);
|
|
115
|
+
var programOptions = {
|
|
116
|
+
rootNames: fileNames,
|
|
117
|
+
options: _$options,
|
|
118
|
+
projectReferences: projectReferences,
|
|
119
|
+
host: host,
|
|
120
|
+
configFileParsingDiagnostics: ts.getConfigFileParsingDiagnostics({
|
|
121
|
+
fileNames: fileNames,
|
|
122
|
+
options: _$options
|
|
123
|
+
})
|
|
124
|
+
};
|
|
125
|
+
var program = ts.createProgram(programOptions);
|
|
126
|
+
var res = program.emit();
|
|
127
|
+
// Step 3: Post-process emitted files (async)
|
|
128
|
+
var postQueue = new _queuecb.default();
|
|
129
|
+
if (res.emittedFiles) {
|
|
130
|
+
res.emittedFiles.forEach(function(file) {
|
|
131
|
+
if (compilerOptions.options.rewriteRelativeImportExtensions) {
|
|
207
132
|
if ((0, _compatts.stringEndsWith)(file, '.d.ts') || (0, _compatts.stringEndsWith)(file, '.d.cts') || (0, _compatts.stringEndsWith)(file, '.d.mts')) {
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
if (execBits) {
|
|
219
|
-
postQueue.defer(function(cb) {
|
|
220
|
-
_fs.default.chmod(file, 420 | execBits, function() {
|
|
221
|
-
return cb();
|
|
222
|
-
}); // Ignore chmod errors
|
|
223
|
-
});
|
|
224
|
-
}
|
|
225
|
-
return "break";
|
|
133
|
+
postQueue.defer(function(cb) {
|
|
134
|
+
_fs.default.readFile(file, 'utf8', function(readErr, content) {
|
|
135
|
+
if (readErr) return cb();
|
|
136
|
+
var updated = (0, _rewriteExtensionsts.rewriteExtensions)(content);
|
|
137
|
+
if (updated !== content) {
|
|
138
|
+
_fs.default.writeFile(file, updated, 'utf8', function() {
|
|
139
|
+
return cb();
|
|
140
|
+
});
|
|
141
|
+
} else {
|
|
142
|
+
cb();
|
|
226
143
|
}
|
|
227
|
-
};
|
|
228
|
-
|
|
229
|
-
var _ret = _loop();
|
|
230
|
-
if (_ret === "break") break;
|
|
231
|
-
}
|
|
232
|
-
} catch (err) {
|
|
233
|
-
_didIteratorError = true;
|
|
234
|
-
_iteratorError = err;
|
|
235
|
-
} finally{
|
|
236
|
-
try {
|
|
237
|
-
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
238
|
-
_iterator.return();
|
|
239
|
-
}
|
|
240
|
-
} finally{
|
|
241
|
-
if (_didIteratorError) {
|
|
242
|
-
throw _iteratorError;
|
|
243
|
-
}
|
|
244
|
-
}
|
|
245
|
-
}
|
|
144
|
+
});
|
|
145
|
+
});
|
|
246
146
|
}
|
|
247
|
-
}
|
|
248
|
-
}
|
|
249
|
-
postQueue.await(function() {
|
|
250
|
-
return callback(null, res.emittedFiles);
|
|
147
|
+
}
|
|
251
148
|
});
|
|
149
|
+
}
|
|
150
|
+
postQueue.await(function() {
|
|
151
|
+
return callback(null, res.emittedFiles);
|
|
252
152
|
});
|
|
253
153
|
});
|
|
254
154
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/typescript/ts-swc-transform/src/workers/transformTypes.ts"],"sourcesContent":["import fs from 'fs';\nimport Iterator, { type Entry } from 'fs-iterator';\nimport Module from 'module';\nimport
|
|
1
|
+
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/typescript/ts-swc-transform/src/workers/transformTypes.ts"],"sourcesContent":["import fs from 'fs';\nimport Iterator, { type Entry } from 'fs-iterator';\nimport Module from 'module';\nimport os from 'os';\nimport Queue from 'queue-cb';\n\nconst concurrency = Math.min(64, Math.max(8, (os.cpus()?.length ?? 4) * 8));\n\nconst _require = typeof require === 'undefined' ? Module.createRequire(import.meta.url) : require;\n\nimport { stringEndsWith } from '../compat.ts';\nimport { typeFileRegEx } from '../constants.ts';\nimport createMatcher from '../createMatcher.ts';\nimport { rewriteExtensions } from '../lib/rewriteExtensions.ts';\n\nimport type { ConfigOptions, TransformTypesCallback } from '../types.ts';\n\nexport default function transformTypesWorker(src: string, dest: string, options: ConfigOptions, callback: TransformTypesCallback) {\n const tsconfig = options.tsconfig;\n const matcher = createMatcher(tsconfig);\n const ts = _require('typescript');\n\n const entries = [];\n const iterator = new Iterator(src);\n iterator.forEach(\n (entry: Entry): void => {\n if (!entry.stats.isFile()) return;\n if (entry.basename[0] === '.') return;\n if (typeFileRegEx.test(entry.basename)) return;\n if (!matcher(entry.fullPath)) return;\n entries.push(entry);\n },\n { concurrency },\n (err) => {\n if (err) return callback(err);\n\n // Step 2: TypeScript emit (inherently sync - cannot change)\n const compilerOptions = ts.convertCompilerOptionsFromJson(tsconfig.config.compilerOptions, '');\n const config = {\n fileNames: entries.map((entry) => entry.fullPath),\n options: {\n ...compilerOptions.options,\n outDir: dest,\n noEmit: false,\n allowJs: true,\n declaration: true,\n emitDeclarationOnly: true,\n listEmittedFiles: true,\n },\n projectReferences: tsconfig.config.references,\n };\n const { fileNames, options, projectReferences } = config;\n const host = ts.createCompilerHostWorker(options, /*setParentNodes*/ undefined, ts.sys);\n const programOptions = {\n rootNames: fileNames,\n options,\n projectReferences,\n host,\n configFileParsingDiagnostics: ts.getConfigFileParsingDiagnostics({ fileNames, options }),\n };\n const program = ts.createProgram(programOptions);\n const res = program.emit();\n\n // Step 3: Post-process emitted files (async)\n const postQueue = new Queue();\n\n if (res.emittedFiles) {\n res.emittedFiles.forEach((file) => {\n if (compilerOptions.options.rewriteRelativeImportExtensions) {\n if (stringEndsWith(file, '.d.ts') || stringEndsWith(file, '.d.cts') || stringEndsWith(file, '.d.mts')) {\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) {\n fs.writeFile(file, updated, 'utf8', () => cb());\n } else {\n cb();\n }\n });\n });\n }\n }\n });\n }\n\n postQueue.await(() => callback(null, res.emittedFiles));\n }\n );\n}\n"],"names":["transformTypesWorker","os","concurrency","Math","min","max","cpus","length","_require","require","Module","createRequire","src","dest","options","callback","tsconfig","matcher","createMatcher","ts","entries","iterator","Iterator","forEach","entry","stats","isFile","basename","typeFileRegEx","test","fullPath","push","err","compilerOptions","convertCompilerOptionsFromJson","config","fileNames","map","outDir","noEmit","allowJs","declaration","emitDeclarationOnly","listEmittedFiles","projectReferences","references","host","createCompilerHostWorker","undefined","sys","programOptions","rootNames","configFileParsingDiagnostics","getConfigFileParsingDiagnostics","program","createProgram","res","emit","postQueue","Queue","emittedFiles","file","rewriteRelativeImportExtensions","stringEndsWith","defer","cb","fs","readFile","readErr","content","updated","rewriteExtensions","writeFile","await"],"mappings":";;;;+BAiBA;;;eAAwBA;;;yDAjBT;iEACsB;6DAClB;yDACJ;8DACG;wBAMa;2BACD;sEACJ;mCACQ;;;;;;;;;;;;;;;;;;;;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IAAQT,YAA0CD,OAA1CC,WAAWtB,YAA+BqB,OAA/BrB,SAAS8B,oBAAsBT,OAAtBS;QAC5B,IAAME,OAAO3B,GAAG4B,wBAAwB,CAACjC,WAAS,gBAAgB,GAAGkC,WAAW7B,GAAG8B,GAAG;QACtF,IAAMC,iBAAiB;YACrBC,WAAWf;YACXtB,SAAAA;YACA8B,mBAAAA;YACAE,MAAAA;YACAM,8BAA8BjC,GAAGkC,+BAA+B,CAAC;gBAAEjB,WAAAA;gBAAWtB,SAAAA;YAAQ;QACxF;QACA,IAAMwC,UAAUnC,GAAGoC,aAAa,CAACL;QACjC,IAAMM,MAAMF,QAAQG,IAAI;QAExB,6CAA6C;QAC7C,IAAMC,YAAY,IAAIC,gBAAK;QAE3B,IAAIH,IAAII,YAAY,EAAE;YACpBJ,IAAII,YAAY,CAACrC,OAAO,CAAC,SAACsC;gBACxB,IAAI5B,gBAAgBnB,OAAO,CAACgD,+BAA+B,EAAE;oBAC3D,IAAIC,IAAAA,wBAAc,EAACF,MAAM,YAAYE,IAAAA,wBAAc,EAACF,MAAM,aAAaE,IAAAA,wBAAc,EAACF,MAAM,WAAW;wBACrGH,UAAUM,KAAK,CAAC,SAACC;4BACfC,WAAE,CAACC,QAAQ,CAACN,MAAM,QAAQ,SAACO,SAASC;gCAClC,IAAID,SAAS,OAAOH;gCACpB,IAAMK,UAAUC,IAAAA,sCAAiB,EAACF;gCAClC,IAAIC,YAAYD,SAAS;oCACvBH,WAAE,CAACM,SAAS,CAACX,MAAMS,SAAS,QAAQ;+CAAML;;gCAC5C,OAAO;oCACLA;gCACF;4BACF;wBACF;oBACF;gBACF;YACF;QACF;QAEAP,UAAUe,KAAK,CAAC;mBAAM1D,SAAS,MAAMyC,IAAII,YAAY;;IACvD;AAEJ"}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import type { Entry } from 'fs-iterator';
|
|
2
2
|
import type { ConfigOptions, TargetType, TransformFileCallback } from '../types.js';
|
|
3
|
-
export default function transformFile(entry: Entry, dest: string, type: TargetType, options: ConfigOptions, callback: TransformFileCallback): void;
|
|
3
|
+
export default function transformFile(entry: Entry, dest: string, type: TargetType, options: ConfigOptions, mode: number | undefined, callback: TransformFileCallback): void;
|
|
@@ -7,7 +7,7 @@ import patchCJS from '../lib/patchCJS.js';
|
|
|
7
7
|
import patchESM from '../lib/patchESM.js';
|
|
8
8
|
import prepareSWCOptions from '../lib/prepareSWCOptions.js';
|
|
9
9
|
const _require = typeof require === 'undefined' ? Module.createRequire(import.meta.url) : require;
|
|
10
|
-
export default function transformFile(entry, dest, type, options, callback) {
|
|
10
|
+
export default function transformFile(entry, dest, type, options, mode, callback) {
|
|
11
11
|
let tsconfig = options.tsconfig;
|
|
12
12
|
// overrides for cjs
|
|
13
13
|
if (type === 'cjs') {
|
|
@@ -30,29 +30,25 @@ export default function transformFile(entry, dest, type, options, callback) {
|
|
|
30
30
|
...ext === '.tsx' || ext === '.jsx' ? swcOptions.tsxOptions : swcOptions.nonTsxOptions,
|
|
31
31
|
filename: entry.basename
|
|
32
32
|
}).then((output)=>{
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
const
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
if (
|
|
43
|
-
|
|
44
|
-
if (err) return callback(err);
|
|
45
|
-
// Preserve executable permissions from source (only +x bits, not full mode)
|
|
46
|
-
const execBits = stats.mode & 0o111;
|
|
33
|
+
const extTarget = type === 'esm' ? patchESM(entry, output, options) : patchCJS(entry, output, options);
|
|
34
|
+
const ext = path.extname(entry.path);
|
|
35
|
+
const outPath = path.join(dest, (ext ? entry.path.slice(0, -ext.length) : entry.path) + extTarget);
|
|
36
|
+
mkdirp(path.dirname(outPath), ()=>{
|
|
37
|
+
const queue = new Queue();
|
|
38
|
+
queue.defer(fs.writeFile.bind(null, outPath, output.code, 'utf8'));
|
|
39
|
+
if (output.map && options.sourceMaps) queue.defer(fs.writeFile.bind(null, `${outPath}.map`, output.map, 'utf8'));
|
|
40
|
+
queue.await((err)=>{
|
|
41
|
+
if (err) return callback(err);
|
|
42
|
+
if (mode) {
|
|
43
|
+
const execBits = mode & 0o111;
|
|
47
44
|
if (execBits) {
|
|
48
45
|
fs.chmod(outPath, 0o644 | execBits, (_chmodErr)=>{
|
|
49
|
-
// Ignore chmod errors (e.g., on Windows)
|
|
50
46
|
callback(null, outPath);
|
|
51
47
|
});
|
|
52
|
-
|
|
53
|
-
callback(null, outPath);
|
|
48
|
+
return;
|
|
54
49
|
}
|
|
55
|
-
}
|
|
50
|
+
}
|
|
51
|
+
callback(null, outPath);
|
|
56
52
|
});
|
|
57
53
|
});
|
|
58
54
|
}).catch(callback);
|
|
@@ -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';\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 { ConfigOptions, TargetType, TransformFileCallback } from '../types.ts';\n\nexport default function transformFile(entry: Entry, dest: string, type: TargetType, options: ConfigOptions, callback: TransformFileCallback): void {\n let tsconfig = options.tsconfig;\n\n // overrides for cjs\n if (type === 'cjs') {\n tsconfig = { ...tsconfig };\n tsconfig.config = { ...tsconfig.config };\n tsconfig.config.compilerOptions = { ...(tsconfig.config.compilerOptions || {}) };\n tsconfig.config.compilerOptions.module = 'commonjs';\n tsconfig.config.compilerOptions.target = 'es5';\n }\n\n const swcOptions = prepareSWCOptions(tsconfig);\n const swc = _require('@swc/core');\n const ext = path.extname(entry.basename);\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
|
|
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';\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 { ConfigOptions, TargetType, TransformFileCallback } from '../types.ts';\n\nexport default function transformFile(entry: Entry, dest: string, type: TargetType, options: ConfigOptions, mode: number | undefined, callback: TransformFileCallback): void {\n let tsconfig = options.tsconfig;\n\n // overrides for cjs\n if (type === 'cjs') {\n tsconfig = { ...tsconfig };\n tsconfig.config = { ...tsconfig.config };\n tsconfig.config.compilerOptions = { ...(tsconfig.config.compilerOptions || {}) };\n tsconfig.config.compilerOptions.module = 'commonjs';\n tsconfig.config.compilerOptions.target = 'es5';\n }\n\n const swcOptions = prepareSWCOptions(tsconfig);\n const swc = _require('@swc/core');\n const ext = path.extname(entry.basename);\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(fs.writeFile.bind(null, outPath, output.code, 'utf8'));\n if (output.map && options.sourceMaps) queue.defer(fs.writeFile.bind(null, `${outPath}.map`, output.map, 'utf8'));\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","config","compilerOptions","module","target","swcOptions","swc","ext","extname","basename","fullPath","tsxOptions","nonTsxOptions","filename","then","output","extTarget","outPath","join","slice","length","dirname","queue","defer","writeFile","bind","code","map","sourceMaps","await","err","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;AAC7B,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,cAAcC,KAAY,EAAEC,IAAY,EAAEC,IAAgB,EAAEC,OAAsB,EAAEC,IAAwB,EAAEC,QAA+B;IACnK,IAAIC,WAAWH,QAAQG,QAAQ;IAE/B,oBAAoB;IACpB,IAAIJ,SAAS,OAAO;QAClBI,WAAW;YAAE,GAAGA,QAAQ;QAAC;QACzBA,SAASC,MAAM,GAAG;YAAE,GAAGD,SAASC,MAAM;QAAC;QACvCD,SAASC,MAAM,CAACC,eAAe,GAAG;YAAE,GAAIF,SAASC,MAAM,CAACC,eAAe,IAAI,CAAC,CAAC;QAAE;QAC/EF,SAASC,MAAM,CAACC,eAAe,CAACC,MAAM,GAAG;QACzCH,SAASC,MA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BACF;gBACAlB,SAAS,MAAMkB;YACjB;QACF;IACF,GACCiB,KAAK,CAACnC;AACX"}
|
|
@@ -28,11 +28,9 @@ export default function transformDirectory(src, dest, type, options, callback) {
|
|
|
28
28
|
...options
|
|
29
29
|
};
|
|
30
30
|
if (typeof callback === 'function') return worker(src, dest, type, opts, callback);
|
|
31
|
-
return new Promise((resolve, reject)=>worker(src, dest, type, opts, (err, result)=>
|
|
32
|
-
err ? reject(err) : resolve(result);
|
|
33
|
-
}));
|
|
31
|
+
return new Promise((resolve, reject)=>worker(src, dest, type, opts, (err, result)=>err ? reject(err) : resolve(result)));
|
|
34
32
|
} catch (err) {
|
|
35
|
-
if (callback) callback(err);
|
|
36
|
-
|
|
33
|
+
if (typeof callback === 'function') return callback(err);
|
|
34
|
+
return Promise.reject(err);
|
|
37
35
|
}
|
|
38
36
|
}
|
|
@@ -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, 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: ConfigOptions = { tsconfig, ...options };\n\n if (typeof callback === 'function') return worker(src, dest, type, opts, callback);\n return new Promise((resolve, reject)
|
|
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, 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: ConfigOptions = { tsconfig, ...options };\n\n if (typeof callback === 'function') return worker(src, dest, type, opts, callback);\n return new Promise((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);\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,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};
|
|
29
29
|
if (typeof callback === 'function') return worker(src, dest, opts, callback);
|
|
30
|
-
return new Promise((resolve, reject)=>worker(src, dest, opts, (err, result)=>
|
|
31
|
-
err ? reject(err) : resolve(result);
|
|
32
|
-
}));
|
|
30
|
+
return new Promise((resolve, reject)=>worker(src, dest, opts, (err, result)=>err ? reject(err) : resolve(result)));
|
|
33
31
|
} catch (err) {
|
|
34
|
-
if (callback) callback(err);
|
|
35
|
-
|
|
32
|
+
if (typeof callback === 'function') return callback(err);
|
|
33
|
+
return Promise.reject(err);
|
|
36
34
|
}
|
|
37
35
|
}
|
|
@@ -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, 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: ConfigOptions = { tsconfig, ...options };\n\n if (typeof callback === 'function') return worker(src, dest, opts, callback);\n return new Promise((resolve, reject)
|
|
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, 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: ConfigOptions = { tsconfig, ...options };\n\n if (typeof callback === 'function') return worker(src, dest, opts, callback);\n return new Promise((resolve, reject) => worker(src, dest, opts, (err, result) => (err ? reject(err) : resolve(result))));\n } catch (err) {\n if (typeof callback === 'function') return callback(err);\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;QACF,IAAI,OAAOH,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,GAAG1B,eAAeiB;QACtE,MAAMU,OAAsB;YAAED;YAAU,GAAGP,OAAO;QAAC;QAEnD,IAAI,OAAOC,aAAa,YAAY,OAAOC,OAAOJ,KAAKC,MAAMS,MAAMP;QACnE,OAAO,IAAIQ,QAAQ,CAACC,SAASC,SAAWT,OAAOJ,KAAKC,MAAMS,MAAM,CAACI,KAAKC,SAAYD,MAAMD,OAAOC,OAAOF,QAAQG;IAChH,EAAE,OAAOD,KAAK;QACZ,IAAI,OAAOX,aAAa,YAAY,OAAOA,SAASW;QACpD,OAAOH,QAAQE,MAAM,CAACC;IACxB;AACF"}
|
|
@@ -8,7 +8,10 @@ export default function transformDirectoryWorker(src, dest, type, options, callb
|
|
|
8
8
|
const tsconfig = options.tsconfig;
|
|
9
9
|
const matcher = createMatcher(tsconfig);
|
|
10
10
|
const entries = [];
|
|
11
|
-
const
|
|
11
|
+
const modeByPath = new Map();
|
|
12
|
+
const iterator = new Iterator(src, {
|
|
13
|
+
alwaysStat: true
|
|
14
|
+
});
|
|
12
15
|
iterator.forEach((entry)=>{
|
|
13
16
|
if (!entry.stats.isFile()) return;
|
|
14
17
|
if (entry.basename[0] === '.') return;
|
|
@@ -17,6 +20,10 @@ export default function transformDirectoryWorker(src, dest, type, options, callb
|
|
|
17
20
|
const ext = path.extname(entry.basename);
|
|
18
21
|
if (ext && extensions.indexOf(ext) < 0) return;
|
|
19
22
|
entries.push(entry);
|
|
23
|
+
const stats = entry.stats;
|
|
24
|
+
if (stats.mode) {
|
|
25
|
+
modeByPath.set(entry.fullPath, stats.mode);
|
|
26
|
+
}
|
|
20
27
|
}, (err)=>{
|
|
21
28
|
if (err) return callback(err);
|
|
22
29
|
const results = [];
|
|
@@ -26,7 +33,8 @@ export default function transformDirectoryWorker(src, dest, type, options, callb
|
|
|
26
33
|
};
|
|
27
34
|
const queue = new Queue();
|
|
28
35
|
entries.forEach((entry)=>{
|
|
29
|
-
|
|
36
|
+
const mode = modeByPath.get(entry.fullPath);
|
|
37
|
+
queue.defer((cb)=>transformFile(entry, dest, type, options, mode, (err, outPath)=>{
|
|
30
38
|
if (err) return cb(err);
|
|
31
39
|
results.push(path.normalize(outPath));
|
|
32
40
|
if (options.sourceMaps) results.push(`${path.normalize(outPath)}.map`);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/typescript/ts-swc-transform/src/workers/transformDirectory.ts"],"sourcesContent":["import Iterator, { type Entry } from 'fs-iterator';\nimport path from 'path';\nimport Queue from 'queue-cb';\n\nimport { extensions, typeFileRegEx } from '../constants.ts';\nimport createMatcher from '../createMatcher.ts';\nimport transformFile from '../lib/transformFile.ts';\n\nimport type { ConfigOptions, TargetType, TransformDirectoryCallback } from '../types.ts';\n\nexport default function transformDirectoryWorker(src: string, dest: string, type: TargetType, options: ConfigOptions, callback: TransformDirectoryCallback) {\n const tsconfig = options.tsconfig;\n const matcher = createMatcher(tsconfig);\n\n const entries: Entry[] = [];\n const iterator = new Iterator(src);\n iterator.forEach(\n (entry: Entry): void => {\n if (!entry.stats.isFile()) return;\n if (entry.basename[0] === '.') return;\n if (typeFileRegEx.test(entry.basename)) return;\n if (!matcher(entry.fullPath)) return;\n const ext = path.extname(entry.basename);\n if (ext && extensions.indexOf(ext) < 0) return;\n entries.push(entry);\n },\n (err) => {\n if (err) return callback(err);\n const results = [];\n options = { ...options, tsconfig };\n\n const queue = new Queue();\n entries.forEach((entry: Entry) => {\n queue.defer((cb) =>\n transformFile(entry, dest, type, options, (err, outPath) => {\n if (err) return cb(err);\n results.push(path.normalize(outPath));\n if (options.sourceMaps) results.push(`${path.normalize(outPath)}.map`);\n cb();\n })\n );\n });\n queue.await((err) => (err ? callback(err) : callback(null, results)));\n }\n );\n}\n"],"names":["Iterator","path","Queue","extensions","typeFileRegEx","createMatcher","transformFile","transformDirectoryWorker","src","dest","type","options","callback","tsconfig","matcher","entries","iterator","forEach","entry","stats","isFile","basename","test","fullPath","ext","extname","indexOf","push","err","results","queue","defer","cb","outPath","normalize","sourceMaps","await"],"mappings":"
|
|
1
|
+
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/typescript/ts-swc-transform/src/workers/transformDirectory.ts"],"sourcesContent":["import type fs from 'fs';\nimport Iterator, { type Entry } from 'fs-iterator';\nimport path from 'path';\nimport Queue from 'queue-cb';\n\nimport { extensions, typeFileRegEx } from '../constants.ts';\nimport createMatcher from '../createMatcher.ts';\nimport transformFile from '../lib/transformFile.ts';\n\nimport type { ConfigOptions, TargetType, TransformDirectoryCallback } from '../types.ts';\n\nexport default function transformDirectoryWorker(src: string, dest: string, type: TargetType, options: ConfigOptions, callback: TransformDirectoryCallback) {\n const tsconfig = options.tsconfig;\n const matcher = createMatcher(tsconfig);\n\n const entries: Entry[] = [];\n const modeByPath = new Map<string, number>();\n const iterator = new Iterator(src, { alwaysStat: true });\n iterator.forEach(\n (entry: Entry): void => {\n if (!entry.stats.isFile()) return;\n if (entry.basename[0] === '.') return;\n if (typeFileRegEx.test(entry.basename)) return;\n if (!matcher(entry.fullPath)) return;\n const ext = path.extname(entry.basename);\n if (ext && extensions.indexOf(ext) < 0) return;\n entries.push(entry);\n\n const stats = entry.stats as fs.Stats;\n if (stats.mode) {\n modeByPath.set(entry.fullPath, stats.mode);\n }\n },\n (err) => {\n if (err) return callback(err);\n const results = [];\n options = { ...options, tsconfig };\n\n const queue = new Queue();\n entries.forEach((entry: Entry) => {\n const mode = modeByPath.get(entry.fullPath);\n queue.defer((cb) =>\n transformFile(entry, dest, type, options, mode, (err, outPath) => {\n if (err) return cb(err);\n results.push(path.normalize(outPath));\n if (options.sourceMaps) results.push(`${path.normalize(outPath)}.map`);\n cb();\n })\n );\n });\n queue.await((err) => (err ? callback(err) : callback(null, results)));\n }\n );\n}\n"],"names":["Iterator","path","Queue","extensions","typeFileRegEx","createMatcher","transformFile","transformDirectoryWorker","src","dest","type","options","callback","tsconfig","matcher","entries","modeByPath","Map","iterator","alwaysStat","forEach","entry","stats","isFile","basename","test","fullPath","ext","extname","indexOf","push","mode","set","err","results","queue","get","defer","cb","outPath","normalize","sourceMaps","await"],"mappings":"AACA,OAAOA,cAA8B,cAAc;AACnD,OAAOC,UAAU,OAAO;AACxB,OAAOC,WAAW,WAAW;AAE7B,SAASC,UAAU,EAAEC,aAAa,QAAQ,kBAAkB;AAC5D,OAAOC,mBAAmB,sBAAsB;AAChD,OAAOC,mBAAmB,0BAA0B;AAIpD,eAAe,SAASC,yBAAyBC,GAAW,EAAEC,IAAY,EAAEC,IAAgB,EAAEC,OAAsB,EAAEC,QAAoC;IACxJ,MAAMC,WAAWF,QAAQE,QAAQ;IACjC,MAAMC,UAAUT,cAAcQ;IAE9B,MAAME,UAAmB,EAAE;IAC3B,MAAMC,aAAa,IAAIC;IACvB,MAAMC,WAAW,IAAIlB,SAASQ,KAAK;QAAEW,YAAY;IAAK;IACtDD,SAASE,OAAO,CACd,CAACC;QACC,IAAI,CAACA,MAAMC,KAAK,CAACC,MAAM,IAAI;QAC3B,IAAIF,MAAMG,QAAQ,CAAC,EAAE,KAAK,KAAK;QAC/B,IAAIpB,cAAcqB,IAAI,CAACJ,MAAMG,QAAQ,GAAG;QACxC,IAAI,CAACV,QAAQO,MAAMK,QAAQ,GAAG;QAC9B,MAAMC,MAAM1B,KAAK2B,OAAO,CAACP,MAAMG,QAAQ;QACvC,IAAIG,OAAOxB,WAAW0B,OAAO,CAACF,OAAO,GAAG;QACxCZ,QAAQe,IAAI,CAACT;QAEb,MAAMC,QAAQD,MAAMC,KAAK;QACzB,IAAIA,MAAMS,IAAI,EAAE;YACdf,WAAWgB,GAAG,CAACX,MAAMK,QAAQ,EAAEJ,MAAMS,IAAI;QAC3C;IACF,GACA,CAACE;QACC,IAAIA,KAAK,OAAOrB,SAASqB;QACzB,MAAMC,UAAU,EAAE;QAClBvB,UAAU;YAAE,GAAGA,OAAO;YAAEE;QAAS;QAEjC,MAAMsB,QAAQ,IAAIjC;QAClBa,QAAQK,OAAO,CAAC,CAACC;YACf,MAAMU,OAAOf,WAAWoB,GAAG,CAACf,MAAMK,QAAQ;YAC1CS,MAAME,KAAK,CAAC,CAACC,KACXhC,cAAce,OAAOZ,MAAMC,MAAMC,SAASoB,MAAM,CAACE,KAAKM;oBACpD,IAAIN,KAAK,OAAOK,GAAGL;oBACnBC,QAAQJ,IAAI,CAAC7B,KAAKuC,SAAS,CAACD;oBAC5B,IAAI5B,QAAQ8B,UAAU,EAAEP,QAAQJ,IAAI,CAAC,GAAG7B,KAAKuC,SAAS,CAACD,SAAS,IAAI,CAAC;oBACrED;gBACF;QAEJ;QACAH,MAAMO,KAAK,CAAC,CAACT,MAASA,MAAMrB,SAASqB,OAAOrB,SAAS,MAAMsB;IAC7D;AAEJ"}
|
|
@@ -1,8 +1,11 @@
|
|
|
1
|
+
var _ref;
|
|
2
|
+
var _os_cpus;
|
|
1
3
|
import fs from 'fs';
|
|
2
4
|
import Iterator from 'fs-iterator';
|
|
3
5
|
import Module from 'module';
|
|
4
|
-
import
|
|
6
|
+
import os from 'os';
|
|
5
7
|
import Queue from 'queue-cb';
|
|
8
|
+
const concurrency = Math.min(64, Math.max(8, ((_ref = (_os_cpus = os.cpus()) === null || _os_cpus === void 0 ? void 0 : _os_cpus.length) !== null && _ref !== void 0 ? _ref : 4) * 8));
|
|
6
9
|
const _require = typeof require === 'undefined' ? Module.createRequire(import.meta.url) : require;
|
|
7
10
|
import { stringEndsWith } from '../compat.js';
|
|
8
11
|
import { typeFileRegEx } from '../constants.js';
|
|
@@ -21,93 +24,59 @@ export default function transformTypesWorker(src, dest, options, callback) {
|
|
|
21
24
|
if (!matcher(entry.fullPath)) return;
|
|
22
25
|
entries.push(entry);
|
|
23
26
|
}, {
|
|
24
|
-
concurrency
|
|
27
|
+
concurrency
|
|
25
28
|
}, (err)=>{
|
|
26
29
|
if (err) return callback(err);
|
|
27
|
-
// Step
|
|
28
|
-
const
|
|
29
|
-
const
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
host,
|
|
62
|
-
configFileParsingDiagnostics: ts.getConfigFileParsingDiagnostics({
|
|
63
|
-
fileNames,
|
|
64
|
-
options
|
|
65
|
-
})
|
|
66
|
-
};
|
|
67
|
-
const program = ts.createProgram(programOptions);
|
|
68
|
-
const res = program.emit();
|
|
69
|
-
// Step 3: Post-process emitted files (async)
|
|
70
|
-
const postQueue = new Queue();
|
|
71
|
-
if (res.emittedFiles) {
|
|
72
|
-
res.emittedFiles.forEach((file)=>{
|
|
73
|
-
// 3a: Rewrite extensions (convert from sync to async)
|
|
74
|
-
// TODO: remove patch for https://github.com/microsoft/TypeScript/issues/61037
|
|
75
|
-
if (compilerOptions.options.rewriteRelativeImportExtensions) {
|
|
76
|
-
if (stringEndsWith(file, '.d.ts') || stringEndsWith(file, '.d.cts') || stringEndsWith(file, '.d.mts')) {
|
|
77
|
-
postQueue.defer((cb)=>{
|
|
78
|
-
fs.readFile(file, 'utf8', (readErr, content)=>{
|
|
79
|
-
if (readErr) return cb(); // Ignore errors, continue
|
|
80
|
-
const updated = rewriteExtensions(content);
|
|
81
|
-
if (updated !== content) {
|
|
82
|
-
fs.writeFile(file, updated, 'utf8', ()=>cb()); // Ignore write errors
|
|
83
|
-
} else {
|
|
84
|
-
cb();
|
|
85
|
-
}
|
|
86
|
-
});
|
|
87
|
-
});
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
// 3b: Apply executable permissions from source files
|
|
30
|
+
// Step 2: TypeScript emit (inherently sync - cannot change)
|
|
31
|
+
const compilerOptions = ts.convertCompilerOptionsFromJson(tsconfig.config.compilerOptions, '');
|
|
32
|
+
const config = {
|
|
33
|
+
fileNames: entries.map((entry)=>entry.fullPath),
|
|
34
|
+
options: {
|
|
35
|
+
...compilerOptions.options,
|
|
36
|
+
outDir: dest,
|
|
37
|
+
noEmit: false,
|
|
38
|
+
allowJs: true,
|
|
39
|
+
declaration: true,
|
|
40
|
+
emitDeclarationOnly: true,
|
|
41
|
+
listEmittedFiles: true
|
|
42
|
+
},
|
|
43
|
+
projectReferences: tsconfig.config.references
|
|
44
|
+
};
|
|
45
|
+
const { fileNames, options, projectReferences } = config;
|
|
46
|
+
const host = ts.createCompilerHostWorker(options, /*setParentNodes*/ undefined, ts.sys);
|
|
47
|
+
const programOptions = {
|
|
48
|
+
rootNames: fileNames,
|
|
49
|
+
options,
|
|
50
|
+
projectReferences,
|
|
51
|
+
host,
|
|
52
|
+
configFileParsingDiagnostics: ts.getConfigFileParsingDiagnostics({
|
|
53
|
+
fileNames,
|
|
54
|
+
options
|
|
55
|
+
})
|
|
56
|
+
};
|
|
57
|
+
const program = ts.createProgram(programOptions);
|
|
58
|
+
const res = program.emit();
|
|
59
|
+
// Step 3: Post-process emitted files (async)
|
|
60
|
+
const postQueue = new Queue();
|
|
61
|
+
if (res.emittedFiles) {
|
|
62
|
+
res.emittedFiles.forEach((file)=>{
|
|
63
|
+
if (compilerOptions.options.rewriteRelativeImportExtensions) {
|
|
91
64
|
if (stringEndsWith(file, '.d.ts') || stringEndsWith(file, '.d.cts') || stringEndsWith(file, '.d.mts')) {
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
postQueue.defer((cb)=>{
|
|
101
|
-
fs.chmod(file, 0o644 | execBits, ()=>cb()); // Ignore chmod errors
|
|
102
|
-
});
|
|
65
|
+
postQueue.defer((cb)=>{
|
|
66
|
+
fs.readFile(file, 'utf8', (readErr, content)=>{
|
|
67
|
+
if (readErr) return cb();
|
|
68
|
+
const updated = rewriteExtensions(content);
|
|
69
|
+
if (updated !== content) {
|
|
70
|
+
fs.writeFile(file, updated, 'utf8', ()=>cb());
|
|
71
|
+
} else {
|
|
72
|
+
cb();
|
|
103
73
|
}
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
}
|
|
74
|
+
});
|
|
75
|
+
});
|
|
107
76
|
}
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
|
|
77
|
+
}
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
postQueue.await(()=>callback(null, res.emittedFiles));
|
|
112
81
|
});
|
|
113
82
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/typescript/ts-swc-transform/src/workers/transformTypes.ts"],"sourcesContent":["import fs from 'fs';\nimport Iterator, { type Entry } from 'fs-iterator';\nimport Module from 'module';\nimport
|
|
1
|
+
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/typescript/ts-swc-transform/src/workers/transformTypes.ts"],"sourcesContent":["import fs from 'fs';\nimport Iterator, { type Entry } from 'fs-iterator';\nimport Module from 'module';\nimport os from 'os';\nimport Queue from 'queue-cb';\n\nconst concurrency = Math.min(64, Math.max(8, (os.cpus()?.length ?? 4) * 8));\n\nconst _require = typeof require === 'undefined' ? Module.createRequire(import.meta.url) : require;\n\nimport { stringEndsWith } from '../compat.ts';\nimport { typeFileRegEx } from '../constants.ts';\nimport createMatcher from '../createMatcher.ts';\nimport { rewriteExtensions } from '../lib/rewriteExtensions.ts';\n\nimport type { ConfigOptions, TransformTypesCallback } from '../types.ts';\n\nexport default function transformTypesWorker(src: string, dest: string, options: ConfigOptions, callback: TransformTypesCallback) {\n const tsconfig = options.tsconfig;\n const matcher = createMatcher(tsconfig);\n const ts = _require('typescript');\n\n const entries = [];\n const iterator = new Iterator(src);\n iterator.forEach(\n (entry: Entry): void => {\n if (!entry.stats.isFile()) return;\n if (entry.basename[0] === '.') return;\n if (typeFileRegEx.test(entry.basename)) return;\n if (!matcher(entry.fullPath)) return;\n entries.push(entry);\n },\n { concurrency },\n (err) => {\n if (err) return callback(err);\n\n // Step 2: TypeScript emit (inherently sync - cannot change)\n const compilerOptions = ts.convertCompilerOptionsFromJson(tsconfig.config.compilerOptions, '');\n const config = {\n fileNames: entries.map((entry) => entry.fullPath),\n options: {\n ...compilerOptions.options,\n outDir: dest,\n noEmit: false,\n allowJs: true,\n declaration: true,\n emitDeclarationOnly: true,\n listEmittedFiles: true,\n },\n projectReferences: tsconfig.config.references,\n };\n const { fileNames, options, projectReferences } = config;\n const host = ts.createCompilerHostWorker(options, /*setParentNodes*/ undefined, ts.sys);\n const programOptions = {\n rootNames: fileNames,\n options,\n projectReferences,\n host,\n configFileParsingDiagnostics: ts.getConfigFileParsingDiagnostics({ fileNames, options }),\n };\n const program = ts.createProgram(programOptions);\n const res = program.emit();\n\n // Step 3: Post-process emitted files (async)\n const postQueue = new Queue();\n\n if (res.emittedFiles) {\n res.emittedFiles.forEach((file) => {\n if (compilerOptions.options.rewriteRelativeImportExtensions) {\n if (stringEndsWith(file, '.d.ts') || stringEndsWith(file, '.d.cts') || stringEndsWith(file, '.d.mts')) {\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) {\n fs.writeFile(file, updated, 'utf8', () => cb());\n } else {\n cb();\n }\n });\n });\n }\n }\n });\n }\n\n postQueue.await(() => callback(null, res.emittedFiles));\n }\n );\n}\n"],"names":["os","fs","Iterator","Module","Queue","concurrency","Math","min","max","cpus","length","_require","require","createRequire","url","stringEndsWith","typeFileRegEx","createMatcher","rewriteExtensions","transformTypesWorker","src","dest","options","callback","tsconfig","matcher","ts","entries","iterator","forEach","entry","stats","isFile","basename","test","fullPath","push","err","compilerOptions","convertCompilerOptionsFromJson","config","fileNames","map","outDir","noEmit","allowJs","declaration","emitDeclarationOnly","listEmittedFiles","projectReferences","references","host","createCompilerHostWorker","undefined","sys","programOptions","rootNames","configFileParsingDiagnostics","getConfigFileParsingDiagnostics","program","createProgram","res","emit","postQueue","emittedFiles","file","rewriteRelativeImportExtensions","defer","cb","readFile","readErr","content","updated","writeFile","await"],"mappings":";IAM8CA;AAN9C,OAAOC,QAAQ,KAAK;AACpB,OAAOC,cAA8B,cAAc;AACnD,OAAOC,YAAY,SAAS;AAC5B,OAAOH,QAAQ,KAAK;AACpB,OAAOI,WAAW,WAAW;AAE7B,MAAMC,cAAcC,KAAKC,GAAG,CAAC,IAAID,KAAKE,GAAG,CAAC,GAAG,UAACR,WAAAA,GAAGS,IAAI,gBAAPT,+BAAAA,SAAWU,MAAM,uCAAI,KAAK;AAExE,MAAMC,WAAW,OAAOC,YAAY,cAAcT,OAAOU,aAAa,CAAC,YAAYC,GAAG,IAAIF;AAE1F,SAASG,cAAc,QAAQ,eAAe;AAC9C,SAASC,aAAa,QAAQ,kBAAkB;AAChD,OAAOC,mBAAmB,sBAAsB;AAChD,SAASC,iBAAiB,QAAQ,8BAA8B;AAIhE,eAAe,SAASC,qBAAqBC,GAAW,EAAEC,IAAY,EAAEC,OAAsB,EAAEC,QAAgC;IAC9H,MAAMC,WAAWF,QAAQE,QAAQ;IACjC,MAAMC,UAAUR,cAAcO;IAC9B,MAAME,KAAKf,SAAS;IAEpB,MAAMgB,UAAU,EAAE;IAClB,MAAMC,WAAW,IAAI1B,SAASkB;IAC9BQ,SAASC,OAAO,CACd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