ts-swc-transform 1.13.10 → 1.13.12
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/ensureBindings.cjs +114 -0
- package/dist/cjs/lib/ensureBindings.cjs.map +1 -0
- package/dist/cjs/lib/swcPrepareOptions.cjs +5 -9
- package/dist/cjs/lib/swcPrepareOptions.cjs.map +1 -1
- package/dist/cjs/lib/transformFile.cjs +3 -5
- package/dist/cjs/lib/transformFile.cjs.map +1 -1
- package/dist/cjs/transformDirectory.cjs +1 -3
- package/dist/cjs/transformDirectory.cjs.map +1 -1
- package/dist/cjs/transformSync.cjs +1 -3
- package/dist/cjs/transformSync.cjs.map +1 -1
- package/dist/cjs/transformTypes.cjs +1 -3
- package/dist/cjs/transformTypes.cjs.map +1 -1
- package/dist/cjs/workers/transformSync.cjs +1 -3
- package/dist/cjs/workers/transformSync.cjs.map +1 -1
- package/dist/cjs/workers/transformTypes.cjs +1 -3
- package/dist/cjs/workers/transformTypes.cjs.map +1 -1
- package/dist/esm/lib/ensureBindings.mjs +47 -0
- package/dist/esm/lib/ensureBindings.mjs.map +1 -0
- package/dist/esm/lib/swcPrepareOptions.mjs +5 -9
- package/dist/esm/lib/swcPrepareOptions.mjs.map +1 -1
- package/dist/esm/lib/transformFile.mjs +2 -4
- package/dist/esm/lib/transformFile.mjs.map +1 -1
- package/dist/esm/transformDirectory.mjs +1 -3
- package/dist/esm/transformDirectory.mjs.map +1 -1
- package/dist/esm/transformSync.mjs +1 -3
- package/dist/esm/transformSync.mjs.map +1 -1
- package/dist/esm/transformTypes.mjs +1 -3
- package/dist/esm/transformTypes.mjs.map +1 -1
- package/dist/esm/workers/transformSync.mjs +1 -3
- package/dist/esm/workers/transformSync.mjs.map +1 -1
- package/dist/esm/workers/transformTypes.mjs +1 -3
- package/dist/esm/workers/transformTypes.mjs.map +1 -1
- package/dist/types/lib/ensureBindings.d.ts +2 -0
- package/package.json +2 -7
- package/dist/cjs/bindings/ensure.cjs +0 -41
- package/dist/cjs/bindings/ensure.cjs.map +0 -1
- package/dist/cjs/bindings/findDependency.cjs +0 -18
- package/dist/cjs/bindings/findDependency.cjs.map +0 -1
- package/dist/cjs/bindings/install.cjs +0 -13
- package/dist/cjs/bindings/install.cjs.map +0 -1
- package/dist/esm/bindings/ensure.cjs +0 -39
- package/dist/esm/bindings/ensure.cjs.map +0 -1
- package/dist/esm/bindings/findDependency.cjs +0 -14
- package/dist/esm/bindings/findDependency.cjs.map +0 -1
- package/dist/esm/bindings/install.cjs +0 -11
- package/dist/esm/bindings/install.cjs.map +0 -1
- package/dist/types/bindings/ensure.d.cts +0 -5
- package/dist/types/bindings/findDependency.d.cts +0 -6
- package/dist/types/bindings/install.d.cts +0 -2
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
function _export(target, all) {
|
|
6
|
+
for(var name in all)Object.defineProperty(target, name, {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: all[name]
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
|
+
_export(exports, {
|
|
12
|
+
default: function() {
|
|
13
|
+
return ensureBindings;
|
|
14
|
+
},
|
|
15
|
+
sync: function() {
|
|
16
|
+
return sync;
|
|
17
|
+
}
|
|
18
|
+
});
|
|
19
|
+
var _fs = /*#__PURE__*/ _interop_require_default(require("fs"));
|
|
20
|
+
var _path = /*#__PURE__*/ _interop_require_default(require("path"));
|
|
21
|
+
var _installmodulelinked = /*#__PURE__*/ _interop_require_wildcard(require("install-module-linked"));
|
|
22
|
+
var _resolve = /*#__PURE__*/ _interop_require_default(require("resolve"));
|
|
23
|
+
var _resolveoncecb = /*#__PURE__*/ _interop_require_default(require("resolve-once-cb"));
|
|
24
|
+
function _interop_require_default(obj) {
|
|
25
|
+
return obj && obj.__esModule ? obj : {
|
|
26
|
+
default: obj
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
function _getRequireWildcardCache(nodeInterop) {
|
|
30
|
+
if (typeof WeakMap !== "function") return null;
|
|
31
|
+
var cacheBabelInterop = new WeakMap();
|
|
32
|
+
var cacheNodeInterop = new WeakMap();
|
|
33
|
+
return (_getRequireWildcardCache = function(nodeInterop) {
|
|
34
|
+
return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
|
|
35
|
+
})(nodeInterop);
|
|
36
|
+
}
|
|
37
|
+
function _interop_require_wildcard(obj, nodeInterop) {
|
|
38
|
+
if (!nodeInterop && obj && obj.__esModule) {
|
|
39
|
+
return obj;
|
|
40
|
+
}
|
|
41
|
+
if (obj === null || typeof obj !== "object" && typeof obj !== "function") {
|
|
42
|
+
return {
|
|
43
|
+
default: obj
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
var cache = _getRequireWildcardCache(nodeInterop);
|
|
47
|
+
if (cache && cache.has(obj)) {
|
|
48
|
+
return cache.get(obj);
|
|
49
|
+
}
|
|
50
|
+
var newObj = {
|
|
51
|
+
__proto__: null
|
|
52
|
+
};
|
|
53
|
+
var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
|
|
54
|
+
for(var key in obj){
|
|
55
|
+
if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
56
|
+
var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;
|
|
57
|
+
if (desc && (desc.get || desc.set)) {
|
|
58
|
+
Object.defineProperty(newObj, key, desc);
|
|
59
|
+
} else {
|
|
60
|
+
newObj[key] = obj[key];
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
newObj.default = obj;
|
|
65
|
+
if (cache) {
|
|
66
|
+
cache.set(obj, newObj);
|
|
67
|
+
}
|
|
68
|
+
return newObj;
|
|
69
|
+
}
|
|
70
|
+
var existsSync = function(test) {
|
|
71
|
+
try {
|
|
72
|
+
(_fs.default.accessSync || _fs.default.statSync)(test);
|
|
73
|
+
return true;
|
|
74
|
+
} catch (_) {
|
|
75
|
+
return false;
|
|
76
|
+
}
|
|
77
|
+
};
|
|
78
|
+
function findDependency(identifier, target) {
|
|
79
|
+
var packagePath = _resolve.default.sync("".concat(identifier, "/package.json"));
|
|
80
|
+
var nodeModules = identifier[0] === '@' ? _path.default.join(packagePath, '..', '..', '..') : _path.default.join(packagePath, '..', '..');
|
|
81
|
+
var optionalDependencies = JSON.parse(_fs.default.readFileSync(packagePath, 'utf8')).optionalDependencies;
|
|
82
|
+
var name = Object.keys(optionalDependencies).find(function(name) {
|
|
83
|
+
return name.indexOf(target) >= 0;
|
|
84
|
+
});
|
|
85
|
+
return name ? {
|
|
86
|
+
name: name,
|
|
87
|
+
version: optionalDependencies[name],
|
|
88
|
+
nodeModules: nodeModules
|
|
89
|
+
} : null;
|
|
90
|
+
}
|
|
91
|
+
var bindings = {};
|
|
92
|
+
function ensureBindings(identifier, target, callback) {
|
|
93
|
+
if (bindings[identifier] === undefined) bindings[identifier] = {};
|
|
94
|
+
if (bindings[identifier][target] === undefined) {
|
|
95
|
+
bindings[identifier][target] = (0, _resolveoncecb.default)(function(cb) {
|
|
96
|
+
var _findDependency = findDependency(identifier, target), name = _findDependency.name, version = _findDependency.version, nodeModules = _findDependency.nodeModules;
|
|
97
|
+
var installString = version ? "".concat(name, "@").concat(version) : name;
|
|
98
|
+
return existsSync(_path.default.join(nodeModules, name)) ? cb() : (0, _installmodulelinked.default)(installString, nodeModules, cb);
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
bindings[identifier][target](callback);
|
|
102
|
+
}
|
|
103
|
+
var bindingsSync = {};
|
|
104
|
+
function sync(identifier, target) {
|
|
105
|
+
if (bindingsSync[identifier] === undefined) bindingsSync[identifier] = {};
|
|
106
|
+
if (bindingsSync[identifier][target] === undefined) {
|
|
107
|
+
bindingsSync[identifier][target] = function() {
|
|
108
|
+
var _findDependency = findDependency(identifier, target), name = _findDependency.name, version = _findDependency.version, nodeModules = _findDependency.nodeModules;
|
|
109
|
+
var installString = version ? "".concat(name, "@").concat(version) : name;
|
|
110
|
+
return existsSync(_path.default.join(nodeModules, name)) ? target : (0, _installmodulelinked.sync)(installString, nodeModules);
|
|
111
|
+
}();
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
/* 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/lib/ensureBindings.ts"],"sourcesContent":["import fs from 'fs';\nimport path from 'path';\nimport installModule, { sync as installModuleSync } from 'install-module-linked';\nimport resolve from 'resolve';\nimport resolveOnce from 'resolve-once-cb';\n\nconst existsSync = (test) => {\n try {\n (fs.accessSync || fs.statSync)(test);\n return true;\n } catch (_) {\n return false;\n }\n};\n\nfunction findDependency(identifier, target) {\n const packagePath = resolve.sync(`${identifier}/package.json`);\n const nodeModules = identifier[0] === '@' ? path.join(packagePath, '..', '..', '..') : path.join(packagePath, '..', '..');\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], nodeModules } : null;\n}\n\nconst bindings = {};\nexport default 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, version, nodeModules } = findDependency(identifier, target);\n const installString = version ? `${name}@${version}` : name;\n return existsSync(path.join(nodeModules, name)) ? cb() : installModule(installString, nodeModules, cb);\n });\n }\n bindings[identifier][target](callback);\n}\n\nconst bindingsSync = {};\nexport function sync(identifier, target) {\n if (bindingsSync[identifier] === undefined) bindingsSync[identifier] = {};\n if (bindingsSync[identifier][target] === undefined) {\n bindingsSync[identifier][target] = (() => {\n const { name, version, nodeModules } = findDependency(identifier, target);\n const installString = version ? `${name}@${version}` : name;\n return existsSync(path.join(nodeModules, name)) ? target : installModuleSync(installString, nodeModules);\n })();\n }\n}\n"],"names":["ensureBindings","sync","existsSync","test","fs","accessSync","statSync","_","findDependency","identifier","target","packagePath","resolve","nodeModules","path","join","optionalDependencies","JSON","parse","readFileSync","name","Object","keys","find","indexOf","version","bindings","callback","undefined","resolveOnce","cb","installString","installModule","bindingsSync","installModuleSync"],"mappings":";;;;;;;;;;;IAwBA,OAUC;eAVuBA;;IAaRC,IAAI;eAAJA;;;yDArCD;2DACE;2EACwC;8DACrC;oEACI;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAExB,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,eAAeC,UAAU,EAAEC,MAAM;IACxC,IAAMC,cAAcC,gBAAO,CAACX,IAAI,CAAC,AAAC,GAAa,OAAXQ,YAAW;IAC/C,IAAMI,cAAcJ,UAAU,CAAC,EAAE,KAAK,MAAMK,aAAI,CAACC,IAAI,CAACJ,aAAa,MAAM,MAAM,QAAQG,aAAI,CAACC,IAAI,CAACJ,aAAa,MAAM;IACpH,IAAMK,uBAAuBC,KAAKC,KAAK,CAACd,WAAE,CAACe,YAAY,CAACR,aAAa,SAASK,oBAAoB;IAClG,IAAMI,OAAOC,OAAOC,IAAI,CAACN,sBAAsBO,IAAI,CAAC,SAACH;eAASA,KAAKI,OAAO,CAACd,WAAW;;IACtF,OAAOU,OAAO;QAAEA,MAAAA;QAAMK,SAAST,oBAAoB,CAACI,KAAK;QAAEP,aAAAA;IAAY,IAAI;AAC7E;AAEA,IAAMa,WAAW,CAAC;AACH,SAAS1B,eAAeS,UAAU,EAAEC,MAAM,EAAEiB,QAAQ;IACjE,IAAID,QAAQ,CAACjB,WAAW,KAAKmB,WAAWF,QAAQ,CAACjB,WAAW,GAAG,CAAC;IAChE,IAAIiB,QAAQ,CAACjB,WAAW,CAACC,OAAO,KAAKkB,WAAW;QAC9CF,QAAQ,CAACjB,WAAW,CAACC,OAAO,GAAGmB,IAAAA,sBAAW,EAAC,SAACC;YAC1C,IAAuCtB,kBAAAA,eAAeC,YAAYC,SAA1DU,OAA+BZ,gBAA/BY,MAAMK,UAAyBjB,gBAAzBiB,SAASZ,cAAgBL,gBAAhBK;YACvB,IAAMkB,gBAAgBN,UAAU,AAAC,GAAUA,OAARL,MAAK,KAAW,OAARK,WAAYL;YACvD,OAAOlB,WAAWY,aAAI,CAACC,IAAI,CAACF,aAAaO,SAASU,OAAOE,IAAAA,4BAAa,EAACD,eAAelB,aAAaiB;QACrG;IACF;IACAJ,QAAQ,CAACjB,WAAW,CAACC,OAAO,CAACiB;AAC/B;AAEA,IAAMM,eAAe,CAAC;AACf,SAAShC,KAAKQ,UAAU,EAAEC,MAAM;IACrC,IAAIuB,YAAY,CAACxB,WAAW,KAAKmB,WAAWK,YAAY,CAACxB,WAAW,GAAG,CAAC;IACxE,IAAIwB,YAAY,CAACxB,WAAW,CAACC,OAAO,KAAKkB,WAAW;QAClDK,YAAY,CAACxB,WAAW,CAACC,OAAO,GAAG,AAAC;YAClC,IAAuCF,kBAAAA,eAAeC,YAAYC,SAA1DU,OAA+BZ,gBAA/BY,MAAMK,UAAyBjB,gBAAzBiB,SAASZ,cAAgBL,gBAAhBK;YACvB,IAAMkB,gBAAgBN,UAAU,AAAC,GAAUA,OAARL,MAAK,KAAW,OAARK,WAAYL;YACvD,OAAOlB,WAAWY,aAAI,CAACC,IAAI,CAACF,aAAaO,SAASV,SAASwB,IAAAA,yBAAiB,EAACH,eAAelB;QAC9F;IACF;AACF"}
|
|
@@ -9,24 +9,20 @@ Object.defineProperty(exports, "default", {
|
|
|
9
9
|
}
|
|
10
10
|
});
|
|
11
11
|
var _path = /*#__PURE__*/ _interop_require_default(require("path"));
|
|
12
|
-
var
|
|
12
|
+
var _ensureBindings = require("./ensureBindings.cjs");
|
|
13
13
|
var _module = /*#__PURE__*/ _interop_require_default(require("module"));
|
|
14
|
-
var _lazycache = /*#__PURE__*/ _interop_require_default(require("lazy-cache"));
|
|
15
14
|
function _interop_require_default(obj) {
|
|
16
15
|
return obj && obj.__esModule ? obj : {
|
|
17
16
|
default: obj
|
|
18
17
|
};
|
|
19
18
|
}
|
|
20
19
|
var _require = typeof require === 'undefined' ? _module.default.createRequire(require("url").pathToFileURL(__filename).toString()) : require;
|
|
21
|
-
var tsLazy = (0, _lazycache.default)(_require)('typescript');
|
|
22
|
-
var swcLazy = (0, _lazycache.default)(_require)('@swc/core');
|
|
23
|
-
var transpilerLazy = (0, _lazycache.default)(_require)('ts-node/transpilers/swc');
|
|
24
20
|
function swcPrepareOptions(tsconfig) {
|
|
25
|
-
(0,
|
|
21
|
+
(0, _ensureBindings.sync)('@swc/core', "".concat(process.platform, "-").concat(process.arch));
|
|
26
22
|
try {
|
|
27
|
-
var ts =
|
|
28
|
-
var swc =
|
|
29
|
-
var transpiler =
|
|
23
|
+
var ts = _require('typescript');
|
|
24
|
+
var swc = _require('@swc/core');
|
|
25
|
+
var transpiler = _require('ts-node/transpilers/swc');
|
|
30
26
|
var parsed = ts.parseJsonConfigFileContent(tsconfig.config, ts.sys, _path.default.dirname(tsconfig.path));
|
|
31
27
|
return transpiler.createSwcOptions(parsed.options, undefined, swc, 'swc');
|
|
32
28
|
} catch (err) {
|
|
@@ -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
|
|
1
|
+
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/typescript/ts-swc-transform/src/lib/swcPrepareOptions.ts"],"sourcesContent":["import path from 'path';\nimport { sync as ensureBindingsSync } from './ensureBindings';\n\nimport Module from 'module';\nconst _require = typeof require === 'undefined' ? Module.createRequire(import.meta.url) : require;\n\nimport type { TsConfigResult } from 'get-tsconfig-compat';\nexport default function swcPrepareOptions(tsconfig: TsConfigResult) {\n ensureBindingsSync('@swc/core', `${process.platform}-${process.arch}`);\n try {\n const ts = _require('typescript');\n const swc = _require('@swc/core');\n const transpiler = _require('ts-node/transpilers/swc');\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","tsconfig","ensureBindingsSync","process","platform","arch","ts","swc","transpiler","parsed","parseJsonConfigFileContent","config","sys","path","dirname","createSwcOptions","options","undefined","err","console","log","message"],"mappings":";;;;+BAOA;;;eAAwBA;;;2DAPP;8BAC0B;6DAExB;;;;;;AACnB,IAAMC,WAAW,OAAOC,YAAY,cAAcC,eAAM,CAACC,aAAa,CAAC,uDAAmBF;AAG3E,SAASF,kBAAkBK,QAAwB;IAChEC,IAAAA,oBAAkB,EAAC,aAAa,AAAC,GAAsBC,OAApBA,QAAQC,QAAQ,EAAC,KAAgB,OAAbD,QAAQE,IAAI;IACnE,IAAI;QACF,IAAMC,KAAKT,SAAS;QACpB,IAAMU,MAAMV,SAAS;QACrB,IAAMW,aAAaX,SAAS;QAC5B,IAAMY,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,12 +12,11 @@ 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 _ensureBindings = /*#__PURE__*/ _interop_require_default(require("./ensureBindings.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"));
|
|
19
19
|
var _module = /*#__PURE__*/ _interop_require_default(require("module"));
|
|
20
|
-
var _lazycache = /*#__PURE__*/ _interop_require_default(require("lazy-cache"));
|
|
21
20
|
function _define_property(obj, key, value) {
|
|
22
21
|
if (key in obj) {
|
|
23
22
|
Object.defineProperty(obj, key, {
|
|
@@ -76,9 +75,8 @@ function _object_spread_props(target, source) {
|
|
|
76
75
|
return target;
|
|
77
76
|
}
|
|
78
77
|
var _require = typeof require === 'undefined' ? _module.default.createRequire(require("url").pathToFileURL(__filename).toString()) : require;
|
|
79
|
-
var swcLazy = (0, _lazycache.default)(_require)('@swc/core');
|
|
80
78
|
function transformFile(entry, dest, type, options, callback) {
|
|
81
|
-
(0,
|
|
79
|
+
(0, _ensureBindings.default)('@swc/core', "".concat(process.platform, "-").concat(process.arch), function(err) {
|
|
82
80
|
if (err) return callback(err);
|
|
83
81
|
var tsconfig = options.tsconfig;
|
|
84
82
|
// overrides for cjs
|
|
@@ -90,7 +88,7 @@ function transformFile(entry, dest, type, options, callback) {
|
|
|
90
88
|
tsconfig.config.compilerOptions.target = 'ES5';
|
|
91
89
|
}
|
|
92
90
|
var swcOptions = (0, _swcPrepareOptions.default)(tsconfig);
|
|
93
|
-
var swc =
|
|
91
|
+
var swc = _require('@swc/core');
|
|
94
92
|
swc.transformFile(entry.fullPath, _object_spread_props(_object_spread({}, entry.basename.endsWith('.tsx') || entry.basename.endsWith('.jsx') ? swcOptions.tsxOptions : swcOptions.nonTsxOptions), {
|
|
95
93
|
filename: entry.basename
|
|
96
94
|
})).then(function(output) {
|
|
@@ -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 './ensureBindings';\n\nimport patchCJS from '../lib/patchCJS';\nimport patchESM from '../lib/patchESM';\nimport swcPrepareOptions from '../lib/swcPrepareOptions';\n\nimport Module from 'module';\nconst _require = typeof require === 'undefined' ? Module.createRequire(import.meta.url) : require;\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 = _require('@swc/core');\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","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":";;;;+BAaA;;;eAAwBA;;;yDAbT;2DACE;oEACE;8DACD;qEACS;+DAEN;+DACA;wEACS;6DAEX;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACnB,IAAMC,WAAW,OAAOC,YAAY,cAAcC,eAAM,CAACC,aAAa,CAAC,uDAAmBF;AAE3E,SAASF,cAAcK,KAAK,EAAEC,IAAI,EAAEC,IAAI,EAAEC,OAAO,EAAEC,QAAQ;IACxEC,IAAAA,uBAAc,EAAC,aAAa,AAAC,GAAsBC,OAApBA,QAAQC,QAAQ,EAAC,KAAgB,OAAbD,QAAQE,IAAI,GAAI,SAACC;QAClE,IAAIA,KAAK,OAAOL,SAASK;QAEzB,IAAIC,WAAWP,QAAQO,QAAQ;QAE/B,oBAAoB;QACpB,IAAIR,SAAS,OAAO;YAClBQ,WAAW,mBAAKA;YAChBA,SAASC,MAAM,GAAG,mBAAKD,SAASC,MAAM;YACtCD,SAASC,MAAM,CAACC,eAAe,GAAG,mBAAMF,SAASC,MAAM,CAACC,eAAe,IAAI,CAAC;YAC5EF,SAASC,MAAM,CAACC,eAAe,CAACC,MAAM,GAAG;YACzCH,SAASC,MAAM,CAACC,eAAe,CAACE,MAAM,GAAG;QAC3C;QAEA,IAAMC,aAAaC,IAAAA,0BAAiB,EAACN;QACrC,IAAMO,MAAMrB,SAAS;QAErBqB,IACGtB,aAAa,CAACK,MAAMkB,QAAQ,EAAE,wCACzBlB,MAAMmB,QAAQ,CAACC,QAAQ,CAAC,WAAWpB,MAAMmB,QAAQ,CAACC,QAAQ,CAAC,UAAUL,WAAWM,UAAU,GAAGN,WAAWO,aAAa;YACzHC,UAAUvB,MAAMmB,QAAQ;YAEzBK,IAAI,CAAC,SAACC;YACL,IAAMC,YAAYxB,SAAS,QAAQyB,IAAAA,iBAAQ,EAAC3B,OAAOyB,QAAQtB,WAAWyB,IAAAA,iBAAQ,EAAC5B,OAAOyB,QAAQtB;YAC9F,IAAM0B,MAAMC,aAAI,CAACC,OAAO,CAAC/B,MAAM8B,IAAI;YACnC,IAAME,UAAUF,aAAI,CAACG,IAAI,CAAChC,MAAM,AAAC4B,CAAAA,MAAM7B,MAAM8B,IAAI,CAACI,KAAK,CAAC,GAAG,CAACL,IAAIM,MAAM,IAAInC,MAAM8B,IAAI,AAAD,IAAKJ;YAExFU,IAAAA,sBAAM,EAACN,aAAI,CAACO,OAAO,CAACL,UAAU;gBAC5B,IAAMM,QAAQ,IAAIC,gBAAK;gBACvBD,MAAME,KAAK,CAACC,WAAE,CAACC,SAAS,CAACC,IAAI,CAAC,MAAMX,SAASP,OAAOmB,IAAI,EAAE;gBAC1D,CAACzC,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"}
|
|
@@ -19,7 +19,6 @@ 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
21
|
var _module = /*#__PURE__*/ _interop_require_default(require("module"));
|
|
22
|
-
var _lazycache = /*#__PURE__*/ _interop_require_default(require("lazy-cache"));
|
|
23
22
|
function _define_property(obj, key, value) {
|
|
24
23
|
if (key in obj) {
|
|
25
24
|
Object.defineProperty(obj, key, {
|
|
@@ -58,11 +57,10 @@ var version = major < 14 ? 'stable' : 'local';
|
|
|
58
57
|
var __dirname = _path.default.dirname(typeof __filename === 'undefined' ? _url.default.fileURLToPath(require("url").pathToFileURL(__filename).toString()) : __filename);
|
|
59
58
|
var workerPath = _path.default.join(__dirname, '..', 'cjs', 'workers', 'transformDirectory.cjs');
|
|
60
59
|
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
60
|
function dispatch(version, src, dest, type, options, callback) {
|
|
63
61
|
if (version === 'local') return _require(workerPath)(src, dest, type, options, callback);
|
|
64
62
|
try {
|
|
65
|
-
callback(null,
|
|
63
|
+
callback(null, _require('node-version-call')({
|
|
66
64
|
version: version,
|
|
67
65
|
callbacks: true
|
|
68
66
|
}, workerPath, src, dest, type, options));
|
|
@@ -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';\
|
|
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';\nconst _require = typeof require === 'undefined' ? Module.createRequire(import.meta.url) : require;\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, _require('node-version-call')({ 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","dispatch","src","dest","type","options","callback","callbacks","err","Error","tsconfig","loadTsConfig","cwd","Promise","resolve","reject","result"],"mappings":";;;;+BAsBA;;;;;;;CAOC,GACD;;;eAAwBA;;;2DA9BP;0DACD;mEACS;6DAON;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AALnB,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;AAGhE,IAAMQ,WAAW,OAAOC,YAAY,cAAcC,eAAM,CAACC,aAAa,CAAC,uDAAmBF;AAE1F,SAASG,SAASb,OAAO,EAAEc,GAAG,EAAEC,IAAI,EAAEC,IAAI,EAAEC,OAAO,EAAEC,QAAQ;IAC3D,IAAIlB,YAAY,SAAS,OAAOS,SAASF,YAAYO,KAAKC,MAAMC,MAAMC,SAASC;IAC/E,IAAI;QACFA,SAAS,MAAMT,SAAS,qBAAqB;YAAET,SAAAA;YAASmB,WAAW;QAAK,GAAGZ,YAAYO,KAAKC,MAAMC,MAAMC;IAC1G,EAAE,OAAOG,KAAK;QACZF,SAASE;IACX;AACF;AAWe,SAAS1B,mBAAmBoB,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,SAASb,SAASc,KAAKC,MAAMC,MAAMC,SAASC;QACvF,OAAO,IAAIO,QAAQ,SAACC,SAASC;mBAAWd,SAASb,SAASc,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"}
|
|
@@ -17,7 +17,6 @@ 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
19
|
var _module = /*#__PURE__*/ _interop_require_default(require("module"));
|
|
20
|
-
var _lazycache = /*#__PURE__*/ _interop_require_default(require("lazy-cache"));
|
|
21
20
|
function _interop_require_default(obj) {
|
|
22
21
|
return obj && obj.__esModule ? obj : {
|
|
23
22
|
default: obj
|
|
@@ -69,10 +68,9 @@ var version = major < 14 ? 'stable' : 'local';
|
|
|
69
68
|
var __dirname = _path.default.dirname(typeof __filename === 'undefined' ? _url.default.fileURLToPath(require("url").pathToFileURL(__filename).toString()) : __filename);
|
|
70
69
|
var workerPath = _path.default.join(__dirname, '..', 'cjs', 'workers', 'transformSync.cjs');
|
|
71
70
|
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
71
|
function dispatch(version, contents, fileName, tsconfig) {
|
|
74
72
|
if (version === 'local') return _require(workerPath)(contents, fileName, tsconfig);
|
|
75
|
-
return
|
|
73
|
+
return _require('node-version-call')(version, workerPath, contents, fileName, tsconfig);
|
|
76
74
|
}
|
|
77
75
|
function transformSync(contents, fileName, tsconfig) {
|
|
78
76
|
if (typeof contents !== 'string') throw new Error('transformTypes: unexpected contents');
|
|
@@ -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';\
|
|
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';\nconst _require = typeof require === 'undefined' ? Module.createRequire(import.meta.url) : require;\n\nfunction dispatch(version, contents, fileName, tsconfig) {\n if (version === 'local') return _require(workerPath)(contents, fileName, tsconfig);\n return _require('node-version-call')(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","dispatch","contents","fileName","tsconfig","Error","getTS","getTsconfig","cwd"],"mappings":";;;;+BAmBA;;;;;CAKC,GACD;;;eAAwBA;;;2DAzBP;0DACD;yEACO;6DAOJ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AALnB,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;AAGhE,IAAMQ,WAAW,OAAOC,YAAY,cAAcC,eAAM,CAACC,aAAa,CAAC,uDAAmBF;AAE1F,SAASG,SAASb,OAAO,EAAEc,QAAQ,EAAEC,QAAQ,EAAEC,QAAQ;IACrD,IAAIhB,YAAY,SAAS,OAAOS,SAASF,YAAYO,UAAUC,UAAUC;IACzE,OAAOP,SAAS,qBAAqBT,SAASO,YAAYO,UAAUC,UAAUC;AAChF;AAUe,SAAStB,cAAcoB,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,CAACvB,QAAQwB,GAAG;IACvD,OAAOP,SAASb,SAASc,UAAUC,UAAUC;AAC/C"}
|
|
@@ -18,7 +18,6 @@ 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
20
|
var _module = /*#__PURE__*/ _interop_require_default(require("module"));
|
|
21
|
-
var _lazycache = /*#__PURE__*/ _interop_require_default(require("lazy-cache"));
|
|
22
21
|
function _define_property(obj, key, value) {
|
|
23
22
|
if (key in obj) {
|
|
24
23
|
Object.defineProperty(obj, key, {
|
|
@@ -57,11 +56,10 @@ var version = major < 14 ? 'stable' : 'local';
|
|
|
57
56
|
var __dirname = _path.default.dirname(typeof __filename === 'undefined' ? _url.default.fileURLToPath(require("url").pathToFileURL(__filename).toString()) : __filename);
|
|
58
57
|
var workerPath = _path.default.join(__dirname, '..', 'cjs', 'workers', 'transformTypes.cjs');
|
|
59
58
|
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
59
|
function dispatch(version, src, dest, options, callback) {
|
|
62
60
|
if (version === 'local') return _require(workerPath)(src, dest, options, callback);
|
|
63
61
|
try {
|
|
64
|
-
callback(null,
|
|
62
|
+
callback(null, _require('node-version-call')({
|
|
65
63
|
version: version,
|
|
66
64
|
callbacks: true
|
|
67
65
|
}, workerPath, src, dest, options));
|
|
@@ -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';\
|
|
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';\nconst _require = typeof require === 'undefined' ? Module.createRequire(import.meta.url) : require;\n\nfunction dispatch(version, src, dest, options, callback) {\n if (version === 'local') return _require(workerPath)(src, dest, options, callback);\n try {\n callback(null, _require('node-version-call')({ 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","dispatch","src","dest","options","callback","callbacks","err","Error","tsconfig","loadTsConfig","cwd","Promise","resolve","reject","result"],"mappings":";;;;+BAsBA;;;;;;CAMC,GACD;;;eAAwBA;;;2DA7BP;0DACD;mEACS;6DAON;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AALnB,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;AAGhE,IAAMQ,WAAW,OAAOC,YAAY,cAAcC,eAAM,CAACC,aAAa,CAAC,uDAAmBF;AAE1F,SAASG,SAASb,OAAO,EAAEc,GAAG,EAAEC,IAAI,EAAEC,OAAO,EAAEC,QAAQ;IACrD,IAAIjB,YAAY,SAAS,OAAOS,SAASF,YAAYO,KAAKC,MAAMC,SAASC;IACzE,IAAI;QACFA,SAAS,MAAMR,SAAS,qBAAqB;YAAET,SAAAA;YAASkB,WAAW;QAAK,GAAGX,YAAYO,KAAKC,MAAMC;IACpG,EAAE,OAAOG,KAAK;QACZF,SAASE;IACX;AACF;AAUe,SAASzB,eAAeoB,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,SAASb,SAASc,KAAKC,MAAMC,SAASC;QACjF,OAAO,IAAIO,QAAQ,SAACC,SAASC;mBAAWb,SAASb,SAASc,KAAKC,MAAMC,SAAS,SAACG,KAAKQ;uBAAYR,MAAMO,OAAOP,OAAOM,QAAQE;;;IAC9H,EAAE,OAAOR,KAAK;QACZ,IAAIF,UAAUA,SAASE;aAClB,OAAOK,QAAQE,MAAM,CAACP;IAC7B;AACF"}
|
|
@@ -10,7 +10,6 @@ Object.defineProperty(exports, "default", {
|
|
|
10
10
|
});
|
|
11
11
|
var _swcPrepareOptions = /*#__PURE__*/ _interop_require_default(require("../lib/swcPrepareOptions.cjs"));
|
|
12
12
|
var _module = /*#__PURE__*/ _interop_require_default(require("module"));
|
|
13
|
-
var _lazycache = /*#__PURE__*/ _interop_require_default(require("lazy-cache"));
|
|
14
13
|
function _define_property(obj, key, value) {
|
|
15
14
|
if (key in obj) {
|
|
16
15
|
Object.defineProperty(obj, key, {
|
|
@@ -69,10 +68,9 @@ function _object_spread_props(target, source) {
|
|
|
69
68
|
return target;
|
|
70
69
|
}
|
|
71
70
|
var _require = typeof require === 'undefined' ? _module.default.createRequire(require("url").pathToFileURL(__filename).toString()) : require;
|
|
72
|
-
var swcLazy = (0, _lazycache.default)(_require)('@swc/core');
|
|
73
71
|
function transformSyncWorker(contents, fileName, tsconfig) {
|
|
74
72
|
var swcOptions = (0, _swcPrepareOptions.default)(tsconfig);
|
|
75
|
-
var swc =
|
|
73
|
+
var swc = _require('@swc/core');
|
|
76
74
|
return swc.transformSync(contents, _object_spread_props(_object_spread({}, fileName.endsWith('.tsx') || fileName.endsWith('.jsx') ? swcOptions.tsxOptions : swcOptions.nonTsxOptions), {
|
|
77
75
|
filename: fileName
|
|
78
76
|
}));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/typescript/ts-swc-transform/src/workers/transformSync.ts"],"sourcesContent":["import swcPrepareOptions from '../lib/swcPrepareOptions';\n\nimport Module from 'module';\
|
|
1
|
+
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/typescript/ts-swc-transform/src/workers/transformSync.ts"],"sourcesContent":["import swcPrepareOptions from '../lib/swcPrepareOptions';\n\nimport Module from 'module';\nconst _require = typeof require === 'undefined' ? Module.createRequire(import.meta.url) : require;\n\nimport type { TsConfigResult } from 'get-tsconfig-compat';\nexport default function transformSyncWorker(contents: string, fileName: string, tsconfig: TsConfigResult) {\n const swcOptions = swcPrepareOptions(tsconfig);\n const swc = _require('@swc/core');\n return swc.transformSync(contents, {\n ...(fileName.endsWith('.tsx') || fileName.endsWith('.jsx') ? swcOptions.tsxOptions : swcOptions.nonTsxOptions),\n filename: fileName,\n });\n}\n"],"names":["transformSyncWorker","_require","require","Module","createRequire","contents","fileName","tsconfig","swcOptions","swcPrepareOptions","swc","transformSync","endsWith","tsxOptions","nonTsxOptions","filename"],"mappings":";;;;+BAMA;;;eAAwBA;;;wEANM;6DAEX;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACnB,IAAMC,WAAW,OAAOC,YAAY,cAAcC,eAAM,CAACC,aAAa,CAAC,uDAAmBF;AAG3E,SAASF,oBAAoBK,QAAgB,EAAEC,QAAgB,EAAEC,QAAwB;IACtG,IAAMC,aAAaC,IAAAA,0BAAiB,EAACF;IACrC,IAAMG,MAAMT,SAAS;IACrB,OAAOS,IAAIC,aAAa,CAACN,UAAU,wCAC7BC,SAASM,QAAQ,CAAC,WAAWN,SAASM,QAAQ,CAAC,UAAUJ,WAAWK,UAAU,GAAGL,WAAWM,aAAa;QAC7GC,UAAUT;;AAEd"}
|
|
@@ -11,7 +11,6 @@ Object.defineProperty(exports, "default", {
|
|
|
11
11
|
var _fsiterator = /*#__PURE__*/ _interop_require_default(require("fs-iterator"));
|
|
12
12
|
var _rimraf2 = /*#__PURE__*/ _interop_require_default(require("rimraf2"));
|
|
13
13
|
var _module = /*#__PURE__*/ _interop_require_default(require("module"));
|
|
14
|
-
var _lazycache = /*#__PURE__*/ _interop_require_default(require("lazy-cache"));
|
|
15
14
|
var _constants = require("../constants.cjs");
|
|
16
15
|
var _createMatcher = /*#__PURE__*/ _interop_require_default(require("../createMatcher.cjs"));
|
|
17
16
|
function _define_property(obj, key, value) {
|
|
@@ -72,10 +71,10 @@ function _object_spread_props(target, source) {
|
|
|
72
71
|
return target;
|
|
73
72
|
}
|
|
74
73
|
var _require = typeof require === 'undefined' ? _module.default.createRequire(require("url").pathToFileURL(__filename).toString()) : require;
|
|
75
|
-
var tsLazy = (0, _lazycache.default)(_require)('typescript');
|
|
76
74
|
function transformTypesWorker(src, dest, options, callback) {
|
|
77
75
|
var tsconfig = options.tsconfig;
|
|
78
76
|
var matcher = (0, _createMatcher.default)(tsconfig);
|
|
77
|
+
var ts = _require('typescript');
|
|
79
78
|
(0, _rimraf2.default)(dest, {
|
|
80
79
|
disableGlob: true
|
|
81
80
|
}, function() {
|
|
@@ -91,7 +90,6 @@ function transformTypesWorker(src, dest, options, callback) {
|
|
|
91
90
|
concurrency: Infinity
|
|
92
91
|
}, function(err) {
|
|
93
92
|
if (err) return callback(err);
|
|
94
|
-
var ts = tsLazy();
|
|
95
93
|
var config = {
|
|
96
94
|
fileNames: entries.map(function(entry) {
|
|
97
95
|
return entry.fullPath;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/typescript/ts-swc-transform/src/workers/transformTypes.ts"],"sourcesContent":["import Iterator from 'fs-iterator';\nimport rimraf2 from 'rimraf2';\n\nimport Module from 'module';\
|
|
1
|
+
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/typescript/ts-swc-transform/src/workers/transformTypes.ts"],"sourcesContent":["import Iterator from 'fs-iterator';\nimport rimraf2 from 'rimraf2';\n\nimport Module from 'module';\nconst _require = typeof require === 'undefined' ? Module.createRequire(import.meta.url) : require;\n\nimport { typeFileRegEx } from '../constants';\nimport createMatcher from '../createMatcher';\n\nexport default function transformTypesWorker(src, dest, options, callback) {\n const tsconfig = options.tsconfig;\n const matcher = createMatcher(tsconfig);\n const ts = _require('typescript');\n\n rimraf2(dest, { disableGlob: true }, () => {\n const entries = [];\n const iterator = new Iterator(src);\n iterator.forEach(\n (entry) => {\n if (!entry.stats.isFile()) return;\n if (entry.basename[0] === '.') return;\n if (typeFileRegEx.test(entry.basename)) return;\n if (!matcher(entry.fullPath)) return;\n entries.push(entry);\n },\n { concurrency: Infinity },\n (err) => {\n if (err) return callback(err);\n\n const config = {\n fileNames: entries.map((entry) => entry.fullPath),\n options: {\n ...(tsconfig.compilerOptions || {}),\n outDir: dest,\n allowJs: true,\n declaration: true,\n emitDeclarationOnly: true,\n listEmittedFiles: true,\n },\n projectReferences: tsconfig.config.references,\n };\n const { fileNames, options, projectReferences } = config;\n const host = ts.createCompilerHostWorker(options, /*setParentNodes*/ undefined, ts.sys);\n const programOptions = {\n rootNames: fileNames,\n options,\n projectReferences,\n host,\n configFileParsingDiagnostics: ts.getConfigFileParsingDiagnostics({ fileNames, options }),\n };\n const program = ts.createProgram(programOptions);\n const res = program.emit();\n callback(null, res.emittedFiles);\n }\n );\n });\n}\n"],"names":["transformTypesWorker","_require","require","Module","createRequire","src","dest","options","callback","tsconfig","matcher","createMatcher","ts","rimraf2","disableGlob","entries","iterator","Iterator","forEach","entry","stats","isFile","basename","typeFileRegEx","test","fullPath","push","concurrency","Infinity","err","config","fileNames","map","compilerOptions","outDir","allowJs","declaration","emitDeclarationOnly","listEmittedFiles","projectReferences","references","host","createCompilerHostWorker","undefined","sys","programOptions","rootNames","configFileParsingDiagnostics","getConfigFileParsingDiagnostics","program","createProgram","res","emit","emittedFiles"],"mappings":";;;;+BASA;;;eAAwBA;;;iEATH;8DACD;6DAED;yBAGW;oEACJ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAH1B,IAAMC,WAAW,OAAOC,YAAY,cAAcC,eAAM,CAACC,aAAa,CAAC,uDAAmBF;AAK3E,SAASF,qBAAqBK,GAAG,EAAEC,IAAI,EAAEC,OAAO,EAAEC,QAAQ;IACvE,IAAMC,WAAWF,QAAQE,QAAQ;IACjC,IAAMC,UAAUC,IAAAA,sBAAa,EAACF;IAC9B,IAAMG,KAAKX,SAAS;IAEpBY,IAAAA,gBAAO,EAACP,MAAM;QAAEQ,aAAa;IAAK,GAAG;QACnC,IAAMC,UAAU,EAAE;QAClB,IAAMC,WAAW,IAAIC,mBAAQ,CAACZ;QAC9BW,SAASE,OAAO,CACd,SAACC;YACC,IAAI,CAACA,MAAMC,KAAK,CAACC,MAAM,IAAI;YAC3B,IAAIF,MAAMG,QAAQ,CAAC,EAAE,KAAK,KAAK;YAC/B,IAAIC,wBAAa,CAACC,IAAI,CAACL,MAAMG,QAAQ,GAAG;YACxC,IAAI,CAACZ,QAAQS,MAAMM,QAAQ,GAAG;YAC9BV,QAAQW,IAAI,CAACP;QACf,GACA;YAAEQ,aAAaC;QAAS,GACxB,SAACC;YACC,IAAIA,KAAK,OAAOrB,SAASqB;YAEzB,IAAMC,SAAS;gBACbC,WAAWhB,QAAQiB,GAAG,CAAC,SAACb;2BAAUA,MAAMM,QAAQ;;gBAChDlB,SAAS,wCACHE,SAASwB,eAAe,IAAI,CAAC;oBACjCC,QAAQ5B;oBACR6B,SAAS;oBACTC,aAAa;oBACbC,qBAAqB;oBACrBC,kBAAkB;;gBAEpBC,mBAAmB9B,SAASqB,MAAM,CAACU,UAAU;YAC/C;YACA,IAAQT,YAA0CD,OAA1CC,WAAWxB,YAA+BuB,OAA/BvB,SAASgC,oBAAsBT,OAAtBS;YAC5B,IAAME,OAAO7B,GAAG8B,wBAAwB,CAACnC,WAAS,gBAAgB,GAAGoC,WAAW/B,GAAGgC,GAAG;YACtF,IAAMC,iBAAiB;gBACrBC,WAAWf;gBACXxB,SAAAA;gBACAgC,mBAAAA;gBACAE,MAAAA;gBACAM,8BAA8BnC,GAAGoC,+BAA+B,CAAC;oBAAEjB,WAAAA;oBAAWxB,SAAAA;gBAAQ;YACxF;YACA,IAAM0C,UAAUrC,GAAGsC,aAAa,CAACL;YACjC,IAAMM,MAAMF,QAAQG,IAAI;YACxB5C,SAAS,MAAM2C,IAAIE,YAAY;QACjC;IAEJ;AACF"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import fs from 'fs';
|
|
2
|
+
import path from 'path';
|
|
3
|
+
import installModule, { sync as installModuleSync } from 'install-module-linked';
|
|
4
|
+
import resolve from 'resolve';
|
|
5
|
+
import resolveOnce from 'resolve-once-cb';
|
|
6
|
+
const existsSync = (test)=>{
|
|
7
|
+
try {
|
|
8
|
+
(fs.accessSync || fs.statSync)(test);
|
|
9
|
+
return true;
|
|
10
|
+
} catch (_) {
|
|
11
|
+
return false;
|
|
12
|
+
}
|
|
13
|
+
};
|
|
14
|
+
function findDependency(identifier, target) {
|
|
15
|
+
const packagePath = resolve.sync(`${identifier}/package.json`);
|
|
16
|
+
const nodeModules = identifier[0] === '@' ? path.join(packagePath, '..', '..', '..') : path.join(packagePath, '..', '..');
|
|
17
|
+
const optionalDependencies = JSON.parse(fs.readFileSync(packagePath, 'utf8')).optionalDependencies;
|
|
18
|
+
const name = Object.keys(optionalDependencies).find((name)=>name.indexOf(target) >= 0);
|
|
19
|
+
return name ? {
|
|
20
|
+
name,
|
|
21
|
+
version: optionalDependencies[name],
|
|
22
|
+
nodeModules
|
|
23
|
+
} : null;
|
|
24
|
+
}
|
|
25
|
+
const bindings = {};
|
|
26
|
+
export default function ensureBindings(identifier, target, callback) {
|
|
27
|
+
if (bindings[identifier] === undefined) bindings[identifier] = {};
|
|
28
|
+
if (bindings[identifier][target] === undefined) {
|
|
29
|
+
bindings[identifier][target] = resolveOnce((cb)=>{
|
|
30
|
+
const { name, version, nodeModules } = findDependency(identifier, target);
|
|
31
|
+
const installString = version ? `${name}@${version}` : name;
|
|
32
|
+
return existsSync(path.join(nodeModules, name)) ? cb() : installModule(installString, nodeModules, cb);
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
bindings[identifier][target](callback);
|
|
36
|
+
}
|
|
37
|
+
const bindingsSync = {};
|
|
38
|
+
export function sync(identifier, target) {
|
|
39
|
+
if (bindingsSync[identifier] === undefined) bindingsSync[identifier] = {};
|
|
40
|
+
if (bindingsSync[identifier][target] === undefined) {
|
|
41
|
+
bindingsSync[identifier][target] = (()=>{
|
|
42
|
+
const { name, version, nodeModules } = findDependency(identifier, target);
|
|
43
|
+
const installString = version ? `${name}@${version}` : name;
|
|
44
|
+
return existsSync(path.join(nodeModules, name)) ? target : installModuleSync(installString, nodeModules);
|
|
45
|
+
})();
|
|
46
|
+
}
|
|
47
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/typescript/ts-swc-transform/src/lib/ensureBindings.ts"],"sourcesContent":["import fs from 'fs';\nimport path from 'path';\nimport installModule, { sync as installModuleSync } from 'install-module-linked';\nimport resolve from 'resolve';\nimport resolveOnce from 'resolve-once-cb';\n\nconst existsSync = (test) => {\n try {\n (fs.accessSync || fs.statSync)(test);\n return true;\n } catch (_) {\n return false;\n }\n};\n\nfunction findDependency(identifier, target) {\n const packagePath = resolve.sync(`${identifier}/package.json`);\n const nodeModules = identifier[0] === '@' ? path.join(packagePath, '..', '..', '..') : path.join(packagePath, '..', '..');\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], nodeModules } : null;\n}\n\nconst bindings = {};\nexport default 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, version, nodeModules } = findDependency(identifier, target);\n const installString = version ? `${name}@${version}` : name;\n return existsSync(path.join(nodeModules, name)) ? cb() : installModule(installString, nodeModules, cb);\n });\n }\n bindings[identifier][target](callback);\n}\n\nconst bindingsSync = {};\nexport function sync(identifier, target) {\n if (bindingsSync[identifier] === undefined) bindingsSync[identifier] = {};\n if (bindingsSync[identifier][target] === undefined) {\n bindingsSync[identifier][target] = (() => {\n const { name, version, nodeModules } = findDependency(identifier, target);\n const installString = version ? `${name}@${version}` : name;\n return existsSync(path.join(nodeModules, name)) ? target : installModuleSync(installString, nodeModules);\n })();\n }\n}\n"],"names":["fs","path","installModule","sync","installModuleSync","resolve","resolveOnce","existsSync","test","accessSync","statSync","_","findDependency","identifier","target","packagePath","nodeModules","join","optionalDependencies","JSON","parse","readFileSync","name","Object","keys","find","indexOf","version","bindings","ensureBindings","callback","undefined","cb","installString","bindingsSync"],"mappings":"AAAA,OAAOA,QAAQ,KAAK;AACpB,OAAOC,UAAU,OAAO;AACxB,OAAOC,iBAAiBC,QAAQC,iBAAiB,QAAQ,wBAAwB;AACjF,OAAOC,aAAa,UAAU;AAC9B,OAAOC,iBAAiB,kBAAkB;AAE1C,MAAMC,aAAa,CAACC;IAClB,IAAI;QACDR,CAAAA,GAAGS,UAAU,IAAIT,GAAGU,QAAQ,AAAD,EAAGF;QAC/B,OAAO;IACT,EAAE,OAAOG,GAAG;QACV,OAAO;IACT;AACF;AAEA,SAASC,eAAeC,UAAU,EAAEC,MAAM;IACxC,MAAMC,cAAcV,QAAQF,IAAI,CAAC,GAAGU,WAAW,aAAa,CAAC;IAC7D,MAAMG,cAAcH,UAAU,CAAC,EAAE,KAAK,MAAMZ,KAAKgB,IAAI,CAACF,aAAa,MAAM,MAAM,QAAQd,KAAKgB,IAAI,CAACF,aAAa,MAAM;IACpH,MAAMG,uBAAuBC,KAAKC,KAAK,CAACpB,GAAGqB,YAAY,CAACN,aAAa,SAASG,oBAAoB;IAClG,MAAMI,OAAOC,OAAOC,IAAI,CAACN,sBAAsBO,IAAI,CAAC,CAACH,OAASA,KAAKI,OAAO,CAACZ,WAAW;IACtF,OAAOQ,OAAO;QAAEA;QAAMK,SAAST,oBAAoB,CAACI,KAAK;QAAEN;IAAY,IAAI;AAC7E;AAEA,MAAMY,WAAW,CAAC;AAClB,eAAe,SAASC,eAAehB,UAAU,EAAEC,MAAM,EAAEgB,QAAQ;IACjE,IAAIF,QAAQ,CAACf,WAAW,KAAKkB,WAAWH,QAAQ,CAACf,WAAW,GAAG,CAAC;IAChE,IAAIe,QAAQ,CAACf,WAAW,CAACC,OAAO,KAAKiB,WAAW;QAC9CH,QAAQ,CAACf,WAAW,CAACC,OAAO,GAAGR,YAAY,CAAC0B;YAC1C,MAAM,EAAEV,IAAI,EAAEK,OAAO,EAAEX,WAAW,EAAE,GAAGJ,eAAeC,YAAYC;YAClE,MAAMmB,gBAAgBN,UAAU,GAAGL,KAAK,CAAC,EAAEK,SAAS,GAAGL;YACvD,OAAOf,WAAWN,KAAKgB,IAAI,CAACD,aAAaM,SAASU,OAAO9B,cAAc+B,eAAejB,aAAagB;QACrG;IACF;IACAJ,QAAQ,CAACf,WAAW,CAACC,OAAO,CAACgB;AAC/B;AAEA,MAAMI,eAAe,CAAC;AACtB,OAAO,SAAS/B,KAAKU,UAAU,EAAEC,MAAM;IACrC,IAAIoB,YAAY,CAACrB,WAAW,KAAKkB,WAAWG,YAAY,CAACrB,WAAW,GAAG,CAAC;IACxE,IAAIqB,YAAY,CAACrB,WAAW,CAACC,OAAO,KAAKiB,WAAW;QAClDG,YAAY,CAACrB,WAAW,CAACC,OAAO,GAAG,AAAC,CAAA;YAClC,MAAM,EAAEQ,IAAI,EAAEK,OAAO,EAAEX,WAAW,EAAE,GAAGJ,eAAeC,YAAYC;YAClE,MAAMmB,gBAAgBN,UAAU,GAAGL,KAAK,CAAC,EAAEK,SAAS,GAAGL;YACvD,OAAOf,WAAWN,KAAKgB,IAAI,CAACD,aAAaM,SAASR,SAASV,kBAAkB6B,eAAejB;QAC9F,CAAA;IACF;AACF"}
|
|
@@ -1,17 +1,13 @@
|
|
|
1
1
|
import path from 'path';
|
|
2
|
-
import { sync as
|
|
2
|
+
import { sync as ensureBindingsSync } from './ensureBindings.mjs';
|
|
3
3
|
import Module from 'module';
|
|
4
|
-
import lazy from 'lazy-cache';
|
|
5
4
|
const _require = typeof require === 'undefined' ? Module.createRequire(import.meta.url) : require;
|
|
6
|
-
const tsLazy = lazy(_require)('typescript');
|
|
7
|
-
const swcLazy = lazy(_require)('@swc/core');
|
|
8
|
-
const transpilerLazy = lazy(_require)('ts-node/transpilers/swc');
|
|
9
5
|
export default function swcPrepareOptions(tsconfig) {
|
|
10
|
-
|
|
6
|
+
ensureBindingsSync('@swc/core', `${process.platform}-${process.arch}`);
|
|
11
7
|
try {
|
|
12
|
-
const ts =
|
|
13
|
-
const swc =
|
|
14
|
-
const transpiler =
|
|
8
|
+
const ts = _require('typescript');
|
|
9
|
+
const swc = _require('@swc/core');
|
|
10
|
+
const transpiler = _require('ts-node/transpilers/swc');
|
|
15
11
|
const parsed = ts.parseJsonConfigFileContent(tsconfig.config, ts.sys, path.dirname(tsconfig.path));
|
|
16
12
|
return transpiler.createSwcOptions(parsed.options, undefined, swc, 'swc');
|
|
17
13
|
} catch (err) {
|
|
@@ -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
|
|
1
|
+
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/typescript/ts-swc-transform/src/lib/swcPrepareOptions.ts"],"sourcesContent":["import path from 'path';\nimport { sync as ensureBindingsSync } from './ensureBindings';\n\nimport Module from 'module';\nconst _require = typeof require === 'undefined' ? Module.createRequire(import.meta.url) : require;\n\nimport type { TsConfigResult } from 'get-tsconfig-compat';\nexport default function swcPrepareOptions(tsconfig: TsConfigResult) {\n ensureBindingsSync('@swc/core', `${process.platform}-${process.arch}`);\n try {\n const ts = _require('typescript');\n const swc = _require('@swc/core');\n const transpiler = _require('ts-node/transpilers/swc');\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","ensureBindingsSync","Module","_require","require","createRequire","url","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,kBAAkB,QAAQ,mBAAmB;AAE9D,OAAOC,YAAY,SAAS;AAC5B,MAAMC,WAAW,OAAOC,YAAY,cAAcF,OAAOG,aAAa,CAAC,YAAYC,GAAG,IAAIF;AAG1F,eAAe,SAASG,kBAAkBC,QAAwB;IAChEP,mBAAmB,aAAa,GAAGQ,QAAQC,QAAQ,CAAC,CAAC,EAAED,QAAQE,IAAI,EAAE;IACrE,IAAI;QACF,MAAMC,KAAKT,SAAS;QACpB,MAAMU,MAAMV,SAAS;QACrB,MAAMW,aAAaX,SAAS;QAC5B,MAAMY,SAASH,GAAGI,0BAA0B,CAACR,SAASS,MAAM,EAAEL,GAAGM,GAAG,EAAEnB,KAAKoB,OAAO,CAACX,SAAST,IAAI;QAChG,OAAOe,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,14 +2,12 @@ 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 './ensureBindings.mjs';
|
|
6
6
|
import patchCJS from '../lib/patchCJS.mjs';
|
|
7
7
|
import patchESM from '../lib/patchESM.mjs';
|
|
8
8
|
import swcPrepareOptions from '../lib/swcPrepareOptions.mjs';
|
|
9
9
|
import Module from 'module';
|
|
10
|
-
import lazy from 'lazy-cache';
|
|
11
10
|
const _require = typeof require === 'undefined' ? Module.createRequire(import.meta.url) : require;
|
|
12
|
-
const swcLazy = lazy(_require)('@swc/core');
|
|
13
11
|
export default function transformFile(entry, dest, type, options, callback) {
|
|
14
12
|
ensureBindings('@swc/core', `${process.platform}-${process.arch}`, (err)=>{
|
|
15
13
|
if (err) return callback(err);
|
|
@@ -29,7 +27,7 @@ export default function transformFile(entry, dest, type, options, callback) {
|
|
|
29
27
|
tsconfig.config.compilerOptions.target = 'ES5';
|
|
30
28
|
}
|
|
31
29
|
const swcOptions = swcPrepareOptions(tsconfig);
|
|
32
|
-
const swc =
|
|
30
|
+
const swc = _require('@swc/core');
|
|
33
31
|
swc.transformFile(entry.fullPath, {
|
|
34
32
|
...entry.basename.endsWith('.tsx') || entry.basename.endsWith('.jsx') ? swcOptions.tsxOptions : swcOptions.nonTsxOptions,
|
|
35
33
|
filename: entry.basename
|
|
@@ -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 './ensureBindings';\n\nimport patchCJS from '../lib/patchCJS';\nimport patchESM from '../lib/patchESM';\nimport swcPrepareOptions from '../lib/swcPrepareOptions';\n\nimport Module from 'module';\nconst _require = typeof require === 'undefined' ? Module.createRequire(import.meta.url) : require;\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 = _require('@swc/core');\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","_require","require","createRequire","url","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,mBAAmB;AAE9C,OAAOC,cAAc,kBAAkB;AACvC,OAAOC,cAAc,kBAAkB;AACvC,OAAOC,uBAAuB,2BAA2B;AAEzD,OAAOC,YAAY,SAAS;AAC5B,MAAMC,WAAW,OAAOC,YAAY,cAAcF,OAAOG,aAAa,CAAC,YAAYC,GAAG,IAAIF;AAE1F,eAAe,SAASG,cAAcC,KAAK,EAAEC,IAAI,EAAEC,IAAI,EAAEC,OAAO,EAAEC,QAAQ;IACxEd,eAAe,aAAa,GAAGe,QAAQC,QAAQ,CAAC,CAAC,EAAED,QAAQE,IAAI,EAAE,EAAE,CAACC;QAClE,IAAIA,KAAK,OAAOJ,SAASI;QAEzB,IAAIC,WAAWN,QAAQM,QAAQ;QAE/B,oBAAoB;QACpB,IAAIP,SAAS,OAAO;YAClBO,WAAW;gBAAE,GAAGA,QAAQ;YAAC;YACzBA,SAASC,MAAM,GAAG;gBAAE,GAAGD,SAASC,MAAM;YAAC;YACvCD,SAASC,MAAM,CAACC,eAAe,GAAG;gBAAE,GAAIF,SAASC,MAAM,CAACC,eAAe,IAAI,CAAC,CAAC;YAAE;YAC/EF,SAASC,MAAM,CAACC,eAAe,CAACC,MAAM,GAAG;YACzCH,SAASC,MAAM,CAACC,eAAe,CAACE,MAAM,GAAG;QAC3C;QAEA,MAAMC,aAAarB,kBAAkBgB;QACrC,MAAMM,MAAMpB,SAAS;QAErBoB,IACGhB,aAAa,CAACC,MAAMgB,QAAQ,EAAE;YAC7B,GAAIhB,MAAMiB,QAAQ,CAACC,QAAQ,CAAC,WAAWlB,MAAMiB,QAAQ,CAACC,QAAQ,CAAC,UAAUJ,WAAWK,UAAU,GAAGL,WAAWM,aAAa;YACzHC,UAAUrB,MAAMiB,QAAQ;QAC1B,GACCK,IAAI,CAAC,CAACC;YACL,MAAMC,YAAYtB,SAAS,QAAQV,SAASQ,OAAOuB,QAAQpB,WAAWZ,SAASS,OAAOuB,QAAQpB;YAC9F,MAAMsB,MAAMtC,KAAKuC,OAAO,CAAC1B,MAAMb,IAAI;YACnC,MAAMwC,UAAUxC,KAAKyC,IAAI,CAAC3B,MAAM,AAACwB,CAAAA,MAAMzB,MAAMb,IAAI,CAAC0C,KAAK,CAAC,GAAG,CAACJ,IAAIK,MAAM,IAAI9B,MAAMb,IAAI,AAAD,IAAKqC;YAExFpC,OAAOD,KAAK4C,OAAO,CAACJ,UAAU;gBAC5B,MAAMK,QAAQ,IAAI3C;gBAClB2C,MAAMC,KAAK,CAAC/C,GAAGgD,SAAS,CAACC,IAAI,CAAC,MAAMR,SAASJ,OAAOa,IAAI,EAAE;gBAC1D,CAACjC,QAAQkC,UAAU,IAAIL,MAAMC,KAAK,CAAC/C,GAAGgD,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"}
|
|
@@ -6,13 +6,11 @@ const version = major < 14 ? 'stable' : 'local';
|
|
|
6
6
|
const __dirname = path.dirname(typeof __filename === 'undefined' ? url.fileURLToPath(import.meta.url) : __filename);
|
|
7
7
|
const workerPath = path.join(__dirname, '..', 'cjs', 'workers', 'transformDirectory.cjs');
|
|
8
8
|
import Module from 'module';
|
|
9
|
-
import lazy from 'lazy-cache';
|
|
10
9
|
const _require = typeof require === 'undefined' ? Module.createRequire(import.meta.url) : require;
|
|
11
|
-
const callLazy = lazy(_require)('node-version-call');
|
|
12
10
|
function dispatch(version, src, dest, type, options, callback) {
|
|
13
11
|
if (version === 'local') return _require(workerPath)(src, dest, type, options, callback);
|
|
14
12
|
try {
|
|
15
|
-
callback(null,
|
|
13
|
+
callback(null, _require('node-version-call')({
|
|
16
14
|
version,
|
|
17
15
|
callbacks: true
|
|
18
16
|
}, workerPath, src, dest, type, options));
|
|
@@ -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';\
|
|
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';\nconst _require = typeof require === 'undefined' ? Module.createRequire(import.meta.url) : require;\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, _require('node-version-call')({ 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","_require","require","createRequire","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,MAAMC,WAAW,OAAOC,YAAY,cAAcF,OAAOG,aAAa,CAAC,YAAYjB,GAAG,IAAIgB;AAE1F,SAASE,SAASX,OAAO,EAAEY,GAAG,EAAEC,IAAI,EAAEC,IAAI,EAAEC,OAAO,EAAEC,QAAQ;IAC3D,IAAIhB,YAAY,SAAS,OAAOQ,SAASH,YAAYO,KAAKC,MAAMC,MAAMC,SAASC;IAC/E,IAAI;QACFA,SAAS,MAAMR,SAAS,qBAAqB;YAAER;YAASiB,WAAW;QAAK,GAAGZ,YAAYO,KAAKC,MAAMC,MAAMC;IAC1G,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,WAAW3B,aAAa;YAAE4B,KAAKV;YAAK,GAAGG,OAAO;QAAC,GAAG;QACxDA,UAAU;YAAEM;YAAU,GAAGN,OAAO;QAAC;QAEjC,IAAI,OAAOC,aAAa,YAAY,OAAOL,SAASX,SAASY,KAAKC,MAAMC,MAAMC,SAASC;QACvF,OAAO,IAAIO,QAAQ,CAACC,SAASC,SAAWd,SAASX,SAASY,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"}
|
|
@@ -6,12 +6,10 @@ const version = major < 14 ? 'stable' : 'local';
|
|
|
6
6
|
const __dirname = path.dirname(typeof __filename === 'undefined' ? url.fileURLToPath(import.meta.url) : __filename);
|
|
7
7
|
const workerPath = path.join(__dirname, '..', 'cjs', 'workers', 'transformSync.cjs');
|
|
8
8
|
import Module from 'module';
|
|
9
|
-
import lazy from 'lazy-cache';
|
|
10
9
|
const _require = typeof require === 'undefined' ? Module.createRequire(import.meta.url) : require;
|
|
11
|
-
const callLazy = lazy(_require)('node-version-call');
|
|
12
10
|
function dispatch(version, contents, fileName, tsconfig) {
|
|
13
11
|
if (version === 'local') return _require(workerPath)(contents, fileName, tsconfig);
|
|
14
|
-
return
|
|
12
|
+
return _require('node-version-call')(version, workerPath, contents, fileName, tsconfig);
|
|
15
13
|
}
|
|
16
14
|
/**
|
|
17
15
|
* @param {string} contents The file contents.
|
|
@@ -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';\
|
|
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';\nconst _require = typeof require === 'undefined' ? Module.createRequire(import.meta.url) : require;\n\nfunction dispatch(version, contents, fileName, tsconfig) {\n if (version === 'local') return _require(workerPath)(contents, fileName, tsconfig);\n return _require('node-version-call')(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","_require","require","createRequire","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,MAAMC,WAAW,OAAOC,YAAY,cAAcF,OAAOG,aAAa,CAAC,YAAYjB,GAAG,IAAIgB;AAE1F,SAASE,SAASX,OAAO,EAAEY,QAAQ,EAAEC,QAAQ,EAAEC,QAAQ;IACrD,IAAId,YAAY,SAAS,OAAOQ,SAASH,YAAYO,UAAUC,UAAUC;IACzE,OAAON,SAAS,qBAAqBR,SAASK,YAAYO,UAAUC,UAAUC;AAChF;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,WAAWpB,MAAMuB,WAAW,CAACrB,QAAQsB,GAAG;IACvD,OAAOP,SAASX,SAASY,UAAUC,UAAUC;AAC/C"}
|
|
@@ -6,13 +6,11 @@ const version = major < 14 ? 'stable' : 'local';
|
|
|
6
6
|
const __dirname = path.dirname(typeof __filename === 'undefined' ? url.fileURLToPath(import.meta.url) : __filename);
|
|
7
7
|
const workerPath = path.join(__dirname, '..', 'cjs', 'workers', 'transformTypes.cjs');
|
|
8
8
|
import Module from 'module';
|
|
9
|
-
import lazy from 'lazy-cache';
|
|
10
9
|
const _require = typeof require === 'undefined' ? Module.createRequire(import.meta.url) : require;
|
|
11
|
-
const callLazy = lazy(_require)('node-version-call');
|
|
12
10
|
function dispatch(version, src, dest, options, callback) {
|
|
13
11
|
if (version === 'local') return _require(workerPath)(src, dest, options, callback);
|
|
14
12
|
try {
|
|
15
|
-
callback(null,
|
|
13
|
+
callback(null, _require('node-version-call')({
|
|
16
14
|
version,
|
|
17
15
|
callbacks: true
|
|
18
16
|
}, workerPath, src, dest, options));
|
|
@@ -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';\
|
|
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';\nconst _require = typeof require === 'undefined' ? Module.createRequire(import.meta.url) : require;\n\nfunction dispatch(version, src, dest, options, callback) {\n if (version === 'local') return _require(workerPath)(src, dest, options, callback);\n try {\n callback(null, _require('node-version-call')({ 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","_require","require","createRequire","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,eAAe,cAAcV,IAAIW,aAAa,CAAC,YAAYX,GAAG,IAAIU;AACxG,MAAME,aAAab,KAAKc,IAAI,CAACL,WAAW,MAAM,OAAO,WAAW;AAEhE,OAAOM,YAAY,SAAS;AAC5B,MAAMC,WAAW,OAAOC,YAAY,cAAcF,OAAOG,aAAa,CAAC,YAAYjB,GAAG,IAAIgB;AAE1F,SAASE,SAASX,OAAO,EAAEY,GAAG,EAAEC,IAAI,EAAEC,OAAO,EAAEC,QAAQ;IACrD,IAAIf,YAAY,SAAS,OAAOQ,SAASH,YAAYO,KAAKC,MAAMC,SAASC;IACzE,IAAI;QACFA,SAAS,MAAMP,SAAS,qBAAqB;YAAER;YAASgB,WAAW;QAAK,GAAGX,YAAYO,KAAKC,MAAMC;IACpG,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,WAAW1B,aAAa;YAAE2B,KAAKT;YAAK,GAAGE,OAAO;QAAC,GAAG;QACxDA,UAAU;YAAEM;YAAU,GAAGN,OAAO;QAAC;QAEjC,IAAI,OAAOC,aAAa,YAAY,OAAOJ,SAASX,SAASY,KAAKC,MAAMC,SAASC;QACjF,OAAO,IAAIO,QAAQ,CAACC,SAASC,SAAWb,SAASX,SAASY,KAAKC,MAAMC,SAAS,CAACG,KAAKQ,SAAYR,MAAMO,OAAOP,OAAOM,QAAQE;IAC9H,EAAE,OAAOR,KAAK;QACZ,IAAIF,UAAUA,SAASE;aAClB,OAAOK,QAAQE,MAAM,CAACP;IAC7B;AACF"}
|
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
import swcPrepareOptions from '../lib/swcPrepareOptions.mjs';
|
|
2
2
|
import Module from 'module';
|
|
3
|
-
import lazy from 'lazy-cache';
|
|
4
3
|
const _require = typeof require === 'undefined' ? Module.createRequire(import.meta.url) : require;
|
|
5
|
-
const swcLazy = lazy(_require)('@swc/core');
|
|
6
4
|
export default function transformSyncWorker(contents, fileName, tsconfig) {
|
|
7
5
|
const swcOptions = swcPrepareOptions(tsconfig);
|
|
8
|
-
const swc =
|
|
6
|
+
const swc = _require('@swc/core');
|
|
9
7
|
return swc.transformSync(contents, {
|
|
10
8
|
...fileName.endsWith('.tsx') || fileName.endsWith('.jsx') ? swcOptions.tsxOptions : swcOptions.nonTsxOptions,
|
|
11
9
|
filename: fileName
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/typescript/ts-swc-transform/src/workers/transformSync.ts"],"sourcesContent":["import swcPrepareOptions from '../lib/swcPrepareOptions';\n\nimport Module from 'module';\
|
|
1
|
+
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/typescript/ts-swc-transform/src/workers/transformSync.ts"],"sourcesContent":["import swcPrepareOptions from '../lib/swcPrepareOptions';\n\nimport Module from 'module';\nconst _require = typeof require === 'undefined' ? Module.createRequire(import.meta.url) : require;\n\nimport type { TsConfigResult } from 'get-tsconfig-compat';\nexport default function transformSyncWorker(contents: string, fileName: string, tsconfig: TsConfigResult) {\n const swcOptions = swcPrepareOptions(tsconfig);\n const swc = _require('@swc/core');\n return swc.transformSync(contents, {\n ...(fileName.endsWith('.tsx') || fileName.endsWith('.jsx') ? swcOptions.tsxOptions : swcOptions.nonTsxOptions),\n filename: fileName,\n });\n}\n"],"names":["swcPrepareOptions","Module","_require","require","createRequire","url","transformSyncWorker","contents","fileName","tsconfig","swcOptions","swc","transformSync","endsWith","tsxOptions","nonTsxOptions","filename"],"mappings":"AAAA,OAAOA,uBAAuB,2BAA2B;AAEzD,OAAOC,YAAY,SAAS;AAC5B,MAAMC,WAAW,OAAOC,YAAY,cAAcF,OAAOG,aAAa,CAAC,YAAYC,GAAG,IAAIF;AAG1F,eAAe,SAASG,oBAAoBC,QAAgB,EAAEC,QAAgB,EAAEC,QAAwB;IACtG,MAAMC,aAAaV,kBAAkBS;IACrC,MAAME,MAAMT,SAAS;IACrB,OAAOS,IAAIC,aAAa,CAACL,UAAU;QACjC,GAAIC,SAASK,QAAQ,CAAC,WAAWL,SAASK,QAAQ,CAAC,UAAUH,WAAWI,UAAU,GAAGJ,WAAWK,aAAa;QAC7GC,UAAUR;IACZ;AACF"}
|
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
import Iterator from 'fs-iterator';
|
|
2
2
|
import rimraf2 from 'rimraf2';
|
|
3
3
|
import Module from 'module';
|
|
4
|
-
import lazy from 'lazy-cache';
|
|
5
4
|
const _require = typeof require === 'undefined' ? Module.createRequire(import.meta.url) : require;
|
|
6
|
-
const tsLazy = lazy(_require)('typescript');
|
|
7
5
|
import { typeFileRegEx } from '../constants.mjs';
|
|
8
6
|
import createMatcher from '../createMatcher.mjs';
|
|
9
7
|
export default function transformTypesWorker(src, dest, options, callback) {
|
|
10
8
|
const tsconfig = options.tsconfig;
|
|
11
9
|
const matcher = createMatcher(tsconfig);
|
|
10
|
+
const ts = _require('typescript');
|
|
12
11
|
rimraf2(dest, {
|
|
13
12
|
disableGlob: true
|
|
14
13
|
}, ()=>{
|
|
@@ -24,7 +23,6 @@ export default function transformTypesWorker(src, dest, options, callback) {
|
|
|
24
23
|
concurrency: Infinity
|
|
25
24
|
}, (err)=>{
|
|
26
25
|
if (err) return callback(err);
|
|
27
|
-
const ts = tsLazy();
|
|
28
26
|
const config = {
|
|
29
27
|
fileNames: entries.map((entry)=>entry.fullPath),
|
|
30
28
|
options: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/typescript/ts-swc-transform/src/workers/transformTypes.ts"],"sourcesContent":["import Iterator from 'fs-iterator';\nimport rimraf2 from 'rimraf2';\n\nimport Module from 'module';\
|
|
1
|
+
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/typescript/ts-swc-transform/src/workers/transformTypes.ts"],"sourcesContent":["import Iterator from 'fs-iterator';\nimport rimraf2 from 'rimraf2';\n\nimport Module from 'module';\nconst _require = typeof require === 'undefined' ? Module.createRequire(import.meta.url) : require;\n\nimport { typeFileRegEx } from '../constants';\nimport createMatcher from '../createMatcher';\n\nexport default function transformTypesWorker(src, dest, options, callback) {\n const tsconfig = options.tsconfig;\n const matcher = createMatcher(tsconfig);\n const ts = _require('typescript');\n\n rimraf2(dest, { disableGlob: true }, () => {\n const entries = [];\n const iterator = new Iterator(src);\n iterator.forEach(\n (entry) => {\n if (!entry.stats.isFile()) return;\n if (entry.basename[0] === '.') return;\n if (typeFileRegEx.test(entry.basename)) return;\n if (!matcher(entry.fullPath)) return;\n entries.push(entry);\n },\n { concurrency: Infinity },\n (err) => {\n if (err) return callback(err);\n\n const config = {\n fileNames: entries.map((entry) => entry.fullPath),\n options: {\n ...(tsconfig.compilerOptions || {}),\n outDir: dest,\n allowJs: true,\n declaration: true,\n emitDeclarationOnly: true,\n listEmittedFiles: true,\n },\n projectReferences: tsconfig.config.references,\n };\n const { fileNames, options, projectReferences } = config;\n const host = ts.createCompilerHostWorker(options, /*setParentNodes*/ undefined, ts.sys);\n const programOptions = {\n rootNames: fileNames,\n options,\n projectReferences,\n host,\n configFileParsingDiagnostics: ts.getConfigFileParsingDiagnostics({ fileNames, options }),\n };\n const program = ts.createProgram(programOptions);\n const res = program.emit();\n callback(null, res.emittedFiles);\n }\n );\n });\n}\n"],"names":["Iterator","rimraf2","Module","_require","require","createRequire","url","typeFileRegEx","createMatcher","transformTypesWorker","src","dest","options","callback","tsconfig","matcher","ts","disableGlob","entries","iterator","forEach","entry","stats","isFile","basename","test","fullPath","push","concurrency","Infinity","err","config","fileNames","map","compilerOptions","outDir","allowJs","declaration","emitDeclarationOnly","listEmittedFiles","projectReferences","references","host","createCompilerHostWorker","undefined","sys","programOptions","rootNames","configFileParsingDiagnostics","getConfigFileParsingDiagnostics","program","createProgram","res","emit","emittedFiles"],"mappings":"AAAA,OAAOA,cAAc,cAAc;AACnC,OAAOC,aAAa,UAAU;AAE9B,OAAOC,YAAY,SAAS;AAC5B,MAAMC,WAAW,OAAOC,YAAY,cAAcF,OAAOG,aAAa,CAAC,YAAYC,GAAG,IAAIF;AAE1F,SAASG,aAAa,QAAQ,eAAe;AAC7C,OAAOC,mBAAmB,mBAAmB;AAE7C,eAAe,SAASC,qBAAqBC,GAAG,EAAEC,IAAI,EAAEC,OAAO,EAAEC,QAAQ;IACvE,MAAMC,WAAWF,QAAQE,QAAQ;IACjC,MAAMC,UAAUP,cAAcM;IAC9B,MAAME,KAAKb,SAAS;IAEpBF,QAAQU,MAAM;QAAEM,aAAa;IAAK,GAAG;QACnC,MAAMC,UAAU,EAAE;QAClB,MAAMC,WAAW,IAAInB,SAASU;QAC9BS,SAASC,OAAO,CACd,CAACC;YACC,IAAI,CAACA,MAAMC,KAAK,CAACC,MAAM,IAAI;YAC3B,IAAIF,MAAMG,QAAQ,CAAC,EAAE,KAAK,KAAK;YAC/B,IAAIjB,cAAckB,IAAI,CAACJ,MAAMG,QAAQ,GAAG;YACxC,IAAI,CAACT,QAAQM,MAAMK,QAAQ,GAAG;YAC9BR,QAAQS,IAAI,CAACN;QACf,GACA;YAAEO,aAAaC;QAAS,GACxB,CAACC;YACC,IAAIA,KAAK,OAAOjB,SAASiB;YAEzB,MAAMC,SAAS;gBACbC,WAAWd,QAAQe,GAAG,CAAC,CAACZ,QAAUA,MAAMK,QAAQ;gBAChDd,SAAS;oBACP,GAAIE,SAASoB,eAAe,IAAI,CAAC,CAAC;oBAClCC,QAAQxB;oBACRyB,SAAS;oBACTC,aAAa;oBACbC,qBAAqB;oBACrBC,kBAAkB;gBACpB;gBACAC,mBAAmB1B,SAASiB,MAAM,CAACU,UAAU;YAC/C;YACA,MAAM,EAAET,SAAS,EAAEpB,OAAO,EAAE4B,iBAAiB,EAAE,GAAGT;YAClD,MAAMW,OAAO1B,GAAG2B,wBAAwB,CAAC/B,SAAS,gBAAgB,GAAGgC,WAAW5B,GAAG6B,GAAG;YACtF,MAAMC,iBAAiB;gBACrBC,WAAWf;gBACXpB;gBACA4B;gBACAE;gBACAM,8BAA8BhC,GAAGiC,+BAA+B,CAAC;oBAAEjB;oBAAWpB;gBAAQ;YACxF;YACA,MAAMsC,UAAUlC,GAAGmC,aAAa,CAACL;YACjC,MAAMM,MAAMF,QAAQG,IAAI;YACxBxC,SAAS,MAAMuC,IAAIE,YAAY;QACjC;IAEJ;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.12",
|
|
4
4
|
"description": "Typescript transformers for swc. Supports Node >= 0.8",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"matcher",
|
|
@@ -48,12 +48,10 @@
|
|
|
48
48
|
"exit": "^0.1.2",
|
|
49
49
|
"fs-iterator": "^5.2.10",
|
|
50
50
|
"get-tsconfig-compat": "^2.0.3",
|
|
51
|
-
"install-module-linked": "^1.1.
|
|
51
|
+
"install-module-linked": "^1.1.10",
|
|
52
52
|
"is-absolute": "^1.0.0",
|
|
53
|
-
"lazy-cache": "^2.0.2",
|
|
54
53
|
"minimatch": "^3.1.2",
|
|
55
54
|
"mkdirp-classic": "^0.5.3",
|
|
56
|
-
"node-version-call": "^1.6.6",
|
|
57
55
|
"path-posix": "^1.0.0",
|
|
58
56
|
"queue-cb": "^1.4.10",
|
|
59
57
|
"resolve": "^1.22.10",
|
|
@@ -70,10 +68,7 @@
|
|
|
70
68
|
"@types/node": "^22.10.5",
|
|
71
69
|
"cr": "^0.1.0",
|
|
72
70
|
"cross-spawn-cb": "^2.1.2",
|
|
73
|
-
"es6-map": "^0.1.5",
|
|
74
|
-
"es6-symbol": "^3.1.4",
|
|
75
71
|
"lodash.difference": "^4.5.0",
|
|
76
|
-
"object-assign": "^4.1.1",
|
|
77
72
|
"pinkie-promise": "^2.0.1",
|
|
78
73
|
"react": "^19.0.0",
|
|
79
74
|
"ts-node": "^10.8.2",
|
|
@@ -1,41 +0,0 @@
|
|
|
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, nodeModules = _findDependency.nodeModules;
|
|
23
|
-
return existsSync(path.join(nodeModules, 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, nodeModules = _findDependency.nodeModules;
|
|
34
|
-
return existsSync(path.join(nodeModules, 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; }
|
|
@@ -1 +0,0 @@
|
|
|
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, nodeModules } = findDependency(identifier, target);\n return existsSync(path.join(nodeModules, 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, nodeModules } = findDependency(identifier, target);\n return existsSync(path.join(nodeModules, 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","nodeModules","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,IAA8BvB,kBAAAA,eAAemB,YAAYC,SAAjDI,OAAsBxB,gBAAtBwB,MAAMC,cAAgBzB,gBAAhByB;YACd,OAAOf,WAAWd,KAAKM,IAAI,CAACuB,aAAaD,SAASD,OAAO1B,QAAQI,YAAYkB,YAAYC,QAAQG;QACnG;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,IAA8BpB,kBAAAA,eAAemB,YAAYC,SAAjDI,OAAsBxB,gBAAtBwB,MAAMC,cAAgBzB,gBAAhByB;YACd,OAAOf,WAAWd,KAAKM,IAAI,CAACuB,aAAaD,SAASJ,SAASvB,QAAQ,qBAAqB;gBAAEY,SAAAA;gBAASmB,WAAW;YAAK,GAAG3B,YAAYkB,YAAYC;QAChJ;IACF;AACF"}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var path = require('path');
|
|
3
|
-
var fs = require('fs');
|
|
4
|
-
var resolve = require('resolve');
|
|
5
|
-
module.exports = function findDependency(identifier, target) {
|
|
6
|
-
var packagePath = resolve.sync("".concat(identifier, "/package.json"));
|
|
7
|
-
var nodeModules = identifier[0] === '@' ? path.join(packagePath, '..', '..', '..') : path.join(packagePath, '..', '..');
|
|
8
|
-
var optionalDependencies = JSON.parse(fs.readFileSync(packagePath, 'utf8')).optionalDependencies;
|
|
9
|
-
var name = Object.keys(optionalDependencies).find(function(name) {
|
|
10
|
-
return name.indexOf(target) >= 0;
|
|
11
|
-
});
|
|
12
|
-
return name ? {
|
|
13
|
-
name: name,
|
|
14
|
-
version: optionalDependencies[name],
|
|
15
|
-
nodeModules: nodeModules
|
|
16
|
-
} : null;
|
|
17
|
-
};
|
|
18
|
-
/* 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/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 nodeModules = identifier[0] === '@' ? path.join(packagePath, '..', '..', '..') : path.join(packagePath, '..', '..');\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], nodeModules } : null;\n};\n"],"names":["path","require","fs","resolve","module","exports","findDependency","identifier","target","packagePath","sync","nodeModules","join","optionalDependencies","JSON","parse","readFileSync","name","Object","keys","find","indexOf","version"],"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,cAAcJ,UAAU,CAAC,EAAE,KAAK,MAAMP,KAAKY,IAAI,CAACH,aAAa,MAAM,MAAM,QAAQT,KAAKY,IAAI,CAACH,aAAa,MAAM;IACpH,IAAMI,uBAAuBC,KAAKC,KAAK,CAACb,GAAGc,YAAY,CAACP,aAAa,SAASI,oBAAoB;IAClG,IAAMI,OAAOC,OAAOC,IAAI,CAACN,sBAAsBO,IAAI,CAAC,SAACH;eAASA,KAAKI,OAAO,CAACb,WAAW;;IACtF,OAAOS,OAAO;QAAEA,MAAAA;QAAMK,SAAST,oBAAoB,CAACI,KAAK;QAAEN,aAAAA;IAAY,IAAI;AAC7E"}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var path = require('path');
|
|
3
|
-
var installModule = require('install-module-linked');
|
|
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, nodeModules = _findDependency.nodeModules;
|
|
7
|
-
var installString = version ? "".concat(name, "@").concat(version) : name;
|
|
8
|
-
installModule(installString, nodeModules, function(err) {
|
|
9
|
-
console.log("installed ".concat(path.join(nodeModules, name)).concat(!err ? '' : ' with errors: ${err.message}'));
|
|
10
|
-
callback(err);
|
|
11
|
-
});
|
|
12
|
-
};
|
|
13
|
-
/* 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/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, nodeModules } = findDependency(identifier, target);\n const installString = version ? `${name}@${version}` : name;\n\n installModule(installString, nodeModules, (err) => {\n console.log(`installed ${path.join(nodeModules, name)}${!err ? '' : ' with errors: ${err.message}'}`);\n callback(err);\n });\n};\n"],"names":["path","require","installModule","findDependency","module","exports","installBindings","identifier","target","callback","name","version","nodeModules","installString","err","console","log","join"],"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,IAAuCN,kBAAAA,eAAeI,YAAYC,SAA1DE,OAA+BP,gBAA/BO,MAAMC,UAAyBR,gBAAzBQ,SAASC,cAAgBT,gBAAhBS;IACvB,IAAMC,gBAAgBF,UAAU,AAAC,GAAUA,OAARD,MAAK,KAAW,OAARC,WAAYD;IAEvDR,cAAcW,eAAeD,aAAa,SAACE;QACzCC,QAAQC,GAAG,CAAC,AAAC,aAA2C,OAA/BhB,KAAKiB,IAAI,CAACL,aAAaF,OAAmD,OAA3C,CAACI,MAAM,KAAK;QACpEL,SAASK;IACX;AACF"}
|
|
@@ -1,39 +0,0 @@
|
|
|
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, nodeModules } = findDependency(identifier, target);
|
|
22
|
-
return existsSync(path.join(nodeModules, 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, nodeModules } = findDependency(identifier, target);
|
|
33
|
-
return existsSync(path.join(nodeModules, name)) ? target : require('node-version-call')({
|
|
34
|
-
version,
|
|
35
|
-
callbacks: true
|
|
36
|
-
}, workerPath, identifier, target);
|
|
37
|
-
})();
|
|
38
|
-
}
|
|
39
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
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, nodeModules } = findDependency(identifier, target);\n return existsSync(path.join(nodeModules, 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, nodeModules } = findDependency(identifier, target);\n return existsSync(path.join(nodeModules, 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","nodeModules","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,KAAK,CAAC,IAAI,CAAC,EAAE;AAClD,MAAMC,UAAUL,QAAQ,KAAK,WAAW;AAExC,MAAMM,aAAa,CAACC;IAClB,IAAI;QACDb,CAAAA,GAAGc,UAAU,IAAId,GAAGe,QAAQ,AAAD,EAAGF;QAC/B,OAAO;IACT,EAAE,OAAOG,GAAG;QACV,OAAO;IACT;AACF;AAEA,MAAMC,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,CAACwB;YAC1C,MAAM,EAAEC,IAAI,EAAEC,WAAW,EAAE,GAAGzB,eAAemB,YAAYC;YACzD,OAAOV,WAAWd,KAAKM,IAAI,CAACuB,aAAaD,SAASD,OAAO1B,QAAQI,YAAYkB,YAAYC,QAAQG;QACnG;IACF;IACAR,QAAQ,CAACI,WAAW,CAACC,OAAO,CAACC;AAC/B;AAEA,MAAMK,eAAe,CAAC;AACtBV,OAAOC,OAAO,CAACU,IAAI,GAAG,CAACR,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,CAAA;YAClC,MAAM,EAAEI,IAAI,EAAEC,WAAW,EAAE,GAAGzB,eAAemB,YAAYC;YACzD,OAAOV,WAAWd,KAAKM,IAAI,CAACuB,aAAaD,SAASJ,SAASvB,QAAQ,qBAAqB;gBAAEY;gBAASmB,WAAW;YAAK,GAAG3B,YAAYkB,YAAYC;QAChJ,CAAA;IACF;AACF"}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
const path = require('path');
|
|
2
|
-
const fs = require('fs');
|
|
3
|
-
const resolve = require('resolve');
|
|
4
|
-
module.exports = function findDependency(identifier, target) {
|
|
5
|
-
const packagePath = resolve.sync(`${identifier}/package.json`);
|
|
6
|
-
const nodeModules = identifier[0] === '@' ? path.join(packagePath, '..', '..', '..') : path.join(packagePath, '..', '..');
|
|
7
|
-
const optionalDependencies = JSON.parse(fs.readFileSync(packagePath, 'utf8')).optionalDependencies;
|
|
8
|
-
const name = Object.keys(optionalDependencies).find((name)=>name.indexOf(target) >= 0);
|
|
9
|
-
return name ? {
|
|
10
|
-
name,
|
|
11
|
-
version: optionalDependencies[name],
|
|
12
|
-
nodeModules
|
|
13
|
-
} : null;
|
|
14
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
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 nodeModules = identifier[0] === '@' ? path.join(packagePath, '..', '..', '..') : path.join(packagePath, '..', '..');\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], nodeModules } : null;\n};\n"],"names":["path","require","fs","resolve","module","exports","findDependency","identifier","target","packagePath","sync","nodeModules","join","optionalDependencies","JSON","parse","readFileSync","name","Object","keys","find","indexOf","version"],"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,cAAcJ,UAAU,CAAC,EAAE,KAAK,MAAMP,KAAKY,IAAI,CAACH,aAAa,MAAM,MAAM,QAAQT,KAAKY,IAAI,CAACH,aAAa,MAAM;IACpH,MAAMI,uBAAuBC,KAAKC,KAAK,CAACb,GAAGc,YAAY,CAACP,aAAa,SAASI,oBAAoB;IAClG,MAAMI,OAAOC,OAAOC,IAAI,CAACN,sBAAsBO,IAAI,CAAC,CAACH,OAASA,KAAKI,OAAO,CAACb,WAAW;IACtF,OAAOS,OAAO;QAAEA;QAAMK,SAAST,oBAAoB,CAACI,KAAK;QAAEN;IAAY,IAAI;AAC7E"}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
const path = require('path');
|
|
2
|
-
const installModule = require('install-module-linked');
|
|
3
|
-
const findDependency = require('./findDependency.cjs');
|
|
4
|
-
module.exports = function installBindings(identifier, target, callback) {
|
|
5
|
-
const { name, version, nodeModules } = findDependency(identifier, target);
|
|
6
|
-
const installString = version ? `${name}@${version}` : name;
|
|
7
|
-
installModule(installString, nodeModules, (err)=>{
|
|
8
|
-
console.log(`installed ${path.join(nodeModules, name)}${!err ? '' : ' with errors: ${err.message}'}`);
|
|
9
|
-
callback(err);
|
|
10
|
-
});
|
|
11
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
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, nodeModules } = findDependency(identifier, target);\n const installString = version ? `${name}@${version}` : name;\n\n installModule(installString, nodeModules, (err) => {\n console.log(`installed ${path.join(nodeModules, name)}${!err ? '' : ' with errors: ${err.message}'}`);\n callback(err);\n });\n};\n"],"names":["path","require","installModule","findDependency","module","exports","installBindings","identifier","target","callback","name","version","nodeModules","installString","err","console","log","join"],"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,WAAW,EAAE,GAAGT,eAAeI,YAAYC;IAClE,MAAMK,gBAAgBF,UAAU,GAAGD,KAAK,CAAC,EAAEC,SAAS,GAAGD;IAEvDR,cAAcW,eAAeD,aAAa,CAACE;QACzCC,QAAQC,GAAG,CAAC,CAAC,UAAU,EAAEhB,KAAKiB,IAAI,CAACL,aAAaF,QAAQ,CAACI,MAAM,KAAK,gCAAgC;QACpGL,SAASK;IACX;AACF"}
|