ts-swc-transform 1.13.8 → 1.13.9
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/bindings/ensure.cjs +41 -0
- package/dist/cjs/bindings/ensure.cjs.map +1 -0
- package/dist/cjs/bindings/findDependency.cjs.map +1 -0
- package/dist/cjs/{workers/installBindings.cjs → bindings/install.cjs} +3 -3
- package/dist/cjs/bindings/install.cjs.map +1 -0
- package/dist/cjs/lib/swcPrepareOptions.cjs +2 -2
- package/dist/cjs/lib/swcPrepareOptions.cjs.map +1 -1
- package/dist/cjs/lib/transformFile.cjs +2 -2
- package/dist/cjs/lib/transformFile.cjs.map +1 -1
- package/dist/cjs/transformDirectory.cjs +1 -2
- package/dist/cjs/transformDirectory.cjs.map +1 -1
- package/dist/cjs/transformSync.cjs +1 -2
- package/dist/cjs/transformSync.cjs.map +1 -1
- package/dist/cjs/transformTypes.cjs +1 -2
- package/dist/cjs/transformTypes.cjs.map +1 -1
- package/dist/esm/bindings/ensure.cjs +39 -0
- package/dist/esm/bindings/ensure.cjs.map +1 -0
- package/dist/esm/bindings/findDependency.cjs.map +1 -0
- package/dist/esm/{workers/installBindings.cjs → bindings/install.cjs} +3 -3
- package/dist/esm/bindings/install.cjs.map +1 -0
- package/dist/esm/lib/swcPrepareOptions.mjs +2 -2
- package/dist/esm/lib/swcPrepareOptions.mjs.map +1 -1
- package/dist/esm/lib/transformFile.mjs +2 -2
- package/dist/esm/lib/transformFile.mjs.map +1 -1
- package/dist/esm/transformDirectory.mjs +1 -2
- package/dist/esm/transformDirectory.mjs.map +1 -1
- package/dist/esm/transformSync.mjs +1 -2
- package/dist/esm/transformSync.mjs.map +1 -1
- package/dist/esm/transformTypes.mjs +1 -2
- package/dist/esm/transformTypes.mjs.map +1 -1
- package/dist/types/bindings/ensure.d.cts +5 -0
- package/dist/types/bindings/install.d.cts +2 -0
- package/package.json +2 -2
- package/dist/cjs/lib/ensureBindings.cjs +0 -33
- package/dist/cjs/lib/ensureBindings.cjs.map +0 -1
- package/dist/cjs/lib/findDependency.cjs.map +0 -1
- package/dist/cjs/workers/installBindings.cjs.map +0 -1
- package/dist/esm/lib/ensureBindings.cjs +0 -29
- package/dist/esm/lib/ensureBindings.cjs.map +0 -1
- package/dist/esm/lib/findDependency.cjs.map +0 -1
- package/dist/esm/workers/installBindings.cjs.map +0 -1
- package/dist/types/lib/ensureBindings.d.cts +0 -2
- package/dist/types/workers/installBindings.d.cts +0 -2
- /package/dist/cjs/{lib → bindings}/findDependency.cjs +0 -0
- /package/dist/esm/{lib → bindings}/findDependency.cjs +0 -0
- /package/dist/types/{lib → bindings}/findDependency.d.cts +0 -0
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var path = require('path');
|
|
3
|
+
var fs = require('fs');
|
|
4
|
+
var resolveOnce = require('resolve-once-cb');
|
|
5
|
+
var findDependency = require('./findDependency.cjs');
|
|
6
|
+
var workerPath = path.join(__dirname, 'install.cjs');
|
|
7
|
+
var major = +process.versions.node.split('.')[0];
|
|
8
|
+
var version = major < 14 ? 'stable' : 'local';
|
|
9
|
+
var existsSync = function(test) {
|
|
10
|
+
try {
|
|
11
|
+
(fs.accessSync || fs.statSync)(test);
|
|
12
|
+
return true;
|
|
13
|
+
} catch (_) {
|
|
14
|
+
return false;
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
var bindings = {};
|
|
18
|
+
module.exports = function ensureBindings(identifier, target, callback) {
|
|
19
|
+
if (bindings[identifier] === undefined) bindings[identifier] = {};
|
|
20
|
+
if (bindings[identifier][target] === undefined) {
|
|
21
|
+
bindings[identifier][target] = resolveOnce(function(cb) {
|
|
22
|
+
var _findDependency = findDependency(identifier, target), name = _findDependency.name, modulePath = _findDependency.modulePath;
|
|
23
|
+
return existsSync(path.join(modulePath, '..', 'node_modules', name)) ? cb() : require(workerPath)(identifier, target, cb);
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
bindings[identifier][target](callback);
|
|
27
|
+
};
|
|
28
|
+
var bindingsSync = {};
|
|
29
|
+
module.exports.sync = function(identifier, target) {
|
|
30
|
+
if (bindingsSync[identifier] === undefined) bindingsSync[identifier] = {};
|
|
31
|
+
if (bindingsSync[identifier][target] === undefined) {
|
|
32
|
+
bindingsSync[identifier][target] = function() {
|
|
33
|
+
var _findDependency = findDependency(identifier, target), name = _findDependency.name, modulePath = _findDependency.modulePath;
|
|
34
|
+
return existsSync(path.join(modulePath, '..', 'node_modules', name)) ? target : require('node-version-call')({
|
|
35
|
+
version: version,
|
|
36
|
+
callbacks: true
|
|
37
|
+
}, workerPath, identifier, target);
|
|
38
|
+
}();
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
/* 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; }
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/typescript/ts-swc-transform/src/bindings/ensure.cjs"],"sourcesContent":["const path = require('path');\nconst fs = require('fs');\nconst resolveOnce = require('resolve-once-cb');\nconst findDependency = require('./findDependency.cjs');\n\nconst workerPath = path.join(__dirname, 'install.cjs');\nconst major = +process.versions.node.split('.')[0];\nconst version = major < 14 ? 'stable' : 'local';\n\nconst existsSync = (test) => {\n try {\n (fs.accessSync || fs.statSync)(test);\n return true;\n } catch (_) {\n return false;\n }\n};\n\nconst bindings = {};\nmodule.exports = function ensureBindings(identifier, target, callback) {\n if (bindings[identifier] === undefined) bindings[identifier] = {};\n if (bindings[identifier][target] === undefined) {\n bindings[identifier][target] = resolveOnce((cb) => {\n const { name, modulePath } = findDependency(identifier, target);\n return existsSync(path.join(modulePath, '..', 'node_modules', name)) ? cb() : require(workerPath)(identifier, target, cb);\n });\n }\n bindings[identifier][target](callback);\n};\n\nconst bindingsSync = {};\nmodule.exports.sync = (identifier, target) => {\n if (bindingsSync[identifier] === undefined) bindingsSync[identifier] = {};\n if (bindingsSync[identifier][target] === undefined) {\n bindingsSync[identifier][target] = (() => {\n const { name, modulePath } = findDependency(identifier, target);\n return existsSync(path.join(modulePath, '..', 'node_modules', name)) ? target : require('node-version-call')({ version, callbacks: true }, workerPath, identifier, target);\n })();\n }\n};\n"],"names":["path","require","fs","resolveOnce","findDependency","workerPath","join","__dirname","major","process","versions","node","split","version","existsSync","test","accessSync","statSync","_","bindings","module","exports","ensureBindings","identifier","target","callback","undefined","cb","name","modulePath","bindingsSync","sync","callbacks"],"mappings":";AAAA,IAAMA,OAAOC,QAAQ;AACrB,IAAMC,KAAKD,QAAQ;AACnB,IAAME,cAAcF,QAAQ;AAC5B,IAAMG,iBAAiBH,QAAQ;AAE/B,IAAMI,aAAaL,KAAKM,IAAI,CAACC,WAAW;AACxC,IAAMC,QAAQ,CAACC,QAAQC,QAAQ,CAACC,IAAI,CAACC,KAAK,CAAC,IAAI,CAAC,EAAE;AAClD,IAAMC,UAAUL,QAAQ,KAAK,WAAW;AAExC,IAAMM,aAAa,SAACC;IAClB,IAAI;QACDb,CAAAA,GAAGc,UAAU,IAAId,GAAGe,QAAQ,AAAD,EAAGF;QAC/B,OAAO;IACT,EAAE,OAAOG,GAAG;QACV,OAAO;IACT;AACF;AAEA,IAAMC,WAAW,CAAC;AAClBC,OAAOC,OAAO,GAAG,SAASC,eAAeC,UAAU,EAAEC,MAAM,EAAEC,QAAQ;IACnE,IAAIN,QAAQ,CAACI,WAAW,KAAKG,WAAWP,QAAQ,CAACI,WAAW,GAAG,CAAC;IAChE,IAAIJ,QAAQ,CAACI,WAAW,CAACC,OAAO,KAAKE,WAAW;QAC9CP,QAAQ,CAACI,WAAW,CAACC,OAAO,GAAGrB,YAAY,SAACwB;YAC1C,IAA6BvB,kBAAAA,eAAemB,YAAYC,SAAhDI,OAAqBxB,gBAArBwB,MAAMC,aAAezB,gBAAfyB;YACd,OAAOf,WAAWd,KAAKM,IAAI,CAACuB,YAAY,MAAM,gBAAgBD,SAASD,OAAO1B,QAAQI,YAAYkB,YAAYC,QAAQG;QACxH;IACF;IACAR,QAAQ,CAACI,WAAW,CAACC,OAAO,CAACC;AAC/B;AAEA,IAAMK,eAAe,CAAC;AACtBV,OAAOC,OAAO,CAACU,IAAI,GAAG,SAACR,YAAYC;IACjC,IAAIM,YAAY,CAACP,WAAW,KAAKG,WAAWI,YAAY,CAACP,WAAW,GAAG,CAAC;IACxE,IAAIO,YAAY,CAACP,WAAW,CAACC,OAAO,KAAKE,WAAW;QAClDI,YAAY,CAACP,WAAW,CAACC,OAAO,GAAG,AAAC;YAClC,IAA6BpB,kBAAAA,eAAemB,YAAYC,SAAhDI,OAAqBxB,gBAArBwB,MAAMC,aAAezB,gBAAfyB;YACd,OAAOf,WAAWd,KAAKM,IAAI,CAACuB,YAAY,MAAM,gBAAgBD,SAASJ,SAASvB,QAAQ,qBAAqB;gBAAEY,SAAAA;gBAASmB,WAAW;YAAK,GAAG3B,YAAYkB,YAAYC;QACrK;IACF;AACF"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/typescript/ts-swc-transform/src/bindings/findDependency.cjs"],"sourcesContent":["const path = require('path');\nconst fs = require('fs');\nconst resolve = require('resolve');\n\nmodule.exports = function findDependency(identifier, target) {\n const packagePath = resolve.sync(`${identifier}/package.json`);\n const optionalDependencies = JSON.parse(fs.readFileSync(packagePath, 'utf8')).optionalDependencies;\n const name = Object.keys(optionalDependencies).find((name) => name.indexOf(target) >= 0);\n return name ? { name, version: optionalDependencies[name], modulePath: path.dirname(packagePath) } : null;\n};\n"],"names":["path","require","fs","resolve","module","exports","findDependency","identifier","target","packagePath","sync","optionalDependencies","JSON","parse","readFileSync","name","Object","keys","find","indexOf","version","modulePath","dirname"],"mappings":";AAAA,IAAMA,OAAOC,QAAQ;AACrB,IAAMC,KAAKD,QAAQ;AACnB,IAAME,UAAUF,QAAQ;AAExBG,OAAOC,OAAO,GAAG,SAASC,eAAeC,UAAU,EAAEC,MAAM;IACzD,IAAMC,cAAcN,QAAQO,IAAI,CAAC,AAAC,GAAa,OAAXH,YAAW;IAC/C,IAAMI,uBAAuBC,KAAKC,KAAK,CAACX,GAAGY,YAAY,CAACL,aAAa,SAASE,oBAAoB;IAClG,IAAMI,OAAOC,OAAOC,IAAI,CAACN,sBAAsBO,IAAI,CAAC,SAACH;eAASA,KAAKI,OAAO,CAACX,WAAW;;IACtF,OAAOO,OAAO;QAAEA,MAAAA;QAAMK,SAAST,oBAAoB,CAACI,KAAK;QAAEM,YAAYrB,KAAKsB,OAAO,CAACb;IAAa,IAAI;AACvG"}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var path = require('path');
|
|
3
3
|
var installModule = require('install-module-linked');
|
|
4
|
-
var findDependency = require('
|
|
5
|
-
module.exports = function installBindings(target, callback) {
|
|
6
|
-
var _findDependency = findDependency(
|
|
4
|
+
var findDependency = require('./findDependency.cjs');
|
|
5
|
+
module.exports = function installBindings(identifier, target, callback) {
|
|
6
|
+
var _findDependency = findDependency(identifier, target), name = _findDependency.name, version = _findDependency.version, modulePath = _findDependency.modulePath;
|
|
7
7
|
var nodeModules = path.join(modulePath, '..', 'node_modules');
|
|
8
8
|
var installString = version ? "".concat(name, "@").concat(version) : name;
|
|
9
9
|
installModule(installString, nodeModules, function(err) {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/typescript/ts-swc-transform/src/bindings/install.cjs"],"sourcesContent":["const path = require('path');\nconst installModule = require('install-module-linked');\nconst findDependency = require('./findDependency.cjs');\n\nmodule.exports = function installBindings(identifier, target, callback) {\n const { name, version, modulePath } = findDependency(identifier, target);\n const nodeModules = path.join(modulePath, '..', 'node_modules');\n const installString = version ? `${name}@${version}` : name;\n\n installModule(installString, nodeModules, (err) => {\n console.log(`installed ${path.join(nodeModules, name)} ${!err ? 'successfully' : 'with errors: ${err.message}'}`);\n callback(err);\n });\n};\n"],"names":["path","require","installModule","findDependency","module","exports","installBindings","identifier","target","callback","name","version","modulePath","nodeModules","join","installString","err","console","log"],"mappings":";AAAA,IAAMA,OAAOC,QAAQ;AACrB,IAAMC,gBAAgBD,QAAQ;AAC9B,IAAME,iBAAiBF,QAAQ;AAE/BG,OAAOC,OAAO,GAAG,SAASC,gBAAgBC,UAAU,EAAEC,MAAM,EAAEC,QAAQ;IACpE,IAAsCN,kBAAAA,eAAeI,YAAYC,SAAzDE,OAA8BP,gBAA9BO,MAAMC,UAAwBR,gBAAxBQ,SAASC,aAAeT,gBAAfS;IACvB,IAAMC,cAAcb,KAAKc,IAAI,CAACF,YAAY,MAAM;IAChD,IAAMG,gBAAgBJ,UAAU,AAAC,GAAUA,OAARD,MAAK,KAAW,OAARC,WAAYD;IAEvDR,cAAca,eAAeF,aAAa,SAACG;QACzCC,QAAQC,GAAG,CAAC,AAAC,aAA4C,OAAhClB,KAAKc,IAAI,CAACD,aAAaH,OAAM,KAAyD,OAAtD,CAACM,MAAM,iBAAiB;QACjFP,SAASO;IACX;AACF"}
|
|
@@ -9,7 +9,7 @@ Object.defineProperty(exports, "default", {
|
|
|
9
9
|
}
|
|
10
10
|
});
|
|
11
11
|
var _path = /*#__PURE__*/ _interop_require_default(require("path"));
|
|
12
|
-
var
|
|
12
|
+
var _ensurecjs = require("../bindings/ensure.cjs");
|
|
13
13
|
var _module = /*#__PURE__*/ _interop_require_default(require("module"));
|
|
14
14
|
var _lazycache = /*#__PURE__*/ _interop_require_default(require("lazy-cache"));
|
|
15
15
|
function _interop_require_default(obj) {
|
|
@@ -22,7 +22,7 @@ var tsLazy = (0, _lazycache.default)(_require)('typescript');
|
|
|
22
22
|
var swcLazy = (0, _lazycache.default)(_require)('@swc/core');
|
|
23
23
|
var transpilerLazy = (0, _lazycache.default)(_require)('ts-node/transpilers/swc');
|
|
24
24
|
function swcPrepareOptions(tsconfig) {
|
|
25
|
-
(0,
|
|
25
|
+
(0, _ensurecjs.sync)('@swc/core', "".concat(process.platform, "-").concat(process.arch));
|
|
26
26
|
try {
|
|
27
27
|
var ts = tsLazy();
|
|
28
28
|
var swc = swcLazy();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/typescript/ts-swc-transform/src/lib/swcPrepareOptions.ts"],"sourcesContent":["import path from 'path';\nimport { sync as ensureBindings } from '
|
|
1
|
+
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/typescript/ts-swc-transform/src/lib/swcPrepareOptions.ts"],"sourcesContent":["import path from 'path';\nimport { sync as ensureBindings } from '../bindings/ensure.cjs';\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');\nconst swcLazy = lazy(_require)('@swc/core');\nconst transpilerLazy = lazy(_require)('ts-node/transpilers/swc');\n\nimport type { TsConfigResult } from 'get-tsconfig-compat';\n\nexport default function swcPrepareOptions(tsconfig: TsConfigResult) {\n ensureBindings('@swc/core', `${process.platform}-${process.arch}`);\n try {\n const ts = tsLazy();\n const swc = swcLazy();\n const transpiler = transpilerLazy();\n const parsed = ts.parseJsonConfigFileContent(tsconfig.config, ts.sys, path.dirname(tsconfig.path));\n return transpiler.createSwcOptions(parsed.options, undefined, swc, 'swc');\n } catch (err) {\n console.log(`swcPrepareOptions failed: ${err.message}`);\n return {};\n }\n}\n"],"names":["swcPrepareOptions","_require","require","Module","createRequire","tsLazy","lazy","swcLazy","transpilerLazy","tsconfig","ensureBindings","process","platform","arch","ts","swc","transpiler","parsed","parseJsonConfigFileContent","config","sys","path","dirname","createSwcOptions","options","undefined","err","console","log","message"],"mappings":";;;;+BAYA;;;eAAwBA;;;2DAZP;yBACsB;6DAEpB;gEACF;;;;;;AACjB,IAAMC,WAAW,OAAOC,YAAY,cAAcC,eAAM,CAACC,aAAa,CAAC,uDAAmBF;AAC1F,IAAMG,SAASC,IAAAA,kBAAI,EAACL,UAAU;AAC9B,IAAMM,UAAUD,IAAAA,kBAAI,EAACL,UAAU;AAC/B,IAAMO,iBAAiBF,IAAAA,kBAAI,EAACL,UAAU;AAIvB,SAASD,kBAAkBS,QAAwB;IAChEC,IAAAA,eAAc,EAAC,aAAa,AAAC,GAAsBC,OAApBA,QAAQC,QAAQ,EAAC,KAAgB,OAAbD,QAAQE,IAAI;IAC/D,IAAI;QACF,IAAMC,KAAKT;QACX,IAAMU,MAAMR;QACZ,IAAMS,aAAaR;QACnB,IAAMS,SAASH,GAAGI,0BAA0B,CAACT,SAASU,MAAM,EAAEL,GAAGM,GAAG,EAAEC,aAAI,CAACC,OAAO,CAACb,SAASY,IAAI;QAChG,OAAOL,WAAWO,gBAAgB,CAACN,OAAOO,OAAO,EAAEC,WAAWV,KAAK;IACrE,EAAE,OAAOW,KAAK;QACZC,QAAQC,GAAG,CAAC,AAAC,6BAAwC,OAAZF,IAAIG,OAAO;QACpD,OAAO,CAAC;IACV;AACF"}
|
|
@@ -12,7 +12,7 @@ var _fs = /*#__PURE__*/ _interop_require_default(require("fs"));
|
|
|
12
12
|
var _path = /*#__PURE__*/ _interop_require_default(require("path"));
|
|
13
13
|
var _mkdirpclassic = /*#__PURE__*/ _interop_require_default(require("mkdirp-classic"));
|
|
14
14
|
var _queuecb = /*#__PURE__*/ _interop_require_default(require("queue-cb"));
|
|
15
|
-
var
|
|
15
|
+
var _ensurecjs = /*#__PURE__*/ _interop_require_default(require("../bindings/ensure.cjs"));
|
|
16
16
|
var _patchCJS = /*#__PURE__*/ _interop_require_default(require("../lib/patchCJS.cjs"));
|
|
17
17
|
var _patchESM = /*#__PURE__*/ _interop_require_default(require("../lib/patchESM.cjs"));
|
|
18
18
|
var _swcPrepareOptions = /*#__PURE__*/ _interop_require_default(require("../lib/swcPrepareOptions.cjs"));
|
|
@@ -78,7 +78,7 @@ function _object_spread_props(target, source) {
|
|
|
78
78
|
var _require = typeof require === 'undefined' ? _module.default.createRequire(require("url").pathToFileURL(__filename).toString()) : require;
|
|
79
79
|
var swcLazy = (0, _lazycache.default)(_require)('@swc/core');
|
|
80
80
|
function transformFile(entry, dest, type, options, callback) {
|
|
81
|
-
(0,
|
|
81
|
+
(0, _ensurecjs.default)('@swc/core', "".concat(process.platform, "-").concat(process.arch), function(err) {
|
|
82
82
|
if (err) return callback(err);
|
|
83
83
|
var tsconfig = options.tsconfig;
|
|
84
84
|
// overrides for cjs
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/typescript/ts-swc-transform/src/lib/transformFile.ts"],"sourcesContent":["import fs from 'fs';\nimport path from 'path';\nimport mkdirp from 'mkdirp-classic';\nimport Queue from 'queue-cb';\nimport ensureBindings from '
|
|
1
|
+
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/typescript/ts-swc-transform/src/lib/transformFile.ts"],"sourcesContent":["import fs from 'fs';\nimport path from 'path';\nimport mkdirp from 'mkdirp-classic';\nimport Queue from 'queue-cb';\nimport ensureBindings from '../bindings/ensure.cjs';\n\nimport patchCJS from '../lib/patchCJS';\nimport patchESM from '../lib/patchESM';\nimport swcPrepareOptions from '../lib/swcPrepareOptions';\n\nimport Module from 'module';\nimport lazy from 'lazy-cache';\nconst _require = typeof require === 'undefined' ? Module.createRequire(import.meta.url) : require;\nconst swcLazy = lazy(_require)('@swc/core');\n\nexport default function transformFile(entry, dest, type, options, callback) {\n ensureBindings('@swc/core', `${process.platform}-${process.arch}`, (err) => {\n if (err) return callback(err);\n\n let tsconfig = options.tsconfig;\n\n // overrides for cjs\n if (type === 'cjs') {\n tsconfig = { ...tsconfig };\n tsconfig.config = { ...tsconfig.config };\n tsconfig.config.compilerOptions = { ...(tsconfig.config.compilerOptions || {}) };\n tsconfig.config.compilerOptions.module = 'CommonJS';\n tsconfig.config.compilerOptions.target = 'ES5';\n }\n\n const swcOptions = swcPrepareOptions(tsconfig);\n const swc = swcLazy();\n\n swc\n .transformFile(entry.fullPath, {\n ...(entry.basename.endsWith('.tsx') || entry.basename.endsWith('.jsx') ? swcOptions.tsxOptions : swcOptions.nonTsxOptions),\n filename: entry.basename,\n })\n .then((output) => {\n const extTarget = type === 'esm' ? patchESM(entry, output, options) : patchCJS(entry, output, options);\n const ext = path.extname(entry.path);\n const outPath = path.join(dest, (ext ? entry.path.slice(0, -ext.length) : entry.path) + extTarget);\n\n mkdirp(path.dirname(outPath), () => {\n const queue = new Queue();\n queue.defer(fs.writeFile.bind(null, outPath, output.code, 'utf8'));\n !options.sourceMaps || queue.defer(fs.writeFile.bind(null, `${outPath}.map`, output.map, 'utf8'));\n queue.await((err) => (err ? callback(err) : callback(null, outPath)));\n });\n })\n .catch(callback);\n });\n}\n"],"names":["transformFile","_require","require","Module","createRequire","swcLazy","lazy","entry","dest","type","options","callback","ensureBindings","process","platform","arch","err","tsconfig","config","compilerOptions","module","target","swcOptions","swcPrepareOptions","swc","fullPath","basename","endsWith","tsxOptions","nonTsxOptions","filename","then","output","extTarget","patchESM","patchCJS","ext","path","extname","outPath","join","slice","length","mkdirp","dirname","queue","Queue","defer","fs","writeFile","bind","code","sourceMaps","map","await","catch"],"mappings":";;;;+BAeA;;;eAAwBA;;;yDAfT;2DACE;oEACE;8DACD;gEACS;+DAEN;+DACA;wEACS;6DAEX;gEACF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACjB,IAAMC,WAAW,OAAOC,YAAY,cAAcC,eAAM,CAACC,aAAa,CAAC,uDAAmBF;AAC1F,IAAMG,UAAUC,IAAAA,kBAAI,EAACL,UAAU;AAEhB,SAASD,cAAcO,KAAK,EAAEC,IAAI,EAAEC,IAAI,EAAEC,OAAO,EAAEC,QAAQ;IACxEC,IAAAA,kBAAc,EAAC,aAAa,AAAC,GAAsBC,OAApBA,QAAQC,QAAQ,EAAC,KAAgB,OAAbD,QAAQE,IAAI,GAAI,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ACzC,QAAQ0C,UAAU,IAAIP,MAAME,KAAK,CAACC,WAAE,CAACC,SAAS,CAACC,IAAI,CAAC,MAAM,AAAC,GAAU,OAARX,SAAQ,SAAOP,OAAOqB,GAAG,EAAE;gBACzFR,MAAMS,KAAK,CAAC,SAACtC;2BAASA,MAAML,SAASK,OAAOL,SAAS,MAAM4B;;YAC7D;QACF,GACCgB,KAAK,CAAC5C;IACX;AACF"}
|
|
@@ -59,9 +59,8 @@ var __dirname = _path.default.dirname(typeof __filename === 'undefined' ? _url.d
|
|
|
59
59
|
var workerPath = _path.default.join(__dirname, '..', 'cjs', 'workers', 'transformDirectory.cjs');
|
|
60
60
|
var _require = typeof require === 'undefined' ? _module.default.createRequire(require("url").pathToFileURL(__filename).toString()) : require;
|
|
61
61
|
var callLazy = (0, _lazycache.default)(_require)('node-version-call');
|
|
62
|
-
var workerLazy = (0, _lazycache.default)(_require)(workerPath);
|
|
63
62
|
function dispatch(version, src, dest, type, options, callback) {
|
|
64
|
-
if (version === 'local') return
|
|
63
|
+
if (version === 'local') return _require(workerPath)(src, dest, type, options, callback);
|
|
65
64
|
try {
|
|
66
65
|
callback(null, callLazy()({
|
|
67
66
|
version: version,
|
|
@@ -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);\nconst workerPath = path.join(__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');\
|
|
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.join(__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');\n\nfunction dispatch(version, src, dest, type, options, callback) {\n if (version === 'local') return _require(workerPath)(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) as undefined;\n return new Promise((resolve, reject) => dispatch(version, src, dest, type, options, (err, result) => (err ? reject(err) : resolve(result))));\n } catch (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","join","_require","require","Module","createRequire","callLazy","lazy","dispatch","src","dest","type","options","callback","callbacks","err","Error","tsconfig","loadTsConfig","cwd","Promise","resolve","reject","result"],"mappings":";;;;+BAwBA;;;;;;;CAOC,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,IAAI,CAACP,WAAW,MAAM,OAAO,WAAW;AAIhE,IAAMQ,WAAW,OAAOC,YAAY,cAAcC,eAAM,CAACC,aAAa,CAAC,uDAAmBF;AAC1F,IAAMG,WAAWC,IAAAA,kBAAI,EAACL,UAAU;AAEhC,SAASM,SAASf,OAAO,EAAEgB,GAAG,EAAEC,IAAI,EAAEC,IAAI,EAAEC,OAAO,EAAEC,QAAQ;IAC3D,IAAIpB,YAAY,SAAS,OAAOS,SAASF,YAAYS,KAAKC,MAAMC,MAAMC,SAASC;IAC/E,IAAI;QACFA,SAAS,MAAMP,WAAW;YAAEb,SAAAA;YAASqB,WAAW;QAAK,GAAGd,YAAYS,KAAKC,MAAMC,MAAMC;IACvF,EAAE,OAAOG,KAAK;QACZF,SAASE;IACX;AACF;AAWe,SAAS5B,mBAAmBsB,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,SAASf,SAASgB,KAAKC,MAAMC,MAAMC,SAASC;QACvF,OAAO,IAAIO,QAAQ,SAACC,SAASC;mBAAWd,SAASf,SAASgB,KAAKC,MAAMC,MAAMC,SAAS,SAACG,KAAKQ;uBAAYR,MAAMO,OAAOP,OAAOM,QAAQE;;;IACpI,EAAE,OAAOR,KAAK;QACZ,IAAIF,UAAUA,SAASE;aAClB,OAAOK,QAAQE,MAAM,CAACP;IAC7B;AACF"}
|
|
@@ -70,9 +70,8 @@ var __dirname = _path.default.dirname(typeof __filename === 'undefined' ? _url.d
|
|
|
70
70
|
var workerPath = _path.default.join(__dirname, '..', 'cjs', 'workers', 'transformSync.cjs');
|
|
71
71
|
var _require = typeof require === 'undefined' ? _module.default.createRequire(require("url").pathToFileURL(__filename).toString()) : require;
|
|
72
72
|
var callLazy = (0, _lazycache.default)(_require)('node-version-call');
|
|
73
|
-
var workerLazy = (0, _lazycache.default)(_require)(workerPath);
|
|
74
73
|
function dispatch(version, contents, fileName, tsconfig) {
|
|
75
|
-
if (version === 'local') return
|
|
74
|
+
if (version === 'local') return _require(workerPath)(contents, fileName, tsconfig);
|
|
76
75
|
return callLazy()(version, workerPath, contents, fileName, tsconfig);
|
|
77
76
|
}
|
|
78
77
|
function transformSync(contents, fileName, tsconfig) {
|
|
@@ -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\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.join(__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');\
|
|
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.join(__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');\n\nfunction dispatch(version, contents, fileName, tsconfig) {\n if (version === 'local') return _require(workerPath)(contents, fileName, tsconfig);\n return callLazy()(version, workerPath, contents, fileName, tsconfig);\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","join","_require","require","Module","createRequire","callLazy","lazy","dispatch","contents","fileName","tsconfig","Error","getTS","getTsconfig","cwd"],"mappings":";;;;+BAqBA;;;;;CAKC,GACD;;;eAAwBA;;;2DA3BP;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,IAAI,CAACP,WAAW,MAAM,OAAO,WAAW;AAIhE,IAAMQ,WAAW,OAAOC,YAAY,cAAcC,eAAM,CAACC,aAAa,CAAC,uDAAmBF;AAC1F,IAAMG,WAAWC,IAAAA,kBAAI,EAACL,UAAU;AAEhC,SAASM,SAASf,OAAO,EAAEgB,QAAQ,EAAEC,QAAQ,EAAEC,QAAQ;IACrD,IAAIlB,YAAY,SAAS,OAAOS,SAASF,YAAYS,UAAUC,UAAUC;IACzE,OAAOL,WAAWb,SAASO,YAAYS,UAAUC,UAAUC;AAC7D;AAUe,SAASxB,cAAcsB,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,CAACzB,QAAQ0B,GAAG;IACvD,OAAOP,SAASf,SAASgB,UAAUC,UAAUC;AAC/C"}
|
|
@@ -58,9 +58,8 @@ var __dirname = _path.default.dirname(typeof __filename === 'undefined' ? _url.d
|
|
|
58
58
|
var workerPath = _path.default.join(__dirname, '..', 'cjs', 'workers', 'transformTypes.cjs');
|
|
59
59
|
var _require = typeof require === 'undefined' ? _module.default.createRequire(require("url").pathToFileURL(__filename).toString()) : require;
|
|
60
60
|
var callLazy = (0, _lazycache.default)(_require)('node-version-call');
|
|
61
|
-
var workerLazy = (0, _lazycache.default)(_require)(workerPath);
|
|
62
61
|
function dispatch(version, src, dest, options, callback) {
|
|
63
|
-
if (version === 'local') return
|
|
62
|
+
if (version === 'local') return _require(workerPath)(src, dest, options, callback);
|
|
64
63
|
try {
|
|
65
64
|
callback(null, callLazy()({
|
|
66
65
|
version: version,
|
|
@@ -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);\nconst workerPath = path.join(__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');\
|
|
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.join(__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');\n\nfunction dispatch(version, src, dest, options, callback) {\n if (version === 'local') return _require(workerPath)(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 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","join","_require","require","Module","createRequire","callLazy","lazy","dispatch","src","dest","options","callback","callbacks","err","Error","tsconfig","loadTsConfig","cwd","Promise","resolve","reject","result"],"mappings":";;;;+BAwBA;;;;;;CAMC,GACD;;;eAAwBA;;;2DA/BP;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,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K,QAAQE,MAAM,CAACP;IAC7B;AACF"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
const path = require('path');
|
|
2
|
+
const fs = require('fs');
|
|
3
|
+
const resolveOnce = require('resolve-once-cb');
|
|
4
|
+
const findDependency = require('./findDependency.cjs');
|
|
5
|
+
const workerPath = path.join(__dirname, 'install.cjs');
|
|
6
|
+
const major = +process.versions.node.split('.')[0];
|
|
7
|
+
const version = major < 14 ? 'stable' : 'local';
|
|
8
|
+
const existsSync = (test)=>{
|
|
9
|
+
try {
|
|
10
|
+
(fs.accessSync || fs.statSync)(test);
|
|
11
|
+
return true;
|
|
12
|
+
} catch (_) {
|
|
13
|
+
return false;
|
|
14
|
+
}
|
|
15
|
+
};
|
|
16
|
+
const bindings = {};
|
|
17
|
+
module.exports = function ensureBindings(identifier, target, callback) {
|
|
18
|
+
if (bindings[identifier] === undefined) bindings[identifier] = {};
|
|
19
|
+
if (bindings[identifier][target] === undefined) {
|
|
20
|
+
bindings[identifier][target] = resolveOnce((cb)=>{
|
|
21
|
+
const { name, modulePath } = findDependency(identifier, target);
|
|
22
|
+
return existsSync(path.join(modulePath, '..', 'node_modules', name)) ? cb() : require(workerPath)(identifier, target, cb);
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
bindings[identifier][target](callback);
|
|
26
|
+
};
|
|
27
|
+
const bindingsSync = {};
|
|
28
|
+
module.exports.sync = (identifier, target)=>{
|
|
29
|
+
if (bindingsSync[identifier] === undefined) bindingsSync[identifier] = {};
|
|
30
|
+
if (bindingsSync[identifier][target] === undefined) {
|
|
31
|
+
bindingsSync[identifier][target] = (()=>{
|
|
32
|
+
const { name, modulePath } = findDependency(identifier, target);
|
|
33
|
+
return existsSync(path.join(modulePath, '..', 'node_modules', name)) ? target : require('node-version-call')({
|
|
34
|
+
version,
|
|
35
|
+
callbacks: true
|
|
36
|
+
}, workerPath, identifier, target);
|
|
37
|
+
})();
|
|
38
|
+
}
|
|
39
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/typescript/ts-swc-transform/src/bindings/ensure.cjs"],"sourcesContent":["const path = require('path');\nconst fs = require('fs');\nconst resolveOnce = require('resolve-once-cb');\nconst findDependency = require('./findDependency.cjs');\n\nconst workerPath = path.join(__dirname, 'install.cjs');\nconst major = +process.versions.node.split('.')[0];\nconst version = major < 14 ? 'stable' : 'local';\n\nconst existsSync = (test) => {\n try {\n (fs.accessSync || fs.statSync)(test);\n return true;\n } catch (_) {\n return false;\n }\n};\n\nconst bindings = {};\nmodule.exports = function ensureBindings(identifier, target, callback) {\n if (bindings[identifier] === undefined) bindings[identifier] = {};\n if (bindings[identifier][target] === undefined) {\n bindings[identifier][target] = resolveOnce((cb) => {\n const { name, modulePath } = findDependency(identifier, target);\n return existsSync(path.join(modulePath, '..', 'node_modules', name)) ? cb() : require(workerPath)(identifier, target, cb);\n });\n }\n bindings[identifier][target](callback);\n};\n\nconst bindingsSync = {};\nmodule.exports.sync = (identifier, target) => {\n if (bindingsSync[identifier] === undefined) bindingsSync[identifier] = {};\n if (bindingsSync[identifier][target] === undefined) {\n bindingsSync[identifier][target] = (() => {\n const { name, modulePath } = findDependency(identifier, target);\n return existsSync(path.join(modulePath, '..', 'node_modules', name)) ? target : require('node-version-call')({ version, callbacks: true }, workerPath, identifier, target);\n })();\n }\n};\n"],"names":["path","require","fs","resolveOnce","findDependency","workerPath","join","__dirname","major","process","versions","node","split","version","existsSync","test","accessSync","statSync","_","bindings","module","exports","ensureBindings","identifier","target","callback","undefined","cb","name","modulePath","bindingsSync","sync","callbacks"],"mappings":"AAAA,MAAMA,OAAOC,QAAQ;AACrB,MAAMC,KAAKD,QAAQ;AACnB,MAAME,cAAcF,QAAQ;AAC5B,MAAMG,iBAAiBH,QAAQ;AAE/B,MAAMI,aAAaL,KAAKM,IAAI,CAACC,WAAW;AACxC,MAAMC,QAAQ,CAACC,QAAQC,QAAQ,CAACC,IAAI,CAACC,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AYC;QACrK,CAAA;IACF;AACF"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/typescript/ts-swc-transform/src/bindings/findDependency.cjs"],"sourcesContent":["const path = require('path');\nconst fs = require('fs');\nconst resolve = require('resolve');\n\nmodule.exports = function findDependency(identifier, target) {\n const packagePath = resolve.sync(`${identifier}/package.json`);\n const optionalDependencies = JSON.parse(fs.readFileSync(packagePath, 'utf8')).optionalDependencies;\n const name = Object.keys(optionalDependencies).find((name) => name.indexOf(target) >= 0);\n return name ? { name, version: optionalDependencies[name], modulePath: path.dirname(packagePath) } : null;\n};\n"],"names":["path","require","fs","resolve","module","exports","findDependency","identifier","target","packagePath","sync","optionalDependencies","JSON","parse","readFileSync","name","Object","keys","find","indexOf","version","modulePath","dirname"],"mappings":"AAAA,MAAMA,OAAOC,QAAQ;AACrB,MAAMC,KAAKD,QAAQ;AACnB,MAAME,UAAUF,QAAQ;AAExBG,OAAOC,OAAO,GAAG,SAASC,eAAeC,UAAU,EAAEC,MAAM;IACzD,MAAMC,cAAcN,QAAQO,IAAI,CAAC,GAAGH,WAAW,aAAa,CAAC;IAC7D,MAAMI,uBAAuBC,KAAKC,KAAK,CAACX,GAAGY,YAAY,CAACL,aAAa,SAASE,oBAAoB;IAClG,MAAMI,OAAOC,OAAOC,IAAI,CAACN,sBAAsBO,IAAI,CAAC,CAACH,OAASA,KAAKI,OAAO,CAACX,WAAW;IACtF,OAAOO,OAAO;QAAEA;QAAMK,SAAST,oBAAoB,CAACI,KAAK;QAAEM,YAAYrB,KAAKsB,OAAO,CAACb;IAAa,IAAI;AACvG"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
const path = require('path');
|
|
2
2
|
const installModule = require('install-module-linked');
|
|
3
|
-
const findDependency = require('
|
|
4
|
-
module.exports = function installBindings(target, callback) {
|
|
5
|
-
const { name, version, modulePath } = findDependency(
|
|
3
|
+
const findDependency = require('./findDependency.cjs');
|
|
4
|
+
module.exports = function installBindings(identifier, target, callback) {
|
|
5
|
+
const { name, version, modulePath } = findDependency(identifier, target);
|
|
6
6
|
const nodeModules = path.join(modulePath, '..', 'node_modules');
|
|
7
7
|
const installString = version ? `${name}@${version}` : name;
|
|
8
8
|
installModule(installString, nodeModules, (err)=>{
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/typescript/ts-swc-transform/src/bindings/install.cjs"],"sourcesContent":["const path = require('path');\nconst installModule = require('install-module-linked');\nconst findDependency = require('./findDependency.cjs');\n\nmodule.exports = function installBindings(identifier, target, callback) {\n const { name, version, modulePath } = findDependency(identifier, target);\n const nodeModules = path.join(modulePath, '..', 'node_modules');\n const installString = version ? `${name}@${version}` : name;\n\n installModule(installString, nodeModules, (err) => {\n console.log(`installed ${path.join(nodeModules, name)} ${!err ? 'successfully' : 'with errors: ${err.message}'}`);\n callback(err);\n });\n};\n"],"names":["path","require","installModule","findDependency","module","exports","installBindings","identifier","target","callback","name","version","modulePath","nodeModules","join","installString","err","console","log"],"mappings":"AAAA,MAAMA,OAAOC,QAAQ;AACrB,MAAMC,gBAAgBD,QAAQ;AAC9B,MAAME,iBAAiBF,QAAQ;AAE/BG,OAAOC,OAAO,GAAG,SAASC,gBAAgBC,UAAU,EAAEC,MAAM,EAAEC,QAAQ;IACpE,MAAM,EAAEC,IAAI,EAAEC,OAAO,EAAEC,UAAU,EAAE,GAAGT,eAAeI,YAAYC;IACjE,MAAMK,cAAcb,KAAKc,IAAI,CAACF,YAAY,MAAM;IAChD,MAAMG,gBAAgBJ,UAAU,GAAGD,KAAK,CAAC,EAAEC,SAAS,GAAGD;IAEvDR,cAAca,eAAeF,aAAa,CAACG;QACzCC,QAAQC,GAAG,CAAC,CAAC,UAAU,EAAElB,KAAKc,IAAI,CAACD,aAAaH,MAAM,CAAC,EAAE,CAACM,MAAM,iBAAiB,+BAA+B;QAChHP,SAASO;IACX;AACF"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import path from 'path';
|
|
2
|
-
import { sync as ensureBindings } from '
|
|
2
|
+
import { sync as ensureBindings } from '../bindings/ensure.cjs';
|
|
3
3
|
import Module from 'module';
|
|
4
4
|
import lazy from 'lazy-cache';
|
|
5
5
|
const _require = typeof require === 'undefined' ? Module.createRequire(import.meta.url) : require;
|
|
@@ -7,7 +7,7 @@ const tsLazy = lazy(_require)('typescript');
|
|
|
7
7
|
const swcLazy = lazy(_require)('@swc/core');
|
|
8
8
|
const transpilerLazy = lazy(_require)('ts-node/transpilers/swc');
|
|
9
9
|
export default function swcPrepareOptions(tsconfig) {
|
|
10
|
-
ensureBindings(`${process.platform}-${process.arch}`);
|
|
10
|
+
ensureBindings('@swc/core', `${process.platform}-${process.arch}`);
|
|
11
11
|
try {
|
|
12
12
|
const ts = tsLazy();
|
|
13
13
|
const swc = swcLazy();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/typescript/ts-swc-transform/src/lib/swcPrepareOptions.ts"],"sourcesContent":["import path from 'path';\nimport { sync as ensureBindings } from '
|
|
1
|
+
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/typescript/ts-swc-transform/src/lib/swcPrepareOptions.ts"],"sourcesContent":["import path from 'path';\nimport { sync as ensureBindings } from '../bindings/ensure.cjs';\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');\nconst swcLazy = lazy(_require)('@swc/core');\nconst transpilerLazy = lazy(_require)('ts-node/transpilers/swc');\n\nimport type { TsConfigResult } from 'get-tsconfig-compat';\n\nexport default function swcPrepareOptions(tsconfig: TsConfigResult) {\n ensureBindings('@swc/core', `${process.platform}-${process.arch}`);\n try {\n const ts = tsLazy();\n const swc = swcLazy();\n const transpiler = transpilerLazy();\n const parsed = ts.parseJsonConfigFileContent(tsconfig.config, ts.sys, path.dirname(tsconfig.path));\n return transpiler.createSwcOptions(parsed.options, undefined, swc, 'swc');\n } catch (err) {\n console.log(`swcPrepareOptions failed: ${err.message}`);\n return {};\n }\n}\n"],"names":["path","sync","ensureBindings","Module","lazy","_require","require","createRequire","url","tsLazy","swcLazy","transpilerLazy","swcPrepareOptions","tsconfig","process","platform","arch","ts","swc","transpiler","parsed","parseJsonConfigFileContent","config","sys","dirname","createSwcOptions","options","undefined","err","console","log","message"],"mappings":"AAAA,OAAOA,UAAU,OAAO;AACxB,SAASC,QAAQC,cAAc,QAAQ,yBAAyB;AAEhE,OAAOC,YAAY,SAAS;AAC5B,OAAOC,UAAU,aAAa;AAC9B,MAAMC,WAAW,OAAOC,YAAY,cAAcH,OAAOI,aAAa,CAAC,YAAYC,GAAG,IAAIF;AAC1F,MAAMG,SAASL,KAAKC,UAAU;AAC9B,MAAMK,UAAUN,KAAKC,UAAU;AAC/B,MAAMM,iBAAiBP,KAAKC,UAAU;AAItC,eAAe,SAASO,kBAAkBC,QAAwB;IAChEX,eAAe,aAAa,GAAGY,QAAQC,QAAQ,CAAC,CAAC,EAAED,QAAQE,IAAI,EAAE;IACjE,IAAI;QACF,MAAMC,KAAKR;QACX,MAAMS,MAAMR;QACZ,MAAMS,aAAaR;QACnB,MAAMS,SAASH,GAAGI,0BAA0B,CAACR,SAASS,MAAM,EAAEL,GAAGM,GAAG,EAAEvB,KAAKwB,OAAO,CAACX,SAASb,IAAI;QAChG,OAAOmB,WAAWM,gBAAgB,CAACL,OAAOM,OAAO,EAAEC,WAAWT,KAAK;IACrE,EAAE,OAAOU,KAAK;QACZC,QAAQC,GAAG,CAAC,CAAC,0BAA0B,EAAEF,IAAIG,OAAO,EAAE;QACtD,OAAO,CAAC;IACV;AACF"}
|
|
@@ -2,7 +2,7 @@ import fs from 'fs';
|
|
|
2
2
|
import path from 'path';
|
|
3
3
|
import mkdirp from 'mkdirp-classic';
|
|
4
4
|
import Queue from 'queue-cb';
|
|
5
|
-
import ensureBindings from '
|
|
5
|
+
import ensureBindings from '../bindings/ensure.cjs';
|
|
6
6
|
import patchCJS from '../lib/patchCJS.mjs';
|
|
7
7
|
import patchESM from '../lib/patchESM.mjs';
|
|
8
8
|
import swcPrepareOptions from '../lib/swcPrepareOptions.mjs';
|
|
@@ -11,7 +11,7 @@ import lazy from 'lazy-cache';
|
|
|
11
11
|
const _require = typeof require === 'undefined' ? Module.createRequire(import.meta.url) : require;
|
|
12
12
|
const swcLazy = lazy(_require)('@swc/core');
|
|
13
13
|
export default function transformFile(entry, dest, type, options, callback) {
|
|
14
|
-
ensureBindings(`${process.platform}-${process.arch}`, (err)=>{
|
|
14
|
+
ensureBindings('@swc/core', `${process.platform}-${process.arch}`, (err)=>{
|
|
15
15
|
if (err) return callback(err);
|
|
16
16
|
let tsconfig = options.tsconfig;
|
|
17
17
|
// overrides for cjs
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/typescript/ts-swc-transform/src/lib/transformFile.ts"],"sourcesContent":["import fs from 'fs';\nimport path from 'path';\nimport mkdirp from 'mkdirp-classic';\nimport Queue from 'queue-cb';\nimport ensureBindings from '
|
|
1
|
+
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/typescript/ts-swc-transform/src/lib/transformFile.ts"],"sourcesContent":["import fs from 'fs';\nimport path from 'path';\nimport mkdirp from 'mkdirp-classic';\nimport Queue from 'queue-cb';\nimport ensureBindings from '../bindings/ensure.cjs';\n\nimport patchCJS from '../lib/patchCJS';\nimport patchESM from '../lib/patchESM';\nimport swcPrepareOptions from '../lib/swcPrepareOptions';\n\nimport Module from 'module';\nimport lazy from 'lazy-cache';\nconst _require = typeof require === 'undefined' ? Module.createRequire(import.meta.url) : require;\nconst swcLazy = lazy(_require)('@swc/core');\n\nexport default function transformFile(entry, dest, type, options, callback) {\n ensureBindings('@swc/core', `${process.platform}-${process.arch}`, (err) => {\n if (err) return callback(err);\n\n let tsconfig = options.tsconfig;\n\n // overrides for cjs\n if (type === 'cjs') {\n tsconfig = { ...tsconfig };\n tsconfig.config = { ...tsconfig.config };\n tsconfig.config.compilerOptions = { ...(tsconfig.config.compilerOptions || {}) };\n tsconfig.config.compilerOptions.module = 'CommonJS';\n tsconfig.config.compilerOptions.target = 'ES5';\n }\n\n const swcOptions = swcPrepareOptions(tsconfig);\n const swc = swcLazy();\n\n swc\n .transformFile(entry.fullPath, {\n ...(entry.basename.endsWith('.tsx') || entry.basename.endsWith('.jsx') ? swcOptions.tsxOptions : swcOptions.nonTsxOptions),\n filename: entry.basename,\n })\n .then((output) => {\n const extTarget = type === 'esm' ? patchESM(entry, output, options) : patchCJS(entry, output, options);\n const ext = path.extname(entry.path);\n const outPath = path.join(dest, (ext ? entry.path.slice(0, -ext.length) : entry.path) + extTarget);\n\n mkdirp(path.dirname(outPath), () => {\n const queue = new Queue();\n queue.defer(fs.writeFile.bind(null, outPath, output.code, 'utf8'));\n !options.sourceMaps || queue.defer(fs.writeFile.bind(null, `${outPath}.map`, output.map, 'utf8'));\n queue.await((err) => (err ? callback(err) : callback(null, outPath)));\n });\n })\n .catch(callback);\n });\n}\n"],"names":["fs","path","mkdirp","Queue","ensureBindings","patchCJS","patchESM","swcPrepareOptions","Module","lazy","_require","require","createRequire","url","swcLazy","transformFile","entry","dest","type","options","callback","process","platform","arch","err","tsconfig","config","compilerOptions","module","target","swcOptions","swc","fullPath","basename","endsWith","tsxOptions","nonTsxOptions","filename","then","output","extTarget","ext","extname","outPath","join","slice","length","dirname","queue","defer","writeFile","bind","code","sourceMaps","map","await","catch"],"mappings":"AAAA,OAAOA,QAAQ,KAAK;AACpB,OAAOC,UAAU,OAAO;AACxB,OAAOC,YAAY,iBAAiB;AACpC,OAAOC,WAAW,WAAW;AAC7B,OAAOC,oBAAoB,yBAAyB;AAEpD,OAAOC,cAAc,kBAAkB;AACvC,OAAOC,cAAc,kBAAkB;AACvC,OAAOC,uBAAuB,2BAA2B;AAEzD,OAAOC,YAAY,SAAS;AAC5B,OAAO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,CAAAA,MAAMzB,MAAMf,IAAI,CAAC4C,KAAK,CAAC,GAAG,CAACJ,IAAIK,MAAM,IAAI9B,MAAMf,IAAI,AAAD,IAAKuC;YAExFtC,OAAOD,KAAK8C,OAAO,CAACJ,UAAU;gBAC5B,MAAMK,QAAQ,IAAI7C;gBAClB6C,MAAMC,KAAK,CAACjD,GAAGkD,SAAS,CAACC,IAAI,CAAC,MAAMR,SAASJ,OAAOa,IAAI,EAAE;gBAC1D,CAACjC,QAAQkC,UAAU,IAAIL,MAAMC,KAAK,CAACjD,GAAGkD,SAAS,CAACC,IAAI,CAAC,MAAM,GAAGR,QAAQ,IAAI,CAAC,EAAEJ,OAAOe,GAAG,EAAE;gBACzFN,MAAMO,KAAK,CAAC,CAAC/B,MAASA,MAAMJ,SAASI,OAAOJ,SAAS,MAAMuB;YAC7D;QACF,GACCa,KAAK,CAACpC;IACX;AACF"}
|
|
@@ -9,9 +9,8 @@ import Module from 'module';
|
|
|
9
9
|
import lazy from 'lazy-cache';
|
|
10
10
|
const _require = typeof require === 'undefined' ? Module.createRequire(import.meta.url) : require;
|
|
11
11
|
const callLazy = lazy(_require)('node-version-call');
|
|
12
|
-
const workerLazy = lazy(_require)(workerPath);
|
|
13
12
|
function dispatch(version, src, dest, type, options, callback) {
|
|
14
|
-
if (version === 'local') return
|
|
13
|
+
if (version === 'local') return _require(workerPath)(src, dest, type, options, callback);
|
|
15
14
|
try {
|
|
16
15
|
callback(null, callLazy()({
|
|
17
16
|
version,
|
|
@@ -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);\nconst workerPath = path.join(__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');\
|
|
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.join(__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');\n\nfunction dispatch(version, src, dest, type, options, callback) {\n if (version === 'local') return _require(workerPath)(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) as undefined;\n return new Promise((resolve, reject) => dispatch(version, src, dest, type, options, (err, result) => (err ? reject(err) : resolve(result))));\n } catch (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","join","Module","lazy","_require","require","createRequire","callLazy","dispatch","src","dest","type","options","callback","callbacks","err","transformDirectory","Error","tsconfig","cwd","Promise","resolve","reject","result"],"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,IAAI,CAACL,WAAW,MAAM,OAAO,WAAW;AAEhE,OAAOM,YAAY,SAAS;AAC5B,OAAOC,UAAU,aAAa;AAC9B,MAAMC,WAAW,OAAOC,YAAY,cAAcH,OAAOI,aAAa,CAAC,YAAYlB,GAAG,IAAIiB;AAC1F,MAAME,WAAWJ,KAAKC,UAAU;AAEhC,SAASI,SAASb,OAAO,EAAEc,GAAG,EAAEC,IAAI,EAAEC,IAAI,EAAEC,OAAO,EAAEC,QAAQ;IAC3D,IAAIlB,YAAY,SAAS,OAAOS,SAASJ,YAAYS,KAAKC,MAAMC,MAAMC,SAASC;IAC/E,IAAI;QACFA,SAAS,MAAMN,WAAW;YAAEZ;YAASmB,WAAW;QAAK,GAAGd,YAAYS,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,WAAW7B,aAAa;YAAE8B,KAAKV;YAAK,GAAGG,OAAO;QAAC,GAAG;QACxDA,UAAU;YAAEM;YAAU,GAAGN,OAAO;QAAC;QAEjC,IAAI,OAAOC,aAAa,YAAY,OAAOL,SAASb,SAASc,KAAKC,MAAMC,MAAMC,SAASC;QACvF,OAAO,IAAIO,QAAQ,CAACC,SAASC,SAAWd,SAASb,SAASc,KAAKC,MAAMC,MAAMC,SAAS,CAACG,KAAKQ,SAAYR,MAAMO,OAAOP,OAAOM,QAAQE;IACpI,EAAE,OAAOR,KAAK;QACZ,IAAIF,UAAUA,SAASE;aAClB,OAAOK,QAAQE,MAAM,CAACP;IAC7B;AACF"}
|
|
@@ -9,9 +9,8 @@ import Module from 'module';
|
|
|
9
9
|
import lazy from 'lazy-cache';
|
|
10
10
|
const _require = typeof require === 'undefined' ? Module.createRequire(import.meta.url) : require;
|
|
11
11
|
const callLazy = lazy(_require)('node-version-call');
|
|
12
|
-
const workerLazy = lazy(_require)(workerPath);
|
|
13
12
|
function dispatch(version, contents, fileName, tsconfig) {
|
|
14
|
-
if (version === 'local') return
|
|
13
|
+
if (version === 'local') return _require(workerPath)(contents, fileName, tsconfig);
|
|
15
14
|
return callLazy()(version, workerPath, contents, fileName, tsconfig);
|
|
16
15
|
}
|
|
17
16
|
/**
|
|
@@ -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\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.join(__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');\
|
|
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.join(__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');\n\nfunction dispatch(version, contents, fileName, tsconfig) {\n if (version === 'local') return _require(workerPath)(contents, fileName, tsconfig);\n return callLazy()(version, workerPath, contents, fileName, tsconfig);\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","join","Module","lazy","_require","require","createRequire","callLazy","dispatch","contents","fileName","tsconfig","transformSync","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,IAAI,CAACL,WAAW,MAAM,OAAO,WAAW;AAEhE,OAAOM,YAAY,SAAS;AAC5B,OAAOC,UAAU,aAAa;AAC9B,MAAMC,WAAW,OAAOC,YAAY,cAAcH,OAAOI,aAAa,CAAC,YAAYlB,GAAG,IAAIiB;AAC1F,MAAME,WAAWJ,KAAKC,UAAU;AAEhC,SAASI,SAASb,OAAO,EAAEc,QAAQ,EAAEC,QAAQ,EAAEC,QAAQ;IACrD,IAAIhB,YAAY,SAAS,OAAOS,SAASJ,YAAYS,UAAUC,UAAUC;IACzE,OAAOJ,WAAWZ,SAASK,YAAYS,UAAUC,UAAUC;AAC7D;AAIA;;;;;CAKC,GACD,eAAe,SAASC,cAAcH,QAAgB,EAAEC,QAAgB,EAAEC,QAAwB;IAChG,IAAI,OAAOF,aAAa,UAAU,MAAM,IAAII,MAAM;IAClD,IAAI,OAAOH,aAAa,UAAU,MAAM,IAAIG,MAAM;IAClD,IAAI,CAACF,UAAUA,WAAWtB,MAAMyB,WAAW,CAACvB,QAAQwB,GAAG;IACvD,OAAOP,SAASb,SAASc,UAAUC,UAAUC;AAC/C"}
|
|
@@ -9,9 +9,8 @@ import Module from 'module';
|
|
|
9
9
|
import lazy from 'lazy-cache';
|
|
10
10
|
const _require = typeof require === 'undefined' ? Module.createRequire(import.meta.url) : require;
|
|
11
11
|
const callLazy = lazy(_require)('node-version-call');
|
|
12
|
-
const workerLazy = lazy(_require)(workerPath);
|
|
13
12
|
function dispatch(version, src, dest, options, callback) {
|
|
14
|
-
if (version === 'local') return
|
|
13
|
+
if (version === 'local') return _require(workerPath)(src, dest, options, callback);
|
|
15
14
|
try {
|
|
16
15
|
callback(null, callLazy()({
|
|
17
16
|
version,
|
|
@@ -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);\nconst workerPath = path.join(__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');\
|
|
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.join(__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');\n\nfunction dispatch(version, src, dest, options, callback) {\n if (version === 'local') return _require(workerPath)(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 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","join","Module","lazy","_require","require","createRequire","callLazy","dispatch","src","dest","options","callback","callbacks","err","transformTypes","Error","tsconfig","cwd","Promise","resolve","reject","result"],"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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AAUA,SAASE;aAClB,OAAOK,QAAQE,MAAM,CAACP;IAC7B;AACF"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ts-swc-transform",
|
|
3
|
-
"version": "1.13.
|
|
3
|
+
"version": "1.13.9",
|
|
4
4
|
"description": "Typescript transformers for swc. Supports Node >= 0.8",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"matcher",
|
|
@@ -57,7 +57,7 @@
|
|
|
57
57
|
"path-posix": "^1.0.0",
|
|
58
58
|
"queue-cb": "^1.4.10",
|
|
59
59
|
"resolve": "^1.22.10",
|
|
60
|
-
"resolve-once-
|
|
60
|
+
"resolve-once-cb": "^0.1.7",
|
|
61
61
|
"rimraf2": "^2.8.2",
|
|
62
62
|
"ts-node": "*",
|
|
63
63
|
"typescript": "*",
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var path = require('path');
|
|
3
|
-
var fs = require('fs');
|
|
4
|
-
var lazy = require('lazy-cache');
|
|
5
|
-
var resolveOnceMap = require('resolve-once-map-cb');
|
|
6
|
-
var installBindings = require('../workers/installBindings.cjs');
|
|
7
|
-
var findDependency = require('./findDependency.cjs');
|
|
8
|
-
var workerPath = path.join(__dirname, 'workers', 'installBindings.cjs');
|
|
9
|
-
var major = +process.versions.node.split('.')[0];
|
|
10
|
-
var version = major < 14 ? 'stable' : 'local';
|
|
11
|
-
var existsSync = function(test) {
|
|
12
|
-
try {
|
|
13
|
-
(fs.accessSync || fs.statSync)(test);
|
|
14
|
-
return true;
|
|
15
|
-
} catch (_) {
|
|
16
|
-
return false;
|
|
17
|
-
}
|
|
18
|
-
};
|
|
19
|
-
var install = lazy(function(target) {
|
|
20
|
-
var _findDependency = findDependency('@swc/core', target), name = _findDependency.name, modulePath = _findDependency.modulePath;
|
|
21
|
-
return existsSync(path.join(modulePath, '..', 'node_modules', name)) ? target : require('node-version-call')({
|
|
22
|
-
version: version,
|
|
23
|
-
callbacks: true
|
|
24
|
-
}, workerPath, target);
|
|
25
|
-
});
|
|
26
|
-
module.exports = resolveOnceMap(function(target, callback) {
|
|
27
|
-
var _findDependency = findDependency('@swc/core', target), name = _findDependency.name, modulePath = _findDependency.modulePath;
|
|
28
|
-
return existsSync(path.join(modulePath, '..', 'node_modules', name)) ? callback() : installBindings(target, callback);
|
|
29
|
-
});
|
|
30
|
-
module.exports.sync = function(target) {
|
|
31
|
-
return install(target)();
|
|
32
|
-
};
|
|
33
|
-
/* 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/ensureBindings.cjs"],"sourcesContent":["const path = require('path');\nconst fs = require('fs');\nconst lazy = require('lazy-cache');\nconst resolveOnceMap = require('resolve-once-map-cb');\nconst installBindings = require('../workers/installBindings');\nconst findDependency = require('./findDependency.cjs');\n\nconst workerPath = path.join(__dirname, 'workers', 'installBindings.cjs');\nconst major = +process.versions.node.split('.')[0];\nconst version = major < 14 ? 'stable' : 'local';\n\nconst existsSync = (test) => {\n try {\n (fs.accessSync || fs.statSync)(test);\n return true;\n } catch (_) {\n return false;\n }\n};\n\nconst install = lazy((target) => {\n const { name, modulePath } = findDependency('@swc/core', target);\n return existsSync(path.join(modulePath, '..', 'node_modules', name)) ? target : require('node-version-call')({ version, callbacks: true }, workerPath, target);\n});\n\nmodule.exports = resolveOnceMap((target, callback) => {\n const { name, modulePath } = findDependency('@swc/core', target);\n return existsSync(path.join(modulePath, '..', 'node_modules', name)) ? callback() : installBindings(target, callback);\n});\nmodule.exports.sync = (target) => install(target)();\n"],"names":["path","require","fs","lazy","resolveOnceMap","installBindings","findDependency","workerPath","join","__dirname","major","process","versions","node","split","version","existsSync","test","accessSync","statSync","_","install","target","name","modulePath","callbacks","module","exports","callback","sync"],"mappings":";AAAA,IAAMA,OAAOC,QAAQ;AACrB,IAAMC,KAAKD,QAAQ;AACnB,IAAME,OAAOF,QAAQ;AACrB,IAAMG,iBAAiBH,QAAQ;AAC/B,IAAMI,kBAAkBJ,QAAQ;AAChC,IAAMK,iBAAiBL,QAAQ;AAE/B,IAAMM,aAAaP,KAAKQ,IAAI,CAACC,WAAW,WAAW;AACnD,IAAMC,QAAQ,CAACC,QAAQC,QAAQ,CAACC,IAAI,CAACC,KAAK,CAAC,IAAI,CAAC,EAAE;AAClD,IAAMC,UAAUL,QAAQ,KAAK,WAAW;AAExC,IAAMM,aAAa,SAACC;IAClB,IAAI;QACDf,CAAAA,GAAGgB,UAAU,IAAIhB,GAAGiB,QAAQ,AAAD,EAAGF;QAC/B,OAAO;IACT,EAAE,OAAOG,GAAG;QACV,OAAO;IACT;AACF;AAEA,IAAMC,UAAUlB,KAAK,SAACmB;IACpB,IAA6BhB,kBAAAA,eAAe,aAAagB,SAAjDC,OAAqBjB,gBAArBiB,MAAMC,aAAelB,gBAAfkB;IACd,OAAOR,WAAWhB,KAAKQ,IAAI,CAACgB,YAAY,MAAM,gBAAgBD,SAASD,SAASrB,QAAQ,qBAAqB;QAAEc,SAAAA;QAASU,WAAW;IAAK,GAAGlB,YAAYe;AACzJ;AAEAI,OAAOC,OAAO,GAAGvB,eAAe,SAACkB,QAAQM;IACvC,IAA6BtB,kBAAAA,eAAe,aAAagB,SAAjDC,OAAqBjB,gBAArBiB,MAAMC,aAAelB,gBAAfkB;IACd,OAAOR,WAAWhB,KAAKQ,IAAI,CAACgB,YAAY,MAAM,gBAAgBD,SAASK,aAAavB,gBAAgBiB,QAAQM;AAC9G;AACAF,OAAOC,OAAO,CAACE,IAAI,GAAG,SAACP;WAAWD,QAAQC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/typescript/ts-swc-transform/src/lib/findDependency.cjs"],"sourcesContent":["const path = require('path');\nconst fs = require('fs');\nconst resolve = require('resolve');\n\nmodule.exports = function findDependency(identifier, target) {\n const packagePath = resolve.sync(`${identifier}/package.json`);\n const optionalDependencies = JSON.parse(fs.readFileSync(packagePath, 'utf8')).optionalDependencies;\n const name = Object.keys(optionalDependencies).find((name) => name.indexOf(target) >= 0);\n return name ? { name, version: optionalDependencies[name], modulePath: path.dirname(packagePath) } : null;\n};\n"],"names":["path","require","fs","resolve","module","exports","findDependency","identifier","target","packagePath","sync","optionalDependencies","JSON","parse","readFileSync","name","Object","keys","find","indexOf","version","modulePath","dirname"],"mappings":";AAAA,IAAMA,OAAOC,QAAQ;AACrB,IAAMC,KAAKD,QAAQ;AACnB,IAAME,UAAUF,QAAQ;AAExBG,OAAOC,OAAO,GAAG,SAASC,eAAeC,UAAU,EAAEC,MAAM;IACzD,IAAMC,cAAcN,QAAQO,IAAI,CAAC,AAAC,GAAa,OAAXH,YAAW;IAC/C,IAAMI,uBAAuBC,KAAKC,KAAK,CAACX,GAAGY,YAAY,CAACL,aAAa,SAASE,oBAAoB;IAClG,IAAMI,OAAOC,OAAOC,IAAI,CAACN,sBAAsBO,IAAI,CAAC,SAACH;eAASA,KAAKI,OAAO,CAACX,WAAW;;IACtF,OAAOO,OAAO;QAAEA,MAAAA;QAAMK,SAAST,oBAAoB,CAACI,KAAK;QAAEM,YAAYrB,KAAKsB,OAAO,CAACb;IAAa,IAAI;AACvG"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/typescript/ts-swc-transform/src/workers/installBindings.cjs"],"sourcesContent":["const path = require('path');\nconst installModule = require('install-module-linked');\nconst findDependency = require('../lib/findDependency.cjs');\n\nmodule.exports = function installBindings(target, callback) {\n const { name, version, modulePath } = findDependency('@swc/core', target);\n const nodeModules = path.join(modulePath, '..', 'node_modules');\n const installString = version ? `${name}@${version}` : name;\n\n installModule(installString, nodeModules, (err) => {\n console.log(`installed ${path.join(nodeModules, name)} ${!err ? 'successfully' : 'with errors: ${err.message}'}`);\n callback(err);\n });\n};\n"],"names":["path","require","installModule","findDependency","module","exports","installBindings","target","callback","name","version","modulePath","nodeModules","join","installString","err","console","log"],"mappings":";AAAA,IAAMA,OAAOC,QAAQ;AACrB,IAAMC,gBAAgBD,QAAQ;AAC9B,IAAME,iBAAiBF,QAAQ;AAE/BG,OAAOC,OAAO,GAAG,SAASC,gBAAgBC,MAAM,EAAEC,QAAQ;IACxD,IAAsCL,kBAAAA,eAAe,aAAaI,SAA1DE,OAA8BN,gBAA9BM,MAAMC,UAAwBP,gBAAxBO,SAASC,aAAeR,gBAAfQ;IACvB,IAAMC,cAAcZ,KAAKa,IAAI,CAACF,YAAY,MAAM;IAChD,IAAMG,gBAAgBJ,UAAU,AAAC,GAAUA,OAARD,MAAK,KAAW,OAARC,WAAYD;IAEvDP,cAAcY,eAAeF,aAAa,SAACG;QACzCC,QAAQC,GAAG,CAAC,AAAC,aAA4C,OAAhCjB,KAAKa,IAAI,CAACD,aAAaH,OAAM,KAAyD,OAAtD,CAACM,MAAM,iBAAiB;QACjFP,SAASO;IACX;AACF"}
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
const path = require('path');
|
|
2
|
-
const fs = require('fs');
|
|
3
|
-
const lazy = require('lazy-cache');
|
|
4
|
-
const resolveOnceMap = require('resolve-once-map-cb');
|
|
5
|
-
const installBindings = require('../workers/installBindings');
|
|
6
|
-
const findDependency = require('./findDependency.cjs');
|
|
7
|
-
const workerPath = path.join(__dirname, 'workers', 'installBindings.cjs');
|
|
8
|
-
const major = +process.versions.node.split('.')[0];
|
|
9
|
-
const version = major < 14 ? 'stable' : 'local';
|
|
10
|
-
const existsSync = (test)=>{
|
|
11
|
-
try {
|
|
12
|
-
(fs.accessSync || fs.statSync)(test);
|
|
13
|
-
return true;
|
|
14
|
-
} catch (_) {
|
|
15
|
-
return false;
|
|
16
|
-
}
|
|
17
|
-
};
|
|
18
|
-
const install = lazy((target)=>{
|
|
19
|
-
const { name, modulePath } = findDependency('@swc/core', target);
|
|
20
|
-
return existsSync(path.join(modulePath, '..', 'node_modules', name)) ? target : require('node-version-call')({
|
|
21
|
-
version,
|
|
22
|
-
callbacks: true
|
|
23
|
-
}, workerPath, target);
|
|
24
|
-
});
|
|
25
|
-
module.exports = resolveOnceMap((target, callback)=>{
|
|
26
|
-
const { name, modulePath } = findDependency('@swc/core', target);
|
|
27
|
-
return existsSync(path.join(modulePath, '..', 'node_modules', name)) ? callback() : installBindings(target, callback);
|
|
28
|
-
});
|
|
29
|
-
module.exports.sync = (target)=>install(target)();
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/typescript/ts-swc-transform/src/lib/ensureBindings.cjs"],"sourcesContent":["const path = require('path');\nconst fs = require('fs');\nconst lazy = require('lazy-cache');\nconst resolveOnceMap = require('resolve-once-map-cb');\nconst installBindings = require('../workers/installBindings');\nconst findDependency = require('./findDependency.cjs');\n\nconst workerPath = path.join(__dirname, 'workers', 'installBindings.cjs');\nconst major = +process.versions.node.split('.')[0];\nconst version = major < 14 ? 'stable' : 'local';\n\nconst existsSync = (test) => {\n try {\n (fs.accessSync || fs.statSync)(test);\n return true;\n } catch (_) {\n return false;\n }\n};\n\nconst install = lazy((target) => {\n const { name, modulePath } = findDependency('@swc/core', target);\n return existsSync(path.join(modulePath, '..', 'node_modules', name)) ? target : require('node-version-call')({ version, callbacks: true }, workerPath, target);\n});\n\nmodule.exports = resolveOnceMap((target, callback) => {\n const { name, modulePath } = findDependency('@swc/core', target);\n return existsSync(path.join(modulePath, '..', 'node_modules', name)) ? callback() : installBindings(target, callback);\n});\nmodule.exports.sync = (target) => install(target)();\n"],"names":["path","require","fs","lazy","resolveOnceMap","installBindings","findDependency","workerPath","join","__dirname","major","process","versions","node","split","version","existsSync","test","accessSync","statSync","_","install","target","name","modulePath","callbacks","module","exports","callback","sync"],"mappings":"AAAA,MAAMA,OAAOC,QAAQ;AACrB,MAAMC,KAAKD,QAAQ;AACnB,MAAME,OAAOF,QAAQ;AACrB,MAAMG,iBAAiBH,QAAQ;AAC/B,MAAMI,kBAAkBJ,QAAQ;AAChC,MAAMK,iBAAiBL,QAAQ;AAE/B,MAAMM,aAAaP,KAAKQ,IAAI,CAACC,WAAW,WAAW;AACnD,MAAMC,QAAQ,CAACC,QAAQC,QAAQ,CAACC,IAAI,CAACC,KAAK,CAAC,IAAI,CAAC,EAAE;AAClD,MAAMC,UAAUL,QAAQ,KAAK,WAAW;AAExC,MAAMM,aAAa,CAACC;IAClB,IAAI;QACDf,CAAAA,GAAGgB,UAAU,IAAIhB,GAAGiB,QAAQ,AAAD,EAAGF;QAC/B,OAAO;IACT,EAAE,OAAOG,GAAG;QACV,OAAO;IACT;AACF;AAEA,MAAMC,UAAUlB,KAAK,CAACmB;IACpB,MAAM,EAAEC,IAAI,EAAEC,UAAU,EAAE,GAAGlB,eAAe,aAAagB;IACzD,OAAON,WAAWhB,KAAKQ,IAAI,CAACgB,YAAY,MAAM,gBAAgBD,SAASD,SAASrB,QAAQ,qBAAqB;QAAEc;QAASU,WAAW;IAAK,GAAGlB,YAAYe;AACzJ;AAEAI,OAAOC,OAAO,GAAGvB,eAAe,CAACkB,QAAQM;IACvC,MAAM,EAAEL,IAAI,EAAEC,UAAU,EAAE,GAAGlB,eAAe,aAAagB;IACzD,OAAON,WAAWhB,KAAKQ,IAAI,CAACgB,YAAY,MAAM,gBAAgBD,SAASK,aAAavB,gBAAgBiB,QAAQM;AAC9G;AACAF,OAAOC,OAAO,CAACE,IAAI,GAAG,CAACP,SAAWD,QAAQC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/typescript/ts-swc-transform/src/lib/findDependency.cjs"],"sourcesContent":["const path = require('path');\nconst fs = require('fs');\nconst resolve = require('resolve');\n\nmodule.exports = function findDependency(identifier, target) {\n const packagePath = resolve.sync(`${identifier}/package.json`);\n const optionalDependencies = JSON.parse(fs.readFileSync(packagePath, 'utf8')).optionalDependencies;\n const name = Object.keys(optionalDependencies).find((name) => name.indexOf(target) >= 0);\n return name ? { name, version: optionalDependencies[name], modulePath: path.dirname(packagePath) } : null;\n};\n"],"names":["path","require","fs","resolve","module","exports","findDependency","identifier","target","packagePath","sync","optionalDependencies","JSON","parse","readFileSync","name","Object","keys","find","indexOf","version","modulePath","dirname"],"mappings":"AAAA,MAAMA,OAAOC,QAAQ;AACrB,MAAMC,KAAKD,QAAQ;AACnB,MAAME,UAAUF,QAAQ;AAExBG,OAAOC,OAAO,GAAG,SAASC,eAAeC,UAAU,EAAEC,MAAM;IACzD,MAAMC,cAAcN,QAAQO,IAAI,CAAC,GAAGH,WAAW,aAAa,CAAC;IAC7D,MAAMI,uBAAuBC,KAAKC,KAAK,CAACX,GAAGY,YAAY,CAACL,aAAa,SAASE,oBAAoB;IAClG,MAAMI,OAAOC,OAAOC,IAAI,CAACN,sBAAsBO,IAAI,CAAC,CAACH,OAASA,KAAKI,OAAO,CAACX,WAAW;IACtF,OAAOO,OAAO;QAAEA;QAAMK,SAAST,oBAAoB,CAACI,KAAK;QAAEM,YAAYrB,KAAKsB,OAAO,CAACb;IAAa,IAAI;AACvG"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/typescript/ts-swc-transform/src/workers/installBindings.cjs"],"sourcesContent":["const path = require('path');\nconst installModule = require('install-module-linked');\nconst findDependency = require('../lib/findDependency.cjs');\n\nmodule.exports = function installBindings(target, callback) {\n const { name, version, modulePath } = findDependency('@swc/core', target);\n const nodeModules = path.join(modulePath, '..', 'node_modules');\n const installString = version ? `${name}@${version}` : name;\n\n installModule(installString, nodeModules, (err) => {\n console.log(`installed ${path.join(nodeModules, name)} ${!err ? 'successfully' : 'with errors: ${err.message}'}`);\n callback(err);\n });\n};\n"],"names":["path","require","installModule","findDependency","module","exports","installBindings","target","callback","name","version","modulePath","nodeModules","join","installString","err","console","log"],"mappings":"AAAA,MAAMA,OAAOC,QAAQ;AACrB,MAAMC,gBAAgBD,QAAQ;AAC9B,MAAME,iBAAiBF,QAAQ;AAE/BG,OAAOC,OAAO,GAAG,SAASC,gBAAgBC,MAAM,EAAEC,QAAQ;IACxD,MAAM,EAAEC,IAAI,EAAEC,OAAO,EAAEC,UAAU,EAAE,GAAGR,eAAe,aAAaI;IAClE,MAAMK,cAAcZ,KAAKa,IAAI,CAACF,YAAY,MAAM;IAChD,MAAMG,gBAAgBJ,UAAU,GAAGD,KAAK,CAAC,EAAEC,SAAS,GAAGD;IAEvDP,cAAcY,eAAeF,aAAa,CAACG;QACzCC,QAAQC,GAAG,CAAC,CAAC,UAAU,EAAEjB,KAAKa,IAAI,CAACD,aAAaH,MAAM,CAAC,EAAE,CAACM,MAAM,iBAAiB,+BAA+B;QAChHP,SAASO;IACX;AACF"}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|