ts-swc-transform 1.13.13 → 1.14.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/lib/swcPrepareOptions.cjs +2 -2
- package/dist/cjs/lib/swcPrepareOptions.cjs.map +1 -1
- package/dist/esm/lib/swcPrepareOptions.mjs +2 -2
- package/dist/esm/lib/swcPrepareOptions.mjs.map +1 -1
- package/package.json +2 -2
- package/dist/cjs/lib/ensureBindingsSync.cjs +0 -43
- package/dist/cjs/lib/ensureBindingsSync.cjs.map +0 -1
- package/dist/esm/lib/ensureBindingsSync.mjs +0 -25
- package/dist/esm/lib/ensureBindingsSync.mjs.map +0 -1
- package/dist/types/lib/ensureBindingsSync.d.ts +0 -1
|
@@ -9,7 +9,7 @@ Object.defineProperty(exports, "default", {
|
|
|
9
9
|
}
|
|
10
10
|
});
|
|
11
11
|
var _path = /*#__PURE__*/ _interop_require_default(require("path"));
|
|
12
|
-
var
|
|
12
|
+
var _installoptional = require("install-optional");
|
|
13
13
|
var _module = /*#__PURE__*/ _interop_require_default(require("module"));
|
|
14
14
|
function _interop_require_default(obj) {
|
|
15
15
|
return obj && obj.__esModule ? obj : {
|
|
@@ -18,7 +18,7 @@ function _interop_require_default(obj) {
|
|
|
18
18
|
}
|
|
19
19
|
var _require = typeof require === 'undefined' ? _module.default.createRequire(require("url").pathToFileURL(__filename).toString()) : require;
|
|
20
20
|
function swcPrepareOptions(tsconfig) {
|
|
21
|
-
(0,
|
|
21
|
+
(0, _installoptional.installSync)('@swc/core', "".concat(process.platform, "-").concat(process.arch));
|
|
22
22
|
try {
|
|
23
23
|
var ts = _require('typescript');
|
|
24
24
|
var swc = _require('@swc/core');
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/typescript/ts-swc-transform/src/lib/swcPrepareOptions.ts"],"sourcesContent":["import path from 'path';\nimport
|
|
1
|
+
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/typescript/ts-swc-transform/src/lib/swcPrepareOptions.ts"],"sourcesContent":["import path from 'path';\nimport { installSync } from 'install-optional';\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 installSync('@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","installSync","process","platform","arch","ts","swc","transpiler","parsed","parseJsonConfigFileContent","config","sys","path","dirname","createSwcOptions","options","undefined","err","console","log","message"],"mappings":";;;;+BAOA;;;eAAwBA;;;2DAPP;+BACW;6DAET;;;;;;AACnB,IAAMC,WAAW,OAAOC,YAAY,cAAcC,eAAM,CAACC,aAAa,CAAC,uDAAmBF;AAG3E,SAASF,kBAAkBK,QAAwB;IAChEC,IAAAA,4BAAW,EAAC,aAAa,AAAC,GAAsBC,OAApBA,QAAQC,QAAQ,EAAC,KAAgB,OAAbD,QAAQE,IAAI;IAC5D,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"}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import path from 'path';
|
|
2
|
-
import
|
|
2
|
+
import { installSync } from 'install-optional';
|
|
3
3
|
import Module from 'module';
|
|
4
4
|
const _require = typeof require === 'undefined' ? Module.createRequire(import.meta.url) : require;
|
|
5
5
|
export default function swcPrepareOptions(tsconfig) {
|
|
6
|
-
|
|
6
|
+
installSync('@swc/core', `${process.platform}-${process.arch}`);
|
|
7
7
|
try {
|
|
8
8
|
const ts = _require('typescript');
|
|
9
9
|
const swc = _require('@swc/core');
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/typescript/ts-swc-transform/src/lib/swcPrepareOptions.ts"],"sourcesContent":["import path from 'path';\nimport
|
|
1
|
+
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/typescript/ts-swc-transform/src/lib/swcPrepareOptions.ts"],"sourcesContent":["import path from 'path';\nimport { installSync } from 'install-optional';\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 installSync('@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","installSync","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,WAAW,QAAQ,mBAAmB;AAE/C,OAAOC,YAAY,SAAS;AAC5B,MAAMC,WAAW,OAAOC,YAAY,cAAcF,OAAOG,aAAa,CAAC,YAAYC,GAAG,IAAIF;AAG1F,eAAe,SAASG,kBAAkBC,QAAwB;IAChEP,YAAY,aAAa,GAAGQ,QAAQC,QAAQ,CAAC,CAAC,EAAED,QAAQE,IAAI,EAAE;IAC9D,IAAI;QACF,MAAMC,KAAKT,SAAS;QACpB,MAAMU,MAAMV,SAAS;QACrB,MAAMW,aAAaX,SAAS;QAC5B,MAAMY,SAASH,GAAGI,0BAA0B,CAACR,SAASS,MAAM,EAAEL,GAAGM,GAAG,EAAElB,KAAKmB,OAAO,CAACX,SAASR,IAAI;QAChG,OAAOc,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"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ts-swc-transform",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.14.0",
|
|
4
4
|
"description": "Typescript transformers for swc. Supports Node >= 0.8",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"matcher",
|
|
@@ -48,7 +48,7 @@
|
|
|
48
48
|
"exit": "^0.1.2",
|
|
49
49
|
"fs-iterator": "^5.2.10",
|
|
50
50
|
"get-tsconfig-compat": "^2.0.3",
|
|
51
|
-
"install-
|
|
51
|
+
"install-optional": "^0.1.0",
|
|
52
52
|
"is-absolute": "^1.0.0",
|
|
53
53
|
"minimatch": "^3.1.2",
|
|
54
54
|
"mkdirp-classic": "^0.5.3",
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", {
|
|
3
|
-
value: true
|
|
4
|
-
});
|
|
5
|
-
Object.defineProperty(exports, "default", {
|
|
6
|
-
enumerable: true,
|
|
7
|
-
get: function() {
|
|
8
|
-
return ensureBindingsSync;
|
|
9
|
-
}
|
|
10
|
-
});
|
|
11
|
-
var _fs = /*#__PURE__*/ _interop_require_default(require("fs"));
|
|
12
|
-
var _path = /*#__PURE__*/ _interop_require_default(require("path"));
|
|
13
|
-
var _installmodulelinked = require("install-module-linked");
|
|
14
|
-
var _resolve = /*#__PURE__*/ _interop_require_default(require("resolve"));
|
|
15
|
-
function _interop_require_default(obj) {
|
|
16
|
-
return obj && obj.__esModule ? obj : {
|
|
17
|
-
default: obj
|
|
18
|
-
};
|
|
19
|
-
}
|
|
20
|
-
var existsSync = function(test) {
|
|
21
|
-
try {
|
|
22
|
-
(_fs.default.accessSync || _fs.default.statSync)(test);
|
|
23
|
-
return true;
|
|
24
|
-
} catch (_) {
|
|
25
|
-
return false;
|
|
26
|
-
}
|
|
27
|
-
};
|
|
28
|
-
var bindingsSync = {};
|
|
29
|
-
function ensureBindingsSync(identifier, target) {
|
|
30
|
-
if (bindingsSync[identifier] === undefined) bindingsSync[identifier] = {};
|
|
31
|
-
if (bindingsSync[identifier][target] === undefined) {
|
|
32
|
-
bindingsSync[identifier][target] = function() {
|
|
33
|
-
var packagePath = _resolve.default.sync("".concat(identifier, "/package.json"));
|
|
34
|
-
var nodeModules = identifier[0] === '@' ? _path.default.join(packagePath, '..', '..', '..') : _path.default.join(packagePath, '..', '..');
|
|
35
|
-
var optionalDependencies = JSON.parse(_fs.default.readFileSync(packagePath, 'utf8')).optionalDependencies;
|
|
36
|
-
var name = Object.keys(optionalDependencies).find(function(name) {
|
|
37
|
-
return name.indexOf(target) >= 0;
|
|
38
|
-
});
|
|
39
|
-
if (!existsSync(_path.default.join(nodeModules, name))) (0, _installmodulelinked.sync)("".concat(name, "@").concat(optionalDependencies[name]), nodeModules);
|
|
40
|
-
}();
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
/* CJS INTEROP */ if (exports.__esModule && exports.default) { try { Object.defineProperty(exports.default, '__esModule', { value: true }); for (var key in exports) { exports.default[key] = exports[key]; } } catch (_) {}; module.exports = exports.default; }
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/typescript/ts-swc-transform/src/lib/ensureBindingsSync.ts"],"sourcesContent":["import fs from 'fs';\nimport path from 'path';\nimport { sync as installModuleSync } from 'install-module-linked';\nimport resolve from 'resolve';\n\nconst existsSync = (test) => {\n try {\n (fs.accessSync || fs.statSync)(test);\n return true;\n } catch (_) {\n return false;\n }\n};\n\nconst bindingsSync = {};\nexport default function ensureBindingsSync(identifier, target) {\n if (bindingsSync[identifier] === undefined) bindingsSync[identifier] = {};\n if (bindingsSync[identifier][target] === undefined) {\n bindingsSync[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 if (!existsSync(path.join(nodeModules, name))) installModuleSync(`${name}@${optionalDependencies[name]}`, nodeModules);\n })();\n }\n}\n"],"names":["ensureBindingsSync","existsSync","test","fs","accessSync","statSync","_","bindingsSync","identifier","target","undefined","packagePath","resolve","sync","nodeModules","path","join","optionalDependencies","JSON","parse","readFileSync","name","Object","keys","find","indexOf","installModuleSync"],"mappings":";;;;+BAeA;;;eAAwBA;;;yDAfT;2DACE;mCACyB;8DACtB;;;;;;AAEpB,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,IAAMC,eAAe,CAAC;AACP,SAASP,mBAAmBQ,UAAU,EAAEC,MAAM;IAC3D,IAAIF,YAAY,CAACC,WAAW,KAAKE,WAAWH,YAAY,CAACC,WAAW,GAAG,CAAC;IACxE,IAAID,YAAY,CAACC,WAAW,CAACC,OAAO,KAAKC,WAAW;QAClDH,YAAY,CAACC,WAAW,CAACC,OAAO,GAAG,AAAC;YAClC,IAAME,cAAcC,gBAAO,CAACC,IAAI,CAAC,AAAC,GAAa,OAAXL,YAAW;YAC/C,IAAMM,cAAcN,UAAU,CAAC,EAAE,KAAK,MAAMO,aAAI,CAACC,IAAI,CAACL,aAAa,MAAM,MAAM,QAAQI,aAAI,CAACC,IAAI,CAACL,aAAa,MAAM;YACpH,IAAMM,uBAAuBC,KAAKC,KAAK,CAAChB,WAAE,CAACiB,YAAY,CAACT,aAAa,SAASM,oBAAoB;YAClG,IAAMI,OAAOC,OAAOC,IAAI,CAACN,sBAAsBO,IAAI,CAAC,SAACH;uBAASA,KAAKI,OAAO,CAAChB,WAAW;;YACtF,IAAI,CAACR,WAAWc,aAAI,CAACC,IAAI,CAACF,aAAaO,QAAQK,IAAAA,yBAAiB,EAAC,AAAC,GAAUT,OAARI,MAAK,KAA8B,OAA3BJ,oBAAoB,CAACI,KAAK,GAAIP;QAC5G;IACF;AACF"}
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import fs from 'fs';
|
|
2
|
-
import path from 'path';
|
|
3
|
-
import { sync as installModuleSync } from 'install-module-linked';
|
|
4
|
-
import resolve from 'resolve';
|
|
5
|
-
const existsSync = (test)=>{
|
|
6
|
-
try {
|
|
7
|
-
(fs.accessSync || fs.statSync)(test);
|
|
8
|
-
return true;
|
|
9
|
-
} catch (_) {
|
|
10
|
-
return false;
|
|
11
|
-
}
|
|
12
|
-
};
|
|
13
|
-
const bindingsSync = {};
|
|
14
|
-
export default function ensureBindingsSync(identifier, target) {
|
|
15
|
-
if (bindingsSync[identifier] === undefined) bindingsSync[identifier] = {};
|
|
16
|
-
if (bindingsSync[identifier][target] === undefined) {
|
|
17
|
-
bindingsSync[identifier][target] = (()=>{
|
|
18
|
-
const packagePath = resolve.sync(`${identifier}/package.json`);
|
|
19
|
-
const nodeModules = identifier[0] === '@' ? path.join(packagePath, '..', '..', '..') : path.join(packagePath, '..', '..');
|
|
20
|
-
const optionalDependencies = JSON.parse(fs.readFileSync(packagePath, 'utf8')).optionalDependencies;
|
|
21
|
-
const name = Object.keys(optionalDependencies).find((name)=>name.indexOf(target) >= 0);
|
|
22
|
-
if (!existsSync(path.join(nodeModules, name))) installModuleSync(`${name}@${optionalDependencies[name]}`, nodeModules);
|
|
23
|
-
})();
|
|
24
|
-
}
|
|
25
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/typescript/ts-swc-transform/src/lib/ensureBindingsSync.ts"],"sourcesContent":["import fs from 'fs';\nimport path from 'path';\nimport { sync as installModuleSync } from 'install-module-linked';\nimport resolve from 'resolve';\n\nconst existsSync = (test) => {\n try {\n (fs.accessSync || fs.statSync)(test);\n return true;\n } catch (_) {\n return false;\n }\n};\n\nconst bindingsSync = {};\nexport default function ensureBindingsSync(identifier, target) {\n if (bindingsSync[identifier] === undefined) bindingsSync[identifier] = {};\n if (bindingsSync[identifier][target] === undefined) {\n bindingsSync[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 if (!existsSync(path.join(nodeModules, name))) installModuleSync(`${name}@${optionalDependencies[name]}`, nodeModules);\n })();\n }\n}\n"],"names":["fs","path","sync","installModuleSync","resolve","existsSync","test","accessSync","statSync","_","bindingsSync","ensureBindingsSync","identifier","target","undefined","packagePath","nodeModules","join","optionalDependencies","JSON","parse","readFileSync","name","Object","keys","find","indexOf"],"mappings":"AAAA,OAAOA,QAAQ,KAAK;AACpB,OAAOC,UAAU,OAAO;AACxB,SAASC,QAAQC,iBAAiB,QAAQ,wBAAwB;AAClE,OAAOC,aAAa,UAAU;AAE9B,MAAMC,aAAa,CAACC;IAClB,IAAI;QACDN,CAAAA,GAAGO,UAAU,IAAIP,GAAGQ,QAAQ,AAAD,EAAGF;QAC/B,OAAO;IACT,EAAE,OAAOG,GAAG;QACV,OAAO;IACT;AACF;AAEA,MAAMC,eAAe,CAAC;AACtB,eAAe,SAASC,mBAAmBC,UAAU,EAAEC,MAAM;IAC3D,IAAIH,YAAY,CAACE,WAAW,KAAKE,WAAWJ,YAAY,CAACE,WAAW,GAAG,CAAC;IACxE,IAAIF,YAAY,CAACE,WAAW,CAACC,OAAO,KAAKC,WAAW;QAClDJ,YAAY,CAACE,WAAW,CAACC,OAAO,GAAG,AAAC,CAAA;YAClC,MAAME,cAAcX,QAAQF,IAAI,CAAC,GAAGU,WAAW,aAAa,CAAC;YAC7D,MAAMI,cAAcJ,UAAU,CAAC,EAAE,KAAK,MAAMX,KAAKgB,IAAI,CAACF,aAAa,MAAM,MAAM,QAAQd,KAAKgB,IAAI,CAACF,aAAa,MAAM;YACpH,MAAMG,uBAAuBC,KAAKC,KAAK,CAACpB,GAAGqB,YAAY,CAACN,aAAa,SAASG,oBAAoB;YAClG,MAAMI,OAAOC,OAAOC,IAAI,CAACN,sBAAsBO,IAAI,CAAC,CAACH,OAASA,KAAKI,OAAO,CAACb,WAAW;YACtF,IAAI,CAACR,WAAWJ,KAAKgB,IAAI,CAACD,aAAaM,QAAQnB,kBAAkB,GAAGmB,KAAK,CAAC,EAAEJ,oBAAoB,CAACI,KAAK,EAAE,EAAEN;QAC5G,CAAA;IACF;AACF"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export default function ensureBindingsSync(identifier: any, target: any): void;
|