ts-swc-transform 1.11.5 → 1.11.6

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.
@@ -0,0 +1,43 @@
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 _default;
14
+ },
15
+ sync: function() {
16
+ return sync;
17
+ }
18
+ });
19
+ var _installBindings = /*#__PURE__*/ _interop_require_default(require("../workers/installBindings.cjs"));
20
+ var _path = /*#__PURE__*/ _interop_require_default(require("path"));
21
+ var _url = /*#__PURE__*/ _interop_require_default(require("url"));
22
+ var _module = /*#__PURE__*/ _interop_require_default(require("module"));
23
+ var _lazycache = /*#__PURE__*/ _interop_require_default(require("lazy-cache"));
24
+ var _lodashmemoize = /*#__PURE__*/ _interop_require_default(require("lodash.memoize"));
25
+ function _interop_require_default(obj) {
26
+ return obj && obj.__esModule ? obj : {
27
+ default: obj
28
+ };
29
+ }
30
+ var _default = _installBindings.default;
31
+ var _require = typeof require === 'undefined' ? _module.default.createRequire(require("url").pathToFileURL(__filename).toString()) : require;
32
+ var __dirname = _path.default.dirname(typeof __filename === 'undefined' ? _url.default.fileURLToPath(require("url").pathToFileURL(__filename).toString()) : __filename);
33
+ var workerPath = _path.default.resolve(__dirname, '..', '..', 'cjs', 'workers', 'installBindings.cjs');
34
+ var major = +process.versions.node.split('.')[0];
35
+ var version = major < 14 ? 'stable' : 'local';
36
+ var call = (0, _lazycache.default)(_require)('node-version-call');
37
+ var sync = (0, _lodashmemoize.default)(function() {
38
+ return call()({
39
+ version: version,
40
+ callbacks: true
41
+ }, workerPath);
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; }
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["/Users/kevin/Dev/OpenSource/typescript/ts-swc-transform/src/lib/installBindings.ts"],"sourcesContent":["import installBindings from '../workers/installBindings';\nexport default installBindings;\n\nimport path from 'path';\nimport url from 'url';\n\nimport Module from 'module';\nimport lazy from 'lazy-cache';\nconst _require = typeof require === 'undefined' ? Module.createRequire(import.meta.url) : require;\nconst __dirname = path.dirname(typeof __filename === 'undefined' ? url.fileURLToPath(import.meta.url) : __filename);\nconst workerPath = path.resolve(__dirname, '..', '..', 'cjs', 'workers', 'installBindings.cjs');\nconst major = +process.versions.node.split('.')[0];\nconst version = major < 14 ? 'stable' : 'local';\n\nconst call = lazy(_require)('node-version-call');\nimport memoize from 'lodash.memoize';\nexport const sync = memoize(() => call()({ version, callbacks: true }, workerPath));\n"],"names":["sync","installBindings","_require","require","Module","createRequire","__dirname","path","dirname","__filename","url","fileURLToPath","workerPath","resolve","major","process","versions","node","split","version","call","lazy","memoize","callbacks"],"mappings":";;;;;;;;;;;IACA,OAA+B;eAA/B;;IAeaA,IAAI;eAAJA;;;sEAhBe;2DAGX;0DACD;6DAEG;gEACF;oEAQG;;;;;;IAdpB,WAAeC,wBAAe;AAO9B,IAAMC,WAAW,OAAOC,YAAY,cAAcC,eAAM,CAACC,aAAa,CAAC,uDAAmBF;AAC1F,IAAMG,YAAYC,aAAI,CAACC,OAAO,CAAC,OAAOC,eAAe,cAAcC,YAAG,CAACC,aAAa,CAAC,uDAAmBF;AACxG,IAAMG,aAAaL,aAAI,CAACM,OAAO,CAACP,WAAW,MAAM,MAAM,OAAO,WAAW;AACzE,IAAMQ,QAAQ,CAACC,QAAQC,QAAQ,CAACC,IAAI,CAACC,KAAK,CAAC,IAAI,CAAC,EAAE;AAClD,IAAMC,UAAUL,QAAQ,KAAK,WAAW;AAExC,IAAMM,OAAOC,IAAAA,kBAAI,EAACnB,UAAU;AAErB,IAAMF,OAAOsB,IAAAA,sBAAO,EAAC;WAAMF,OAAO;QAAED,SAAAA;QAASI,WAAW;IAAK,GAAGX"}
@@ -50,10 +50,7 @@ function wrapWorkerSync(workerPath) {
50
50
  }
51
51
  if (version === 'local') return workerLazy().apply(null, args);
52
52
  return call().apply(this, [
53
- {
54
- version: version,
55
- callbacks: true
56
- },
53
+ version,
57
54
  workerPath
58
55
  ].concat(_to_consumable_array(args)));
59
56
  };
@@ -1 +1 @@
1
- {"version":3,"sources":["/Users/kevin/Dev/OpenSource/typescript/ts-swc-transform/src/lib/wrapWorkerSync.ts"],"sourcesContent":["import Module from 'module';\nimport lazy from 'lazy-cache';\nconst _require = typeof require === 'undefined' ? Module.createRequire(import.meta.url) : require;\nconst call = lazy(_require)('node-version-call');\n\nexport default function wrapWorkerSync(workerPath: string) {\n const workerLazy = lazy(_require)(workerPath);\n\n return function workerWrapperSync(version, ...args) {\n if (version === 'local') return workerLazy().apply(null, args);\n return call()({ version, callbacks: true }, workerPath, ...args);\n };\n}\n"],"names":["wrapWorkerSync","_require","require","Module","createRequire","call","lazy","workerPath","workerLazy","workerWrapperSync","version","args","apply","callbacks"],"mappings":";;;;+BAKA;;;eAAwBA;;;6DALL;gEACF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACjB,IAAMC,WAAW,OAAOC,YAAY,cAAcC,eAAM,CAACC,aAAa,CAAC,uDAAmBF;AAC1F,IAAMG,OAAOC,IAAAA,kBAAI,EAACL,UAAU;AAEb,SAASD,eAAeO,UAAkB;IACvD,IAAMC,aAAaF,IAAAA,kBAAI,EAACL,UAAUM;IAElC,OAAO,SAASE,kBAAkBC,OAAO;QAAE,IAAA,IAAA,OAAA,UAAA,QAAA,AAAGC,OAAH,UAAA,OAAA,IAAA,OAAA,QAAA,OAAA,GAAA,OAAA,MAAA;YAAGA,KAAH,OAAA,KAAA,SAAA,CAAA,KAAO;;QAChD,IAAID,YAAY,SAAS,OAAOF,aAAaI,KAAK,CAAC,MAAMD;QACzD,OAAON,aAAAA,IAAM,EAANA;YAAO;gBAAEK,SAAAA;gBAASG,WAAW;YAAK;YAAGN;SAAoB,CAAzDF,OAAiD,qBAAGM;IAC7D;AACF"}
1
+ {"version":3,"sources":["/Users/kevin/Dev/OpenSource/typescript/ts-swc-transform/src/lib/wrapWorkerSync.ts"],"sourcesContent":["import Module from 'module';\nimport lazy from 'lazy-cache';\nconst _require = typeof require === 'undefined' ? Module.createRequire(import.meta.url) : require;\nconst call = lazy(_require)('node-version-call');\n\nexport default function wrapWorkerSync(workerPath: string) {\n const workerLazy = lazy(_require)(workerPath);\n\n return function workerWrapperSync(version, ...args) {\n if (version === 'local') return workerLazy().apply(null, args);\n return call()(version, workerPath, ...args);\n };\n}\n"],"names":["wrapWorkerSync","_require","require","Module","createRequire","call","lazy","workerPath","workerLazy","workerWrapperSync","version","args","apply"],"mappings":";;;;+BAKA;;;eAAwBA;;;6DALL;gEACF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACjB,IAAMC,WAAW,OAAOC,YAAY,cAAcC,eAAM,CAACC,aAAa,CAAC,uDAAmBF;AAC1F,IAAMG,OAAOC,IAAAA,kBAAI,EAACL,UAAU;AAEb,SAASD,eAAeO,UAAkB;IACvD,IAAMC,aAAaF,IAAAA,kBAAI,EAACL,UAAUM;IAElC,OAAO,SAASE,kBAAkBC,OAAO;QAAE,IAAA,IAAA,OAAA,UAAA,QAAA,AAAGC,OAAH,UAAA,OAAA,IAAA,OAAA,QAAA,OAAA,GAAA,OAAA,MAAA;YAAGA,KAAH,OAAA,KAAA,SAAA,CAAA,KAAO;;QAChD,IAAID,YAAY,SAAS,OAAOF,aAAaI,KAAK,CAAC,MAAMD;QACzD,OAAON,aAAAA,IAAM,EAANA;YAAOK;YAASH;SAAoB,CAApCF,OAA4B,qBAAGM;IACxC;AACF"}
@@ -65,10 +65,12 @@ function _interop_require_wildcard(obj, nodeInterop) {
65
65
  }
66
66
  var __dirname = _path.default.dirname(typeof __filename === 'undefined' ? _url.default.fileURLToPath(require("url").pathToFileURL(__filename).toString()) : __filename);
67
67
  var workerWrapper = (0, _wrapWorkerSync.default)(_path.default.resolve(__dirname, '..', 'cjs', 'workers', 'transformSync.cjs'));
68
+ var major = +process.versions.node.split('.')[0];
69
+ var version = major < 14 ? 'stable' : 'local';
68
70
  function transformSync(contents, fileName, tsconfig) {
69
71
  if (typeof contents !== 'string') throw new Error('transformTypes: unexpected contents');
70
72
  if (typeof fileName !== 'string') throw new Error('transformTypes: unexpected fileName');
71
73
  if (!tsconfig) tsconfig = _gettsconfigcompat.getTsconfig(process.cwd());
72
- return workerWrapper('stable', contents, fileName, tsconfig);
74
+ return workerWrapper(version, contents, fileName, tsconfig);
73
75
  }
74
76
  /* CJS INTEROP */ if (exports.__esModule && exports.default) { try { Object.defineProperty(exports.default, '__esModule', { value: true }); for (var key in exports) { exports.default[key] = exports[key]; } } catch (_) {}; module.exports = exports.default; }
@@ -1 +1 @@
1
- {"version":3,"sources":["/Users/kevin/Dev/OpenSource/typescript/ts-swc-transform/src/transformSync.ts"],"sourcesContent":["import path from 'path';\nimport url from 'url';\nimport * as getTS from 'get-tsconfig-compat';\n\nimport wrapWorkerSync from './lib/wrapWorkerSync';\nconst __dirname = path.dirname(typeof __filename === 'undefined' ? url.fileURLToPath(import.meta.url) : __filename);\nconst workerWrapper = wrapWorkerSync(path.resolve(__dirname, '..', 'cjs', 'workers', 'transformSync.cjs'));\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 workerWrapper('stable', contents, fileName, tsconfig);\n}\n"],"names":["transformSync","__dirname","path","dirname","__filename","url","fileURLToPath","workerWrapper","wrapWorkerSync","resolve","contents","fileName","tsconfig","Error","getTS","getTsconfig","process","cwd"],"mappings":";;;;+BAUA;;;;;CAKC,GACD;;;eAAwBA;;;2DAhBP;0DACD;yEACO;qEAEI;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAC3B,IAAMC,YAAYC,aAAI,CAACC,OAAO,CAAC,OAAOC,eAAe,cAAcC,YAAG,CAACC,aAAa,CAAC,uDAAmBF;AACxG,IAAMG,gBAAgBC,IAAAA,uBAAc,EAACN,aAAI,CAACO,OAAO,CAACR,WAAW,MAAM,OAAO,WAAW;AAUtE,SAASD,cAAcU,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,CAACC,QAAQC,GAAG;IACvD,OAAOV,cAAc,UAAUG,UAAUC,UAAUC;AACrD"}
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\nimport wrapWorkerSync from './lib/wrapWorkerSync';\nconst __dirname = path.dirname(typeof __filename === 'undefined' ? url.fileURLToPath(import.meta.url) : __filename);\nconst workerWrapper = wrapWorkerSync(path.resolve(__dirname, '..', 'cjs', 'workers', 'transformSync.cjs'));\nconst major = +process.versions.node.split('.')[0];\nconst version = major < 14 ? 'stable' : 'local';\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 workerWrapper(version, contents, fileName, tsconfig);\n}\n"],"names":["transformSync","__dirname","path","dirname","__filename","url","fileURLToPath","workerWrapper","wrapWorkerSync","resolve","major","process","versions","node","split","version","contents","fileName","tsconfig","Error","getTS","getTsconfig","cwd"],"mappings":";;;;+BAYA;;;;;CAKC,GACD;;;eAAwBA;;;2DAlBP;0DACD;yEACO;qEAEI;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAC3B,IAAMC,YAAYC,aAAI,CAACC,OAAO,CAAC,OAAOC,eAAe,cAAcC,YAAG,CAACC,aAAa,CAAC,uDAAmBF;AACxG,IAAMG,gBAAgBC,IAAAA,uBAAc,EAACN,aAAI,CAACO,OAAO,CAACR,WAAW,MAAM,OAAO,WAAW;AACrF,IAAMS,QAAQ,CAACC,QAAQC,QAAQ,CAACC,IAAI,CAACC,KAAK,CAAC,IAAI,CAAC,EAAE;AAClD,IAAMC,UAAUL,QAAQ,KAAK,WAAW;AAUzB,SAASV,cAAcgB,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,CAACV,QAAQW,GAAG;IACvD,OAAOf,cAAcQ,SAASC,UAAUC,UAAUC;AACpD"}
@@ -0,0 +1,43 @@
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 _default;
9
+ }
10
+ });
11
+ var _fs = /*#__PURE__*/ _interop_require_default(require("fs"));
12
+ var _path = /*#__PURE__*/ _interop_require_default(require("path"));
13
+ var _installmodulelinked = /*#__PURE__*/ _interop_require_default(require("install-module-linked"));
14
+ var _queuecb = /*#__PURE__*/ _interop_require_default(require("queue-cb"));
15
+ var _resolve = /*#__PURE__*/ _interop_require_default(require("resolve"));
16
+ var _resolveoncecb = /*#__PURE__*/ _interop_require_default(require("resolve-once-cb"));
17
+ function _interop_require_default(obj) {
18
+ return obj && obj.__esModule ? obj : {
19
+ default: obj
20
+ };
21
+ }
22
+ var _default = (0, _resolveoncecb.default)(function installBindings(callback) {
23
+ var packagePath = _resolve.default.sync('@swc/core/package.json');
24
+ var nodeModules = _path.default.dirname(_path.default.dirname(_path.default.dirname(packagePath)));
25
+ var optionalDependencies = JSON.parse(_fs.default.readFileSync(packagePath, 'utf8')).optionalDependencies;
26
+ var depKey = "".concat(process.platform, "-");
27
+ var queue = new _queuecb.default();
28
+ Object.keys(optionalDependencies).filter(function(name) {
29
+ return name.indexOf(depKey) >= 0;
30
+ }).map(function(name) {
31
+ queue.defer(function(callback) {
32
+ var version = optionalDependencies[name];
33
+ var installString = version ? "".concat(name, "@").concat(version) : name;
34
+ (0, _installmodulelinked.default)(installString, nodeModules, function(err) {
35
+ if (err) return callback(err);
36
+ console.log("installed ".concat(_path.default.join(nodeModules, name)));
37
+ callback();
38
+ });
39
+ });
40
+ });
41
+ queue.await(callback);
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; }
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["/Users/kevin/Dev/OpenSource/typescript/ts-swc-transform/src/workers/installBindings.ts"],"sourcesContent":["import fs from 'fs';\nimport path from 'path';\nimport installModule from 'install-module-linked';\nimport Queue from 'queue-cb';\nimport resolve from 'resolve';\nimport resolveOnce from 'resolve-once-cb';\n\nexport default resolveOnce(function installBindings(callback) {\n const packagePath = resolve.sync('@swc/core/package.json');\n const nodeModules = path.dirname(path.dirname(path.dirname(packagePath)));\n const optionalDependencies = JSON.parse(fs.readFileSync(packagePath, 'utf8')).optionalDependencies;\n const depKey = `${process.platform}-`;\n\n const queue = new Queue();\n Object.keys(optionalDependencies)\n .filter((name) => name.indexOf(depKey) >= 0)\n .map((name) => {\n queue.defer((callback) => {\n const version = optionalDependencies[name];\n const installString = version ? `${name}@${version}` : name;\n installModule(installString, nodeModules, (err) => {\n if (err) return callback(err);\n console.log(`installed ${path.join(nodeModules, name)}`);\n callback();\n });\n });\n });\n queue.await(callback);\n});\n"],"names":["resolveOnce","installBindings","callback","packagePath","resolve","sync","nodeModules","path","dirname","optionalDependencies","JSON","parse","fs","readFileSync","depKey","process","platform","queue","Queue","Object","keys","filter","name","indexOf","map","defer","version","installString","installModule","err","console","log","join","await"],"mappings":";;;;+BAOA;;;eAAA;;;yDAPe;2DACE;0EACS;8DACR;8DACE;oEACI;;;;;;IAExB,WAAeA,IAAAA,sBAAW,EAAC,SAASC,gBAAgBC,QAAQ;IAC1D,IAAMC,cAAcC,gBAAO,CAACC,IAAI,CAAC;IACjC,IAAMC,cAAcC,aAAI,CAACC,OAAO,CAACD,aAAI,CAACC,OAAO,CAACD,aAAI,CAACC,OAAO,CAACL;IAC3D,IAAMM,uBAAuBC,KAAKC,KAAK,CAACC,WAAE,CAACC,YAAY,CAACV,aAAa,SAASM,oBAAoB;IAClG,IAAMK,SAAS,AAAC,GAAmB,OAAjBC,QAAQC,QAAQ,EAAC;IAEnC,IAAMC,QAAQ,IAAIC,gBAAK;IACvBC,OAAOC,IAAI,CAACX,sBACTY,MAAM,CAAC,SAACC;eAASA,KAAKC,OAAO,CAACT,WAAW;OACzCU,GAAG,CAAC,SAACF;QACJL,MAAMQ,KAAK,CAAC,SAACvB;YACX,IAAMwB,UAAUjB,oBAAoB,CAACa,KAAK;YAC1C,IAAMK,gBAAgBD,UAAU,AAAC,GAAUA,OAARJ,MAAK,KAAW,OAARI,WAAYJ;YACvDM,IAAAA,4BAAa,EAACD,eAAerB,aAAa,SAACuB;gBACzC,IAAIA,KAAK,OAAO3B,SAAS2B;gBACzBC,QAAQC,GAAG,CAAC,AAAC,aAAyC,OAA7BxB,aAAI,CAACyB,IAAI,CAAC1B,aAAagB;gBAChDpB;YACF;QACF;IACF;IACFe,MAAMgB,KAAK,CAAC/B;AACd"}
@@ -13,6 +13,7 @@ var _queuecb = /*#__PURE__*/ _interop_require_default(require("queue-cb"));
13
13
  var _rimraf2 = /*#__PURE__*/ _interop_require_default(require("rimraf2"));
14
14
  var _constants = require("../constants.cjs");
15
15
  var _createMatcher = /*#__PURE__*/ _interop_require_default(require("../createMatcher.cjs"));
16
+ var _installBindings = /*#__PURE__*/ _interop_require_default(require("../lib/installBindings.cjs"));
16
17
  var _transformFile = /*#__PURE__*/ _interop_require_default(require("../lib/transformFile.cjs"));
17
18
  function _define_property(obj, key, value) {
18
19
  if (key in obj) {
@@ -74,38 +75,41 @@ function _object_spread_props(target, source) {
74
75
  function transformDirectoryWorker(src, dest, type, options, callback) {
75
76
  var tsconfig = options.tsconfig;
76
77
  var matcher = (0, _createMatcher.default)(tsconfig);
77
- (0, _rimraf2.default)(dest, {
78
- disableGlob: true
79
- }, function() {
80
- var entries = [];
81
- var iterator = new _fsiterator.default(src);
82
- iterator.forEach(function(entry) {
83
- if (!entry.stats.isFile()) return;
84
- if (!matcher(entry.fullPath)) return;
85
- if (_constants.typeFileRegEx.test(entry.basename)) return;
86
- if (_constants.SKIPS.indexOf(entry.basename) >= 0) return;
87
- entries.push(entry);
88
- }, function(err) {
89
- if (err) return callback(err);
90
- var results = [];
91
- options = _object_spread_props(_object_spread({}, options), {
92
- tsconfig: tsconfig,
93
- src: src,
94
- dest: dest
95
- });
96
- var queue = new _queuecb.default();
97
- entries.forEach(function(entry) {
98
- queue.defer(function(cb) {
99
- return (0, _transformFile.default)(entry, dest, type, options, function(err, outPath) {
100
- if (err) return cb(err);
101
- results.push(outPath);
102
- if (options.sourceMaps) results.push("".concat(outPath, ".map"));
103
- cb();
78
+ (0, _installBindings.default)(function(err) {
79
+ if (err) return callback(err);
80
+ (0, _rimraf2.default)(dest, {
81
+ disableGlob: true
82
+ }, function() {
83
+ var entries = [];
84
+ var iterator = new _fsiterator.default(src);
85
+ iterator.forEach(function(entry) {
86
+ if (!entry.stats.isFile()) return;
87
+ if (!matcher(entry.fullPath)) return;
88
+ if (_constants.typeFileRegEx.test(entry.basename)) return;
89
+ if (_constants.SKIPS.indexOf(entry.basename) >= 0) return;
90
+ entries.push(entry);
91
+ }, function(err) {
92
+ if (err) return callback(err);
93
+ var results = [];
94
+ options = _object_spread_props(_object_spread({}, options), {
95
+ tsconfig: tsconfig,
96
+ src: src,
97
+ dest: dest
98
+ });
99
+ var queue = new _queuecb.default();
100
+ entries.forEach(function(entry) {
101
+ queue.defer(function(cb) {
102
+ return (0, _transformFile.default)(entry, dest, type, options, function(err, outPath) {
103
+ if (err) return cb(err);
104
+ results.push(outPath);
105
+ if (options.sourceMaps) results.push("".concat(outPath, ".map"));
106
+ cb();
107
+ });
104
108
  });
105
109
  });
106
- });
107
- queue.await(function(err) {
108
- return err ? callback(err) : callback(null, results);
110
+ queue.await(function(err) {
111
+ return err ? callback(err) : callback(null, results);
112
+ });
109
113
  });
110
114
  });
111
115
  });
@@ -1 +1 @@
1
- {"version":3,"sources":["/Users/kevin/Dev/OpenSource/typescript/ts-swc-transform/src/workers/transformDirectory.ts"],"sourcesContent":["import path from 'path';\nimport Iterator from 'fs-iterator';\nimport Queue from 'queue-cb';\nimport rimraf2 from 'rimraf2';\n\nimport { SKIPS, typeFileRegEx } from '../constants';\nimport createMatcher from '../createMatcher';\nimport transformFile from '../lib/transformFile';\n\nexport default function transformDirectoryWorker(src, dest, type, options, callback) {\n const tsconfig = options.tsconfig;\n const matcher = createMatcher(tsconfig);\n\n rimraf2(dest, { disableGlob: true }, () => {\n const entries = [];\n const iterator = new Iterator(src);\n iterator.forEach(\n (entry) => {\n if (!entry.stats.isFile()) return;\n if (!matcher(entry.fullPath)) return;\n if (typeFileRegEx.test(entry.basename)) return;\n if (SKIPS.indexOf(entry.basename) >= 0) return;\n entries.push(entry);\n },\n (err) => {\n if (err) return callback(err);\n const results = [];\n options = { ...options, tsconfig, src, dest };\n\n const queue = new Queue();\n entries.forEach((entry) => {\n queue.defer((cb) =>\n transformFile(entry, dest, type, options, (err, outPath) => {\n if (err) return cb(err);\n results.push(outPath);\n if (options.sourceMaps) results.push(`${outPath}.map`);\n cb();\n })\n );\n });\n queue.await((err) => (err ? callback(err) : callback(null, results)));\n }\n );\n });\n}\n"],"names":["transformDirectoryWorker","src","dest","type","options","callback","tsconfig","matcher","createMatcher","rimraf2","disableGlob","entries","iterator","Iterator","forEach","entry","stats","isFile","fullPath","typeFileRegEx","test","basename","SKIPS","indexOf","push","err","results","queue","Queue","defer","cb","transformFile","outPath","sourceMaps","await"],"mappings":";;;;+BASA;;;eAAwBA;;;iEARH;8DACH;8DACE;yBAEiB;oEACX;oEACA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEX,SAASA,yBAAyBC,GAAG,EAAEC,IAAI,EAAEC,IAAI,EAAEC,OAAO,EAAEC,QAAQ;IACjF,IAAMC,WAAWF,QAAQE,QAAQ;IACjC,IAAMC,UAAUC,IAAAA,sBAAa,EAACF;IAE9BG,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,IAAI,CAACV,QAAQQ,MAAMG,QAAQ,GAAG;YAC9B,IAAIC,wBAAa,CAACC,IAAI,CAACL,MAAMM,QAAQ,GAAG;YACxC,IAAIC,gBAAK,CAACC,OAAO,CAACR,MAAMM,QAAQ,KAAK,GAAG;YACxCV,QAAQa,IAAI,CAACT;QACf,GACA,SAACU;YACC,IAAIA,KAAK,OAAOpB,SAASoB;YACzB,IAAMC,UAAU,EAAE;YAClBtB,UAAU,wCAAKA;gBAASE,UAAAA;gBAAUL,KAAAA;gBAAKC,MAAAA;;YAEvC,IAAMyB,QAAQ,IAAIC,gBAAK;YACvBjB,QAAQG,OAAO,CAAC,SAACC;gBACfY,MAAME,KAAK,CAAC,SAACC;2BACXC,IAAAA,sBAAa,EAAChB,OAAOb,MAAMC,MAAMC,SAAS,SAACqB,KAAKO;wBAC9C,IAAIP,KAAK,OAAOK,GAAGL;wBACnBC,QAAQF,IAAI,CAACQ;wBACb,IAAI5B,QAAQ6B,UAAU,EAAEP,QAAQF,IAAI,CAAC,AAAC,GAAU,OAARQ,SAAQ;wBAChDF;oBACF;;YAEJ;YACAH,MAAMO,KAAK,CAAC,SAACT;uBAASA,MAAMpB,SAASoB,OAAOpB,SAAS,MAAMqB;;QAC7D;IAEJ;AACF"}
1
+ {"version":3,"sources":["/Users/kevin/Dev/OpenSource/typescript/ts-swc-transform/src/workers/transformDirectory.ts"],"sourcesContent":["import Iterator from 'fs-iterator';\nimport Queue from 'queue-cb';\nimport rimraf2 from 'rimraf2';\n\nimport { SKIPS, typeFileRegEx } from '../constants';\nimport createMatcher from '../createMatcher';\nimport installBindings from '../lib/installBindings';\nimport transformFile from '../lib/transformFile';\n\nexport default function transformDirectoryWorker(src, dest, type, options, callback) {\n const tsconfig = options.tsconfig;\n const matcher = createMatcher(tsconfig);\n\n installBindings((err) => {\n if (err) return callback(err);\n\n rimraf2(dest, { disableGlob: true }, () => {\n const entries = [];\n const iterator = new Iterator(src);\n iterator.forEach(\n (entry) => {\n if (!entry.stats.isFile()) return;\n if (!matcher(entry.fullPath)) return;\n if (typeFileRegEx.test(entry.basename)) return;\n if (SKIPS.indexOf(entry.basename) >= 0) return;\n entries.push(entry);\n },\n (err) => {\n if (err) return callback(err);\n const results = [];\n options = { ...options, tsconfig, src, dest };\n\n const queue = new Queue();\n entries.forEach((entry) => {\n queue.defer((cb) =>\n transformFile(entry, dest, type, options, (err, outPath) => {\n if (err) return cb(err);\n results.push(outPath);\n if (options.sourceMaps) results.push(`${outPath}.map`);\n cb();\n })\n );\n });\n queue.await((err) => (err ? callback(err) : callback(null, results)));\n }\n );\n });\n });\n}\n"],"names":["transformDirectoryWorker","src","dest","type","options","callback","tsconfig","matcher","createMatcher","installBindings","err","rimraf2","disableGlob","entries","iterator","Iterator","forEach","entry","stats","isFile","fullPath","typeFileRegEx","test","basename","SKIPS","indexOf","push","results","queue","Queue","defer","cb","transformFile","outPath","sourceMaps","await"],"mappings":";;;;+BASA;;;eAAwBA;;;iEATH;8DACH;8DACE;yBAEiB;oEACX;sEACE;oEACF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEX,SAASA,yBAAyBC,GAAG,EAAEC,IAAI,EAAEC,IAAI,EAAEC,OAAO,EAAEC,QAAQ;IACjF,IAAMC,WAAWF,QAAQE,QAAQ;IACjC,IAAMC,UAAUC,IAAAA,sBAAa,EAACF;IAE9BG,IAAAA,wBAAe,EAAC,SAACC;QACf,IAAIA,KAAK,OAAOL,SAASK;QAEzBC,IAAAA,gBAAO,EAACT,MAAM;YAAEU,aAAa;QAAK,GAAG;YACnC,IAAMC,UAAU,EAAE;YAClB,IAAMC,WAAW,IAAIC,mBAAQ,CAACd;YAC9Ba,SAASE,OAAO,CACd,SAACC;gBACC,IAAI,CAACA,MAAMC,KAAK,CAACC,MAAM,IAAI;gBAC3B,IAAI,CAACZ,QAAQU,MAAMG,QAAQ,GAAG;gBAC9B,IAAIC,wBAAa,CAACC,IAAI,CAACL,MAAMM,QAAQ,GAAG;gBACxC,IAAIC,gBAAK,CAACC,OAAO,CAACR,MAAMM,QAAQ,KAAK,GAAG;gBACxCV,QAAQa,IAAI,CAACT;YACf,GACA,SAACP;gBACC,IAAIA,KAAK,OAAOL,SAASK;gBACzB,IAAMiB,UAAU,EAAE;gBAClBvB,UAAU,wCAAKA;oBAASE,UAAAA;oBAAUL,KAAAA;oBAAKC,MAAAA;;gBAEvC,IAAM0B,QAAQ,IAAIC,gBAAK;gBACvBhB,QAAQG,OAAO,CAAC,SAACC;oBACfW,MAAME,KAAK,CAAC,SAACC;+BACXC,IAAAA,sBAAa,EAACf,OAAOf,MAAMC,MAAMC,SAAS,SAACM,KAAKuB;4BAC9C,IAAIvB,KAAK,OAAOqB,GAAGrB;4BACnBiB,QAAQD,IAAI,CAACO;4BACb,IAAI7B,QAAQ8B,UAAU,EAAEP,QAAQD,IAAI,CAAC,AAAC,GAAU,OAARO,SAAQ;4BAChDF;wBACF;;gBAEJ;gBACAH,MAAMO,KAAK,CAAC,SAACzB;2BAASA,MAAML,SAASK,OAAOL,SAAS,MAAMsB;;YAC7D;QAEJ;IACF;AACF"}
@@ -8,6 +8,7 @@ Object.defineProperty(exports, "default", {
8
8
  return transformSyncWorker;
9
9
  }
10
10
  });
11
+ var _installBindings = require("../lib/installBindings.cjs");
11
12
  var _swcPrepareOptions = /*#__PURE__*/ _interop_require_default(require("../lib/swcPrepareOptions.cjs"));
12
13
  var _module = /*#__PURE__*/ _interop_require_default(require("module"));
13
14
  var _lazycache = /*#__PURE__*/ _interop_require_default(require("lazy-cache"));
@@ -70,13 +71,12 @@ function _object_spread_props(target, source) {
70
71
  }
71
72
  var _require = typeof require === 'undefined' ? _module.default.createRequire(require("url").pathToFileURL(__filename).toString()) : require;
72
73
  var swcLazy = (0, _lazycache.default)(_require)('@swc/core');
73
- function transformSyncWorker(contents, fileName, tsconfig, callback) {
74
+ function transformSyncWorker(contents, fileName, tsconfig) {
75
+ (0, _installBindings.sync)();
74
76
  var swcOptions = (0, _swcPrepareOptions.default)(tsconfig);
75
77
  var swc = swcLazy();
76
- swc.transform(contents, _object_spread_props(_object_spread({}, fileName.endsWith('.tsx') || fileName.endsWith('.jsx') ? swcOptions.tsxOptions : swcOptions.nonTsxOptions), {
78
+ return swc.transformSync(contents, _object_spread_props(_object_spread({}, fileName.endsWith('.tsx') || fileName.endsWith('.jsx') ? swcOptions.tsxOptions : swcOptions.nonTsxOptions), {
77
79
  filename: fileName
78
- })).then(function(output) {
79
- return callback(null, output);
80
- }).catch(callback);
80
+ }));
81
81
  }
82
82
  /* CJS INTEROP */ if (exports.__esModule && exports.default) { try { Object.defineProperty(exports.default, '__esModule', { value: true }); for (var key in exports) { exports.default[key] = exports[key]; } } catch (_) {}; module.exports = exports.default; }
@@ -1 +1 @@
1
- {"version":3,"sources":["/Users/kevin/Dev/OpenSource/typescript/ts-swc-transform/src/workers/transformSync.ts"],"sourcesContent":["import swcPrepareOptions from '../lib/swcPrepareOptions';\n\nimport Module from 'module';\nimport lazy from 'lazy-cache';\nconst _require = typeof require === 'undefined' ? Module.createRequire(import.meta.url) : require;\nconst swcLazy = lazy(_require)('@swc/core');\n\nimport type { TsConfigResult } from 'get-tsconfig-compat';\nexport default function transformSyncWorker(contents: string, fileName: string, tsconfig: TsConfigResult, callback) {\n const swcOptions = swcPrepareOptions(tsconfig);\n const swc = swcLazy();\n swc\n .transform(contents, {\n ...(fileName.endsWith('.tsx') || fileName.endsWith('.jsx') ? swcOptions.tsxOptions : swcOptions.nonTsxOptions),\n filename: fileName,\n })\n .then((output) => callback(null, output))\n .catch(callback);\n}\n"],"names":["transformSyncWorker","_require","require","Module","createRequire","swcLazy","lazy","contents","fileName","tsconfig","callback","swcOptions","swcPrepareOptions","swc","transform","endsWith","tsxOptions","nonTsxOptions","filename","then","output","catch"],"mappings":";;;;+BAQA;;;eAAwBA;;;wEARM;6DAEX;gEACF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACjB,IAAMC,WAAW,OAAOC,YAAY,cAAcC,eAAM,CAACC,aAAa,CAAC,uDAAmBF;AAC1F,IAAMG,UAAUC,IAAAA,kBAAI,EAACL,UAAU;AAGhB,SAASD,oBAAoBO,QAAgB,EAAEC,QAAgB,EAAEC,QAAwB,EAAEC,QAAQ;IAChH,IAAMC,aAAaC,IAAAA,0BAAiB,EAACH;IACrC,IAAMI,MAAMR;IACZQ,IACGC,SAAS,CAACP,UAAU,wCACfC,SAASO,QAAQ,CAAC,WAAWP,SAASO,QAAQ,CAAC,UAAUJ,WAAWK,UAAU,GAAGL,WAAWM,aAAa;QAC7GC,UAAUV;QAEXW,IAAI,CAAC,SAACC;eAAWV,SAAS,MAAMU;OAChCC,KAAK,CAACX;AACX"}
1
+ {"version":3,"sources":["/Users/kevin/Dev/OpenSource/typescript/ts-swc-transform/src/workers/transformSync.ts"],"sourcesContent":["import { sync as installBindingsSync } from '../lib/installBindings';\nimport swcPrepareOptions from '../lib/swcPrepareOptions';\n\nimport Module from 'module';\nimport lazy from 'lazy-cache';\nconst _require = typeof require === 'undefined' ? Module.createRequire(import.meta.url) : require;\nconst swcLazy = lazy(_require)('@swc/core');\n\nimport type { TsConfigResult } from 'get-tsconfig-compat';\nexport default function transformSyncWorker(contents: string, fileName: string, tsconfig: TsConfigResult) {\n installBindingsSync();\n\n const swcOptions = swcPrepareOptions(tsconfig);\n const swc = swcLazy();\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","swcLazy","lazy","contents","fileName","tsconfig","installBindingsSync","swcOptions","swcPrepareOptions","swc","transformSync","endsWith","tsxOptions","nonTsxOptions","filename"],"mappings":";;;;+BASA;;;eAAwBA;;;+BAToB;wEACd;6DAEX;gEACF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACjB,IAAMC,WAAW,OAAOC,YAAY,cAAcC,eAAM,CAACC,aAAa,CAAC,uDAAmBF;AAC1F,IAAMG,UAAUC,IAAAA,kBAAI,EAACL,UAAU;AAGhB,SAASD,oBAAoBO,QAAgB,EAAEC,QAAgB,EAAEC,QAAwB;IACtGC,IAAAA,qBAAmB;IAEnB,IAAMC,aAAaC,IAAAA,0BAAiB,EAACH;IACrC,IAAMI,MAAMR;IACZ,OAAOQ,IAAIC,aAAa,CAACP,UAAU,wCAC7BC,SAASO,QAAQ,CAAC,WAAWP,SAASO,QAAQ,CAAC,UAAUJ,WAAWK,UAAU,GAAGL,WAAWM,aAAa;QAC7GC,UAAUV;;AAEd"}
@@ -0,0 +1,17 @@
1
+ import installBindings from '../workers/installBindings.mjs';
2
+ export default installBindings;
3
+ import path from 'path';
4
+ import url from 'url';
5
+ import Module from 'module';
6
+ import lazy from 'lazy-cache';
7
+ const _require = typeof require === 'undefined' ? Module.createRequire(import.meta.url) : require;
8
+ const __dirname = path.dirname(typeof __filename === 'undefined' ? url.fileURLToPath(import.meta.url) : __filename);
9
+ const workerPath = path.resolve(__dirname, '..', '..', 'cjs', 'workers', 'installBindings.cjs');
10
+ const major = +process.versions.node.split('.')[0];
11
+ const version = major < 14 ? 'stable' : 'local';
12
+ const call = lazy(_require)('node-version-call');
13
+ import memoize from 'lodash.memoize';
14
+ export const sync = memoize(()=>call()({
15
+ version,
16
+ callbacks: true
17
+ }, workerPath));
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["/Users/kevin/Dev/OpenSource/typescript/ts-swc-transform/src/lib/installBindings.ts"],"sourcesContent":["import installBindings from '../workers/installBindings';\nexport default installBindings;\n\nimport path from 'path';\nimport url from 'url';\n\nimport Module from 'module';\nimport lazy from 'lazy-cache';\nconst _require = typeof require === 'undefined' ? Module.createRequire(import.meta.url) : require;\nconst __dirname = path.dirname(typeof __filename === 'undefined' ? url.fileURLToPath(import.meta.url) : __filename);\nconst workerPath = path.resolve(__dirname, '..', '..', 'cjs', 'workers', 'installBindings.cjs');\nconst major = +process.versions.node.split('.')[0];\nconst version = major < 14 ? 'stable' : 'local';\n\nconst call = lazy(_require)('node-version-call');\nimport memoize from 'lodash.memoize';\nexport const sync = memoize(() => call()({ version, callbacks: true }, workerPath));\n"],"names":["installBindings","path","url","Module","lazy","_require","require","createRequire","__dirname","dirname","__filename","fileURLToPath","workerPath","resolve","major","process","versions","node","split","version","call","memoize","sync","callbacks"],"mappings":"AAAA,OAAOA,qBAAqB,6BAA6B;AACzD,eAAeA,gBAAgB;AAE/B,OAAOC,UAAU,OAAO;AACxB,OAAOC,SAAS,MAAM;AAEtB,OAAOC,YAAY,SAAS;AAC5B,OAAOC,UAAU,aAAa;AAC9B,MAAMC,WAAW,OAAOC,YAAY,cAAcH,OAAOI,aAAa,CAAC,YAAYL,GAAG,IAAII;AAC1F,MAAME,YAAYP,KAAKQ,OAAO,CAAC,OAAOC,eAAe,cAAcR,IAAIS,aAAa,CAAC,YAAYT,GAAG,IAAIQ;AACxG,MAAME,aAAaX,KAAKY,OAAO,CAACL,WAAW,MAAM,MAAM,OAAO,WAAW;AACzE,MAAMM,QAAQ,CAACC,QAAQC,QAAQ,CAACC,IAAI,CAACC,KAAK,CAAC,IAAI,CAAC,EAAE;AAClD,MAAMC,UAAUL,QAAQ,KAAK,WAAW;AAExC,MAAMM,OAAOhB,KAAKC,UAAU;AAC5B,OAAOgB,aAAa,iBAAiB;AACrC,OAAO,MAAMC,OAAOD,QAAQ,IAAMD,OAAO;QAAED;QAASI,WAAW;IAAK,GAAGX,aAAa"}
@@ -6,9 +6,6 @@ export default function wrapWorkerSync(workerPath) {
6
6
  const workerLazy = lazy(_require)(workerPath);
7
7
  return function workerWrapperSync(version, ...args) {
8
8
  if (version === 'local') return workerLazy().apply(null, args);
9
- return call()({
10
- version,
11
- callbacks: true
12
- }, workerPath, ...args);
9
+ return call()(version, workerPath, ...args);
13
10
  };
14
11
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["/Users/kevin/Dev/OpenSource/typescript/ts-swc-transform/src/lib/wrapWorkerSync.ts"],"sourcesContent":["import Module from 'module';\nimport lazy from 'lazy-cache';\nconst _require = typeof require === 'undefined' ? Module.createRequire(import.meta.url) : require;\nconst call = lazy(_require)('node-version-call');\n\nexport default function wrapWorkerSync(workerPath: string) {\n const workerLazy = lazy(_require)(workerPath);\n\n return function workerWrapperSync(version, ...args) {\n if (version === 'local') return workerLazy().apply(null, args);\n return call()({ version, callbacks: true }, workerPath, ...args);\n };\n}\n"],"names":["Module","lazy","_require","require","createRequire","url","call","wrapWorkerSync","workerPath","workerLazy","workerWrapperSync","version","args","apply","callbacks"],"mappings":"AAAA,OAAOA,YAAY,SAAS;AAC5B,OAAOC,UAAU,aAAa;AAC9B,MAAMC,WAAW,OAAOC,YAAY,cAAcH,OAAOI,aAAa,CAAC,YAAYC,GAAG,IAAIF;AAC1F,MAAMG,OAAOL,KAAKC,UAAU;AAE5B,eAAe,SAASK,eAAeC,UAAkB;IACvD,MAAMC,aAAaR,KAAKC,UAAUM;IAElC,OAAO,SAASE,kBAAkBC,OAAO,EAAE,GAAGC,IAAI;QAChD,IAAID,YAAY,SAAS,OAAOF,aAAaI,KAAK,CAAC,MAAMD;QACzD,OAAON,OAAO;YAAEK;YAASG,WAAW;QAAK,GAAGN,eAAeI;IAC7D;AACF"}
1
+ {"version":3,"sources":["/Users/kevin/Dev/OpenSource/typescript/ts-swc-transform/src/lib/wrapWorkerSync.ts"],"sourcesContent":["import Module from 'module';\nimport lazy from 'lazy-cache';\nconst _require = typeof require === 'undefined' ? Module.createRequire(import.meta.url) : require;\nconst call = lazy(_require)('node-version-call');\n\nexport default function wrapWorkerSync(workerPath: string) {\n const workerLazy = lazy(_require)(workerPath);\n\n return function workerWrapperSync(version, ...args) {\n if (version === 'local') return workerLazy().apply(null, args);\n return call()(version, workerPath, ...args);\n };\n}\n"],"names":["Module","lazy","_require","require","createRequire","url","call","wrapWorkerSync","workerPath","workerLazy","workerWrapperSync","version","args","apply"],"mappings":"AAAA,OAAOA,YAAY,SAAS;AAC5B,OAAOC,UAAU,aAAa;AAC9B,MAAMC,WAAW,OAAOC,YAAY,cAAcH,OAAOI,aAAa,CAAC,YAAYC,GAAG,IAAIF;AAC1F,MAAMG,OAAOL,KAAKC,UAAU;AAE5B,eAAe,SAASK,eAAeC,UAAkB;IACvD,MAAMC,aAAaR,KAAKC,UAAUM;IAElC,OAAO,SAASE,kBAAkBC,OAAO,EAAE,GAAGC,IAAI;QAChD,IAAID,YAAY,SAAS,OAAOF,aAAaI,KAAK,CAAC,MAAMD;QACzD,OAAON,OAAOK,SAASH,eAAeI;IACxC;AACF"}
@@ -4,6 +4,8 @@ import * as getTS from 'get-tsconfig-compat';
4
4
  import wrapWorkerSync from './lib/wrapWorkerSync.mjs';
5
5
  const __dirname = path.dirname(typeof __filename === 'undefined' ? url.fileURLToPath(import.meta.url) : __filename);
6
6
  const workerWrapper = wrapWorkerSync(path.resolve(__dirname, '..', 'cjs', 'workers', 'transformSync.cjs'));
7
+ const major = +process.versions.node.split('.')[0];
8
+ const version = major < 14 ? 'stable' : 'local';
7
9
  /**
8
10
  * @param {string} contents The file contents.
9
11
  * @param {string} fileName The filename.
@@ -13,5 +15,5 @@ const workerWrapper = wrapWorkerSync(path.resolve(__dirname, '..', 'cjs', 'worke
13
15
  if (typeof contents !== 'string') throw new Error('transformTypes: unexpected contents');
14
16
  if (typeof fileName !== 'string') throw new Error('transformTypes: unexpected fileName');
15
17
  if (!tsconfig) tsconfig = getTS.getTsconfig(process.cwd());
16
- return workerWrapper('stable', contents, fileName, tsconfig);
18
+ return workerWrapper(version, contents, fileName, tsconfig);
17
19
  }
@@ -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\nimport wrapWorkerSync from './lib/wrapWorkerSync';\nconst __dirname = path.dirname(typeof __filename === 'undefined' ? url.fileURLToPath(import.meta.url) : __filename);\nconst workerWrapper = wrapWorkerSync(path.resolve(__dirname, '..', 'cjs', 'workers', 'transformSync.cjs'));\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 workerWrapper('stable', contents, fileName, tsconfig);\n}\n"],"names":["path","url","getTS","wrapWorkerSync","__dirname","dirname","__filename","fileURLToPath","workerWrapper","resolve","transformSync","contents","fileName","tsconfig","Error","getTsconfig","process","cwd"],"mappings":"AAAA,OAAOA,UAAU,OAAO;AACxB,OAAOC,SAAS,MAAM;AACtB,YAAYC,WAAW,sBAAsB;AAE7C,OAAOC,oBAAoB,uBAAuB;AAClD,MAAMC,YAAYJ,KAAKK,OAAO,CAAC,OAAOC,eAAe,cAAcL,IAAIM,aAAa,CAAC,YAAYN,GAAG,IAAIK;AACxG,MAAME,gBAAgBL,eAAeH,KAAKS,OAAO,CAACL,WAAW,MAAM,OAAO,WAAW;AAIrF;;;;;CAKC,GACD,eAAe,SAASM,cAAcC,QAAgB,EAAEC,QAAgB,EAAEC,QAAwB;IAChG,IAAI,OAAOF,aAAa,UAAU,MAAM,IAAIG,MAAM;IAClD,IAAI,OAAOF,aAAa,UAAU,MAAM,IAAIE,MAAM;IAClD,IAAI,CAACD,UAAUA,WAAWX,MAAMa,WAAW,CAACC,QAAQC,GAAG;IACvD,OAAOT,cAAc,UAAUG,UAAUC,UAAUC;AACrD"}
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\nimport wrapWorkerSync from './lib/wrapWorkerSync';\nconst __dirname = path.dirname(typeof __filename === 'undefined' ? url.fileURLToPath(import.meta.url) : __filename);\nconst workerWrapper = wrapWorkerSync(path.resolve(__dirname, '..', 'cjs', 'workers', 'transformSync.cjs'));\nconst major = +process.versions.node.split('.')[0];\nconst version = major < 14 ? 'stable' : 'local';\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 workerWrapper(version, contents, fileName, tsconfig);\n}\n"],"names":["path","url","getTS","wrapWorkerSync","__dirname","dirname","__filename","fileURLToPath","workerWrapper","resolve","major","process","versions","node","split","version","transformSync","contents","fileName","tsconfig","Error","getTsconfig","cwd"],"mappings":"AAAA,OAAOA,UAAU,OAAO;AACxB,OAAOC,SAAS,MAAM;AACtB,YAAYC,WAAW,sBAAsB;AAE7C,OAAOC,oBAAoB,uBAAuB;AAClD,MAAMC,YAAYJ,KAAKK,OAAO,CAAC,OAAOC,eAAe,cAAcL,IAAIM,aAAa,CAAC,YAAYN,GAAG,IAAIK;AACxG,MAAME,gBAAgBL,eAAeH,KAAKS,OAAO,CAACL,WAAW,MAAM,OAAO,WAAW;AACrF,MAAMM,QAAQ,CAACC,QAAQC,QAAQ,CAACC,IAAI,CAACC,KAAK,CAAC,IAAI,CAAC,EAAE;AAClD,MAAMC,UAAUL,QAAQ,KAAK,WAAW;AAIxC;;;;;CAKC,GACD,eAAe,SAASM,cAAcC,QAAgB,EAAEC,QAAgB,EAAEC,QAAwB;IAChG,IAAI,OAAOF,aAAa,UAAU,MAAM,IAAIG,MAAM;IAClD,IAAI,OAAOF,aAAa,UAAU,MAAM,IAAIE,MAAM;IAClD,IAAI,CAACD,UAAUA,WAAWjB,MAAMmB,WAAW,CAACV,QAAQW,GAAG;IACvD,OAAOd,cAAcO,SAASE,UAAUC,UAAUC;AACpD"}
@@ -0,0 +1,25 @@
1
+ import fs from 'fs';
2
+ import path from 'path';
3
+ import installModule from 'install-module-linked';
4
+ import Queue from 'queue-cb';
5
+ import resolve from 'resolve';
6
+ import resolveOnce from 'resolve-once-cb';
7
+ export default resolveOnce(function installBindings(callback) {
8
+ const packagePath = resolve.sync('@swc/core/package.json');
9
+ const nodeModules = path.dirname(path.dirname(path.dirname(packagePath)));
10
+ const optionalDependencies = JSON.parse(fs.readFileSync(packagePath, 'utf8')).optionalDependencies;
11
+ const depKey = `${process.platform}-`;
12
+ const queue = new Queue();
13
+ Object.keys(optionalDependencies).filter((name)=>name.indexOf(depKey) >= 0).map((name)=>{
14
+ queue.defer((callback)=>{
15
+ const version = optionalDependencies[name];
16
+ const installString = version ? `${name}@${version}` : name;
17
+ installModule(installString, nodeModules, (err)=>{
18
+ if (err) return callback(err);
19
+ console.log(`installed ${path.join(nodeModules, name)}`);
20
+ callback();
21
+ });
22
+ });
23
+ });
24
+ queue.await(callback);
25
+ });
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["/Users/kevin/Dev/OpenSource/typescript/ts-swc-transform/src/workers/installBindings.ts"],"sourcesContent":["import fs from 'fs';\nimport path from 'path';\nimport installModule from 'install-module-linked';\nimport Queue from 'queue-cb';\nimport resolve from 'resolve';\nimport resolveOnce from 'resolve-once-cb';\n\nexport default resolveOnce(function installBindings(callback) {\n const packagePath = resolve.sync('@swc/core/package.json');\n const nodeModules = path.dirname(path.dirname(path.dirname(packagePath)));\n const optionalDependencies = JSON.parse(fs.readFileSync(packagePath, 'utf8')).optionalDependencies;\n const depKey = `${process.platform}-`;\n\n const queue = new Queue();\n Object.keys(optionalDependencies)\n .filter((name) => name.indexOf(depKey) >= 0)\n .map((name) => {\n queue.defer((callback) => {\n const version = optionalDependencies[name];\n const installString = version ? `${name}@${version}` : name;\n installModule(installString, nodeModules, (err) => {\n if (err) return callback(err);\n console.log(`installed ${path.join(nodeModules, name)}`);\n callback();\n });\n });\n });\n queue.await(callback);\n});\n"],"names":["fs","path","installModule","Queue","resolve","resolveOnce","installBindings","callback","packagePath","sync","nodeModules","dirname","optionalDependencies","JSON","parse","readFileSync","depKey","process","platform","queue","Object","keys","filter","name","indexOf","map","defer","version","installString","err","console","log","join","await"],"mappings":"AAAA,OAAOA,QAAQ,KAAK;AACpB,OAAOC,UAAU,OAAO;AACxB,OAAOC,mBAAmB,wBAAwB;AAClD,OAAOC,WAAW,WAAW;AAC7B,OAAOC,aAAa,UAAU;AAC9B,OAAOC,iBAAiB,kBAAkB;AAE1C,eAAeA,YAAY,SAASC,gBAAgBC,QAAQ;IAC1D,MAAMC,cAAcJ,QAAQK,IAAI,CAAC;IACjC,MAAMC,cAAcT,KAAKU,OAAO,CAACV,KAAKU,OAAO,CAACV,KAAKU,OAAO,CAACH;IAC3D,MAAMI,uBAAuBC,KAAKC,KAAK,CAACd,GAAGe,YAAY,CAACP,aAAa,SAASI,oBAAoB;IAClG,MAAMI,SAAS,GAAGC,QAAQC,QAAQ,CAAC,CAAC,CAAC;IAErC,MAAMC,QAAQ,IAAIhB;IAClBiB,OAAOC,IAAI,CAACT,sBACTU,MAAM,CAAC,CAACC,OAASA,KAAKC,OAAO,CAACR,WAAW,GACzCS,GAAG,CAAC,CAACF;QACJJ,MAAMO,KAAK,CAAC,CAACnB;YACX,MAAMoB,UAAUf,oBAAoB,CAACW,KAAK;YAC1C,MAAMK,gBAAgBD,UAAU,GAAGJ,KAAK,CAAC,EAAEI,SAAS,GAAGJ;YACvDrB,cAAc0B,eAAelB,aAAa,CAACmB;gBACzC,IAAIA,KAAK,OAAOtB,SAASsB;gBACzBC,QAAQC,GAAG,CAAC,CAAC,UAAU,EAAE9B,KAAK+B,IAAI,CAACtB,aAAaa,OAAO;gBACvDhB;YACF;QACF;IACF;IACFY,MAAMc,KAAK,CAAC1B;AACd,GAAG"}
@@ -3,40 +3,44 @@ import Queue from 'queue-cb';
3
3
  import rimraf2 from 'rimraf2';
4
4
  import { SKIPS, typeFileRegEx } from '../constants.mjs';
5
5
  import createMatcher from '../createMatcher.mjs';
6
+ import installBindings from '../lib/installBindings.mjs';
6
7
  import transformFile from '../lib/transformFile.mjs';
7
8
  export default function transformDirectoryWorker(src, dest, type, options, callback) {
8
9
  const tsconfig = options.tsconfig;
9
10
  const matcher = createMatcher(tsconfig);
10
- rimraf2(dest, {
11
- disableGlob: true
12
- }, ()=>{
13
- const entries = [];
14
- const iterator = new Iterator(src);
15
- iterator.forEach((entry)=>{
16
- if (!entry.stats.isFile()) return;
17
- if (!matcher(entry.fullPath)) return;
18
- if (typeFileRegEx.test(entry.basename)) return;
19
- if (SKIPS.indexOf(entry.basename) >= 0) return;
20
- entries.push(entry);
21
- }, (err)=>{
22
- if (err) return callback(err);
23
- const results = [];
24
- options = {
25
- ...options,
26
- tsconfig,
27
- src,
28
- dest
29
- };
30
- const queue = new Queue();
31
- entries.forEach((entry)=>{
32
- queue.defer((cb)=>transformFile(entry, dest, type, options, (err, outPath)=>{
33
- if (err) return cb(err);
34
- results.push(outPath);
35
- if (options.sourceMaps) results.push(`${outPath}.map`);
36
- cb();
37
- }));
11
+ installBindings((err)=>{
12
+ if (err) return callback(err);
13
+ rimraf2(dest, {
14
+ disableGlob: true
15
+ }, ()=>{
16
+ const entries = [];
17
+ const iterator = new Iterator(src);
18
+ iterator.forEach((entry)=>{
19
+ if (!entry.stats.isFile()) return;
20
+ if (!matcher(entry.fullPath)) return;
21
+ if (typeFileRegEx.test(entry.basename)) return;
22
+ if (SKIPS.indexOf(entry.basename) >= 0) return;
23
+ entries.push(entry);
24
+ }, (err)=>{
25
+ if (err) return callback(err);
26
+ const results = [];
27
+ options = {
28
+ ...options,
29
+ tsconfig,
30
+ src,
31
+ dest
32
+ };
33
+ const queue = new Queue();
34
+ entries.forEach((entry)=>{
35
+ queue.defer((cb)=>transformFile(entry, dest, type, options, (err, outPath)=>{
36
+ if (err) return cb(err);
37
+ results.push(outPath);
38
+ if (options.sourceMaps) results.push(`${outPath}.map`);
39
+ cb();
40
+ }));
41
+ });
42
+ queue.await((err)=>err ? callback(err) : callback(null, results));
38
43
  });
39
- queue.await((err)=>err ? callback(err) : callback(null, results));
40
44
  });
41
45
  });
42
46
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["/Users/kevin/Dev/OpenSource/typescript/ts-swc-transform/src/workers/transformDirectory.ts"],"sourcesContent":["import path from 'path';\nimport Iterator from 'fs-iterator';\nimport Queue from 'queue-cb';\nimport rimraf2 from 'rimraf2';\n\nimport { SKIPS, typeFileRegEx } from '../constants';\nimport createMatcher from '../createMatcher';\nimport transformFile from '../lib/transformFile';\n\nexport default function transformDirectoryWorker(src, dest, type, options, callback) {\n const tsconfig = options.tsconfig;\n const matcher = createMatcher(tsconfig);\n\n rimraf2(dest, { disableGlob: true }, () => {\n const entries = [];\n const iterator = new Iterator(src);\n iterator.forEach(\n (entry) => {\n if (!entry.stats.isFile()) return;\n if (!matcher(entry.fullPath)) return;\n if (typeFileRegEx.test(entry.basename)) return;\n if (SKIPS.indexOf(entry.basename) >= 0) return;\n entries.push(entry);\n },\n (err) => {\n if (err) return callback(err);\n const results = [];\n options = { ...options, tsconfig, src, dest };\n\n const queue = new Queue();\n entries.forEach((entry) => {\n queue.defer((cb) =>\n transformFile(entry, dest, type, options, (err, outPath) => {\n if (err) return cb(err);\n results.push(outPath);\n if (options.sourceMaps) results.push(`${outPath}.map`);\n cb();\n })\n );\n });\n queue.await((err) => (err ? callback(err) : callback(null, results)));\n }\n );\n });\n}\n"],"names":["Iterator","Queue","rimraf2","SKIPS","typeFileRegEx","createMatcher","transformFile","transformDirectoryWorker","src","dest","type","options","callback","tsconfig","matcher","disableGlob","entries","iterator","forEach","entry","stats","isFile","fullPath","test","basename","indexOf","push","err","results","queue","defer","cb","outPath","sourceMaps","await"],"mappings":"AACA,OAAOA,cAAc,cAAc;AACnC,OAAOC,WAAW,WAAW;AAC7B,OAAOC,aAAa,UAAU;AAE9B,SAASC,KAAK,EAAEC,aAAa,QAAQ,eAAe;AACpD,OAAOC,mBAAmB,mBAAmB;AAC7C,OAAOC,mBAAmB,uBAAuB;AAEjD,eAAe,SAASC,yBAAyBC,GAAG,EAAEC,IAAI,EAAEC,IAAI,EAAEC,OAAO,EAAEC,QAAQ;IACjF,MAAMC,WAAWF,QAAQE,QAAQ;IACjC,MAAMC,UAAUT,cAAcQ;IAE9BX,QAAQO,MAAM;QAAEM,aAAa;IAAK,GAAG;QACnC,MAAMC,UAAU,EAAE;QAClB,MAAMC,WAAW,IAAIjB,SAASQ;QAC9BS,SAASC,OAAO,CACd,CAACC;YACC,IAAI,CAACA,MAAMC,KAAK,CAACC,MAAM,IAAI;YAC3B,IAAI,CAACP,QAAQK,MAAMG,QAAQ,GAAG;YAC9B,IAAIlB,cAAcmB,IAAI,CAACJ,MAAMK,QAAQ,GAAG;YACxC,IAAIrB,MAAMsB,OAAO,CAACN,MAAMK,QAAQ,KAAK,GAAG;YACxCR,QAAQU,IAAI,CAACP;QACf,GACA,CAACQ;YACC,IAAIA,KAAK,OAAOf,SAASe;YACzB,MAAMC,UAAU,EAAE;YAClBjB,UAAU;gBAAE,GAAGA,OAAO;gBAAEE;gBAAUL;gBAAKC;YAAK;YAE5C,MAAMoB,QAAQ,IAAI5B;YAClBe,QAAQE,OAAO,CAAC,CAACC;gBACfU,MAAMC,KAAK,CAAC,CAACC,KACXzB,cAAca,OAAOV,MAAMC,MAAMC,SAAS,CAACgB,KAAKK;wBAC9C,IAAIL,KAAK,OAAOI,GAAGJ;wBACnBC,QAAQF,IAAI,CAACM;wBACb,IAAIrB,QAAQsB,UAAU,EAAEL,QAAQF,IAAI,CAAC,GAAGM,QAAQ,IAAI,CAAC;wBACrDD;oBACF;YAEJ;YACAF,MAAMK,KAAK,CAAC,CAACP,MAASA,MAAMf,SAASe,OAAOf,SAAS,MAAMgB;QAC7D;IAEJ;AACF"}
1
+ {"version":3,"sources":["/Users/kevin/Dev/OpenSource/typescript/ts-swc-transform/src/workers/transformDirectory.ts"],"sourcesContent":["import Iterator from 'fs-iterator';\nimport Queue from 'queue-cb';\nimport rimraf2 from 'rimraf2';\n\nimport { SKIPS, typeFileRegEx } from '../constants';\nimport createMatcher from '../createMatcher';\nimport installBindings from '../lib/installBindings';\nimport transformFile from '../lib/transformFile';\n\nexport default function transformDirectoryWorker(src, dest, type, options, callback) {\n const tsconfig = options.tsconfig;\n const matcher = createMatcher(tsconfig);\n\n installBindings((err) => {\n if (err) return callback(err);\n\n rimraf2(dest, { disableGlob: true }, () => {\n const entries = [];\n const iterator = new Iterator(src);\n iterator.forEach(\n (entry) => {\n if (!entry.stats.isFile()) return;\n if (!matcher(entry.fullPath)) return;\n if (typeFileRegEx.test(entry.basename)) return;\n if (SKIPS.indexOf(entry.basename) >= 0) return;\n entries.push(entry);\n },\n (err) => {\n if (err) return callback(err);\n const results = [];\n options = { ...options, tsconfig, src, dest };\n\n const queue = new Queue();\n entries.forEach((entry) => {\n queue.defer((cb) =>\n transformFile(entry, dest, type, options, (err, outPath) => {\n if (err) return cb(err);\n results.push(outPath);\n if (options.sourceMaps) results.push(`${outPath}.map`);\n cb();\n })\n );\n });\n queue.await((err) => (err ? callback(err) : callback(null, results)));\n }\n );\n });\n });\n}\n"],"names":["Iterator","Queue","rimraf2","SKIPS","typeFileRegEx","createMatcher","installBindings","transformFile","transformDirectoryWorker","src","dest","type","options","callback","tsconfig","matcher","err","disableGlob","entries","iterator","forEach","entry","stats","isFile","fullPath","test","basename","indexOf","push","results","queue","defer","cb","outPath","sourceMaps","await"],"mappings":"AAAA,OAAOA,cAAc,cAAc;AACnC,OAAOC,WAAW,WAAW;AAC7B,OAAOC,aAAa,UAAU;AAE9B,SAASC,KAAK,EAAEC,aAAa,QAAQ,eAAe;AACpD,OAAOC,mBAAmB,mBAAmB;AAC7C,OAAOC,qBAAqB,yBAAyB;AACrD,OAAOC,mBAAmB,uBAAuB;AAEjD,eAAe,SAASC,yBAAyBC,GAAG,EAAEC,IAAI,EAAEC,IAAI,EAAEC,OAAO,EAAEC,QAAQ;IACjF,MAAMC,WAAWF,QAAQE,QAAQ;IACjC,MAAMC,UAAUV,cAAcS;IAE9BR,gBAAgB,CAACU;QACf,IAAIA,KAAK,OAAOH,SAASG;QAEzBd,QAAQQ,MAAM;YAAEO,aAAa;QAAK,GAAG;YACnC,MAAMC,UAAU,EAAE;YAClB,MAAMC,WAAW,IAAInB,SAASS;YAC9BU,SAASC,OAAO,CACd,CAACC;gBACC,IAAI,CAACA,MAAMC,KAAK,CAACC,MAAM,IAAI;gBAC3B,IAAI,CAACR,QAAQM,MAAMG,QAAQ,GAAG;gBAC9B,IAAIpB,cAAcqB,IAAI,CAACJ,MAAMK,QAAQ,GAAG;gBACxC,IAAIvB,MAAMwB,OAAO,CAACN,MAAMK,QAAQ,KAAK,GAAG;gBACxCR,QAAQU,IAAI,CAACP;YACf,GACA,CAACL;gBACC,IAAIA,KAAK,OAAOH,SAASG;gBACzB,MAAMa,UAAU,EAAE;gBAClBjB,UAAU;oBAAE,GAAGA,OAAO;oBAAEE;oBAAUL;oBAAKC;gBAAK;gBAE5C,MAAMoB,QAAQ,IAAI7B;gBAClBiB,QAAQE,OAAO,CAAC,CAACC;oBACfS,MAAMC,KAAK,CAAC,CAACC,KACXzB,cAAcc,OAAOX,MAAMC,MAAMC,SAAS,CAACI,KAAKiB;4BAC9C,IAAIjB,KAAK,OAAOgB,GAAGhB;4BACnBa,QAAQD,IAAI,CAACK;4BACb,IAAIrB,QAAQsB,UAAU,EAAEL,QAAQD,IAAI,CAAC,GAAGK,QAAQ,IAAI,CAAC;4BACrDD;wBACF;gBAEJ;gBACAF,MAAMK,KAAK,CAAC,CAACnB,MAASA,MAAMH,SAASG,OAAOH,SAAS,MAAMgB;YAC7D;QAEJ;IACF;AACF"}
@@ -1,13 +1,15 @@
1
+ import { sync as installBindingsSync } from '../lib/installBindings.mjs';
1
2
  import swcPrepareOptions from '../lib/swcPrepareOptions.mjs';
2
3
  import Module from 'module';
3
4
  import lazy from 'lazy-cache';
4
5
  const _require = typeof require === 'undefined' ? Module.createRequire(import.meta.url) : require;
5
6
  const swcLazy = lazy(_require)('@swc/core');
6
- export default function transformSyncWorker(contents, fileName, tsconfig, callback) {
7
+ export default function transformSyncWorker(contents, fileName, tsconfig) {
8
+ installBindingsSync();
7
9
  const swcOptions = swcPrepareOptions(tsconfig);
8
10
  const swc = swcLazy();
9
- swc.transform(contents, {
11
+ return swc.transformSync(contents, {
10
12
  ...fileName.endsWith('.tsx') || fileName.endsWith('.jsx') ? swcOptions.tsxOptions : swcOptions.nonTsxOptions,
11
13
  filename: fileName
12
- }).then((output)=>callback(null, output)).catch(callback);
14
+ });
13
15
  }
@@ -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';\nimport lazy from 'lazy-cache';\nconst _require = typeof require === 'undefined' ? Module.createRequire(import.meta.url) : require;\nconst swcLazy = lazy(_require)('@swc/core');\n\nimport type { TsConfigResult } from 'get-tsconfig-compat';\nexport default function transformSyncWorker(contents: string, fileName: string, tsconfig: TsConfigResult, callback) {\n const swcOptions = swcPrepareOptions(tsconfig);\n const swc = swcLazy();\n swc\n .transform(contents, {\n ...(fileName.endsWith('.tsx') || fileName.endsWith('.jsx') ? swcOptions.tsxOptions : swcOptions.nonTsxOptions),\n filename: fileName,\n })\n .then((output) => callback(null, output))\n .catch(callback);\n}\n"],"names":["swcPrepareOptions","Module","lazy","_require","require","createRequire","url","swcLazy","transformSyncWorker","contents","fileName","tsconfig","callback","swcOptions","swc","transform","endsWith","tsxOptions","nonTsxOptions","filename","then","output","catch"],"mappings":"AAAA,OAAOA,uBAAuB,2BAA2B;AAEzD,OAAOC,YAAY,SAAS;AAC5B,OAAOC,UAAU,aAAa;AAC9B,MAAMC,WAAW,OAAOC,YAAY,cAAcH,OAAOI,aAAa,CAAC,YAAYC,GAAG,IAAIF;AAC1F,MAAMG,UAAUL,KAAKC,UAAU;AAG/B,eAAe,SAASK,oBAAoBC,QAAgB,EAAEC,QAAgB,EAAEC,QAAwB,EAAEC,QAAQ;IAChH,MAAMC,aAAab,kBAAkBW;IACrC,MAAMG,MAAMP;IACZO,IACGC,SAAS,CAACN,UAAU;QACnB,GAAIC,SAASM,QAAQ,CAAC,WAAWN,SAASM,QAAQ,CAAC,UAAUH,WAAWI,UAAU,GAAGJ,WAAWK,aAAa;QAC7GC,UAAUT;IACZ,GACCU,IAAI,CAAC,CAACC,SAAWT,SAAS,MAAMS,SAChCC,KAAK,CAACV;AACX"}
1
+ {"version":3,"sources":["/Users/kevin/Dev/OpenSource/typescript/ts-swc-transform/src/workers/transformSync.ts"],"sourcesContent":["import { sync as installBindingsSync } from '../lib/installBindings';\nimport swcPrepareOptions from '../lib/swcPrepareOptions';\n\nimport Module from 'module';\nimport lazy from 'lazy-cache';\nconst _require = typeof require === 'undefined' ? Module.createRequire(import.meta.url) : require;\nconst swcLazy = lazy(_require)('@swc/core');\n\nimport type { TsConfigResult } from 'get-tsconfig-compat';\nexport default function transformSyncWorker(contents: string, fileName: string, tsconfig: TsConfigResult) {\n installBindingsSync();\n\n const swcOptions = swcPrepareOptions(tsconfig);\n const swc = swcLazy();\n return swc.transformSync(contents, {\n ...(fileName.endsWith('.tsx') || fileName.endsWith('.jsx') ? swcOptions.tsxOptions : swcOptions.nonTsxOptions),\n filename: fileName,\n });\n}\n"],"names":["sync","installBindingsSync","swcPrepareOptions","Module","lazy","_require","require","createRequire","url","swcLazy","transformSyncWorker","contents","fileName","tsconfig","swcOptions","swc","transformSync","endsWith","tsxOptions","nonTsxOptions","filename"],"mappings":"AAAA,SAASA,QAAQC,mBAAmB,QAAQ,yBAAyB;AACrE,OAAOC,uBAAuB,2BAA2B;AAEzD,OAAOC,YAAY,SAAS;AAC5B,OAAOC,UAAU,aAAa;AAC9B,MAAMC,WAAW,OAAOC,YAAY,cAAcH,OAAOI,aAAa,CAAC,YAAYC,GAAG,IAAIF;AAC1F,MAAMG,UAAUL,KAAKC,UAAU;AAG/B,eAAe,SAASK,oBAAoBC,QAAgB,EAAEC,QAAgB,EAAEC,QAAwB;IACtGZ;IAEA,MAAMa,aAAaZ,kBAAkBW;IACrC,MAAME,MAAMN;IACZ,OAAOM,IAAIC,aAAa,CAACL,UAAU;QACjC,GAAIC,SAASK,QAAQ,CAAC,WAAWL,SAASK,QAAQ,CAAC,UAAUH,WAAWI,UAAU,GAAGJ,WAAWK,aAAa;QAC7GC,UAAUR;IACZ;AACF"}
@@ -0,0 +1,3 @@
1
+ import installBindings from '../workers/installBindings';
2
+ export default installBindings;
3
+ export declare const sync: any;
@@ -0,0 +1,2 @@
1
+ declare const _default: any;
2
+ export default _default;
@@ -1,2 +1,2 @@
1
1
  import type { TsConfigResult } from 'get-tsconfig-compat';
2
- export default function transformSyncWorker(contents: string, fileName: string, tsconfig: TsConfigResult, callback: any): void;
2
+ export default function transformSyncWorker(contents: string, fileName: string, tsconfig: TsConfigResult): any;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ts-swc-transform",
3
- "version": "1.11.5",
3
+ "version": "1.11.6",
4
4
  "description": "Typescript transformers for swc. Supports Node >= 0.8",
5
5
  "keywords": [
6
6
  "matcher",
@@ -36,16 +36,6 @@
36
36
  "dist",
37
37
  "scripts"
38
38
  ],
39
- "scripts": {
40
- "build": "tsds build",
41
- "deploy": "tsds deploy",
42
- "format": "biome check --write --unsafe src/ test/ && biome check --config-path biome.es5.json --write --unsafe scripts/",
43
- "postinstall": "node ./scripts/postinstall.cjs",
44
- "test": "tsds test:node --no-timeouts",
45
- "test:engines": "nvu engines npm test",
46
- "version": "",
47
- "version2": "tsds version"
48
- },
49
39
  "dependencies": {
50
40
  "@swc/core": "*",
51
41
  "exit": "^0.1.2",
@@ -54,12 +44,14 @@
54
44
  "install-module-linked": "^0.2.0",
55
45
  "is-absolute": "^1.0.0",
56
46
  "lazy-cache": "^2.0.2",
47
+ "lodash.memoize": "^4.1.2",
57
48
  "minimatch": "^3.1.2",
58
49
  "mkdirp-classic": "^0.5.3",
59
- "node-version-call": "^1.4.3",
50
+ "node-version-call": "^1.4.5",
60
51
  "path-posix": "^1.0.0",
61
52
  "queue-cb": "^1.4.4",
62
53
  "resolve": "^1.22.10",
54
+ "resolve-once-cb": "^0.1.2",
63
55
  "rimraf2": "^2.8.2",
64
56
  "ts-node": "*",
65
57
  "typescript": "*",
@@ -69,7 +61,7 @@
69
61
  "@biomejs/biome": "^1.9.4",
70
62
  "@swc/core": "^1.9.3",
71
63
  "@types/mocha": "^10.0.10",
72
- "@types/node": "^22.10.2",
64
+ "@types/node": "^22.10.3",
73
65
  "cr": "^0.1.0",
74
66
  "cross-spawn-cb": "^2.0.1",
75
67
  "es6-map": "^0.1.5",
@@ -86,5 +78,14 @@
86
78
  },
87
79
  "tsds": {
88
80
  "source": "src/index.ts"
81
+ },
82
+ "scripts": {
83
+ "build": "tsds build",
84
+ "deploy": "tsds deploy",
85
+ "format": "biome check --write --unsafe src/ test/",
86
+ "test": "tsds test:node --no-timeouts",
87
+ "test:engines": "nvu engines npm test",
88
+ "version": "",
89
+ "version2": "tsds version"
89
90
  }
90
- }
91
+ }
@@ -1,43 +0,0 @@
1
- #!/usr/bin/env node
2
-
3
- var fs = require('fs');
4
- var path = require('path');
5
- var installModule = require('install-module-linked');
6
- var Queue = require('queue-cb');
7
- var resolve = require('resolve');
8
-
9
- function patch(callback) {
10
- var packagePath = resolve.sync('@swc/core/package.json');
11
- var nodeModules = path.dirname(path.dirname(path.dirname(packagePath)));
12
- var optionalDependencies = JSON.parse(fs.readFileSync(packagePath, 'utf8')).optionalDependencies;
13
- var depKey = process.platform + '-';
14
-
15
- var queue = new Queue();
16
- Object.keys(optionalDependencies)
17
- .filter(function (name) {
18
- return name.indexOf(depKey) >= 0;
19
- })
20
- .map(function (name) {
21
- queue.defer(function (callback) {
22
- var version = optionalDependencies[name];
23
- var installString = version ? name + '@' + version : name;
24
- installModule(installString, nodeModules, function (err) {
25
- if (err) return callback(err);
26
- console.log('installed ' + path.join(nodeModules, name));
27
- callback();
28
- });
29
- });
30
- });
31
- queue.await(callback);
32
- }
33
-
34
- // run patch
35
- patch(function (err) {
36
- if (err) {
37
- console.log('postinstall failed. Error: ' + err.message);
38
- process.exit(-1);
39
- } else {
40
- console.log('postinstall succeeded');
41
- process.exit(0);
42
- }
43
- });