ts-swc-transform 1.12.2 → 1.12.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/lib/installBindings.cjs +2 -2
- package/dist/cjs/lib/installBindings.cjs.map +1 -1
- package/dist/cjs/toPath.cjs +9 -1
- package/dist/cjs/toPath.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/esm/lib/installBindings.mjs +2 -2
- package/dist/esm/lib/installBindings.mjs.map +1 -1
- package/dist/esm/toPath.mjs +9 -1
- package/dist/esm/toPath.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/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
|
@@ -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"}
|
package/dist/cjs/toPath.cjs
CHANGED
|
@@ -19,6 +19,14 @@ function _interop_require_default(obj) {
|
|
|
19
19
|
default: obj
|
|
20
20
|
};
|
|
21
21
|
}
|
|
22
|
+
var existsSync = function(test) {
|
|
23
|
+
try {
|
|
24
|
+
(_fs.default.accessSync || _fs.default.statSync)(test);
|
|
25
|
+
return true;
|
|
26
|
+
} catch (_) {
|
|
27
|
+
return false;
|
|
28
|
+
}
|
|
29
|
+
};
|
|
22
30
|
function getParentPath(context) {
|
|
23
31
|
if (context.parentPath) return _path.default.dirname(context.parentPath);
|
|
24
32
|
return context.parentURL ? _path.default.dirname(toPath(context.parentURL)) : process.cwd();
|
|
@@ -55,7 +63,7 @@ function toPath(specifier, context) {
|
|
|
55
63
|
var modulePath = _path.default.resolve(pkg.dir, pkg.json.module);
|
|
56
64
|
var mainPath = _path.default.resolve(pkg.dir, pkg.json.main);
|
|
57
65
|
var moduleResolved = _path.default.resolve(modulePath, _path.default.relative(mainPath, main));
|
|
58
|
-
return moduleResolved.indexOf(specifier.replace(pkg.json.name, '')) < 0 || !
|
|
66
|
+
return moduleResolved.indexOf(specifier.replace(pkg.json.name, '')) < 0 || !existsSync(moduleResolved) ? main : moduleResolved;
|
|
59
67
|
}
|
|
60
68
|
return specifier;
|
|
61
69
|
}
|
package/dist/cjs/toPath.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/typescript/ts-swc-transform/src/toPath.ts"],"sourcesContent":["import fs from 'fs';\nimport path from 'path';\nimport isAbsolute from 'is-absolute';\nimport resolve from 'resolve';\nimport { moduleRegEx } from './constants';\nimport fileURLToPath from './lib/fileURLToPath';\nimport type { Context } from './types';\n\nfunction getParentPath(context: Context) {\n if (context.parentPath) return path.dirname(context.parentPath);\n return context.parentURL ? path.dirname(toPath(context.parentURL)) : process.cwd();\n}\n\nexport default function toPath(specifier: string, context?: Context) {\n if (specifier.startsWith('file:')) return fileURLToPath(specifier);\n if (isAbsolute(specifier)) return specifier;\n if (specifier[0] === '.') {\n const parentPath = context ? getParentPath(context) : process.cwd();\n return path.resolve(parentPath, specifier);\n }\n if (moduleRegEx.test(specifier)) {\n const parentPath = context ? getParentPath(context) : process.cwd();\n\n let pkg = null;\n const main = resolve.sync(specifier, {\n basedir: parentPath,\n extensions: ['.js', '.json', '.node', '.mjs'],\n packageFilter(json, dir) {\n pkg = { json, dir };\n return json;\n },\n });\n if (!pkg || !pkg.json.module) return main; // no modules, use main\n if (pkg.json.name === specifier) return path.resolve(pkg.dir, pkg.json.module); // the module\n\n // a relative path. Only accept if it doesn't break the relative naming and it exists\n const modulePath = path.resolve(pkg.dir, pkg.json.module);\n const mainPath = path.resolve(pkg.dir, pkg.json.main);\n const moduleResolved = path.resolve(modulePath, path.relative(mainPath, main));\n return moduleResolved.indexOf(specifier.replace(pkg.json.name, '')) < 0 || !
|
|
1
|
+
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/typescript/ts-swc-transform/src/toPath.ts"],"sourcesContent":["import fs from 'fs';\nimport path from 'path';\nimport isAbsolute from 'is-absolute';\nimport resolve from 'resolve';\nimport { moduleRegEx } from './constants';\nimport fileURLToPath from './lib/fileURLToPath';\nimport type { Context } from './types';\n\nconst existsSync = (test) => {\n try {\n (fs.accessSync || fs.statSync)(test);\n return true;\n } catch (_) {\n return false;\n }\n};\n\nfunction getParentPath(context: Context) {\n if (context.parentPath) return path.dirname(context.parentPath);\n return context.parentURL ? path.dirname(toPath(context.parentURL)) : process.cwd();\n}\n\nexport default function toPath(specifier: string, context?: Context) {\n if (specifier.startsWith('file:')) return fileURLToPath(specifier);\n if (isAbsolute(specifier)) return specifier;\n if (specifier[0] === '.') {\n const parentPath = context ? getParentPath(context) : process.cwd();\n return path.resolve(parentPath, specifier);\n }\n if (moduleRegEx.test(specifier)) {\n const parentPath = context ? getParentPath(context) : process.cwd();\n\n let pkg = null;\n const main = resolve.sync(specifier, {\n basedir: parentPath,\n extensions: ['.js', '.json', '.node', '.mjs'],\n packageFilter(json, dir) {\n pkg = { json, dir };\n return json;\n },\n });\n if (!pkg || !pkg.json.module) return main; // no modules, use main\n if (pkg.json.name === specifier) return path.resolve(pkg.dir, pkg.json.module); // the module\n\n // a relative path. Only accept if it doesn't break the relative naming and it exists\n const modulePath = path.resolve(pkg.dir, pkg.json.module);\n const mainPath = path.resolve(pkg.dir, pkg.json.main);\n const moduleResolved = path.resolve(modulePath, path.relative(mainPath, main));\n return moduleResolved.indexOf(specifier.replace(pkg.json.name, '')) < 0 || !existsSync(moduleResolved) ? main : moduleResolved;\n }\n\n return specifier;\n}\n"],"names":["toPath","existsSync","test","fs","accessSync","statSync","_","getParentPath","context","parentPath","path","dirname","parentURL","process","cwd","specifier","startsWith","fileURLToPath","isAbsolute","resolve","moduleRegEx","pkg","main","sync","basedir","extensions","packageFilter","json","dir","module","name","modulePath","mainPath","moduleResolved","relative","indexOf","replace"],"mappings":";;;;+BAsBA;;;eAAwBA;;;yDAtBT;2DACE;iEACM;8DACH;yBACQ;oEACF;;;;;;AAG1B,IAAMC,aAAa,SAACC;IAClB,IAAI;QACDC,CAAAA,WAAE,CAACC,UAAU,IAAID,WAAE,CAACE,QAAQ,AAAD,EAAGH;QAC/B,OAAO;IACT,EAAE,OAAOI,GAAG;QACV,OAAO;IACT;AACF;AAEA,SAASC,cAAcC,OAAgB;IACrC,IAAIA,QAAQC,UAAU,EAAE,OAAOC,aAAI,CAACC,OAAO,CAACH,QAAQC,UAAU;IAC9D,OAAOD,QAAQI,SAAS,GAAGF,aAAI,CAACC,OAAO,CAACX,OAAOQ,QAAQI,SAAS,KAAKC,QAAQC,GAAG;AAClF;AAEe,SAASd,OAAOe,SAAiB,EAAEP,OAAiB;IACjE,IAAIO,UAAUC,UAAU,CAAC,UAAU,OAAOC,IAAAA,sBAAa,EAACF;IACxD,IAAIG,IAAAA,mBAAU,EAACH,YAAY,OAAOA;IAClC,IAAIA,SAAS,CAAC,EAAE,KAAK,KAAK;QACxB,IAAMN,aAAaD,UAAUD,cAAcC,WAAWK,QAAQC,GAAG;QACjE,OAAOJ,aAAI,CAACS,OAAO,CAACV,YAAYM;IAClC;IACA,IAAIK,sBAAW,CAAClB,IAAI,CAACa,YAAY;QAC/B,IAAMN,cAAaD,UAAUD,cAAcC,WAAWK,QAAQC,GAAG;QAEjE,IAAIO,MAAM;QACV,IAAMC,OAAOH,gBAAO,CAACI,IAAI,CAACR,WAAW;YACnCS,SAASf;YACTgB,YAAY;gBAAC;gBAAO;gBAAS;gBAAS;aAAO;YAC7CC,eAAAA,SAAAA,cAAcC,IAAI,EAAEC,GAAG;gBACrBP,MAAM;oBAAEM,MAAAA;oBAAMC,KAAAA;gBAAI;gBAClB,OAAOD;YACT;QACF;QACA,IAAI,CAACN,OAAO,CAACA,IAAIM,IAAI,CAACE,MAAM,EAAE,OAAOP,MAAM,uBAAuB;QAClE,IAAID,IAAIM,IAAI,CAACG,IAAI,KAAKf,WAAW,OAAOL,aAAI,CAACS,OAAO,CAACE,IAAIO,GAAG,EAAEP,IAAIM,IAAI,CAACE,MAAM,GAAG,aAAa;QAE7F,qFAAqF;QACrF,IAAME,aAAarB,aAAI,CAACS,OAAO,CAACE,IAAIO,GAAG,EAAEP,IAAIM,IAAI,CAACE,MAAM;QACxD,IAAMG,WAAWtB,aAAI,CAACS,OAAO,CAACE,IAAIO,GAAG,EAAEP,IAAIM,IAAI,CAACL,IAAI;QACpD,IAAMW,iBAAiBvB,aAAI,CAACS,OAAO,CAACY,YAAYrB,aAAI,CAACwB,QAAQ,CAACF,UAAUV;QACxE,OAAOW,eAAeE,OAAO,CAACpB,UAAUqB,OAAO,CAACf,IAAIM,IAAI,CAACG,IAAI,EAAE,OAAO,KAAK,CAAC7B,WAAWgC,kBAAkBX,OAAOW;IAClH;IAEA,OAAOlB;AACT"}
|
|
@@ -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"}
|
|
@@ -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"}
|
package/dist/esm/toPath.mjs
CHANGED
|
@@ -4,6 +4,14 @@ import isAbsolute from 'is-absolute';
|
|
|
4
4
|
import resolve from 'resolve';
|
|
5
5
|
import { moduleRegEx } from './constants.mjs';
|
|
6
6
|
import fileURLToPath from './lib/fileURLToPath.mjs';
|
|
7
|
+
const existsSync = (test)=>{
|
|
8
|
+
try {
|
|
9
|
+
(fs.accessSync || fs.statSync)(test);
|
|
10
|
+
return true;
|
|
11
|
+
} catch (_) {
|
|
12
|
+
return false;
|
|
13
|
+
}
|
|
14
|
+
};
|
|
7
15
|
function getParentPath(context) {
|
|
8
16
|
if (context.parentPath) return path.dirname(context.parentPath);
|
|
9
17
|
return context.parentURL ? path.dirname(toPath(context.parentURL)) : process.cwd();
|
|
@@ -40,7 +48,7 @@ export default function toPath(specifier, context) {
|
|
|
40
48
|
const modulePath = path.resolve(pkg.dir, pkg.json.module);
|
|
41
49
|
const mainPath = path.resolve(pkg.dir, pkg.json.main);
|
|
42
50
|
const moduleResolved = path.resolve(modulePath, path.relative(mainPath, main));
|
|
43
|
-
return moduleResolved.indexOf(specifier.replace(pkg.json.name, '')) < 0 || !
|
|
51
|
+
return moduleResolved.indexOf(specifier.replace(pkg.json.name, '')) < 0 || !existsSync(moduleResolved) ? main : moduleResolved;
|
|
44
52
|
}
|
|
45
53
|
return specifier;
|
|
46
54
|
}
|
package/dist/esm/toPath.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/typescript/ts-swc-transform/src/toPath.ts"],"sourcesContent":["import fs from 'fs';\nimport path from 'path';\nimport isAbsolute from 'is-absolute';\nimport resolve from 'resolve';\nimport { moduleRegEx } from './constants';\nimport fileURLToPath from './lib/fileURLToPath';\nimport type { Context } from './types';\n\nfunction getParentPath(context: Context) {\n if (context.parentPath) return path.dirname(context.parentPath);\n return context.parentURL ? path.dirname(toPath(context.parentURL)) : process.cwd();\n}\n\nexport default function toPath(specifier: string, context?: Context) {\n if (specifier.startsWith('file:')) return fileURLToPath(specifier);\n if (isAbsolute(specifier)) return specifier;\n if (specifier[0] === '.') {\n const parentPath = context ? getParentPath(context) : process.cwd();\n return path.resolve(parentPath, specifier);\n }\n if (moduleRegEx.test(specifier)) {\n const parentPath = context ? getParentPath(context) : process.cwd();\n\n let pkg = null;\n const main = resolve.sync(specifier, {\n basedir: parentPath,\n extensions: ['.js', '.json', '.node', '.mjs'],\n packageFilter(json, dir) {\n pkg = { json, dir };\n return json;\n },\n });\n if (!pkg || !pkg.json.module) return main; // no modules, use main\n if (pkg.json.name === specifier) return path.resolve(pkg.dir, pkg.json.module); // the module\n\n // a relative path. Only accept if it doesn't break the relative naming and it exists\n const modulePath = path.resolve(pkg.dir, pkg.json.module);\n const mainPath = path.resolve(pkg.dir, pkg.json.main);\n const moduleResolved = path.resolve(modulePath, path.relative(mainPath, main));\n return moduleResolved.indexOf(specifier.replace(pkg.json.name, '')) < 0 || !
|
|
1
|
+
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/typescript/ts-swc-transform/src/toPath.ts"],"sourcesContent":["import fs from 'fs';\nimport path from 'path';\nimport isAbsolute from 'is-absolute';\nimport resolve from 'resolve';\nimport { moduleRegEx } from './constants';\nimport fileURLToPath from './lib/fileURLToPath';\nimport type { Context } from './types';\n\nconst existsSync = (test) => {\n try {\n (fs.accessSync || fs.statSync)(test);\n return true;\n } catch (_) {\n return false;\n }\n};\n\nfunction getParentPath(context: Context) {\n if (context.parentPath) return path.dirname(context.parentPath);\n return context.parentURL ? path.dirname(toPath(context.parentURL)) : process.cwd();\n}\n\nexport default function toPath(specifier: string, context?: Context) {\n if (specifier.startsWith('file:')) return fileURLToPath(specifier);\n if (isAbsolute(specifier)) return specifier;\n if (specifier[0] === '.') {\n const parentPath = context ? getParentPath(context) : process.cwd();\n return path.resolve(parentPath, specifier);\n }\n if (moduleRegEx.test(specifier)) {\n const parentPath = context ? getParentPath(context) : process.cwd();\n\n let pkg = null;\n const main = resolve.sync(specifier, {\n basedir: parentPath,\n extensions: ['.js', '.json', '.node', '.mjs'],\n packageFilter(json, dir) {\n pkg = { json, dir };\n return json;\n },\n });\n if (!pkg || !pkg.json.module) return main; // no modules, use main\n if (pkg.json.name === specifier) return path.resolve(pkg.dir, pkg.json.module); // the module\n\n // a relative path. Only accept if it doesn't break the relative naming and it exists\n const modulePath = path.resolve(pkg.dir, pkg.json.module);\n const mainPath = path.resolve(pkg.dir, pkg.json.main);\n const moduleResolved = path.resolve(modulePath, path.relative(mainPath, main));\n return moduleResolved.indexOf(specifier.replace(pkg.json.name, '')) < 0 || !existsSync(moduleResolved) ? main : moduleResolved;\n }\n\n return specifier;\n}\n"],"names":["fs","path","isAbsolute","resolve","moduleRegEx","fileURLToPath","existsSync","test","accessSync","statSync","_","getParentPath","context","parentPath","dirname","parentURL","toPath","process","cwd","specifier","startsWith","pkg","main","sync","basedir","extensions","packageFilter","json","dir","module","name","modulePath","mainPath","moduleResolved","relative","indexOf","replace"],"mappings":"AAAA,OAAOA,QAAQ,KAAK;AACpB,OAAOC,UAAU,OAAO;AACxB,OAAOC,gBAAgB,cAAc;AACrC,OAAOC,aAAa,UAAU;AAC9B,SAASC,WAAW,QAAQ,cAAc;AAC1C,OAAOC,mBAAmB,sBAAsB;AAGhD,MAAMC,aAAa,CAACC;IAClB,IAAI;QACDP,CAAAA,GAAGQ,UAAU,IAAIR,GAAGS,QAAQ,AAAD,EAAGF;QAC/B,OAAO;IACT,EAAE,OAAOG,GAAG;QACV,OAAO;IACT;AACF;AAEA,SAASC,cAAcC,OAAgB;IACrC,IAAIA,QAAQC,UAAU,EAAE,OAAOZ,KAAKa,OAAO,CAACF,QAAQC,UAAU;IAC9D,OAAOD,QAAQG,SAAS,GAAGd,KAAKa,OAAO,CAACE,OAAOJ,QAAQG,SAAS,KAAKE,QAAQC,GAAG;AAClF;AAEA,eAAe,SAASF,OAAOG,SAAiB,EAAEP,OAAiB;IACjE,IAAIO,UAAUC,UAAU,CAAC,UAAU,OAAOf,cAAcc;IACxD,IAAIjB,WAAWiB,YAAY,OAAOA;IAClC,IAAIA,SAAS,CAAC,EAAE,KAAK,KAAK;QACxB,MAAMN,aAAaD,UAAUD,cAAcC,WAAWK,QAAQC,GAAG;QACjE,OAAOjB,KAAKE,OAAO,CAACU,YAAYM;IAClC;IACA,IAAIf,YAAYG,IAAI,CAACY,YAAY;QAC/B,MAAMN,aAAaD,UAAUD,cAAcC,WAAWK,QAAQC,GAAG;QAEjE,IAAIG,MAAM;QACV,MAAMC,OAAOnB,QAAQoB,IAAI,CAACJ,WAAW;YACnCK,SAASX;YACTY,YAAY;gBAAC;gBAAO;gBAAS;gBAAS;aAAO;YAC7CC,eAAcC,IAAI,EAAEC,GAAG;gBACrBP,MAAM;oBAAEM;oBAAMC;gBAAI;gBAClB,OAAOD;YACT;QACF;QACA,IAAI,CAACN,OAAO,CAACA,IAAIM,IAAI,CAACE,MAAM,EAAE,OAAOP,MAAM,uBAAuB;QAClE,IAAID,IAAIM,IAAI,CAACG,IAAI,KAAKX,WAAW,OAAOlB,KAAKE,OAAO,CAACkB,IAAIO,GAAG,EAAEP,IAAIM,IAAI,CAACE,MAAM,GAAG,aAAa;QAE7F,qFAAqF;QACrF,MAAME,aAAa9B,KAAKE,OAAO,CAACkB,IAAIO,GAAG,EAAEP,IAAIM,IAAI,CAACE,MAAM;QACxD,MAAMG,WAAW/B,KAAKE,OAAO,CAACkB,IAAIO,GAAG,EAAEP,IAAIM,IAAI,CAACL,IAAI;QACpD,MAAMW,iBAAiBhC,KAAKE,OAAO,CAAC4B,YAAY9B,KAAKiC,QAAQ,CAACF,UAAUV;QACxE,OAAOW,eAAeE,OAAO,CAAChB,UAAUiB,OAAO,CAACf,IAAIM,IAAI,CAACG,IAAI,EAAE,OAAO,KAAK,CAACxB,WAAW2B,kBAAkBX,OAAOW;IAClH;IAEA,OAAOd;AACT"}
|
|
@@ -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"}
|
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;
|