ts-swc-transform 1.12.1 → 1.12.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/constants.cjs +0 -6
- package/dist/cjs/constants.cjs.map +1 -1
- package/dist/cjs/lib/installBindings.cjs +2 -2
- package/dist/cjs/lib/installBindings.cjs.map +1 -1
- package/dist/cjs/transformDirectory.cjs +19 -4
- package/dist/cjs/transformDirectory.cjs.map +1 -1
- package/dist/cjs/transformSync.cjs +12 -4
- package/dist/cjs/transformSync.cjs.map +1 -1
- package/dist/cjs/transformTypes.cjs +19 -4
- package/dist/cjs/transformTypes.cjs.map +1 -1
- package/dist/cjs/workers/transformDirectory.cjs +2 -2
- package/dist/cjs/workers/transformDirectory.cjs.map +1 -1
- package/dist/cjs/workers/transformTypes.cjs +2 -2
- package/dist/cjs/workers/transformTypes.cjs.map +1 -1
- package/dist/esm/constants.mjs +0 -3
- package/dist/esm/constants.mjs.map +1 -1
- package/dist/esm/lib/installBindings.mjs +2 -2
- package/dist/esm/lib/installBindings.mjs.map +1 -1
- package/dist/esm/transformDirectory.mjs +19 -4
- package/dist/esm/transformDirectory.mjs.map +1 -1
- package/dist/esm/transformSync.mjs +12 -4
- package/dist/esm/transformSync.mjs.map +1 -1
- package/dist/esm/transformTypes.mjs +19 -4
- package/dist/esm/transformTypes.mjs.map +1 -1
- package/dist/esm/workers/transformDirectory.mjs +3 -3
- package/dist/esm/workers/transformDirectory.mjs.map +1 -1
- package/dist/esm/workers/transformTypes.mjs +3 -3
- package/dist/esm/workers/transformTypes.mjs.map +1 -1
- package/dist/types/constants.d.ts +0 -1
- package/package.json +1 -1
- package/dist/cjs/lib/wrapWorker.cjs +0 -66
- package/dist/cjs/lib/wrapWorker.cjs.map +0 -1
- package/dist/cjs/lib/wrapWorkerSync.cjs +0 -58
- package/dist/cjs/lib/wrapWorkerSync.cjs.map +0 -1
- package/dist/esm/lib/wrapWorker.mjs +0 -19
- package/dist/esm/lib/wrapWorker.mjs.map +0 -1
- package/dist/esm/lib/wrapWorkerSync.mjs +0 -11
- package/dist/esm/lib/wrapWorkerSync.mjs.map +0 -1
- package/dist/types/lib/wrapWorker.d.ts +0 -1
- package/dist/types/lib/wrapWorkerSync.d.ts +0 -1
package/dist/cjs/constants.cjs
CHANGED
|
@@ -9,9 +9,6 @@ function _export(target, all) {
|
|
|
9
9
|
});
|
|
10
10
|
}
|
|
11
11
|
_export(exports, {
|
|
12
|
-
SKIPS: function() {
|
|
13
|
-
return SKIPS;
|
|
14
|
-
},
|
|
15
12
|
extensions: function() {
|
|
16
13
|
return extensions;
|
|
17
14
|
},
|
|
@@ -52,7 +49,4 @@ var extensions = [
|
|
|
52
49
|
'.es6',
|
|
53
50
|
'.es'
|
|
54
51
|
];
|
|
55
|
-
var SKIPS = [
|
|
56
|
-
'.DS_Store'
|
|
57
|
-
];
|
|
58
52
|
/* 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/constants.ts"],"sourcesContent":["export const moduleRegEx = /^[^.\\/]|^\\.[^.\\/]|^\\.\\.[^\\/]/;\nexport const typeFileRegEx = /^[^.]+\\.d\\.[cm]?ts$/;\n\nexport const moduleDependencyRegEx = '\\\\s*[\\'\"`]([^\\'\"`]+)[\\'\"`]\\\\s*';\nexport const moduleNameRegEx = '\\\\s*(?:[\\\\w${},\\\\s*]+)\\\\s*';\nexport const requireRegEx = new RegExp(`(?:(?:var|const|let)${moduleNameRegEx}=\\\\s*)?require\\\\(${moduleDependencyRegEx}\\\\)?`, 'g');\nexport const importRegEx = new RegExp(`${requireRegEx}|import(?:${moduleNameRegEx}from\\\\s*)?${moduleDependencyRegEx};?|export(?:${moduleNameRegEx}from\\\\s*)?${moduleDependencyRegEx}?`, 'g');\nexport const extensions = ['.js', '.jsx', '.cjs', '.mjs', '.ts', '.tsx', '.cts', '.mts', '.es6', '.es'];\n
|
|
1
|
+
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/typescript/ts-swc-transform/src/constants.ts"],"sourcesContent":["export const moduleRegEx = /^[^.\\/]|^\\.[^.\\/]|^\\.\\.[^\\/]/;\nexport const typeFileRegEx = /^[^.]+\\.d\\.[cm]?ts$/;\n\nexport const moduleDependencyRegEx = '\\\\s*[\\'\"`]([^\\'\"`]+)[\\'\"`]\\\\s*';\nexport const moduleNameRegEx = '\\\\s*(?:[\\\\w${},\\\\s*]+)\\\\s*';\nexport const requireRegEx = new RegExp(`(?:(?:var|const|let)${moduleNameRegEx}=\\\\s*)?require\\\\(${moduleDependencyRegEx}\\\\)?`, 'g');\nexport const importRegEx = new RegExp(`${requireRegEx}|import(?:${moduleNameRegEx}from\\\\s*)?${moduleDependencyRegEx};?|export(?:${moduleNameRegEx}from\\\\s*)?${moduleDependencyRegEx}?`, 'g');\nexport const extensions = ['.js', '.jsx', '.cjs', '.mjs', '.ts', '.tsx', '.cts', '.mts', '.es6', '.es'];\n"],"names":["extensions","importRegEx","moduleDependencyRegEx","moduleNameRegEx","moduleRegEx","requireRegEx","typeFileRegEx","RegExp"],"mappings":";;;;;;;;;;;IAOaA,UAAU;eAAVA;;IADAC,WAAW;eAAXA;;IAHAC,qBAAqB;eAArBA;;IACAC,eAAe;eAAfA;;IAJAC,WAAW;eAAXA;;IAKAC,YAAY;eAAZA;;IAJAC,aAAa;eAAbA;;;AADN,IAAMF,cAAc;AACpB,IAAME,gBAAgB;AAEtB,IAAMJ,wBAAwB;AAC9B,IAAMC,kBAAkB;AACxB,IAAME,eAAe,IAAIE,OAAO,AAAC,uBAAyDL,OAAnCC,iBAAgB,qBAAyC,OAAtBD,uBAAsB,SAAO;AACvH,IAAMD,cAAc,IAAIM,OAAO,AAAC,GAA2BJ,OAAzBE,cAAa,cAAwCH,OAA5BC,iBAAgB,cAAgDA,OAApCD,uBAAsB,gBAA0CA,OAA5BC,iBAAgB,cAAkC,OAAtBD,uBAAsB,MAAI;AACjL,IAAMF,aAAa;IAAC;IAAO;IAAQ;IAAQ;IAAQ;IAAO;IAAQ;IAAQ;IAAQ;IAAQ;CAAM"}
|
|
@@ -73,9 +73,9 @@ var __dirname = _path.default.dirname(typeof __filename === 'undefined' ? _url.d
|
|
|
73
73
|
var workerPath = _path.default.resolve(__dirname, '..', '..', 'cjs', 'workers', 'installBindings.cjs');
|
|
74
74
|
var major = +process.versions.node.split('.')[0];
|
|
75
75
|
var version = major < 14 ? 'stable' : 'local';
|
|
76
|
-
var
|
|
76
|
+
var callLazy = (0, _lazycache.default)(_require)('node-version-call');
|
|
77
77
|
var install = (0, _lazycache.default)(function(target) {
|
|
78
|
-
return (0, _installBindings.isInstalled)(target) ? target :
|
|
78
|
+
return (0, _installBindings.isInstalled)(target) ? target : callLazy()({
|
|
79
79
|
version: version,
|
|
80
80
|
callbacks: true
|
|
81
81
|
}, workerPath, target);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/typescript/ts-swc-transform/src/lib/installBindings.ts"],"sourcesContent":["import installBindings, { isInstalled } from '../workers/installBindings';\nexport default installBindings;\n\nimport path from 'path';\nimport url from 'url';\n\nimport Module from 'module';\nimport lazy from 'lazy-cache';\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.resolve(__dirname, '..', '..', 'cjs', 'workers', 'installBindings.cjs');\nconst major = +process.versions.node.split('.')[0];\nconst version = major < 14 ? 'stable' : 'local';\n\nconst
|
|
1
|
+
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/typescript/ts-swc-transform/src/lib/installBindings.ts"],"sourcesContent":["import installBindings, { isInstalled } from '../workers/installBindings';\nexport default installBindings;\n\nimport path from 'path';\nimport url from 'url';\n\nimport Module from 'module';\nimport lazy from 'lazy-cache';\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.resolve(__dirname, '..', '..', 'cjs', 'workers', 'installBindings.cjs');\nconst major = +process.versions.node.split('.')[0];\nconst version = major < 14 ? 'stable' : 'local';\n\nconst callLazy = lazy(_require)('node-version-call');\nconst install = lazy((target) => {\n return isInstalled(target) ? target : callLazy()({ version, callbacks: true }, workerPath, target);\n});\n\nexport const sync = (target) => install(target)();\n"],"names":["sync","installBindings","_require","require","Module","createRequire","__dirname","path","dirname","__filename","url","fileURLToPath","workerPath","resolve","major","process","versions","node","split","version","callLazy","lazy","install","target","isInstalled","callbacks"],"mappings":";;;;;;;;;;;IACA,OAA+B;eAA/B;;IAkBaA,IAAI;eAAJA;;;uEAnBgC;2DAG5B;0DACD;6DAEG;gEACF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IANjB,WAAeC,wBAAe;AAO9B,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,OAAO,CAACP,WAAW,MAAM,MAAM,OAAO,WAAW;AACzE,IAAMQ,QAAQ,CAACC,QAAQC,QAAQ,CAACC,IAAI,CAACC,KAAK,CAAC,IAAI,CAAC,EAAE;AAClD,IAAMC,UAAUL,QAAQ,KAAK,WAAW;AAExC,IAAMM,WAAWC,IAAAA,kBAAI,EAACnB,UAAU;AAChC,IAAMoB,UAAUD,IAAAA,kBAAI,EAAC,SAACE;IACpB,OAAOC,IAAAA,4BAAW,EAACD,UAAUA,SAASH,WAAW;QAAED,SAAAA;QAASM,WAAW;IAAK,GAAGb,YAAYW;AAC7F;AAEO,IAAMvB,OAAO,SAACuB;WAAWD,QAAQC"}
|
|
@@ -18,7 +18,8 @@ Object.defineProperty(exports, /**
|
|
|
18
18
|
var _path = /*#__PURE__*/ _interop_require_default(require("path"));
|
|
19
19
|
var _url = /*#__PURE__*/ _interop_require_default(require("url"));
|
|
20
20
|
var _loadTsConfig = /*#__PURE__*/ _interop_require_default(require("./loadTsConfig.cjs"));
|
|
21
|
-
var
|
|
21
|
+
var _module = /*#__PURE__*/ _interop_require_default(require("module"));
|
|
22
|
+
var _lazycache = /*#__PURE__*/ _interop_require_default(require("lazy-cache"));
|
|
22
23
|
function _define_property(obj, key, value) {
|
|
23
24
|
if (key in obj) {
|
|
24
25
|
Object.defineProperty(obj, key, {
|
|
@@ -55,7 +56,21 @@ function _object_spread(target) {
|
|
|
55
56
|
var major = +process.versions.node.split('.')[0];
|
|
56
57
|
var version = major < 14 ? 'stable' : 'local';
|
|
57
58
|
var __dirname = _path.default.dirname(typeof __filename === 'undefined' ? _url.default.fileURLToPath(require("url").pathToFileURL(__filename).toString()) : __filename);
|
|
58
|
-
var
|
|
59
|
+
var workerPath = _path.default.resolve(__dirname, '..', 'cjs', 'workers', 'transformDirectory.cjs');
|
|
60
|
+
var _require = typeof require === 'undefined' ? _module.default.createRequire(require("url").pathToFileURL(__filename).toString()) : require;
|
|
61
|
+
var callLazy = (0, _lazycache.default)(_require)('node-version-call');
|
|
62
|
+
var workerLazy = (0, _lazycache.default)(_require)(workerPath);
|
|
63
|
+
function dispatch(version, src, dest, type, options, callback) {
|
|
64
|
+
if (version === 'local') return workerLazy()(src, dest, type, options, callback);
|
|
65
|
+
try {
|
|
66
|
+
callback(null, callLazy()({
|
|
67
|
+
version: version,
|
|
68
|
+
callbacks: true
|
|
69
|
+
}, workerPath, src, dest, type, options));
|
|
70
|
+
} catch (err) {
|
|
71
|
+
callback(err);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
59
74
|
function transformDirectory(src, dest, type, options, callback) {
|
|
60
75
|
try {
|
|
61
76
|
if (typeof src !== 'string') throw new Error('transformDirectory: unexpected source');
|
|
@@ -72,9 +87,9 @@ function transformDirectory(src, dest, type, options, callback) {
|
|
|
72
87
|
options = _object_spread({
|
|
73
88
|
tsconfig: tsconfig
|
|
74
89
|
}, options);
|
|
75
|
-
if (typeof callback === 'function') return
|
|
90
|
+
if (typeof callback === 'function') return dispatch(version, src, dest, type, options, callback);
|
|
76
91
|
return new Promise(function(resolve, reject) {
|
|
77
|
-
return
|
|
92
|
+
return dispatch(version, src, dest, type, options, function(err, result) {
|
|
78
93
|
return err ? reject(err) : resolve(result);
|
|
79
94
|
});
|
|
80
95
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/typescript/ts-swc-transform/src/transformDirectory.ts"],"sourcesContent":["import path from 'path';\nimport url from 'url';\nimport loadTsConfig from './loadTsConfig';\n\nconst major = +process.versions.node.split('.')[0];\nconst version = major < 14 ? 'stable' : 'local';\nconst __dirname = path.dirname(typeof __filename === 'undefined' ? url.fileURLToPath(import.meta.url) : __filename);\
|
|
1
|
+
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/typescript/ts-swc-transform/src/transformDirectory.ts"],"sourcesContent":["import path from 'path';\nimport url from 'url';\nimport loadTsConfig from './loadTsConfig';\n\nconst major = +process.versions.node.split('.')[0];\nconst version = major < 14 ? 'stable' : 'local';\nconst __dirname = path.dirname(typeof __filename === 'undefined' ? url.fileURLToPath(import.meta.url) : __filename);\nconst workerPath = path.resolve(__dirname, '..', 'cjs', 'workers', 'transformDirectory.cjs');\n\nimport Module from 'module';\nimport lazy from 'lazy-cache';\nconst _require = typeof require === 'undefined' ? Module.createRequire(import.meta.url) : require;\nconst callLazy = lazy(_require)('node-version-call');\nconst workerLazy = lazy(_require)(workerPath);\n\nfunction dispatch(version, src, dest, type, options, callback) {\n if (version === 'local') return workerLazy()(src, dest, type, options, callback);\n try {\n callback(null, callLazy()({ version, callbacks: true }, workerPath, src, dest, type, options));\n } catch (err) {\n callback(err);\n }\n}\n\nimport type { ConfigOptions, TransformDirectoryCallback } from './types';\n/**\n * @param {string} src The source directory to traverse.\n * @param {string} dest The output directory to write files to.\n * @param {string} type The type of transform ('esm' or 'cjs').\n * @param {{sourceMaps: boolean}} options Options to pass to swc.\n * @param {(err?: Error) =>} [callback] Optional callback. Uses promise if callback not provided.\n * @returns {void | Promise<any>} Optional promise if callback not provided.\n */\nexport default function transformDirectory(src: string, dest: string, type: string, options?: ConfigOptions | TransformDirectoryCallback, callback?: TransformDirectoryCallback): undefined | 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 if (typeof options === 'function') {\n callback = options as TransformDirectoryCallback;\n options = null;\n }\n options = options || {};\n const tsconfig = loadTsConfig({ cwd: src, ...options }, 'transformDirectory');\n options = { tsconfig, ...options };\n\n if (typeof callback === 'function') return dispatch(version, src, dest, type, options, callback);\n return new Promise((resolve, reject) => dispatch(version, src, dest, type, options, (err, result) => (err ? reject(err) : resolve(result))));\n } catch (err) {\n console.log(err);\n if (callback) callback(err);\n else return Promise.reject(err);\n }\n}\n"],"names":["transformDirectory","major","process","versions","node","split","version","__dirname","path","dirname","__filename","url","fileURLToPath","workerPath","resolve","_require","require","Module","createRequire","callLazy","lazy","workerLazy","dispatch","src","dest","type","options","callback","callbacks","err","Error","tsconfig","loadTsConfig","cwd","Promise","reject","result","console","log"],"mappings":";;;;+BAyBA;;;;;;;CAOC,GACD;;;eAAwBA;;;2DAjCP;0DACD;mEACS;6DAON;gEACF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AANjB,IAAMC,QAAQ,CAACC,QAAQC,QAAQ,CAACC,IAAI,CAACC,KAAK,CAAC,IAAI,CAAC,EAAE;AAClD,IAAMC,UAAUL,QAAQ,KAAK,WAAW;AACxC,IAAMM,YAAYC,aAAI,CAACC,OAAO,CAAC,OAAOC,eAAe,cAAcC,YAAG,CAACC,aAAa,CAAC,uDAAmBF;AACxG,IAAMG,aAAaL,aAAI,CAACM,OAAO,CAACP,WAAW,MAAM,OAAO,WAAW;AAInE,IAAMQ,WAAW,OAAOC,YAAY,cAAcC,eAAM,CAACC,aAAa,CAAC,uDAAmBF;AAC1F,IAAMG,WAAWC,IAAAA,kBAAI,EAACL,UAAU;AAChC,IAAMM,aAAaD,IAAAA,kBAAI,EAACL,UAAUF;AAElC,SAASS,SAAShB,OAAO,EAAEiB,GAAG,EAAEC,IAAI,EAAEC,IAAI,EAAEC,OAAO,EAAEC,QAAQ;IAC3D,IAAIrB,YAAY,SAAS,OAAOe,aAAaE,KAAKC,MAAMC,MAAMC,SAASC;IACvE,IAAI;QACFA,SAAS,MAAMR,WAAW;YAAEb,SAAAA;YAASsB,WAAW;QAAK,GAAGf,YAAYU,KAAKC,MAAMC,MAAMC;IACvF,EAAE,OAAOG,KAAK;QACZF,SAASE;IACX;AACF;AAWe,SAAS7B,mBAAmBuB,GAAW,EAAEC,IAAY,EAAEC,IAAY,EAAEC,OAAoD,EAAEC,QAAqC;IAC7K,IAAI;QACF,IAAI,OAAOJ,QAAQ,UAAU,MAAM,IAAIO,MAAM;QAC7C,IAAI,OAAON,SAAS,UAAU,MAAM,IAAIM,MAAM;QAC9C,IAAI,OAAOL,SAAS,UAAU,MAAM,IAAIK,MAAM;QAE9C,IAAI,OAAOJ,YAAY,YAAY;YACjCC,WAAWD;YACXA,UAAU;QACZ;QACAA,UAAUA,WAAW,CAAC;QACtB,IAAMK,WAAWC,IAAAA,qBAAY,EAAC;YAAEC,KAAKV;WAAQG,UAAW;QACxDA,UAAU;YAAEK,UAAAA;WAAaL;QAEzB,IAAI,OAAOC,aAAa,YAAY,OAAOL,SAAShB,SAASiB,KAAKC,MAAMC,MAAMC,SAASC;QACvF,OAAO,IAAIO,QAAQ,SAACpB,SAASqB;mBAAWb,SAAShB,SAASiB,KAAKC,MAAMC,MAAMC,SAAS,SAACG,KAAKO;uBAAYP,MAAMM,OAAON,OAAOf,QAAQsB;;;IACpI,EAAE,OAAOP,KAAK;QACZQ,QAAQC,GAAG,CAACT;QACZ,IAAIF,UAAUA,SAASE;aAClB,OAAOK,QAAQC,MAAM,CAACN;IAC7B;AACF"}
|
|
@@ -16,7 +16,8 @@ Object.defineProperty(exports, /**
|
|
|
16
16
|
var _path = /*#__PURE__*/ _interop_require_default(require("path"));
|
|
17
17
|
var _url = /*#__PURE__*/ _interop_require_default(require("url"));
|
|
18
18
|
var _gettsconfigcompat = /*#__PURE__*/ _interop_require_wildcard(require("get-tsconfig-compat"));
|
|
19
|
-
var
|
|
19
|
+
var _module = /*#__PURE__*/ _interop_require_default(require("module"));
|
|
20
|
+
var _lazycache = /*#__PURE__*/ _interop_require_default(require("lazy-cache"));
|
|
20
21
|
function _interop_require_default(obj) {
|
|
21
22
|
return obj && obj.__esModule ? obj : {
|
|
22
23
|
default: obj
|
|
@@ -63,14 +64,21 @@ function _interop_require_wildcard(obj, nodeInterop) {
|
|
|
63
64
|
}
|
|
64
65
|
return newObj;
|
|
65
66
|
}
|
|
66
|
-
var __dirname = _path.default.dirname(typeof __filename === 'undefined' ? _url.default.fileURLToPath(require("url").pathToFileURL(__filename).toString()) : __filename);
|
|
67
|
-
var workerWrapper = (0, _wrapWorkerSync.default)(_path.default.resolve(__dirname, '..', 'cjs', 'workers', 'transformSync.cjs'));
|
|
68
67
|
var major = +process.versions.node.split('.')[0];
|
|
69
68
|
var version = major < 14 ? 'stable' : 'local';
|
|
69
|
+
var __dirname = _path.default.dirname(typeof __filename === 'undefined' ? _url.default.fileURLToPath(require("url").pathToFileURL(__filename).toString()) : __filename);
|
|
70
|
+
var workerPath = _path.default.resolve(__dirname, '..', 'cjs', 'workers', 'transformSync.cjs');
|
|
71
|
+
var _require = typeof require === 'undefined' ? _module.default.createRequire(require("url").pathToFileURL(__filename).toString()) : require;
|
|
72
|
+
var callLazy = (0, _lazycache.default)(_require)('node-version-call');
|
|
73
|
+
var workerLazy = (0, _lazycache.default)(_require)(workerPath);
|
|
74
|
+
function dispatch(version, src, dest, options) {
|
|
75
|
+
if (version === 'local') return workerLazy()(src, dest, options);
|
|
76
|
+
return callLazy()(version, workerPath, src, dest, options);
|
|
77
|
+
}
|
|
70
78
|
function transformSync(contents, fileName, tsconfig) {
|
|
71
79
|
if (typeof contents !== 'string') throw new Error('transformTypes: unexpected contents');
|
|
72
80
|
if (typeof fileName !== 'string') throw new Error('transformTypes: unexpected fileName');
|
|
73
81
|
if (!tsconfig) tsconfig = _gettsconfigcompat.getTsconfig(process.cwd());
|
|
74
|
-
return
|
|
82
|
+
return dispatch(version, contents, fileName, tsconfig);
|
|
75
83
|
}
|
|
76
84
|
/* CJS INTEROP */ if (exports.__esModule && exports.default) { try { Object.defineProperty(exports.default, '__esModule', { value: true }); for (var key in exports) { exports.default[key] = exports[key]; } } catch (_) {}; module.exports = exports.default; }
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/typescript/ts-swc-transform/src/transformSync.ts"],"sourcesContent":["import path from 'path';\nimport url from 'url';\nimport * as getTS from 'get-tsconfig-compat';\n\
|
|
1
|
+
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/typescript/ts-swc-transform/src/transformSync.ts"],"sourcesContent":["import path from 'path';\nimport url from 'url';\nimport * as getTS from 'get-tsconfig-compat';\n\nconst major = +process.versions.node.split('.')[0];\nconst version = major < 14 ? 'stable' : 'local';\nconst __dirname = path.dirname(typeof __filename === 'undefined' ? url.fileURLToPath(import.meta.url) : __filename);\nconst workerPath = path.resolve(__dirname, '..', 'cjs', 'workers', 'transformSync.cjs');\n\nimport Module from 'module';\nimport lazy from 'lazy-cache';\nconst _require = typeof require === 'undefined' ? Module.createRequire(import.meta.url) : require;\nconst callLazy = lazy(_require)('node-version-call');\nconst workerLazy = lazy(_require)(workerPath);\n\nfunction dispatch(version, src, dest, options) {\n if (version === 'local') return workerLazy()(src, dest, options);\n return callLazy()(version, workerPath, src, dest, options);\n}\n\nimport type { Output } from '@swc/core';\nimport type { TsConfigResult } from 'get-tsconfig-compat';\n/**\n * @param {string} contents The file contents.\n * @param {string} fileName The filename.\n * @param {TsConfigResult} tsconfig The configuration.\n * @returns {{ code: string, map?: string }} Returns object with the transformed code and source map if option sourceMaps was provided.\n */\nexport default function transformSync(contents: string, fileName: string, tsconfig: TsConfigResult): Output {\n if (typeof contents !== 'string') throw new Error('transformTypes: unexpected contents');\n if (typeof fileName !== 'string') throw new Error('transformTypes: unexpected fileName');\n if (!tsconfig) tsconfig = getTS.getTsconfig(process.cwd());\n return dispatch(version, contents, fileName, tsconfig);\n}\n"],"names":["transformSync","major","process","versions","node","split","version","__dirname","path","dirname","__filename","url","fileURLToPath","workerPath","resolve","_require","require","Module","createRequire","callLazy","lazy","workerLazy","dispatch","src","dest","options","contents","fileName","tsconfig","Error","getTS","getTsconfig","cwd"],"mappings":";;;;+BAsBA;;;;;CAKC,GACD;;;eAAwBA;;;2DA5BP;0DACD;yEACO;6DAOJ;gEACF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AANjB,IAAMC,QAAQ,CAACC,QAAQC,QAAQ,CAACC,IAAI,CAACC,KAAK,CAAC,IAAI,CAAC,EAAE;AAClD,IAAMC,UAAUL,QAAQ,KAAK,WAAW;AACxC,IAAMM,YAAYC,aAAI,CAACC,OAAO,CAAC,OAAOC,eAAe,cAAcC,YAAG,CAACC,aAAa,CAAC,uDAAmBF;AACxG,IAAMG,aAAaL,aAAI,CAACM,OAAO,CAACP,WAAW,MAAM,OAAO,WAAW;AAInE,IAAMQ,WAAW,OAAOC,YAAY,cAAcC,eAAM,CAACC,aAAa,CAAC,uDAAmBF;AAC1F,IAAMG,WAAWC,IAAAA,kBAAI,EAACL,UAAU;AAChC,IAAMM,aAAaD,IAAAA,kBAAI,EAACL,UAAUF;AAElC,SAASS,SAAShB,OAAO,EAAEiB,GAAG,EAAEC,IAAI,EAAEC,OAAO;IAC3C,IAAInB,YAAY,SAAS,OAAOe,aAAaE,KAAKC,MAAMC;IACxD,OAAON,WAAWb,SAASO,YAAYU,KAAKC,MAAMC;AACpD;AAUe,SAASzB,cAAc0B,QAAgB,EAAEC,QAAgB,EAAEC,QAAwB;IAChG,IAAI,OAAOF,aAAa,UAAU,MAAM,IAAIG,MAAM;IAClD,IAAI,OAAOF,aAAa,UAAU,MAAM,IAAIE,MAAM;IAClD,IAAI,CAACD,UAAUA,WAAWE,mBAAMC,WAAW,CAAC7B,QAAQ8B,GAAG;IACvD,OAAOV,SAAShB,SAASoB,UAAUC,UAAUC;AAC/C"}
|
|
@@ -17,7 +17,8 @@ Object.defineProperty(exports, /**
|
|
|
17
17
|
var _path = /*#__PURE__*/ _interop_require_default(require("path"));
|
|
18
18
|
var _url = /*#__PURE__*/ _interop_require_default(require("url"));
|
|
19
19
|
var _loadTsConfig = /*#__PURE__*/ _interop_require_default(require("./loadTsConfig.cjs"));
|
|
20
|
-
var
|
|
20
|
+
var _module = /*#__PURE__*/ _interop_require_default(require("module"));
|
|
21
|
+
var _lazycache = /*#__PURE__*/ _interop_require_default(require("lazy-cache"));
|
|
21
22
|
function _define_property(obj, key, value) {
|
|
22
23
|
if (key in obj) {
|
|
23
24
|
Object.defineProperty(obj, key, {
|
|
@@ -54,7 +55,21 @@ function _object_spread(target) {
|
|
|
54
55
|
var major = +process.versions.node.split('.')[0];
|
|
55
56
|
var version = major < 14 ? 'stable' : 'local';
|
|
56
57
|
var __dirname = _path.default.dirname(typeof __filename === 'undefined' ? _url.default.fileURLToPath(require("url").pathToFileURL(__filename).toString()) : __filename);
|
|
57
|
-
var
|
|
58
|
+
var workerPath = _path.default.resolve(__dirname, '..', 'cjs', 'workers', 'transformTypes.cjs');
|
|
59
|
+
var _require = typeof require === 'undefined' ? _module.default.createRequire(require("url").pathToFileURL(__filename).toString()) : require;
|
|
60
|
+
var callLazy = (0, _lazycache.default)(_require)('node-version-call');
|
|
61
|
+
var workerLazy = (0, _lazycache.default)(_require)(workerPath);
|
|
62
|
+
function dispatch(version, src, dest, options, callback) {
|
|
63
|
+
if (version === 'local') return workerLazy()(src, dest, options, callback);
|
|
64
|
+
try {
|
|
65
|
+
callback(null, callLazy()({
|
|
66
|
+
version: version,
|
|
67
|
+
callbacks: true
|
|
68
|
+
}, workerPath, src, dest, options));
|
|
69
|
+
} catch (err) {
|
|
70
|
+
callback(err);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
58
73
|
function transformTypes(src, dest, options, callback) {
|
|
59
74
|
try {
|
|
60
75
|
if (typeof src !== 'string') throw new Error('transformTypes: unexpected source');
|
|
@@ -70,9 +85,9 @@ function transformTypes(src, dest, options, callback) {
|
|
|
70
85
|
options = _object_spread({
|
|
71
86
|
tsconfig: tsconfig
|
|
72
87
|
}, options);
|
|
73
|
-
if (typeof callback === 'function') return
|
|
88
|
+
if (typeof callback === 'function') return dispatch(version, src, dest, options, callback);
|
|
74
89
|
return new Promise(function(resolve, reject) {
|
|
75
|
-
return
|
|
90
|
+
return dispatch(version, src, dest, options, function(err, result) {
|
|
76
91
|
return err ? reject(err) : resolve(result);
|
|
77
92
|
});
|
|
78
93
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/typescript/ts-swc-transform/src/transformTypes.ts"],"sourcesContent":["import path from 'path';\nimport url from 'url';\nimport loadTsConfig from './loadTsConfig';\n\nconst major = +process.versions.node.split('.')[0];\nconst version = major < 14 ? 'stable' : 'local';\nconst __dirname = path.dirname(typeof __filename === 'undefined' ? url.fileURLToPath(import.meta.url) : __filename);\
|
|
1
|
+
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/typescript/ts-swc-transform/src/transformTypes.ts"],"sourcesContent":["import path from 'path';\nimport url from 'url';\nimport loadTsConfig from './loadTsConfig';\n\nconst major = +process.versions.node.split('.')[0];\nconst version = major < 14 ? 'stable' : 'local';\nconst __dirname = path.dirname(typeof __filename === 'undefined' ? url.fileURLToPath(import.meta.url) : __filename);\nconst workerPath = path.resolve(__dirname, '..', 'cjs', 'workers', 'transformTypes.cjs');\n\nimport Module from 'module';\nimport lazy from 'lazy-cache';\nconst _require = typeof require === 'undefined' ? Module.createRequire(import.meta.url) : require;\nconst callLazy = lazy(_require)('node-version-call');\nconst workerLazy = lazy(_require)(workerPath);\n\nfunction dispatch(version, src, dest, options, callback) {\n if (version === 'local') return workerLazy()(src, dest, options, callback);\n try {\n callback(null, callLazy()({ version, callbacks: true }, workerPath, src, dest, options));\n } catch (err) {\n callback(err);\n }\n}\n\nimport type { ConfigOptions, TransformTypesCallback } from './types';\n/**\n * @param {string} src The source directory to traverse.\n * @param {string} dest The output directory to write files to.\n * @param {{tsconfig: TsConfigResult}} options Options.\n * @param {(err?: Error) =>} [callback] Optional callback. Uses promise if callback not provided.\n * @returns {void | Promise<any>} Optional promise if callback not provided.\n */\nexport default function transformTypes(src: string, dest: string, options?: ConfigOptions | TransformTypesCallback, callback?: TransformTypesCallback): undefined | 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 if (typeof options === 'function') {\n callback = options as TransformTypesCallback;\n options = null;\n }\n options = options || {};\n const tsconfig = loadTsConfig({ cwd: src, ...options }, 'transformTypes');\n options = { tsconfig, ...options };\n\n if (typeof callback === 'function') return dispatch(version, src, dest, options, callback);\n return new Promise((resolve, reject) => dispatch(version, src, dest, options, (err, result) => (err ? reject(err) : resolve(result))));\n } catch (err) {\n console.log(err);\n if (callback) callback(err);\n else return Promise.reject(err);\n }\n}\n"],"names":["transformTypes","major","process","versions","node","split","version","__dirname","path","dirname","__filename","url","fileURLToPath","workerPath","resolve","_require","require","Module","createRequire","callLazy","lazy","workerLazy","dispatch","src","dest","options","callback","callbacks","err","Error","tsconfig","loadTsConfig","cwd","Promise","reject","result","console","log"],"mappings":";;;;+BAyBA;;;;;;CAMC,GACD;;;eAAwBA;;;2DAhCP;0DACD;mEACS;6DAON;gEACF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AANjB,IAAMC,QAAQ,CAACC,QAAQC,QAAQ,CAACC,IAAI,CAACC,KAAK,CAAC,IAAI,CAAC,EAAE;AAClD,IAAMC,UAAUL,QAAQ,KAAK,WAAW;AACxC,IAAMM,YAAYC,aAAI,CAACC,OAAO,CAAC,OAAOC,eAAe,cAAcC,YAAG,CAACC,aAAa,CAAC,uDAAmBF;AACxG,IAAMG,aAAaL,aAAI,CAACM,OAAO,CAACP,WAAW,MAAM,OAAO,WAAW;AAInE,IAAMQ,WAAW,OAAOC,YAAY,cAAcC,eAAM,CAACC,aAAa,CAAC,uDAAmBF;AAC1F,IAAMG,WAAWC,IAAAA,kBAAI,EAACL,UAAU;AAChC,IAAMM,aAAaD,IAAAA,kBAAI,EAACL,UAAUF;AAElC,SAASS,SAAShB,OAAO,EAAEiB,GAAG,EAAEC,IAAI,EAAEC,OAAO,EAAEC,QAAQ;IACrD,IAAIpB,YAAY,SAAS,OAAOe,aAAaE,KAAKC,MAAMC,SAASC;IACjE,IAAI;QACFA,SAAS,MAAMP,WAAW;YAAEb,SAAAA;YAASqB,WAAW;QAAK,GAAGd,YAAYU,KAAKC,MAAMC;IACjF,EAAE,OAAOG,KAAK;QACZF,SAASE;IACX;AACF;AAUe,SAAS5B,eAAeuB,GAAW,EAAEC,IAAY,EAAEC,OAAgD,EAAEC,QAAiC;IACnJ,IAAI;QACF,IAAI,OAAOH,QAAQ,UAAU,MAAM,IAAIM,MAAM;QAC7C,IAAI,OAAOL,SAAS,UAAU,MAAM,IAAIK,MAAM;QAE9C,IAAI,OAAOJ,YAAY,YAAY;YACjCC,WAAWD;YACXA,UAAU;QACZ;QACAA,UAAUA,WAAW,CAAC;QACtB,IAAMK,WAAWC,IAAAA,qBAAY,EAAC;YAAEC,KAAKT;WAAQE,UAAW;QACxDA,UAAU;YAAEK,UAAAA;WAAaL;QAEzB,IAAI,OAAOC,aAAa,YAAY,OAAOJ,SAAShB,SAASiB,KAAKC,MAAMC,SAASC;QACjF,OAAO,IAAIO,QAAQ,SAACnB,SAASoB;mBAAWZ,SAAShB,SAASiB,KAAKC,MAAMC,SAAS,SAACG,KAAKO;uBAAYP,MAAMM,OAAON,OAAOd,QAAQqB;;;IAC9H,EAAE,OAAOP,KAAK;QACZQ,QAAQC,GAAG,CAACT;QACZ,IAAIF,UAAUA,SAASE;aAClB,OAAOK,QAAQC,MAAM,CAACN;IAC7B;AACF"}
|
|
@@ -86,9 +86,9 @@ function transformDirectoryWorker(src, dest, type, options, callback) {
|
|
|
86
86
|
var iterator = new _fsiterator.default(src);
|
|
87
87
|
iterator.forEach(function(entry) {
|
|
88
88
|
if (!entry.stats.isFile()) return;
|
|
89
|
-
if (
|
|
89
|
+
if (entry.basename[0] === '.') return;
|
|
90
90
|
if (_constants.typeFileRegEx.test(entry.basename)) return;
|
|
91
|
-
if (
|
|
91
|
+
if (!matcher(entry.fullPath)) return;
|
|
92
92
|
var ext = _path.default.extname(entry.basename);
|
|
93
93
|
if (ext && _constants.extensions.indexOf(ext) < 0) return;
|
|
94
94
|
entries.push(entry);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/typescript/ts-swc-transform/src/workers/transformDirectory.ts"],"sourcesContent":["import path from 'path';\nimport Iterator from 'fs-iterator';\nimport Queue from 'queue-cb';\nimport rimraf2 from 'rimraf2';\n\nimport {
|
|
1
|
+
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/typescript/ts-swc-transform/src/workers/transformDirectory.ts"],"sourcesContent":["import path from 'path';\nimport Iterator from 'fs-iterator';\nimport Queue from 'queue-cb';\nimport rimraf2 from 'rimraf2';\n\nimport { extensions, typeFileRegEx } from '../constants';\nimport createMatcher from '../createMatcher';\nimport installBindings from '../lib/installBindings';\nimport transformFile from '../lib/transformFile';\n\nconst target = `${process.platform}-${process.arch}`;\n\nexport default function transformDirectoryWorker(src, dest, type, options, callback) {\n const tsconfig = options.tsconfig;\n const matcher = createMatcher(tsconfig);\n\n installBindings(target, (err) => {\n if (err) return callback(err);\n\n rimraf2(dest, { disableGlob: true }, () => {\n const entries = [];\n const iterator = new Iterator(src);\n iterator.forEach(\n (entry) => {\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, src, dest };\n\n const queue = new Queue();\n entries.forEach((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 });\n}\n"],"names":["transformDirectoryWorker","target","process","platform","arch","src","dest","type","options","callback","tsconfig","matcher","createMatcher","installBindings","err","rimraf2","disableGlob","entries","iterator","Iterator","forEach","entry","stats","isFile","basename","typeFileRegEx","test","fullPath","ext","path","extname","extensions","indexOf","push","results","queue","Queue","defer","cb","transformFile","outPath","normalize","sourceMaps","await"],"mappings":";;;;+BAYA;;;eAAwBA;;;2DAZP;iEACI;8DACH;8DACE;yBAEsB;oEAChB;sEACE;oEACF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAE1B,IAAMC,SAAS,AAAC,GAAsBC,OAApBA,QAAQC,QAAQ,EAAC,KAAgB,OAAbD,QAAQE,IAAI;AAEnC,SAASJ,yBAAyBK,GAAG,EAAEC,IAAI,EAAEC,IAAI,EAAEC,OAAO,EAAEC,QAAQ;IACjF,IAAMC,WAAWF,QAAQE,QAAQ;IACjC,IAAMC,UAAUC,IAAAA,sBAAa,EAACF;IAE9BG,IAAAA,wBAAe,EAACZ,QAAQ,SAACa;QACvB,IAAIA,KAAK,OAAOL,SAASK;QAEzBC,IAAAA,gBAAO,EAACT,MAAM;YAAEU,aAAa;QAAK,GAAG;YACnC,IAAMC,UAAU,EAAE;YAClB,IAAMC,WAAW,IAAIC,mBAAQ,CAACd;YAC9Ba,SAASE,OAAO,CACd,SAACC;gBACC,IAAI,CAACA,MAAMC,KAAK,CAACC,MAAM,IAAI;gBAC3B,IAAIF,MAAMG,QAAQ,CAAC,EAAE,KAAK,KAAK;gBAC/B,IAAIC,wBAAa,CAACC,IAAI,CAACL,MAAMG,QAAQ,GAAG;gBACxC,IAAI,CAACb,QAAQU,MAAMM,QAAQ,GAAG;gBAC9B,IAAMC,MAAMC,aAAI,CAACC,OAAO,CAACT,MAAMG,QAAQ;gBACvC,IAAII,OAAOG,qBAAU,CAACC,OAAO,CAACJ,OAAO,GAAG;gBACxCX,QAAQgB,IAAI,CAACZ;YACf,GACA,SAACP;gBACC,IAAIA,KAAK,OAAOL,SAASK;gBACzB,IAAMoB,UAAU,EAAE;gBAClB1B,UAAU,wCAAKA;oBAASE,UAAAA;oBAAUL,KAAAA;oBAAKC,MAAAA;;gBAEvC,IAAM6B,QAAQ,IAAIC,gBAAK;gBACvBnB,QAAQG,OAAO,CAAC,SAACC;oBACfc,MAAME,KAAK,CAAC,SAACC;+BACXC,IAAAA,sBAAa,EAAClB,OAAOf,MAAMC,MAAMC,SAAS,SAACM,KAAK0B;4BAC9C,IAAI1B,KAAK,OAAOwB,GAAGxB;4BACnBoB,QAAQD,IAAI,CAACJ,aAAI,CAACY,SAAS,CAACD;4BAC5B,IAAIhC,QAAQkC,UAAU,EAAER,QAAQD,IAAI,CAAC,AAAC,GAA0B,OAAxBJ,aAAI,CAACY,SAAS,CAACD,UAAS;4BAChEF;wBACF;;gBAEJ;gBACAH,MAAMQ,KAAK,CAAC,SAAC7B;2BAASA,MAAML,SAASK,OAAOL,SAAS,MAAMyB;;YAC7D;QAEJ;IACF;AACF"}
|
|
@@ -83,9 +83,9 @@ function transformTypesWorker(src, dest, options, callback) {
|
|
|
83
83
|
var iterator = new _fsiterator.default(src);
|
|
84
84
|
iterator.forEach(function(entry) {
|
|
85
85
|
if (!entry.stats.isFile()) return;
|
|
86
|
-
if (
|
|
86
|
+
if (entry.basename[0] === '.') return;
|
|
87
87
|
if (_constants.typeFileRegEx.test(entry.basename)) return;
|
|
88
|
-
if (
|
|
88
|
+
if (!matcher(entry.fullPath)) return;
|
|
89
89
|
entries.push(entry);
|
|
90
90
|
}, {
|
|
91
91
|
concurrency: Infinity
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/typescript/ts-swc-transform/src/workers/transformTypes.ts"],"sourcesContent":["import Iterator from 'fs-iterator';\nimport rimraf2 from 'rimraf2';\n\nimport Module from 'module';\nimport lazy from 'lazy-cache';\nconst _require = typeof require === 'undefined' ? Module.createRequire(import.meta.url) : require;\nconst tsLazy = lazy(_require)('typescript');\n\nimport {
|
|
1
|
+
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/typescript/ts-swc-transform/src/workers/transformTypes.ts"],"sourcesContent":["import Iterator from 'fs-iterator';\nimport rimraf2 from 'rimraf2';\n\nimport Module from 'module';\nimport lazy from 'lazy-cache';\nconst _require = typeof require === 'undefined' ? Module.createRequire(import.meta.url) : require;\nconst tsLazy = lazy(_require)('typescript');\n\nimport { typeFileRegEx } from '../constants';\nimport createMatcher from '../createMatcher';\n\nexport default function transformTypesWorker(src, dest, options, callback) {\n const tsconfig = options.tsconfig;\n const matcher = createMatcher(tsconfig);\n\n rimraf2(dest, { disableGlob: true }, () => {\n const entries = [];\n const iterator = new Iterator(src);\n iterator.forEach(\n (entry) => {\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: Infinity },\n (err) => {\n if (err) return callback(err);\n\n const ts = tsLazy();\n const config = {\n fileNames: entries.map((entry) => entry.fullPath),\n options: {\n ...(tsconfig.compilerOptions || {}),\n outDir: dest,\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 callback(null, res.emittedFiles);\n }\n );\n });\n}\n"],"names":["transformTypesWorker","_require","require","Module","createRequire","tsLazy","lazy","src","dest","options","callback","tsconfig","matcher","createMatcher","rimraf2","disableGlob","entries","iterator","Iterator","forEach","entry","stats","isFile","basename","typeFileRegEx","test","fullPath","push","concurrency","Infinity","err","ts","config","fileNames","map","compilerOptions","outDir","allowJs","declaration","emitDeclarationOnly","listEmittedFiles","projectReferences","references","host","createCompilerHostWorker","undefined","sys","programOptions","rootNames","configFileParsingDiagnostics","getConfigFileParsingDiagnostics","program","createProgram","res","emit","emittedFiles"],"mappings":";;;;+BAWA;;;eAAwBA;;;iEAXH;8DACD;6DAED;gEACF;yBAIa;oEACJ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAJ1B,IAAMC,WAAW,OAAOC,YAAY,cAAcC,eAAM,CAACC,aAAa,CAAC,uDAAmBF;AAC1F,IAAMG,SAASC,IAAAA,kBAAI,EAACL,UAAU;AAKf,SAASD,qBAAqBO,GAAG,EAAEC,IAAI,EAAEC,OAAO,EAAEC,QAAQ;IACvE,IAAMC,WAAWF,QAAQE,QAAQ;IACjC,IAAMC,UAAUC,IAAAA,sBAAa,EAACF;IAE9BG,IAAAA,gBAAO,EAACN,MAAM;QAAEO,aAAa;IAAK,GAAG;QACnC,IAAMC,UAAU,EAAE;QAClB,IAAMC,WAAW,IAAIC,mBAAQ,CAACX;QAC9BU,SAASE,OAAO,CACd,SAACC;YACC,IAAI,CAACA,MAAMC,KAAK,CAACC,MAAM,IAAI;YAC3B,IAAIF,MAAMG,QAAQ,CAAC,EAAE,KAAK,KAAK;YAC/B,IAAIC,wBAAa,CAACC,IAAI,CAACL,MAAMG,QAAQ,GAAG;YACxC,IAAI,CAACX,QAAQQ,MAAMM,QAAQ,GAAG;YAC9BV,QAAQW,IAAI,CAACP;QACf,GACA;YAAEQ,aAAaC;QAAS,GACxB,SAACC;YACC,IAAIA,KAAK,OAAOpB,SAASoB;YAEzB,IAAMC,KAAK1B;YACX,IAAM2B,SAAS;gBACbC,WAAWjB,QAAQkB,GAAG,CAAC,SAACd;2BAAUA,MAAMM,QAAQ;;gBAChDjB,SAAS,wCACHE,SAASwB,eAAe,IAAI,CAAC;oBACjCC,QAAQ5B;oBACR6B,SAAS;oBACTC,aAAa;oBACbC,qBAAqB;oBACrBC,kBAAkB;;gBAEpBC,mBAAmB9B,SAASqB,MAAM,CAACU,UAAU;YAC/C;YACA,IAAQT,YAA0CD,OAA1CC,WAAWxB,YAA+BuB,OAA/BvB,SAASgC,oBAAsBT,OAAtBS;YAC5B,IAAME,OAAOZ,GAAGa,wBAAwB,CAACnC,WAAS,gBAAgB,GAAGoC,WAAWd,GAAGe,GAAG;YACtF,IAAMC,iBAAiB;gBACrBC,WAAWf;gBACXxB,SAAAA;gBACAgC,mBAAAA;gBACAE,MAAAA;gBACAM,8BAA8BlB,GAAGmB,+BAA+B,CAAC;oBAAEjB,WAAAA;oBAAWxB,SAAAA;gBAAQ;YACxF;YACA,IAAM0C,UAAUpB,GAAGqB,aAAa,CAACL;YACjC,IAAMM,MAAMF,QAAQG,IAAI;YACxB5C,SAAS,MAAM2C,IAAIE,YAAY;QACjC;IAEJ;AACF"}
|
package/dist/esm/constants.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/typescript/ts-swc-transform/src/constants.ts"],"sourcesContent":["export const moduleRegEx = /^[^.\\/]|^\\.[^.\\/]|^\\.\\.[^\\/]/;\nexport const typeFileRegEx = /^[^.]+\\.d\\.[cm]?ts$/;\n\nexport const moduleDependencyRegEx = '\\\\s*[\\'\"`]([^\\'\"`]+)[\\'\"`]\\\\s*';\nexport const moduleNameRegEx = '\\\\s*(?:[\\\\w${},\\\\s*]+)\\\\s*';\nexport const requireRegEx = new RegExp(`(?:(?:var|const|let)${moduleNameRegEx}=\\\\s*)?require\\\\(${moduleDependencyRegEx}\\\\)?`, 'g');\nexport const importRegEx = new RegExp(`${requireRegEx}|import(?:${moduleNameRegEx}from\\\\s*)?${moduleDependencyRegEx};?|export(?:${moduleNameRegEx}from\\\\s*)?${moduleDependencyRegEx}?`, 'g');\nexport const extensions = ['.js', '.jsx', '.cjs', '.mjs', '.ts', '.tsx', '.cts', '.mts', '.es6', '.es'];\n
|
|
1
|
+
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/typescript/ts-swc-transform/src/constants.ts"],"sourcesContent":["export const moduleRegEx = /^[^.\\/]|^\\.[^.\\/]|^\\.\\.[^\\/]/;\nexport const typeFileRegEx = /^[^.]+\\.d\\.[cm]?ts$/;\n\nexport const moduleDependencyRegEx = '\\\\s*[\\'\"`]([^\\'\"`]+)[\\'\"`]\\\\s*';\nexport const moduleNameRegEx = '\\\\s*(?:[\\\\w${},\\\\s*]+)\\\\s*';\nexport const requireRegEx = new RegExp(`(?:(?:var|const|let)${moduleNameRegEx}=\\\\s*)?require\\\\(${moduleDependencyRegEx}\\\\)?`, 'g');\nexport const importRegEx = new RegExp(`${requireRegEx}|import(?:${moduleNameRegEx}from\\\\s*)?${moduleDependencyRegEx};?|export(?:${moduleNameRegEx}from\\\\s*)?${moduleDependencyRegEx}?`, 'g');\nexport const extensions = ['.js', '.jsx', '.cjs', '.mjs', '.ts', '.tsx', '.cts', '.mts', '.es6', '.es'];\n"],"names":["moduleRegEx","typeFileRegEx","moduleDependencyRegEx","moduleNameRegEx","requireRegEx","RegExp","importRegEx","extensions"],"mappings":"AAAA,OAAO,MAAMA,cAAc,+BAA+B;AAC1D,OAAO,MAAMC,gBAAgB,sBAAsB;AAEnD,OAAO,MAAMC,wBAAwB,iCAAiC;AACtE,OAAO,MAAMC,kBAAkB,6BAA6B;AAC5D,OAAO,MAAMC,eAAe,IAAIC,OAAO,CAAC,oBAAoB,EAAEF,gBAAgB,iBAAiB,EAAED,sBAAsB,IAAI,CAAC,EAAE,KAAK;AACnI,OAAO,MAAMI,cAAc,IAAID,OAAO,GAAGD,aAAa,UAAU,EAAED,gBAAgB,UAAU,EAAED,sBAAsB,YAAY,EAAEC,gBAAgB,UAAU,EAAED,sBAAsB,CAAC,CAAC,EAAE,KAAK;AAC7L,OAAO,MAAMK,aAAa;IAAC;IAAO;IAAQ;IAAQ;IAAQ;IAAO;IAAQ;IAAQ;IAAQ;IAAQ;CAAM,CAAC"}
|
|
@@ -9,9 +9,9 @@ const __dirname = path.dirname(typeof __filename === 'undefined' ? url.fileURLTo
|
|
|
9
9
|
const workerPath = path.resolve(__dirname, '..', '..', 'cjs', 'workers', 'installBindings.cjs');
|
|
10
10
|
const major = +process.versions.node.split('.')[0];
|
|
11
11
|
const version = major < 14 ? 'stable' : 'local';
|
|
12
|
-
const
|
|
12
|
+
const callLazy = lazy(_require)('node-version-call');
|
|
13
13
|
const install = lazy((target)=>{
|
|
14
|
-
return isInstalled(target) ? target :
|
|
14
|
+
return isInstalled(target) ? target : callLazy()({
|
|
15
15
|
version,
|
|
16
16
|
callbacks: true
|
|
17
17
|
}, workerPath, target);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/typescript/ts-swc-transform/src/lib/installBindings.ts"],"sourcesContent":["import installBindings, { isInstalled } from '../workers/installBindings';\nexport default installBindings;\n\nimport path from 'path';\nimport url from 'url';\n\nimport Module from 'module';\nimport lazy from 'lazy-cache';\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.resolve(__dirname, '..', '..', 'cjs', 'workers', 'installBindings.cjs');\nconst major = +process.versions.node.split('.')[0];\nconst version = major < 14 ? 'stable' : 'local';\n\nconst
|
|
1
|
+
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/typescript/ts-swc-transform/src/lib/installBindings.ts"],"sourcesContent":["import installBindings, { isInstalled } from '../workers/installBindings';\nexport default installBindings;\n\nimport path from 'path';\nimport url from 'url';\n\nimport Module from 'module';\nimport lazy from 'lazy-cache';\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.resolve(__dirname, '..', '..', 'cjs', 'workers', 'installBindings.cjs');\nconst major = +process.versions.node.split('.')[0];\nconst version = major < 14 ? 'stable' : 'local';\n\nconst callLazy = lazy(_require)('node-version-call');\nconst install = lazy((target) => {\n return isInstalled(target) ? target : callLazy()({ version, callbacks: true }, workerPath, target);\n});\n\nexport const sync = (target) => install(target)();\n"],"names":["installBindings","isInstalled","path","url","Module","lazy","_require","require","createRequire","__dirname","dirname","__filename","fileURLToPath","workerPath","resolve","major","process","versions","node","split","version","callLazy","install","target","callbacks","sync"],"mappings":"AAAA,OAAOA,mBAAmBC,WAAW,QAAQ,6BAA6B;AAC1E,eAAeD,gBAAgB;AAE/B,OAAOE,UAAU,OAAO;AACxB,OAAOC,SAAS,MAAM;AAEtB,OAAOC,YAAY,SAAS;AAC5B,OAAOC,UAAU,aAAa;AAC9B,MAAMC,WAAW,OAAOC,YAAY,cAAcH,OAAOI,aAAa,CAAC,YAAYL,GAAG,IAAII;AAC1F,MAAME,YAAYP,KAAKQ,OAAO,CAAC,OAAOC,eAAe,cAAcR,IAAIS,aAAa,CAAC,YAAYT,GAAG,IAAIQ;AACxG,MAAME,aAAaX,KAAKY,OAAO,CAACL,WAAW,MAAM,MAAM,OAAO,WAAW;AACzE,MAAMM,QAAQ,CAACC,QAAQC,QAAQ,CAACC,IAAI,CAACC,KAAK,CAAC,IAAI,CAAC,EAAE;AAClD,MAAMC,UAAUL,QAAQ,KAAK,WAAW;AAExC,MAAMM,WAAWhB,KAAKC,UAAU;AAChC,MAAMgB,UAAUjB,KAAK,CAACkB;IACpB,OAAOtB,YAAYsB,UAAUA,SAASF,WAAW;QAAED;QAASI,WAAW;IAAK,GAAGX,YAAYU;AAC7F;AAEA,OAAO,MAAME,OAAO,CAACF,SAAWD,QAAQC,UAAU"}
|
|
@@ -4,8 +4,23 @@ import loadTsConfig from './loadTsConfig.mjs';
|
|
|
4
4
|
const major = +process.versions.node.split('.')[0];
|
|
5
5
|
const version = major < 14 ? 'stable' : 'local';
|
|
6
6
|
const __dirname = path.dirname(typeof __filename === 'undefined' ? url.fileURLToPath(import.meta.url) : __filename);
|
|
7
|
-
|
|
8
|
-
|
|
7
|
+
const workerPath = path.resolve(__dirname, '..', 'cjs', 'workers', 'transformDirectory.cjs');
|
|
8
|
+
import Module from 'module';
|
|
9
|
+
import lazy from 'lazy-cache';
|
|
10
|
+
const _require = typeof require === 'undefined' ? Module.createRequire(import.meta.url) : require;
|
|
11
|
+
const callLazy = lazy(_require)('node-version-call');
|
|
12
|
+
const workerLazy = lazy(_require)(workerPath);
|
|
13
|
+
function dispatch(version, src, dest, type, options, callback) {
|
|
14
|
+
if (version === 'local') return workerLazy()(src, dest, type, options, callback);
|
|
15
|
+
try {
|
|
16
|
+
callback(null, callLazy()({
|
|
17
|
+
version,
|
|
18
|
+
callbacks: true
|
|
19
|
+
}, workerPath, src, dest, type, options));
|
|
20
|
+
} catch (err) {
|
|
21
|
+
callback(err);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
9
24
|
/**
|
|
10
25
|
* @param {string} src The source directory to traverse.
|
|
11
26
|
* @param {string} dest The output directory to write files to.
|
|
@@ -31,8 +46,8 @@ const workerWrapper = wrapWorker(path.resolve(__dirname, '..', 'cjs', 'workers',
|
|
|
31
46
|
tsconfig,
|
|
32
47
|
...options
|
|
33
48
|
};
|
|
34
|
-
if (typeof callback === 'function') return
|
|
35
|
-
return new Promise((resolve, reject)=>
|
|
49
|
+
if (typeof callback === 'function') return dispatch(version, src, dest, type, options, callback);
|
|
50
|
+
return new Promise((resolve, reject)=>dispatch(version, src, dest, type, options, (err, result)=>err ? reject(err) : resolve(result)));
|
|
36
51
|
} catch (err) {
|
|
37
52
|
console.log(err);
|
|
38
53
|
if (callback) callback(err);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/typescript/ts-swc-transform/src/transformDirectory.ts"],"sourcesContent":["import path from 'path';\nimport url from 'url';\nimport loadTsConfig from './loadTsConfig';\n\nconst major = +process.versions.node.split('.')[0];\nconst version = major < 14 ? 'stable' : 'local';\nconst __dirname = path.dirname(typeof __filename === 'undefined' ? url.fileURLToPath(import.meta.url) : __filename);\
|
|
1
|
+
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/typescript/ts-swc-transform/src/transformDirectory.ts"],"sourcesContent":["import path from 'path';\nimport url from 'url';\nimport loadTsConfig from './loadTsConfig';\n\nconst major = +process.versions.node.split('.')[0];\nconst version = major < 14 ? 'stable' : 'local';\nconst __dirname = path.dirname(typeof __filename === 'undefined' ? url.fileURLToPath(import.meta.url) : __filename);\nconst workerPath = path.resolve(__dirname, '..', 'cjs', 'workers', 'transformDirectory.cjs');\n\nimport Module from 'module';\nimport lazy from 'lazy-cache';\nconst _require = typeof require === 'undefined' ? Module.createRequire(import.meta.url) : require;\nconst callLazy = lazy(_require)('node-version-call');\nconst workerLazy = lazy(_require)(workerPath);\n\nfunction dispatch(version, src, dest, type, options, callback) {\n if (version === 'local') return workerLazy()(src, dest, type, options, callback);\n try {\n callback(null, callLazy()({ version, callbacks: true }, workerPath, src, dest, type, options));\n } catch (err) {\n callback(err);\n }\n}\n\nimport type { ConfigOptions, TransformDirectoryCallback } from './types';\n/**\n * @param {string} src The source directory to traverse.\n * @param {string} dest The output directory to write files to.\n * @param {string} type The type of transform ('esm' or 'cjs').\n * @param {{sourceMaps: boolean}} options Options to pass to swc.\n * @param {(err?: Error) =>} [callback] Optional callback. Uses promise if callback not provided.\n * @returns {void | Promise<any>} Optional promise if callback not provided.\n */\nexport default function transformDirectory(src: string, dest: string, type: string, options?: ConfigOptions | TransformDirectoryCallback, callback?: TransformDirectoryCallback): undefined | 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 if (typeof options === 'function') {\n callback = options as TransformDirectoryCallback;\n options = null;\n }\n options = options || {};\n const tsconfig = loadTsConfig({ cwd: src, ...options }, 'transformDirectory');\n options = { tsconfig, ...options };\n\n if (typeof callback === 'function') return dispatch(version, src, dest, type, options, callback);\n return new Promise((resolve, reject) => dispatch(version, src, dest, type, options, (err, result) => (err ? reject(err) : resolve(result))));\n } catch (err) {\n console.log(err);\n if (callback) callback(err);\n else return Promise.reject(err);\n }\n}\n"],"names":["path","url","loadTsConfig","major","process","versions","node","split","version","__dirname","dirname","__filename","fileURLToPath","workerPath","resolve","Module","lazy","_require","require","createRequire","callLazy","workerLazy","dispatch","src","dest","type","options","callback","callbacks","err","transformDirectory","Error","tsconfig","cwd","Promise","reject","result","console","log"],"mappings":"AAAA,OAAOA,UAAU,OAAO;AACxB,OAAOC,SAAS,MAAM;AACtB,OAAOC,kBAAkB,iBAAiB;AAE1C,MAAMC,QAAQ,CAACC,QAAQC,QAAQ,CAACC,IAAI,CAACC,KAAK,CAAC,IAAI,CAAC,EAAE;AAClD,MAAMC,UAAUL,QAAQ,KAAK,WAAW;AACxC,MAAMM,YAAYT,KAAKU,OAAO,CAAC,OAAOC,eAAe,cAAcV,IAAIW,aAAa,CAAC,YAAYX,GAAG,IAAIU;AACxG,MAAME,aAAab,KAAKc,OAAO,CAACL,WAAW,MAAM,OAAO,WAAW;AAEnE,OAAOM,YAAY,SAAS;AAC5B,OAAOC,UAAU,aAAa;AAC9B,MAAMC,WAAW,OAAOC,YAAY,cAAcH,OAAOI,aAAa,CAAC,YAAYlB,GAAG,IAAIiB;AAC1F,MAAME,WAAWJ,KAAKC,UAAU;AAChC,MAAMI,aAAaL,KAAKC,UAAUJ;AAElC,SAASS,SAASd,OAAO,EAAEe,GAAG,EAAEC,IAAI,EAAEC,IAAI,EAAEC,OAAO,EAAEC,QAAQ;IAC3D,IAAInB,YAAY,SAAS,OAAOa,aAAaE,KAAKC,MAAMC,MAAMC,SAASC;IACvE,IAAI;QACFA,SAAS,MAAMP,WAAW;YAAEZ;YAASoB,WAAW;QAAK,GAAGf,YAAYU,KAAKC,MAAMC,MAAMC;IACvF,EAAE,OAAOG,KAAK;QACZF,SAASE;IACX;AACF;AAGA;;;;;;;CAOC,GACD,eAAe,SAASC,mBAAmBP,GAAW,EAAEC,IAAY,EAAEC,IAAY,EAAEC,OAAoD,EAAEC,QAAqC;IAC7K,IAAI;QACF,IAAI,OAAOJ,QAAQ,UAAU,MAAM,IAAIQ,MAAM;QAC7C,IAAI,OAAOP,SAAS,UAAU,MAAM,IAAIO,MAAM;QAC9C,IAAI,OAAON,SAAS,UAAU,MAAM,IAAIM,MAAM;QAE9C,IAAI,OAAOL,YAAY,YAAY;YACjCC,WAAWD;YACXA,UAAU;QACZ;QACAA,UAAUA,WAAW,CAAC;QACtB,MAAMM,WAAW9B,aAAa;YAAE+B,KAAKV;YAAK,GAAGG,OAAO;QAAC,GAAG;QACxDA,UAAU;YAAEM;YAAU,GAAGN,OAAO;QAAC;QAEjC,IAAI,OAAOC,aAAa,YAAY,OAAOL,SAASd,SAASe,KAAKC,MAAMC,MAAMC,SAASC;QACvF,OAAO,IAAIO,QAAQ,CAACpB,SAASqB,SAAWb,SAASd,SAASe,KAAKC,MAAMC,MAAMC,SAAS,CAACG,KAAKO,SAAYP,MAAMM,OAAON,OAAOf,QAAQsB;IACpI,EAAE,OAAOP,KAAK;QACZQ,QAAQC,GAAG,CAACT;QACZ,IAAIF,UAAUA,SAASE;aAClB,OAAOK,QAAQC,MAAM,CAACN;IAC7B;AACF"}
|
|
@@ -1,11 +1,19 @@
|
|
|
1
1
|
import path from 'path';
|
|
2
2
|
import url from 'url';
|
|
3
3
|
import * as getTS from 'get-tsconfig-compat';
|
|
4
|
-
import wrapWorkerSync from './lib/wrapWorkerSync.mjs';
|
|
5
|
-
const __dirname = path.dirname(typeof __filename === 'undefined' ? url.fileURLToPath(import.meta.url) : __filename);
|
|
6
|
-
const workerWrapper = wrapWorkerSync(path.resolve(__dirname, '..', 'cjs', 'workers', 'transformSync.cjs'));
|
|
7
4
|
const major = +process.versions.node.split('.')[0];
|
|
8
5
|
const version = major < 14 ? 'stable' : 'local';
|
|
6
|
+
const __dirname = path.dirname(typeof __filename === 'undefined' ? url.fileURLToPath(import.meta.url) : __filename);
|
|
7
|
+
const workerPath = path.resolve(__dirname, '..', 'cjs', 'workers', 'transformSync.cjs');
|
|
8
|
+
import Module from 'module';
|
|
9
|
+
import lazy from 'lazy-cache';
|
|
10
|
+
const _require = typeof require === 'undefined' ? Module.createRequire(import.meta.url) : require;
|
|
11
|
+
const callLazy = lazy(_require)('node-version-call');
|
|
12
|
+
const workerLazy = lazy(_require)(workerPath);
|
|
13
|
+
function dispatch(version, src, dest, options) {
|
|
14
|
+
if (version === 'local') return workerLazy()(src, dest, options);
|
|
15
|
+
return callLazy()(version, workerPath, src, dest, options);
|
|
16
|
+
}
|
|
9
17
|
/**
|
|
10
18
|
* @param {string} contents The file contents.
|
|
11
19
|
* @param {string} fileName The filename.
|
|
@@ -15,5 +23,5 @@ const version = major < 14 ? 'stable' : 'local';
|
|
|
15
23
|
if (typeof contents !== 'string') throw new Error('transformTypes: unexpected contents');
|
|
16
24
|
if (typeof fileName !== 'string') throw new Error('transformTypes: unexpected fileName');
|
|
17
25
|
if (!tsconfig) tsconfig = getTS.getTsconfig(process.cwd());
|
|
18
|
-
return
|
|
26
|
+
return dispatch(version, contents, fileName, tsconfig);
|
|
19
27
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/typescript/ts-swc-transform/src/transformSync.ts"],"sourcesContent":["import path from 'path';\nimport url from 'url';\nimport * as getTS from 'get-tsconfig-compat';\n\
|
|
1
|
+
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/typescript/ts-swc-transform/src/transformSync.ts"],"sourcesContent":["import path from 'path';\nimport url from 'url';\nimport * as getTS from 'get-tsconfig-compat';\n\nconst major = +process.versions.node.split('.')[0];\nconst version = major < 14 ? 'stable' : 'local';\nconst __dirname = path.dirname(typeof __filename === 'undefined' ? url.fileURLToPath(import.meta.url) : __filename);\nconst workerPath = path.resolve(__dirname, '..', 'cjs', 'workers', 'transformSync.cjs');\n\nimport Module from 'module';\nimport lazy from 'lazy-cache';\nconst _require = typeof require === 'undefined' ? Module.createRequire(import.meta.url) : require;\nconst callLazy = lazy(_require)('node-version-call');\nconst workerLazy = lazy(_require)(workerPath);\n\nfunction dispatch(version, src, dest, options) {\n if (version === 'local') return workerLazy()(src, dest, options);\n return callLazy()(version, workerPath, src, dest, options);\n}\n\nimport type { Output } from '@swc/core';\nimport type { TsConfigResult } from 'get-tsconfig-compat';\n/**\n * @param {string} contents The file contents.\n * @param {string} fileName The filename.\n * @param {TsConfigResult} tsconfig The configuration.\n * @returns {{ code: string, map?: string }} Returns object with the transformed code and source map if option sourceMaps was provided.\n */\nexport default function transformSync(contents: string, fileName: string, tsconfig: TsConfigResult): Output {\n if (typeof contents !== 'string') throw new Error('transformTypes: unexpected contents');\n if (typeof fileName !== 'string') throw new Error('transformTypes: unexpected fileName');\n if (!tsconfig) tsconfig = getTS.getTsconfig(process.cwd());\n return dispatch(version, contents, fileName, tsconfig);\n}\n"],"names":["path","url","getTS","major","process","versions","node","split","version","__dirname","dirname","__filename","fileURLToPath","workerPath","resolve","Module","lazy","_require","require","createRequire","callLazy","workerLazy","dispatch","src","dest","options","transformSync","contents","fileName","tsconfig","Error","getTsconfig","cwd"],"mappings":"AAAA,OAAOA,UAAU,OAAO;AACxB,OAAOC,SAAS,MAAM;AACtB,YAAYC,WAAW,sBAAsB;AAE7C,MAAMC,QAAQ,CAACC,QAAQC,QAAQ,CAACC,IAAI,CAACC,KAAK,CAAC,IAAI,CAAC,EAAE;AAClD,MAAMC,UAAUL,QAAQ,KAAK,WAAW;AACxC,MAAMM,YAAYT,KAAKU,OAAO,CAAC,OAAOC,eAAe,cAAcV,IAAIW,aAAa,CAAC,YAAYX,GAAG,IAAIU;AACxG,MAAME,aAAab,KAAKc,OAAO,CAACL,WAAW,MAAM,OAAO,WAAW;AAEnE,OAAOM,YAAY,SAAS;AAC5B,OAAOC,UAAU,aAAa;AAC9B,MAAMC,WAAW,OAAOC,YAAY,cAAcH,OAAOI,aAAa,CAAC,YAAYlB,GAAG,IAAIiB;AAC1F,MAAME,WAAWJ,KAAKC,UAAU;AAChC,MAAMI,aAAaL,KAAKC,UAAUJ;AAElC,SAASS,SAASd,OAAO,EAAEe,GAAG,EAAEC,IAAI,EAAEC,OAAO;IAC3C,IAAIjB,YAAY,SAAS,OAAOa,aAAaE,KAAKC,MAAMC;IACxD,OAAOL,WAAWZ,SAASK,YAAYU,KAAKC,MAAMC;AACpD;AAIA;;;;;CAKC,GACD,eAAe,SAASC,cAAcC,QAAgB,EAAEC,QAAgB,EAAEC,QAAwB;IAChG,IAAI,OAAOF,aAAa,UAAU,MAAM,IAAIG,MAAM;IAClD,IAAI,OAAOF,aAAa,UAAU,MAAM,IAAIE,MAAM;IAClD,IAAI,CAACD,UAAUA,WAAW3B,MAAM6B,WAAW,CAAC3B,QAAQ4B,GAAG;IACvD,OAAOV,SAASd,SAASmB,UAAUC,UAAUC;AAC/C"}
|
|
@@ -4,8 +4,23 @@ import loadTsConfig from './loadTsConfig.mjs';
|
|
|
4
4
|
const major = +process.versions.node.split('.')[0];
|
|
5
5
|
const version = major < 14 ? 'stable' : 'local';
|
|
6
6
|
const __dirname = path.dirname(typeof __filename === 'undefined' ? url.fileURLToPath(import.meta.url) : __filename);
|
|
7
|
-
|
|
8
|
-
|
|
7
|
+
const workerPath = path.resolve(__dirname, '..', 'cjs', 'workers', 'transformTypes.cjs');
|
|
8
|
+
import Module from 'module';
|
|
9
|
+
import lazy from 'lazy-cache';
|
|
10
|
+
const _require = typeof require === 'undefined' ? Module.createRequire(import.meta.url) : require;
|
|
11
|
+
const callLazy = lazy(_require)('node-version-call');
|
|
12
|
+
const workerLazy = lazy(_require)(workerPath);
|
|
13
|
+
function dispatch(version, src, dest, options, callback) {
|
|
14
|
+
if (version === 'local') return workerLazy()(src, dest, options, callback);
|
|
15
|
+
try {
|
|
16
|
+
callback(null, callLazy()({
|
|
17
|
+
version,
|
|
18
|
+
callbacks: true
|
|
19
|
+
}, workerPath, src, dest, options));
|
|
20
|
+
} catch (err) {
|
|
21
|
+
callback(err);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
9
24
|
/**
|
|
10
25
|
* @param {string} src The source directory to traverse.
|
|
11
26
|
* @param {string} dest The output directory to write files to.
|
|
@@ -29,8 +44,8 @@ const workerWrapper = wrapWorker(path.resolve(__dirname, '..', 'cjs', 'workers',
|
|
|
29
44
|
tsconfig,
|
|
30
45
|
...options
|
|
31
46
|
};
|
|
32
|
-
if (typeof callback === 'function') return
|
|
33
|
-
return new Promise((resolve, reject)=>
|
|
47
|
+
if (typeof callback === 'function') return dispatch(version, src, dest, options, callback);
|
|
48
|
+
return new Promise((resolve, reject)=>dispatch(version, src, dest, options, (err, result)=>err ? reject(err) : resolve(result)));
|
|
34
49
|
} catch (err) {
|
|
35
50
|
console.log(err);
|
|
36
51
|
if (callback) callback(err);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/typescript/ts-swc-transform/src/transformTypes.ts"],"sourcesContent":["import path from 'path';\nimport url from 'url';\nimport loadTsConfig from './loadTsConfig';\n\nconst major = +process.versions.node.split('.')[0];\nconst version = major < 14 ? 'stable' : 'local';\nconst __dirname = path.dirname(typeof __filename === 'undefined' ? url.fileURLToPath(import.meta.url) : __filename);\
|
|
1
|
+
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/typescript/ts-swc-transform/src/transformTypes.ts"],"sourcesContent":["import path from 'path';\nimport url from 'url';\nimport loadTsConfig from './loadTsConfig';\n\nconst major = +process.versions.node.split('.')[0];\nconst version = major < 14 ? 'stable' : 'local';\nconst __dirname = path.dirname(typeof __filename === 'undefined' ? url.fileURLToPath(import.meta.url) : __filename);\nconst workerPath = path.resolve(__dirname, '..', 'cjs', 'workers', 'transformTypes.cjs');\n\nimport Module from 'module';\nimport lazy from 'lazy-cache';\nconst _require = typeof require === 'undefined' ? Module.createRequire(import.meta.url) : require;\nconst callLazy = lazy(_require)('node-version-call');\nconst workerLazy = lazy(_require)(workerPath);\n\nfunction dispatch(version, src, dest, options, callback) {\n if (version === 'local') return workerLazy()(src, dest, options, callback);\n try {\n callback(null, callLazy()({ version, callbacks: true }, workerPath, src, dest, options));\n } catch (err) {\n callback(err);\n }\n}\n\nimport type { ConfigOptions, TransformTypesCallback } from './types';\n/**\n * @param {string} src The source directory to traverse.\n * @param {string} dest The output directory to write files to.\n * @param {{tsconfig: TsConfigResult}} options Options.\n * @param {(err?: Error) =>} [callback] Optional callback. Uses promise if callback not provided.\n * @returns {void | Promise<any>} Optional promise if callback not provided.\n */\nexport default function transformTypes(src: string, dest: string, options?: ConfigOptions | TransformTypesCallback, callback?: TransformTypesCallback): undefined | 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 if (typeof options === 'function') {\n callback = options as TransformTypesCallback;\n options = null;\n }\n options = options || {};\n const tsconfig = loadTsConfig({ cwd: src, ...options }, 'transformTypes');\n options = { tsconfig, ...options };\n\n if (typeof callback === 'function') return dispatch(version, src, dest, options, callback);\n return new Promise((resolve, reject) => dispatch(version, src, dest, options, (err, result) => (err ? reject(err) : resolve(result))));\n } catch (err) {\n console.log(err);\n if (callback) callback(err);\n else return Promise.reject(err);\n }\n}\n"],"names":["path","url","loadTsConfig","major","process","versions","node","split","version","__dirname","dirname","__filename","fileURLToPath","workerPath","resolve","Module","lazy","_require","require","createRequire","callLazy","workerLazy","dispatch","src","dest","options","callback","callbacks","err","transformTypes","Error","tsconfig","cwd","Promise","reject","result","console","log"],"mappings":"AAAA,OAAOA,UAAU,OAAO;AACxB,OAAOC,SAAS,MAAM;AACtB,OAAOC,kBAAkB,iBAAiB;AAE1C,MAAMC,QAAQ,CAACC,QAAQC,QAAQ,CAACC,IAAI,CAACC,KAAK,CAAC,IAAI,CAAC,EAAE;AAClD,MAAMC,UAAUL,QAAQ,KAAK,WAAW;AACxC,MAAMM,YAAYT,KAAKU,OAAO,CAAC,OAAOC,eAAe,cAAcV,IAAIW,aAAa,CAAC,YAAYX,GAAG,IAAIU;AACxG,MAAME,aAAab,KAAKc,OAAO,CAACL,WAAW,MAAM,OAAO,WAAW;AAEnE,OAAOM,YAAY,SAAS;AAC5B,OAAOC,UAAU,aAAa;AAC9B,MAAMC,WAAW,OAAOC,YAAY,cAAcH,OAAOI,aAAa,CAAC,YAAYlB,GAAG,IAAIiB;AAC1F,MAAME,WAAWJ,KAAKC,UAAU;AAChC,MAAMI,aAAaL,KAAKC,UAAUJ;AAElC,SAASS,SAASd,OAAO,EAAEe,GAAG,EAAEC,IAAI,EAAEC,OAAO,EAAEC,QAAQ;IACrD,IAAIlB,YAAY,SAAS,OAAOa,aAAaE,KAAKC,MAAMC,SAASC;IACjE,IAAI;QACFA,SAAS,MAAMN,WAAW;YAAEZ;YAASmB,WAAW;QAAK,GAAGd,YAAYU,KAAKC,MAAMC;IACjF,EAAE,OAAOG,KAAK;QACZF,SAASE;IACX;AACF;AAGA;;;;;;CAMC,GACD,eAAe,SAASC,eAAeN,GAAW,EAAEC,IAAY,EAAEC,OAAgD,EAAEC,QAAiC;IACnJ,IAAI;QACF,IAAI,OAAOH,QAAQ,UAAU,MAAM,IAAIO,MAAM;QAC7C,IAAI,OAAON,SAAS,UAAU,MAAM,IAAIM,MAAM;QAE9C,IAAI,OAAOL,YAAY,YAAY;YACjCC,WAAWD;YACXA,UAAU;QACZ;QACAA,UAAUA,WAAW,CAAC;QACtB,MAAMM,WAAW7B,aAAa;YAAE8B,KAAKT;YAAK,GAAGE,OAAO;QAAC,GAAG;QACxDA,UAAU;YAAEM;YAAU,GAAGN,OAAO;QAAC;QAEjC,IAAI,OAAOC,aAAa,YAAY,OAAOJ,SAASd,SAASe,KAAKC,MAAMC,SAASC;QACjF,OAAO,IAAIO,QAAQ,CAACnB,SAASoB,SAAWZ,SAASd,SAASe,KAAKC,MAAMC,SAAS,CAACG,KAAKO,SAAYP,MAAMM,OAAON,OAAOd,QAAQqB;IAC9H,EAAE,OAAOP,KAAK;QACZQ,QAAQC,GAAG,CAACT;QACZ,IAAIF,UAAUA,SAASE;aAClB,OAAOK,QAAQC,MAAM,CAACN;IAC7B;AACF"}
|
|
@@ -2,7 +2,7 @@ import path from 'path';
|
|
|
2
2
|
import Iterator from 'fs-iterator';
|
|
3
3
|
import Queue from 'queue-cb';
|
|
4
4
|
import rimraf2 from 'rimraf2';
|
|
5
|
-
import {
|
|
5
|
+
import { extensions, typeFileRegEx } from '../constants.mjs';
|
|
6
6
|
import createMatcher from '../createMatcher.mjs';
|
|
7
7
|
import installBindings from '../lib/installBindings.mjs';
|
|
8
8
|
import transformFile from '../lib/transformFile.mjs';
|
|
@@ -19,9 +19,9 @@ export default function transformDirectoryWorker(src, dest, type, options, callb
|
|
|
19
19
|
const iterator = new Iterator(src);
|
|
20
20
|
iterator.forEach((entry)=>{
|
|
21
21
|
if (!entry.stats.isFile()) return;
|
|
22
|
-
if (
|
|
22
|
+
if (entry.basename[0] === '.') return;
|
|
23
23
|
if (typeFileRegEx.test(entry.basename)) return;
|
|
24
|
-
if (
|
|
24
|
+
if (!matcher(entry.fullPath)) return;
|
|
25
25
|
const ext = path.extname(entry.basename);
|
|
26
26
|
if (ext && extensions.indexOf(ext) < 0) return;
|
|
27
27
|
entries.push(entry);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/typescript/ts-swc-transform/src/workers/transformDirectory.ts"],"sourcesContent":["import path from 'path';\nimport Iterator from 'fs-iterator';\nimport Queue from 'queue-cb';\nimport rimraf2 from 'rimraf2';\n\nimport {
|
|
1
|
+
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/typescript/ts-swc-transform/src/workers/transformDirectory.ts"],"sourcesContent":["import path from 'path';\nimport Iterator from 'fs-iterator';\nimport Queue from 'queue-cb';\nimport rimraf2 from 'rimraf2';\n\nimport { extensions, typeFileRegEx } from '../constants';\nimport createMatcher from '../createMatcher';\nimport installBindings from '../lib/installBindings';\nimport transformFile from '../lib/transformFile';\n\nconst target = `${process.platform}-${process.arch}`;\n\nexport default function transformDirectoryWorker(src, dest, type, options, callback) {\n const tsconfig = options.tsconfig;\n const matcher = createMatcher(tsconfig);\n\n installBindings(target, (err) => {\n if (err) return callback(err);\n\n rimraf2(dest, { disableGlob: true }, () => {\n const entries = [];\n const iterator = new Iterator(src);\n iterator.forEach(\n (entry) => {\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, src, dest };\n\n const queue = new Queue();\n entries.forEach((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 });\n}\n"],"names":["path","Iterator","Queue","rimraf2","extensions","typeFileRegEx","createMatcher","installBindings","transformFile","target","process","platform","arch","transformDirectoryWorker","src","dest","type","options","callback","tsconfig","matcher","err","disableGlob","entries","iterator","forEach","entry","stats","isFile","basename","test","fullPath","ext","extname","indexOf","push","results","queue","defer","cb","outPath","normalize","sourceMaps","await"],"mappings":"AAAA,OAAOA,UAAU,OAAO;AACxB,OAAOC,cAAc,cAAc;AACnC,OAAOC,WAAW,WAAW;AAC7B,OAAOC,aAAa,UAAU;AAE9B,SAASC,UAAU,EAAEC,aAAa,QAAQ,eAAe;AACzD,OAAOC,mBAAmB,mBAAmB;AAC7C,OAAOC,qBAAqB,yBAAyB;AACrD,OAAOC,mBAAmB,uBAAuB;AAEjD,MAAMC,SAAS,GAAGC,QAAQC,QAAQ,CAAC,CAAC,EAAED,QAAQE,IAAI,EAAE;AAEpD,eAAe,SAASC,yBAAyBC,GAAG,EAAEC,IAAI,EAAEC,IAAI,EAAEC,OAAO,EAAEC,QAAQ;IACjF,MAAMC,WAAWF,QAAQE,QAAQ;IACjC,MAAMC,UAAUd,cAAca;IAE9BZ,gBAAgBE,QAAQ,CAACY;QACvB,IAAIA,KAAK,OAAOH,SAASG;QAEzBlB,QAAQY,MAAM;YAAEO,aAAa;QAAK,GAAG;YACnC,MAAMC,UAAU,EAAE;YAClB,MAAMC,WAAW,IAAIvB,SAASa;YAC9BU,SAASC,OAAO,CACd,CAACC;gBACC,IAAI,CAACA,MAAMC,KAAK,CAACC,MAAM,IAAI;gBAC3B,IAAIF,MAAMG,QAAQ,CAAC,EAAE,KAAK,KAAK;gBAC/B,IAAIxB,cAAcyB,IAAI,CAACJ,MAAMG,QAAQ,GAAG;gBACxC,IAAI,CAACT,QAAQM,MAAMK,QAAQ,GAAG;gBAC9B,MAAMC,MAAMhC,KAAKiC,OAAO,CAACP,MAAMG,QAAQ;gBACvC,IAAIG,OAAO5B,WAAW8B,OAAO,CAACF,OAAO,GAAG;gBACxCT,QAAQY,IAAI,CAACT;YACf,GACA,CAACL;gBACC,IAAIA,KAAK,OAAOH,SAASG;gBACzB,MAAMe,UAAU,EAAE;gBAClBnB,UAAU;oBAAE,GAAGA,OAAO;oBAAEE;oBAAUL;oBAAKC;gBAAK;gBAE5C,MAAMsB,QAAQ,IAAInC;gBAClBqB,QAAQE,OAAO,CAAC,CAACC;oBACfW,MAAMC,KAAK,CAAC,CAACC,KACX/B,cAAckB,OAAOX,MAAMC,MAAMC,SAAS,CAACI,KAAKmB;4BAC9C,IAAInB,KAAK,OAAOkB,GAAGlB;4BACnBe,QAAQD,IAAI,CAACnC,KAAKyC,SAAS,CAACD;4BAC5B,IAAIvB,QAAQyB,UAAU,EAAEN,QAAQD,IAAI,CAAC,GAAGnC,KAAKyC,SAAS,CAACD,SAAS,IAAI,CAAC;4BACrED;wBACF;gBAEJ;gBACAF,MAAMM,KAAK,CAAC,CAACtB,MAASA,MAAMH,SAASG,OAAOH,SAAS,MAAMkB;YAC7D;QAEJ;IACF;AACF"}
|
|
@@ -4,7 +4,7 @@ import Module from 'module';
|
|
|
4
4
|
import lazy from 'lazy-cache';
|
|
5
5
|
const _require = typeof require === 'undefined' ? Module.createRequire(import.meta.url) : require;
|
|
6
6
|
const tsLazy = lazy(_require)('typescript');
|
|
7
|
-
import {
|
|
7
|
+
import { typeFileRegEx } from '../constants.mjs';
|
|
8
8
|
import createMatcher from '../createMatcher.mjs';
|
|
9
9
|
export default function transformTypesWorker(src, dest, options, callback) {
|
|
10
10
|
const tsconfig = options.tsconfig;
|
|
@@ -16,9 +16,9 @@ export default function transformTypesWorker(src, dest, options, callback) {
|
|
|
16
16
|
const iterator = new Iterator(src);
|
|
17
17
|
iterator.forEach((entry)=>{
|
|
18
18
|
if (!entry.stats.isFile()) return;
|
|
19
|
-
if (
|
|
19
|
+
if (entry.basename[0] === '.') return;
|
|
20
20
|
if (typeFileRegEx.test(entry.basename)) return;
|
|
21
|
-
if (
|
|
21
|
+
if (!matcher(entry.fullPath)) return;
|
|
22
22
|
entries.push(entry);
|
|
23
23
|
}, {
|
|
24
24
|
concurrency: Infinity
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/typescript/ts-swc-transform/src/workers/transformTypes.ts"],"sourcesContent":["import Iterator from 'fs-iterator';\nimport rimraf2 from 'rimraf2';\n\nimport Module from 'module';\nimport lazy from 'lazy-cache';\nconst _require = typeof require === 'undefined' ? Module.createRequire(import.meta.url) : require;\nconst tsLazy = lazy(_require)('typescript');\n\nimport {
|
|
1
|
+
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/typescript/ts-swc-transform/src/workers/transformTypes.ts"],"sourcesContent":["import Iterator from 'fs-iterator';\nimport rimraf2 from 'rimraf2';\n\nimport Module from 'module';\nimport lazy from 'lazy-cache';\nconst _require = typeof require === 'undefined' ? Module.createRequire(import.meta.url) : require;\nconst tsLazy = lazy(_require)('typescript');\n\nimport { typeFileRegEx } from '../constants';\nimport createMatcher from '../createMatcher';\n\nexport default function transformTypesWorker(src, dest, options, callback) {\n const tsconfig = options.tsconfig;\n const matcher = createMatcher(tsconfig);\n\n rimraf2(dest, { disableGlob: true }, () => {\n const entries = [];\n const iterator = new Iterator(src);\n iterator.forEach(\n (entry) => {\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: Infinity },\n (err) => {\n if (err) return callback(err);\n\n const ts = tsLazy();\n const config = {\n fileNames: entries.map((entry) => entry.fullPath),\n options: {\n ...(tsconfig.compilerOptions || {}),\n outDir: dest,\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 callback(null, res.emittedFiles);\n }\n );\n });\n}\n"],"names":["Iterator","rimraf2","Module","lazy","_require","require","createRequire","url","tsLazy","typeFileRegEx","createMatcher","transformTypesWorker","src","dest","options","callback","tsconfig","matcher","disableGlob","entries","iterator","forEach","entry","stats","isFile","basename","test","fullPath","push","concurrency","Infinity","err","ts","config","fileNames","map","compilerOptions","outDir","allowJs","declaration","emitDeclarationOnly","listEmittedFiles","projectReferences","references","host","createCompilerHostWorker","undefined","sys","programOptions","rootNames","configFileParsingDiagnostics","getConfigFileParsingDiagnostics","program","createProgram","res","emit","emittedFiles"],"mappings":"AAAA,OAAOA,cAAc,cAAc;AACnC,OAAOC,aAAa,UAAU;AAE9B,OAAOC,YAAY,SAAS;AAC5B,OAAOC,UAAU,aAAa;AAC9B,MAAMC,WAAW,OAAOC,YAAY,cAAcH,OAAOI,aAAa,CAAC,YAAYC,GAAG,IAAIF;AAC1F,MAAMG,SAASL,KAAKC,UAAU;AAE9B,SAASK,aAAa,QAAQ,eAAe;AAC7C,OAAOC,mBAAmB,mBAAmB;AAE7C,eAAe,SAASC,qBAAqBC,GAAG,EAAEC,IAAI,EAAEC,OAAO,EAAEC,QAAQ;IACvE,MAAMC,WAAWF,QAAQE,QAAQ;IACjC,MAAMC,UAAUP,cAAcM;IAE9Bf,QAAQY,MAAM;QAAEK,aAAa;IAAK,GAAG;QACnC,MAAMC,UAAU,EAAE;QAClB,MAAMC,WAAW,IAAIpB,SAASY;QAC9BQ,SAASC,OAAO,CACd,CAACC;YACC,IAAI,CAACA,MAAMC,KAAK,CAACC,MAAM,IAAI;YAC3B,IAAIF,MAAMG,QAAQ,CAAC,EAAE,KAAK,KAAK;YAC/B,IAAIhB,cAAciB,IAAI,CAACJ,MAAMG,QAAQ,GAAG;YACxC,IAAI,CAACR,QAAQK,MAAMK,QAAQ,GAAG;YAC9BR,QAAQS,IAAI,CAACN;QACf,GACA;YAAEO,aAAaC;QAAS,GACxB,CAACC;YACC,IAAIA,KAAK,OAAOhB,SAASgB;YAEzB,MAAMC,KAAKxB;YACX,MAAMyB,SAAS;gBACbC,WAAWf,QAAQgB,GAAG,CAAC,CAACb,QAAUA,MAAMK,QAAQ;gBAChDb,SAAS;oBACP,GAAIE,SAASoB,eAAe,IAAI,CAAC,CAAC;oBAClCC,QAAQxB;oBACRyB,SAAS;oBACTC,aAAa;oBACbC,qBAAqB;oBACrBC,kBAAkB;gBACpB;gBACAC,mBAAmB1B,SAASiB,MAAM,CAACU,UAAU;YAC/C;YACA,MAAM,EAAET,SAAS,EAAEpB,OAAO,EAAE4B,iBAAiB,EAAE,GAAGT;YAClD,MAAMW,OAAOZ,GAAGa,wBAAwB,CAAC/B,SAAS,gBAAgB,GAAGgC,WAAWd,GAAGe,GAAG;YACtF,MAAMC,iBAAiB;gBACrBC,WAAWf;gBACXpB;gBACA4B;gBACAE;gBACAM,8BAA8BlB,GAAGmB,+BAA+B,CAAC;oBAAEjB;oBAAWpB;gBAAQ;YACxF;YACA,MAAMsC,UAAUpB,GAAGqB,aAAa,CAACL;YACjC,MAAMM,MAAMF,QAAQG,IAAI;YACxBxC,SAAS,MAAMuC,IAAIE,YAAY;QACjC;IAEJ;AACF"}
|
package/package.json
CHANGED
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", {
|
|
3
|
-
value: true
|
|
4
|
-
});
|
|
5
|
-
Object.defineProperty(exports, "default", {
|
|
6
|
-
enumerable: true,
|
|
7
|
-
get: function() {
|
|
8
|
-
return wrapWorker;
|
|
9
|
-
}
|
|
10
|
-
});
|
|
11
|
-
var _module = /*#__PURE__*/ _interop_require_default(require("module"));
|
|
12
|
-
var _lazycache = /*#__PURE__*/ _interop_require_default(require("lazy-cache"));
|
|
13
|
-
function _array_like_to_array(arr, len) {
|
|
14
|
-
if (len == null || len > arr.length) len = arr.length;
|
|
15
|
-
for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
|
|
16
|
-
return arr2;
|
|
17
|
-
}
|
|
18
|
-
function _array_without_holes(arr) {
|
|
19
|
-
if (Array.isArray(arr)) return _array_like_to_array(arr);
|
|
20
|
-
}
|
|
21
|
-
function _interop_require_default(obj) {
|
|
22
|
-
return obj && obj.__esModule ? obj : {
|
|
23
|
-
default: obj
|
|
24
|
-
};
|
|
25
|
-
}
|
|
26
|
-
function _iterable_to_array(iter) {
|
|
27
|
-
if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
|
|
28
|
-
}
|
|
29
|
-
function _non_iterable_spread() {
|
|
30
|
-
throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
31
|
-
}
|
|
32
|
-
function _to_consumable_array(arr) {
|
|
33
|
-
return _array_without_holes(arr) || _iterable_to_array(arr) || _unsupported_iterable_to_array(arr) || _non_iterable_spread();
|
|
34
|
-
}
|
|
35
|
-
function _unsupported_iterable_to_array(o, minLen) {
|
|
36
|
-
if (!o) return;
|
|
37
|
-
if (typeof o === "string") return _array_like_to_array(o, minLen);
|
|
38
|
-
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
39
|
-
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
40
|
-
if (n === "Map" || n === "Set") return Array.from(n);
|
|
41
|
-
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
|
|
42
|
-
}
|
|
43
|
-
var _require = typeof require === 'undefined' ? _module.default.createRequire(require("url").pathToFileURL(__filename).toString()) : require;
|
|
44
|
-
var call = (0, _lazycache.default)(_require)('node-version-call');
|
|
45
|
-
function wrapWorker(workerPath) {
|
|
46
|
-
var workerLazy = (0, _lazycache.default)(_require)(workerPath);
|
|
47
|
-
return function workerWrapper(version) {
|
|
48
|
-
for(var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++){
|
|
49
|
-
args[_key - 1] = arguments[_key];
|
|
50
|
-
}
|
|
51
|
-
if (version === 'local') return workerLazy().apply(null, args);
|
|
52
|
-
var callback = args.pop();
|
|
53
|
-
try {
|
|
54
|
-
callback(null, call().apply(this, [
|
|
55
|
-
{
|
|
56
|
-
version: version,
|
|
57
|
-
callbacks: true
|
|
58
|
-
},
|
|
59
|
-
workerPath
|
|
60
|
-
].concat(_to_consumable_array(args))));
|
|
61
|
-
} catch (err) {
|
|
62
|
-
callback(err);
|
|
63
|
-
}
|
|
64
|
-
};
|
|
65
|
-
}
|
|
66
|
-
/* 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 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/typescript/ts-swc-transform/src/lib/wrapWorker.ts"],"sourcesContent":["import Module from 'module';\nimport lazy from 'lazy-cache';\nconst _require = typeof require === 'undefined' ? Module.createRequire(import.meta.url) : require;\nconst call = lazy(_require)('node-version-call');\n\nexport default function wrapWorker(workerPath: string) {\n const workerLazy = lazy(_require)(workerPath);\n\n return function workerWrapper(version, ...args) {\n if (version === 'local') return workerLazy().apply(null, args);\n\n const callback = args.pop();\n try {\n callback(null, call()({ version, callbacks: true }, workerPath, ...args));\n } catch (err) {\n callback(err);\n }\n };\n}\n"],"names":["wrapWorker","_require","require","Module","createRequire","call","lazy","workerPath","workerLazy","workerWrapper","version","args","apply","callback","pop","callbacks","err"],"mappings":";;;;+BAKA;;;eAAwBA;;;6DALL;gEACF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACjB,IAAMC,WAAW,OAAOC,YAAY,cAAcC,eAAM,CAACC,aAAa,CAAC,uDAAmBF;AAC1F,IAAMG,OAAOC,IAAAA,kBAAI,EAACL,UAAU;AAEb,SAASD,WAAWO,UAAkB;IACnD,IAAMC,aAAaF,IAAAA,kBAAI,EAACL,UAAUM;IAElC,OAAO,SAASE,cAAcC,OAAO;QAAE,IAAA,IAAA,OAAA,UAAA,QAAA,AAAGC,OAAH,UAAA,OAAA,IAAA,OAAA,QAAA,OAAA,GAAA,OAAA,MAAA;YAAGA,KAAH,OAAA,KAAA,SAAA,CAAA,KAAO;;QAC5C,IAAID,YAAY,SAAS,OAAOF,aAAaI,KAAK,CAAC,MAAMD;QAEzD,IAAME,WAAWF,KAAKG,GAAG;QACzB,IAAI;YACFD,SAAS,MAAMR,aAAAA,IAAM,EAANA;gBAAO;oBAAEK,SAAAA;oBAASK,WAAW;gBAAK;gBAAGR;aAAoB,CAAzDF,OAAiD,qBAAGM;QACrE,EAAE,OAAOK,KAAK;YACZH,SAASG;QACX;IACF;AACF"}
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", {
|
|
3
|
-
value: true
|
|
4
|
-
});
|
|
5
|
-
Object.defineProperty(exports, "default", {
|
|
6
|
-
enumerable: true,
|
|
7
|
-
get: function() {
|
|
8
|
-
return wrapWorkerSync;
|
|
9
|
-
}
|
|
10
|
-
});
|
|
11
|
-
var _module = /*#__PURE__*/ _interop_require_default(require("module"));
|
|
12
|
-
var _lazycache = /*#__PURE__*/ _interop_require_default(require("lazy-cache"));
|
|
13
|
-
function _array_like_to_array(arr, len) {
|
|
14
|
-
if (len == null || len > arr.length) len = arr.length;
|
|
15
|
-
for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
|
|
16
|
-
return arr2;
|
|
17
|
-
}
|
|
18
|
-
function _array_without_holes(arr) {
|
|
19
|
-
if (Array.isArray(arr)) return _array_like_to_array(arr);
|
|
20
|
-
}
|
|
21
|
-
function _interop_require_default(obj) {
|
|
22
|
-
return obj && obj.__esModule ? obj : {
|
|
23
|
-
default: obj
|
|
24
|
-
};
|
|
25
|
-
}
|
|
26
|
-
function _iterable_to_array(iter) {
|
|
27
|
-
if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
|
|
28
|
-
}
|
|
29
|
-
function _non_iterable_spread() {
|
|
30
|
-
throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
31
|
-
}
|
|
32
|
-
function _to_consumable_array(arr) {
|
|
33
|
-
return _array_without_holes(arr) || _iterable_to_array(arr) || _unsupported_iterable_to_array(arr) || _non_iterable_spread();
|
|
34
|
-
}
|
|
35
|
-
function _unsupported_iterable_to_array(o, minLen) {
|
|
36
|
-
if (!o) return;
|
|
37
|
-
if (typeof o === "string") return _array_like_to_array(o, minLen);
|
|
38
|
-
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
39
|
-
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
40
|
-
if (n === "Map" || n === "Set") return Array.from(n);
|
|
41
|
-
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
|
|
42
|
-
}
|
|
43
|
-
var _require = typeof require === 'undefined' ? _module.default.createRequire(require("url").pathToFileURL(__filename).toString()) : require;
|
|
44
|
-
var call = (0, _lazycache.default)(_require)('node-version-call');
|
|
45
|
-
function wrapWorkerSync(workerPath) {
|
|
46
|
-
var workerLazy = (0, _lazycache.default)(_require)(workerPath);
|
|
47
|
-
return function workerWrapperSync(version) {
|
|
48
|
-
for(var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++){
|
|
49
|
-
args[_key - 1] = arguments[_key];
|
|
50
|
-
}
|
|
51
|
-
if (version === 'local') return workerLazy().apply(null, args);
|
|
52
|
-
return call().apply(this, [
|
|
53
|
-
version,
|
|
54
|
-
workerPath
|
|
55
|
-
].concat(_to_consumable_array(args)));
|
|
56
|
-
};
|
|
57
|
-
}
|
|
58
|
-
/* 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 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/typescript/ts-swc-transform/src/lib/wrapWorkerSync.ts"],"sourcesContent":["import Module from 'module';\nimport lazy from 'lazy-cache';\nconst _require = typeof require === 'undefined' ? Module.createRequire(import.meta.url) : require;\nconst call = lazy(_require)('node-version-call');\n\nexport default function wrapWorkerSync(workerPath: string) {\n const workerLazy = lazy(_require)(workerPath);\n\n return function workerWrapperSync(version, ...args) {\n if (version === 'local') return workerLazy().apply(null, args);\n return call()(version, workerPath, ...args);\n };\n}\n"],"names":["wrapWorkerSync","_require","require","Module","createRequire","call","lazy","workerPath","workerLazy","workerWrapperSync","version","args","apply"],"mappings":";;;;+BAKA;;;eAAwBA;;;6DALL;gEACF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACjB,IAAMC,WAAW,OAAOC,YAAY,cAAcC,eAAM,CAACC,aAAa,CAAC,uDAAmBF;AAC1F,IAAMG,OAAOC,IAAAA,kBAAI,EAACL,UAAU;AAEb,SAASD,eAAeO,UAAkB;IACvD,IAAMC,aAAaF,IAAAA,kBAAI,EAACL,UAAUM;IAElC,OAAO,SAASE,kBAAkBC,OAAO;QAAE,IAAA,IAAA,OAAA,UAAA,QAAA,AAAGC,OAAH,UAAA,OAAA,IAAA,OAAA,QAAA,OAAA,GAAA,OAAA,MAAA;YAAGA,KAAH,OAAA,KAAA,SAAA,CAAA,KAAO;;QAChD,IAAID,YAAY,SAAS,OAAOF,aAAaI,KAAK,CAAC,MAAMD;QACzD,OAAON,aAAAA,IAAM,EAANA;YAAOK;YAASH;SAAoB,CAApCF,OAA4B,qBAAGM;IACxC;AACF"}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import Module from 'module';
|
|
2
|
-
import lazy from 'lazy-cache';
|
|
3
|
-
const _require = typeof require === 'undefined' ? Module.createRequire(import.meta.url) : require;
|
|
4
|
-
const call = lazy(_require)('node-version-call');
|
|
5
|
-
export default function wrapWorker(workerPath) {
|
|
6
|
-
const workerLazy = lazy(_require)(workerPath);
|
|
7
|
-
return function workerWrapper(version, ...args) {
|
|
8
|
-
if (version === 'local') return workerLazy().apply(null, args);
|
|
9
|
-
const callback = args.pop();
|
|
10
|
-
try {
|
|
11
|
-
callback(null, call()({
|
|
12
|
-
version,
|
|
13
|
-
callbacks: true
|
|
14
|
-
}, workerPath, ...args));
|
|
15
|
-
} catch (err) {
|
|
16
|
-
callback(err);
|
|
17
|
-
}
|
|
18
|
-
};
|
|
19
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/typescript/ts-swc-transform/src/lib/wrapWorker.ts"],"sourcesContent":["import Module from 'module';\nimport lazy from 'lazy-cache';\nconst _require = typeof require === 'undefined' ? Module.createRequire(import.meta.url) : require;\nconst call = lazy(_require)('node-version-call');\n\nexport default function wrapWorker(workerPath: string) {\n const workerLazy = lazy(_require)(workerPath);\n\n return function workerWrapper(version, ...args) {\n if (version === 'local') return workerLazy().apply(null, args);\n\n const callback = args.pop();\n try {\n callback(null, call()({ version, callbacks: true }, workerPath, ...args));\n } catch (err) {\n callback(err);\n }\n };\n}\n"],"names":["Module","lazy","_require","require","createRequire","url","call","wrapWorker","workerPath","workerLazy","workerWrapper","version","args","apply","callback","pop","callbacks","err"],"mappings":"AAAA,OAAOA,YAAY,SAAS;AAC5B,OAAOC,UAAU,aAAa;AAC9B,MAAMC,WAAW,OAAOC,YAAY,cAAcH,OAAOI,aAAa,CAAC,YAAYC,GAAG,IAAIF;AAC1F,MAAMG,OAAOL,KAAKC,UAAU;AAE5B,eAAe,SAASK,WAAWC,UAAkB;IACnD,MAAMC,aAAaR,KAAKC,UAAUM;IAElC,OAAO,SAASE,cAAcC,OAAO,EAAE,GAAGC,IAAI;QAC5C,IAAID,YAAY,SAAS,OAAOF,aAAaI,KAAK,CAAC,MAAMD;QAEzD,MAAME,WAAWF,KAAKG,GAAG;QACzB,IAAI;YACFD,SAAS,MAAMR,OAAO;gBAAEK;gBAASK,WAAW;YAAK,GAAGR,eAAeI;QACrE,EAAE,OAAOK,KAAK;YACZH,SAASG;QACX;IACF;AACF"}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import Module from 'module';
|
|
2
|
-
import lazy from 'lazy-cache';
|
|
3
|
-
const _require = typeof require === 'undefined' ? Module.createRequire(import.meta.url) : require;
|
|
4
|
-
const call = lazy(_require)('node-version-call');
|
|
5
|
-
export default function wrapWorkerSync(workerPath) {
|
|
6
|
-
const workerLazy = lazy(_require)(workerPath);
|
|
7
|
-
return function workerWrapperSync(version, ...args) {
|
|
8
|
-
if (version === 'local') return workerLazy().apply(null, args);
|
|
9
|
-
return call()(version, workerPath, ...args);
|
|
10
|
-
};
|
|
11
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/typescript/ts-swc-transform/src/lib/wrapWorkerSync.ts"],"sourcesContent":["import Module from 'module';\nimport lazy from 'lazy-cache';\nconst _require = typeof require === 'undefined' ? Module.createRequire(import.meta.url) : require;\nconst call = lazy(_require)('node-version-call');\n\nexport default function wrapWorkerSync(workerPath: string) {\n const workerLazy = lazy(_require)(workerPath);\n\n return function workerWrapperSync(version, ...args) {\n if (version === 'local') return workerLazy().apply(null, args);\n return call()(version, workerPath, ...args);\n };\n}\n"],"names":["Module","lazy","_require","require","createRequire","url","call","wrapWorkerSync","workerPath","workerLazy","workerWrapperSync","version","args","apply"],"mappings":"AAAA,OAAOA,YAAY,SAAS;AAC5B,OAAOC,UAAU,aAAa;AAC9B,MAAMC,WAAW,OAAOC,YAAY,cAAcH,OAAOI,aAAa,CAAC,YAAYC,GAAG,IAAIF;AAC1F,MAAMG,OAAOL,KAAKC,UAAU;AAE5B,eAAe,SAASK,eAAeC,UAAkB;IACvD,MAAMC,aAAaR,KAAKC,UAAUM;IAElC,OAAO,SAASE,kBAAkBC,OAAO,EAAE,GAAGC,IAAI;QAChD,IAAID,YAAY,SAAS,OAAOF,aAAaI,KAAK,CAAC,MAAMD;QACzD,OAAON,OAAOK,SAASH,eAAeI;IACxC;AACF"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export default function wrapWorker(workerPath: string): (version: any, ...args: any[]) => any;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export default function wrapWorkerSync(workerPath: string): (version: any, ...args: any[]) => any;
|