ts-swc-transform 2.10.1 → 2.11.0
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/transformDirectory.js +4 -7
- package/dist/cjs/transformDirectory.js.map +1 -1
- package/dist/cjs/transformTypes.js +5 -8
- package/dist/cjs/transformTypes.js.map +1 -1
- package/dist/esm/transformDirectory.js +4 -7
- package/dist/esm/transformDirectory.js.map +1 -1
- package/dist/esm/transformTypes.js +7 -8
- package/dist/esm/transformTypes.js.map +1 -1
- package/package.json +1 -1
|
@@ -63,15 +63,12 @@ function transformDirectory(src, dest, type, options, callback) {
|
|
|
63
63
|
if (typeof src !== 'string') throw new Error('transformDirectory: unexpected source');
|
|
64
64
|
if (typeof dest !== 'string') throw new Error('transformDirectory: unexpected destination directory');
|
|
65
65
|
if (typeof type !== 'string') throw new Error('transformDirectory: unexpected type');
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
}
|
|
70
|
-
var baseOpts = options || {};
|
|
71
|
-
var tsconfig = baseOpts.tsconfig ? baseOpts.tsconfig : (0, _readtsconfigsync.default)(src);
|
|
66
|
+
callback = typeof options === 'function' ? options : callback;
|
|
67
|
+
options = typeof options === 'function' ? {} : options || {};
|
|
68
|
+
var tsconfig = options.tsconfig ? options.tsconfig : (0, _readtsconfigsync.default)(src);
|
|
72
69
|
var opts = _object_spread({
|
|
73
70
|
tsconfig: tsconfig
|
|
74
|
-
},
|
|
71
|
+
}, options);
|
|
75
72
|
if (typeof callback === 'function') return worker(src, dest, type, opts, callback);
|
|
76
73
|
return new Promise(function(resolve, reject) {
|
|
77
74
|
return worker(src, dest, type, opts, function(err, result) {
|
|
@@ -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
|
|
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) =>\n worker(src, dest, type, opts, (err, result) => {\n err ? reject(err) : resolve(result);\n })\n );\n } catch (err) {\n if (callback) callback(err);\n else 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,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,IAAgB,EAAEC,OAAsB,EAAEC,QAAoC;IACpH,OAAOjB,SAASU,YAAYG,KAAKC,MAAMC,MAAMC,SAASC;AACxD;AAEA,8DAA8D;AAC9D,IAAMC,SAASvB,SAAS,KAAKiB,MAAMO,IAAAA,qBAAI,EAAC,QAAQT,YAAY;IAAEU,WAAW;IAAMC,cAAc;AAAM;AAMpF,SAAS3B,mBAAmBmB,GAAW,EAAEC,IAAY,EAAEC,IAAgB,EAAEC,OAAoD,EAAEC,QAAqC;IACjL,IAAI;QACF,IAAI,OAAOJ,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,IAAMO,WAAWP,QAAQO,QAAQ,GAAGP,QAAQO,QAAQ,GAAGC,IAAAA,yBAAc,EAACX;QACtE,IAAMY,OAAsB;YAAEF,UAAAA;WAAaP;QAE3C,IAAI,OAAOC,aAAa,YAAY,OAAOC,OAAOL,KAAKC,MAAMC,MAAMU,MAAMR;QACzE,OAAO,IAAIS,QAAQ,SAACC,SAASC;mBAC3BV,OAAOL,KAAKC,MAAMC,MAAMU,MAAM,SAACI,KAAKC;gBAClCD,MAAMD,OAAOC,OAAOF,QAAQG;YAC9B;;IAEJ,EAAE,OAAOD,KAAK;QACZ,IAAIZ,UAAUA,SAASY;aAClB,OAAOH,QAAQE,MAAM,CAACC;IAC7B;AACF"}
|
|
@@ -62,19 +62,16 @@ function transformTypes(src, dest, options, callback) {
|
|
|
62
62
|
try {
|
|
63
63
|
if (typeof src !== 'string') throw new Error('transformTypes: unexpected source');
|
|
64
64
|
if (typeof dest !== 'string') throw new Error('transformTypes: unexpected destination directory');
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
}
|
|
69
|
-
var baseOpts = options || {};
|
|
70
|
-
var tsconfig = baseOpts.tsconfig ? baseOpts.tsconfig : (0, _readtsconfigsync.default)(src);
|
|
65
|
+
callback = typeof options === 'function' ? options : callback;
|
|
66
|
+
options = typeof options === 'function' ? {} : options || {};
|
|
67
|
+
var tsconfig = options.tsconfig ? options.tsconfig : (0, _readtsconfigsync.default)(src);
|
|
71
68
|
var opts = _object_spread({
|
|
72
69
|
tsconfig: tsconfig
|
|
73
|
-
},
|
|
70
|
+
}, options);
|
|
74
71
|
if (typeof callback === 'function') return worker(src, dest, opts, callback);
|
|
75
72
|
return new Promise(function(resolve, reject) {
|
|
76
73
|
return worker(src, dest, opts, function(err, result) {
|
|
77
|
-
|
|
74
|
+
err ? reject(err) : resolve(result);
|
|
78
75
|
});
|
|
79
76
|
});
|
|
80
77
|
} catch (err) {
|
|
@@ -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
|
|
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) =>\n worker(src, dest, opts, (err, result) => {\n err ? reject(err) : resolve(result);\n })\n );\n } catch (err) {\n if (callback) callback(err);\n else 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;mBAC3BV,OAAOJ,KAAKC,MAAMU,MAAM,SAACI,KAAKC;gBAC5BD,MAAMD,OAAOC,OAAOF,QAAQG;YAC9B;;IAEJ,EAAE,OAAOD,KAAK;QACZ,IAAIZ,UAAUA,SAASY;aAClB,OAAOH,QAAQE,MAAM,CAACC;IAC7B;AACF"}
|
|
@@ -20,15 +20,12 @@ export default function transformDirectory(src, dest, type, options, callback) {
|
|
|
20
20
|
if (typeof src !== 'string') throw new Error('transformDirectory: unexpected source');
|
|
21
21
|
if (typeof dest !== 'string') throw new Error('transformDirectory: unexpected destination directory');
|
|
22
22
|
if (typeof type !== 'string') throw new Error('transformDirectory: unexpected type');
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
}
|
|
27
|
-
const baseOpts = options || {};
|
|
28
|
-
const tsconfig = baseOpts.tsconfig ? baseOpts.tsconfig : loadConfigSync(src);
|
|
23
|
+
callback = typeof options === 'function' ? options : callback;
|
|
24
|
+
options = typeof options === 'function' ? {} : options || {};
|
|
25
|
+
const tsconfig = options.tsconfig ? options.tsconfig : loadConfigSync(src);
|
|
29
26
|
const opts = {
|
|
30
27
|
tsconfig,
|
|
31
|
-
...
|
|
28
|
+
...options
|
|
32
29
|
};
|
|
33
30
|
if (typeof callback === 'function') return worker(src, dest, type, opts, callback);
|
|
34
31
|
return new Promise((resolve, reject)=>worker(src, dest, type, opts, (err, result)=>{
|
|
@@ -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
|
|
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) =>\n worker(src, dest, type, opts, (err, result) => {\n err ? reject(err) : resolve(result);\n })\n );\n } catch (err) {\n if (callback) callback(err);\n else 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;QACF,IAAI,OAAOJ,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,GAAG3B,eAAeiB;QACtE,MAAMW,OAAsB;YAAED;YAAU,GAAGP,OAAO;QAAC;QAEnD,IAAI,OAAOC,aAAa,YAAY,OAAOC,OAAOL,KAAKC,MAAMC,MAAMS,MAAMP;QACzE,OAAO,IAAIQ,QAAQ,CAACC,SAASC,SAC3BT,OAAOL,KAAKC,MAAMC,MAAMS,MAAM,CAACI,KAAKC;gBAClCD,MAAMD,OAAOC,OAAOF,QAAQG;YAC9B;IAEJ,EAAE,OAAOD,KAAK;QACZ,IAAIX,UAAUA,SAASW;aAClB,OAAOH,QAAQE,MAAM,CAACC;IAC7B;AACF"}
|
|
@@ -19,18 +19,17 @@ export default function transformTypes(src, dest, options, callback) {
|
|
|
19
19
|
try {
|
|
20
20
|
if (typeof src !== 'string') throw new Error('transformTypes: unexpected source');
|
|
21
21
|
if (typeof dest !== 'string') throw new Error('transformTypes: unexpected destination directory');
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
}
|
|
26
|
-
const baseOpts = options || {};
|
|
27
|
-
const tsconfig = baseOpts.tsconfig ? baseOpts.tsconfig : loadConfigSync(src);
|
|
22
|
+
callback = typeof options === 'function' ? options : callback;
|
|
23
|
+
options = typeof options === 'function' ? {} : options || {};
|
|
24
|
+
const tsconfig = options.tsconfig ? options.tsconfig : loadConfigSync(src);
|
|
28
25
|
const opts = {
|
|
29
26
|
tsconfig,
|
|
30
|
-
...
|
|
27
|
+
...options
|
|
31
28
|
};
|
|
32
29
|
if (typeof callback === 'function') return worker(src, dest, opts, callback);
|
|
33
|
-
return new Promise((resolve, reject)=>worker(src, dest, opts, (err, result)=>
|
|
30
|
+
return new Promise((resolve, reject)=>worker(src, dest, opts, (err, result)=>{
|
|
31
|
+
err ? reject(err) : resolve(result);
|
|
32
|
+
}));
|
|
34
33
|
} catch (err) {
|
|
35
34
|
if (callback) callback(err);
|
|
36
35
|
else return Promise.reject(err);
|
|
@@ -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
|
|
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) =>\n worker(src, dest, opts, (err, result) => {\n err ? reject(err) : resolve(result);\n })\n );\n } catch (err) {\n if (callback) callback(err);\n else 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,SAC3BT,OAAOJ,KAAKC,MAAMS,MAAM,CAACI,KAAKC;gBAC5BD,MAAMD,OAAOC,OAAOF,QAAQG;YAC9B;IAEJ,EAAE,OAAOD,KAAK;QACZ,IAAIX,UAAUA,SAASW;aAClB,OAAOH,QAAQE,MAAM,CAACC;IAC7B;AACF"}
|