ts-swc-transform 1.0.3 → 1.1.1

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.
Files changed (65) hide show
  1. package/dist/cjs/createMatcher.js +4 -4
  2. package/dist/cjs/createMatcher.js.map +1 -1
  3. package/dist/cjs/index.js +2 -2
  4. package/dist/cjs/index.js.map +1 -1
  5. package/dist/cjs/lazy.js +3 -0
  6. package/dist/cjs/lazy.js.map +1 -0
  7. package/dist/cjs/lib/existsSync.js +11 -0
  8. package/dist/cjs/lib/existsSync.js.map +1 -0
  9. package/dist/cjs/lib/installBindings.js +24 -0
  10. package/dist/cjs/lib/installBindings.js.map +1 -0
  11. package/dist/cjs/process.js +3 -0
  12. package/dist/cjs/process.js.map +1 -0
  13. package/dist/cjs/transformDirectory.js +6 -6
  14. package/dist/cjs/transformDirectory.js.map +1 -1
  15. package/dist/cjs/transformFile.js +12 -11
  16. package/dist/cjs/transformFile.js.map +1 -1
  17. package/dist/cjs/transformSync.js +27 -10
  18. package/dist/cjs/transformSync.js.map +1 -1
  19. package/dist/cjs/workers/installBinding.js +73 -0
  20. package/dist/cjs/workers/installBinding.js.map +1 -0
  21. package/dist/cjs/workers/transformSync.js +7 -1
  22. package/dist/cjs/workers/transformSync.js.map +1 -1
  23. package/dist/esm/createMatcher.mjs +4 -4
  24. package/dist/esm/createMatcher.mjs.map +1 -1
  25. package/dist/esm/index.mjs +1 -1
  26. package/dist/esm/index.mjs.map +1 -1
  27. package/dist/esm/lazy.cjs +1 -0
  28. package/dist/esm/lazy.cjs.map +1 -0
  29. package/dist/esm/lib/existsSync.cjs +9 -0
  30. package/dist/esm/lib/existsSync.cjs.map +1 -0
  31. package/dist/esm/lib/installBindings.cjs +22 -0
  32. package/dist/esm/lib/installBindings.cjs.map +1 -0
  33. package/dist/esm/process.cjs +1 -0
  34. package/dist/esm/process.cjs.map +1 -0
  35. package/dist/esm/transformDirectory.mjs +5 -3
  36. package/dist/esm/transformDirectory.mjs.map +1 -1
  37. package/dist/esm/transformFile.mjs +16 -14
  38. package/dist/esm/transformFile.mjs.map +1 -1
  39. package/dist/esm/transformSync.mjs +18 -0
  40. package/dist/esm/transformSync.mjs.map +1 -0
  41. package/dist/esm/workers/installBinding.cjs +46 -0
  42. package/dist/esm/workers/installBinding.cjs.map +1 -0
  43. package/dist/esm/workers/transformSync.cjs +7 -1
  44. package/dist/esm/workers/transformSync.cjs.map +1 -1
  45. package/dist/types/{createMatcher.d.mts → createMatcher.d.ts} +1 -4
  46. package/dist/types/index.d.ts +4 -0
  47. package/dist/types/lazy.d.cts +1 -0
  48. package/dist/types/lib/existsSync.d.cts +1 -0
  49. package/dist/types/lib/installBindings.d.cts +1 -0
  50. package/dist/types/process.d.cts +1 -0
  51. package/dist/types/{transformDirectory.d.mts → transformDirectory.d.ts} +1 -3
  52. package/dist/types/{transformFile.d.mts → transformFile.d.ts} +1 -3
  53. package/dist/types/transformSync.d.ts +6 -0
  54. package/dist/types/workers/installBinding.d.cts +1 -0
  55. package/dist/types/workers/transformSync.d.cts +1 -5
  56. package/package.json +14 -11
  57. package/dist/cjs/lib/regexDependencies.js +0 -21
  58. package/dist/cjs/lib/regexDependencies.js.map +0 -1
  59. package/dist/esm/lib/regexDependencies.mjs +0 -10
  60. package/dist/esm/lib/regexDependencies.mjs.map +0 -1
  61. package/dist/esm/transformSync.cjs +0 -13
  62. package/dist/esm/transformSync.cjs.map +0 -1
  63. package/dist/types/index.d.mts +0 -4
  64. package/dist/types/lib/regexDependencies.d.mts +0 -1
  65. package/dist/types/transformSync.d.cts +0 -5
@@ -13,16 +13,16 @@ Object.defineProperty(exports, /**
13
13
  });
14
14
  var _minimatch = /*#__PURE__*/ _interop_require_default(require("minimatch"));
15
15
  var _pathposix = /*#__PURE__*/ _interop_require_default(require("path-posix"));
16
- var _slash = /*#__PURE__*/ _interop_require_default(require("slash"));
16
+ var _unixify = /*#__PURE__*/ _interop_require_default(require("unixify"));
17
17
  function _interop_require_default(obj) {
18
18
  return obj && obj.__esModule ? obj : {
19
19
  default: obj
20
20
  };
21
21
  }
22
22
  function createMatcher(config) {
23
- var configPath = _pathposix.default.dirname((0, _slash.default)(config.path));
23
+ var configPath = _pathposix.default.dirname((0, _unixify.default)(config.path));
24
24
  function matchFn(condition) {
25
- var pattern = (0, _slash.default)(condition);
25
+ var pattern = (0, _unixify.default)(condition);
26
26
  if (!_pathposix.default.isAbsolute(pattern) && !pattern.startsWith('*')) pattern = _pathposix.default.join(configPath, pattern);
27
27
  return function match(filePath) {
28
28
  return filePath.startsWith(pattern) || (0, _minimatch.default)(filePath, pattern);
@@ -32,7 +32,7 @@ function createMatcher(config) {
32
32
  var excludes = (config.config.exclude || []).map(matchFn);
33
33
  return function matcher(filePath) {
34
34
  if (filePath.endsWith('.json')) return false;
35
- filePath = (0, _slash.default)(filePath);
35
+ filePath = (0, _unixify.default)(filePath);
36
36
  for(var i = 0; i < excludes.length; ++i){
37
37
  if (excludes[i](filePath)) return false;
38
38
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["createMatcher.mjs"],"sourcesContent":["import minimatch from 'minimatch';\nimport path from 'path-posix';\nimport slash from 'slash';\n\n/**\n * @param {{path: string, config: Object}} config The path to the loaded TS config and typescript config.\n * @returns {(filePath:string) => boolean} The function to test for typescript files being included or excluded\n */\nexport default function createMatcher(config) {\n const configPath = path.dirname(slash(config.path));\n\n function matchFn(condition) {\n let pattern = slash(condition);\n if (!path.isAbsolute(pattern) && !pattern.startsWith('*')) pattern = path.join(configPath, pattern);\n\n return function match(filePath) {\n return filePath.startsWith(pattern) || minimatch(filePath, pattern);\n };\n }\n\n const includes = (config.config.include || []).map(matchFn);\n const excludes = (config.config.exclude || []).map(matchFn);\n\n return function matcher(filePath) {\n if (filePath.endsWith('.json')) return false;\n\n filePath = slash(filePath);\n for (let i = 0; i < excludes.length; ++i) {\n if (excludes[i](filePath)) return false;\n }\n for (let j = 0; j < includes.length; ++j) {\n if (includes[j](filePath)) return true;\n }\n return !includes.length;\n };\n}\n"],"names":["createMatcher","config","configPath","path","dirname","slash","matchFn","condition","pattern","isAbsolute","startsWith","join","match","filePath","minimatch","includes","include","map","excludes","exclude","matcher","endsWith","i","length","j"],"mappings":";;;;+BAIA;;;CAGC,GACD;;;eAAwBA;;;gEARF;gEACL;4DACC;;;;;;AAMH,SAASA,cAAcC,MAAM;IAC1C,IAAMC,aAAaC,kBAAI,CAACC,OAAO,CAACC,IAAAA,cAAK,EAACJ,OAAOE,IAAI;IAEjD,SAASG,QAAQC,SAAS;QACxB,IAAIC,UAAUH,IAAAA,cAAK,EAACE;QACpB,IAAI,CAACJ,kBAAI,CAACM,UAAU,CAACD,YAAY,CAACA,QAAQE,UAAU,CAAC,MAAMF,UAAUL,kBAAI,CAACQ,IAAI,CAACT,YAAYM;QAE3F,OAAO,SAASI,MAAMC,QAAQ;YAC5B,OAAOA,SAASH,UAAU,CAACF,YAAYM,IAAAA,kBAAS,EAACD,UAAUL;QAC7D;IACF;IAEA,IAAMO,WAAW,AAACd,CAAAA,OAAOA,MAAM,CAACe,OAAO,IAAI,EAAE,AAAD,EAAGC,GAAG,CAACX;IACnD,IAAMY,WAAW,AAACjB,CAAAA,OAAOA,MAAM,CAACkB,OAAO,IAAI,EAAE,AAAD,EAAGF,GAAG,CAACX;IAEnD,OAAO,SAASc,QAAQP,QAAQ;QAC9B,IAAIA,SAASQ,QAAQ,CAAC,UAAU,OAAO;QAEvCR,WAAWR,IAAAA,cAAK,EAACQ;QACjB,IAAK,IAAIS,IAAI,GAAGA,IAAIJ,SAASK,MAAM,EAAE,EAAED,EAAG;YACxC,IAAIJ,QAAQ,CAACI,EAAE,CAACT,WAAW,OAAO;QACpC;QACA,IAAK,IAAIW,IAAI,GAAGA,IAAIT,SAASQ,MAAM,EAAE,EAAEC,EAAG;YACxC,IAAIT,QAAQ,CAACS,EAAE,CAACX,WAAW,OAAO;QACpC;QACA,OAAO,CAACE,SAASQ,MAAM;IACzB;AACF"}
1
+ {"version":3,"sources":["createMatcher.ts"],"sourcesContent":["import minimatch from 'minimatch';\nimport path from 'path-posix';\nimport unixify from 'unixify';\n\n/**\n * @param {{path: string, config: Object}} config The path to the loaded TS config and typescript config.\n * @returns {(filePath:string) => boolean} The function to test for typescript files being included or excluded\n */\nexport default function createMatcher(config) {\n const configPath = path.dirname(unixify(config.path));\n\n function matchFn(condition) {\n let pattern = unixify(condition);\n if (!path.isAbsolute(pattern) && !pattern.startsWith('*')) pattern = path.join(configPath, pattern);\n\n return function match(filePath) {\n return filePath.startsWith(pattern) || minimatch(filePath, pattern);\n };\n }\n\n const includes = (config.config.include || []).map(matchFn);\n const excludes = (config.config.exclude || []).map(matchFn);\n\n return function matcher(filePath) {\n if (filePath.endsWith('.json')) return false;\n\n filePath = unixify(filePath);\n for (let i = 0; i < excludes.length; ++i) {\n if (excludes[i](filePath)) return false;\n }\n for (let j = 0; j < includes.length; ++j) {\n if (includes[j](filePath)) return true;\n }\n return !includes.length;\n };\n}\n"],"names":["createMatcher","config","configPath","path","dirname","unixify","matchFn","condition","pattern","isAbsolute","startsWith","join","match","filePath","minimatch","includes","include","map","excludes","exclude","matcher","endsWith","i","length","j"],"mappings":";;;;+BAIA;;;CAGC,GACD;;;eAAwBA;;;gEARF;gEACL;8DACG;;;;;;AAML,SAASA,cAAcC,MAAM;IAC1C,IAAMC,aAAaC,kBAAI,CAACC,OAAO,CAACC,IAAAA,gBAAO,EAACJ,OAAOE,IAAI;IAEnD,SAASG,QAAQC,SAAS;QACxB,IAAIC,UAAUH,IAAAA,gBAAO,EAACE;QACtB,IAAI,CAACJ,kBAAI,CAACM,UAAU,CAACD,YAAY,CAACA,QAAQE,UAAU,CAAC,MAAMF,UAAUL,kBAAI,CAACQ,IAAI,CAACT,YAAYM;QAE3F,OAAO,SAASI,MAAMC,QAAQ;YAC5B,OAAOA,SAASH,UAAU,CAACF,YAAYM,IAAAA,kBAAS,EAACD,UAAUL;QAC7D;IACF;IAEA,IAAMO,WAAW,AAACd,CAAAA,OAAOA,MAAM,CAACe,OAAO,IAAI,EAAE,AAAD,EAAGC,GAAG,CAACX;IACnD,IAAMY,WAAW,AAACjB,CAAAA,OAAOA,MAAM,CAACkB,OAAO,IAAI,EAAE,AAAD,EAAGF,GAAG,CAACX;IAEnD,OAAO,SAASc,QAAQP,QAAQ;QAC9B,IAAIA,SAASQ,QAAQ,CAAC,UAAU,OAAO;QAEvCR,WAAWR,IAAAA,gBAAO,EAACQ;QACnB,IAAK,IAAIS,IAAI,GAAGA,IAAIJ,SAASK,MAAM,EAAE,EAAED,EAAG;YACxC,IAAIJ,QAAQ,CAACI,EAAE,CAACT,WAAW,OAAO;QACpC;QACA,IAAK,IAAIW,IAAI,GAAGA,IAAIT,SAASQ,MAAM,EAAE,EAAEC,EAAG;YACxC,IAAIT,QAAQ,CAACS,EAAE,CAACX,WAAW,OAAO;QACpC;QACA,OAAO,CAACE,SAASQ,MAAM;IACzB;AACF"}
package/dist/cjs/index.js CHANGED
@@ -19,13 +19,13 @@ _export(exports, {
19
19
  return _transformFile.default;
20
20
  },
21
21
  transformSync: function() {
22
- return _transformSynccjs.default;
22
+ return _transformSync.default;
23
23
  }
24
24
  });
25
25
  var _createMatcher = /*#__PURE__*/ _interop_require_default(require("./createMatcher.js"));
26
26
  var _transformFile = /*#__PURE__*/ _interop_require_default(require("./transformFile.js"));
27
27
  var _transformDirectory = /*#__PURE__*/ _interop_require_default(require("./transformDirectory.js"));
28
- var _transformSynccjs = /*#__PURE__*/ _interop_require_default(require("./transformSync.js"));
28
+ var _transformSync = /*#__PURE__*/ _interop_require_default(require("./transformSync.js"));
29
29
  function _interop_require_default(obj) {
30
30
  return obj && obj.__esModule ? obj : {
31
31
  default: obj
@@ -1 +1 @@
1
- {"version":3,"sources":["index.mjs"],"sourcesContent":["export { default as createMatcher } from './createMatcher.mjs';\nexport { default as transformFile } from './transformFile.mjs';\nexport { default as transformDirectory } from './transformDirectory.mjs';\nexport { default as transformSync } from './transformSync.cjs';\n"],"names":["createMatcher","transformDirectory","transformFile","transformSync"],"mappings":";;;;;;;;;;;IAAoBA,aAAa;eAAbA,sBAAa;;IAEbC,kBAAkB;eAAlBA,2BAAkB;;IADlBC,aAAa;eAAbA,sBAAa;;IAEbC,aAAa;eAAbA,yBAAa;;;oEAHQ;oEACA;yEACK;uEACL"}
1
+ {"version":3,"sources":["index.ts"],"sourcesContent":["export { default as createMatcher } from './createMatcher.js';\nexport { default as transformFile } from './transformFile.js';\nexport { default as transformDirectory } from './transformDirectory.js';\nexport { default as transformSync } from './transformSync.js';\n"],"names":["createMatcher","transformDirectory","transformFile","transformSync"],"mappings":";;;;;;;;;;;IAAoBA,aAAa;eAAbA,sBAAa;;IAEbC,kBAAkB;eAAlBA,2BAAkB;;IADlBC,aAAa;eAAbA,sBAAa;;IAEbC,aAAa;eAAbA,sBAAa;;;oEAHQ;oEACA;yEACK;oEACL"}
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ module.exports = require('lazy-cache')(require);
3
+ /* 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":["lazy.cts"],"sourcesContent":["module.exports = require('lazy-cache')(require);\n"],"names":["module","exports","require"],"mappings":";AAAAA,OAAOC,OAAO,GAAGC,QAAQ,cAAcA"}
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ var accessSync = require('fs-access-sync-compat');
3
+ module.exports = function existsSync(path) {
4
+ try {
5
+ accessSync(path);
6
+ return true;
7
+ } catch (_) {
8
+ return false;
9
+ }
10
+ };
11
+ /* 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":["existsSync.cts"],"sourcesContent":["const accessSync = require('fs-access-sync-compat');\n\nmodule.exports = function existsSync(path) {\n try {\n accessSync(path);\n return true;\n } catch (_) {\n return false;\n }\n};\n"],"names":["accessSync","require","module","exports","existsSync","path","_"],"mappings":";AAAA,IAAMA,aAAaC,QAAQ;AAE3BC,OAAOC,OAAO,GAAG,SAASC,WAAWC,IAAI;IACvC,IAAI;QACFL,WAAWK;QACX,OAAO;IACT,EAAE,OAAOC,GAAG;QACV,OAAO;IACT;AACF"}
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+ var path = require('path');
3
+ var existsSync = require('./existsSync.js');
4
+ var lazy = require('../lazy.js');
5
+ var major = +process.versions.node.split('.')[0];
6
+ var version = major >= 14 ? 'local' : 'lts';
7
+ var worker = path.resolve(path.dirname(__dirname), 'workers', "installBinding".concat(path.extname(__filename)));
8
+ var call = lazy('node-version-call');
9
+ var installDir = path.dirname(path.dirname(path.dirname(require.resolve('@swc/core/package.json'))));
10
+ var optionalDependencies = require('@swc/core/package.json').optionalDependencies;
11
+ var depKey = "".concat(process.platform, "-").concat(process.arch);
12
+ for(var key in optionalDependencies){
13
+ var depPath = path.join(installDir, key);
14
+ if (key.indexOf(depKey) < 0 || existsSync(depPath)) continue;
15
+ try {
16
+ call()({
17
+ version: version,
18
+ callbacks: true
19
+ }, worker, key, optionalDependencies[key]);
20
+ } catch (err) {
21
+ console.log("Failed to install ".concat(key, "@").concat(optionalDependencies[key], ". Error: ").concat(err.message));
22
+ }
23
+ }
24
+ /* 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":["installBindings.cts"],"sourcesContent":["const path = require('path');\nconst existsSync = require('./existsSync.cjs');\nconst lazy = require('../lazy.cjs');\n\nconst major = +process.versions.node.split('.')[0];\nconst version = major >= 14 ? 'local' : 'lts';\nconst worker = path.resolve(path.dirname(__dirname), 'workers', `installBinding${path.extname(__filename)}`);\nconst call = lazy('node-version-call');\n\nconst installDir = path.dirname(path.dirname(path.dirname(require.resolve('@swc/core/package.json'))));\nconst { optionalDependencies } = require('@swc/core/package.json');\nconst depKey = `${process.platform}-${process.arch}`;\n\nfor (const key in optionalDependencies) {\n const depPath = path.join(installDir, key);\n if (key.indexOf(depKey) < 0 || existsSync(depPath)) continue;\n\n try {\n call()({ version, callbacks: true }, worker, key, optionalDependencies[key]);\n } catch (err) {\n console.log(`Failed to install ${key}@${optionalDependencies[key]}. Error: ${err.message}`);\n }\n}\n"],"names":["path","require","existsSync","lazy","major","process","versions","node","split","version","worker","resolve","dirname","__dirname","extname","__filename","call","installDir","optionalDependencies","depKey","platform","arch","key","depPath","join","indexOf","callbacks","err","console","log","message"],"mappings":";AAAA,IAAMA,OAAOC,QAAQ;AACrB,IAAMC,aAAaD,QAAQ;AAC3B,IAAME,OAAOF,QAAQ;AAErB,IAAMG,QAAQ,CAACC,QAAQC,QAAQ,CAACC,IAAI,CAACC,KAAK,CAAC,IAAI,CAAC,EAAE;AAClD,IAAMC,UAAUL,SAAS,KAAK,UAAU;AACxC,IAAMM,SAASV,KAAKW,OAAO,CAACX,KAAKY,OAAO,CAACC,YAAY,WAAW,AAAC,iBAAyC,OAAzBb,KAAKc,OAAO,CAACC;AAC9F,IAAMC,OAAOb,KAAK;AAElB,IAAMc,aAAajB,KAAKY,OAAO,CAACZ,KAAKY,OAAO,CAACZ,KAAKY,OAAO,CAACX,QAAQU,OAAO,CAAC;AAC1E,IAAM,AAAEO,uBAAyBjB,QAAQ,0BAAjCiB;AACR,IAAMC,SAAS,AAAC,GAAsBd,OAApBA,QAAQe,QAAQ,EAAC,KAAgB,OAAbf,QAAQgB,IAAI;AAElD,IAAK,IAAMC,OAAOJ,qBAAsB;IACtC,IAAMK,UAAUvB,KAAKwB,IAAI,CAACP,YAAYK;IACtC,IAAIA,IAAIG,OAAO,CAACN,UAAU,KAAKjB,WAAWqB,UAAU;IAEpD,IAAI;QACFP,OAAO;YAAEP,SAAAA;YAASiB,WAAW;QAAK,GAAGhB,QAAQY,KAAKJ,oBAAoB,CAACI,IAAI;IAC7E,EAAE,OAAOK,KAAK;QACZC,QAAQC,GAAG,CAAC,AAAC,qBAA2BX,OAAPI,KAAI,KAAwCK,OAArCT,oBAAoB,CAACI,IAAI,EAAC,aAAuB,OAAZK,IAAIG,OAAO;IAC1F;AACF"}
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ module.exports = process;
3
+ /* 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":["process.cts"],"sourcesContent":["module.exports = process;\n"],"names":["module","exports","process"],"mappings":";AAAAA,OAAOC,OAAO,GAAGC"}
@@ -18,8 +18,8 @@ Object.defineProperty(exports, /**
18
18
  var _path = /*#__PURE__*/ _interop_require_default(require("path"));
19
19
  var _fsiterator = /*#__PURE__*/ _interop_require_default(require("fs-iterator"));
20
20
  var _gettsconfigcompat = /*#__PURE__*/ _interop_require_default(require("get-tsconfig-compat"));
21
- var _createMatcher = /*#__PURE__*/ _interop_require_default(require("./createMatcher.js"));
22
- var _transformFile = /*#__PURE__*/ _interop_require_default(require("./transformFile.js"));
21
+ var _createMatcherts = /*#__PURE__*/ _interop_require_default(require("./createMatcher.js"));
22
+ var _transformFilets = /*#__PURE__*/ _interop_require_default(require("./transformFile.js"));
23
23
  function _define_property(obj, key, value) {
24
24
  if (key in obj) {
25
25
  Object.defineProperty(obj, key, {
@@ -86,16 +86,16 @@ function transformDirectoryCallback(src, dest, type, options, callback) {
86
86
  if (typeof src !== 'string') throw new Error('transformDirectory: unexpected source');
87
87
  if (typeof dest !== 'string') throw new Error('transformDirectory: unexpected destination directory');
88
88
  if (typeof type !== 'string') throw new Error('transformDirectory: unexpected type');
89
- var config = options.confg ? options.confg : _gettsconfigcompat.default.getTsconfig(src);
90
- var matcher = (0, _createMatcher.default)(config);
89
+ var tsconfig = options.tsconfig ? options.tsconfig : _gettsconfigcompat.default.getTsconfig(src);
90
+ var matcher = (0, _createMatcherts.default)(tsconfig);
91
91
  options = _object_spread_props(_object_spread({}, options), {
92
- config: config
92
+ tsconfig: tsconfig
93
93
  });
94
94
  var iterator = new _fsiterator.default(src);
95
95
  iterator.forEach(function(entry, cb) {
96
96
  if (!entry.stats.isFile()) return cb();
97
97
  if (!matcher(entry.fullPath)) return cb();
98
- (0, _transformFile.default)(entry.fullPath, _path.default.dirname(_path.default.join(dest, entry.path)), type, options, cb);
98
+ (0, _transformFilets.default)(entry.fullPath, _path.default.dirname(_path.default.join(dest, entry.path)), type, options, cb);
99
99
  }, {
100
100
  callbacks: true,
101
101
  concurrency: options.concurrency || 1024
@@ -1 +1 @@
1
- {"version":3,"sources":["transformDirectory.mjs"],"sourcesContent":["import path from 'path';\nimport Iterator from 'fs-iterator';\nimport getTS from 'get-tsconfig-compat';\n\nimport createMatcher from './createMatcher.mjs';\nimport transformFile from './transformFile.mjs';\n\nfunction transformDirectoryCallback(src, dest, type, options, callback) {\n if (typeof options === 'function') {\n callback = options;\n options = {};\n }\n options = options || {};\n\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 const config = options.confg ? options.confg : getTS.getTsconfig(src);\n const matcher = createMatcher(config);\n\n options = { ...options, config };\n const iterator = new Iterator(src);\n iterator.forEach(\n (entry, cb) => {\n if (!entry.stats.isFile()) return cb();\n if (!matcher(entry.fullPath)) return cb();\n transformFile(entry.fullPath, path.dirname(path.join(dest, entry.path)), type, options, cb);\n },\n { callbacks: true, concurrency: options.concurrency || 1024 },\n callback\n );\n}\n\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, dest, type, options, callback) {\n if (typeof options === 'function') {\n callback = options;\n options = null;\n }\n options = options || {};\n\n if (typeof callback === 'function') return transformDirectoryCallback(src, dest, type, options, callback);\n return new Promise((resolve, reject) => {\n transformDirectoryCallback(src, dest, type, options, function compileCallback(err, result) {\n err ? reject(err) : resolve(result);\n });\n });\n}\n"],"names":["transformDirectory","transformDirectoryCallback","src","dest","type","options","callback","Error","config","confg","getTS","getTsconfig","matcher","createMatcher","iterator","Iterator","forEach","entry","cb","stats","isFile","fullPath","transformFile","path","dirname","join","callbacks","concurrency","Promise","resolve","reject","compileCallback","err","result"],"mappings":";;;;+BAkCA;;;;;;;CAOC,GACD;;;eAAwBA;;;2DA1CP;iEACI;wEACH;oEAEQ;oEACA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAE1B,SAASC,2BAA2BC,GAAG,EAAEC,IAAI,EAAEC,IAAI,EAAEC,OAAO,EAAEC,QAAQ;IACpE,IAAI,OAAOD,YAAY,YAAY;QACjCC,WAAWD;QACXA,UAAU,CAAC;IACb;IACAA,UAAUA,WAAW,CAAC;IAEtB,IAAI,OAAOH,QAAQ,UAAU,MAAM,IAAIK,MAAM;IAC7C,IAAI,OAAOJ,SAAS,UAAU,MAAM,IAAII,MAAM;IAC9C,IAAI,OAAOH,SAAS,UAAU,MAAM,IAAIG,MAAM;IAE9C,IAAMC,SAASH,QAAQI,KAAK,GAAGJ,QAAQI,KAAK,GAAGC,0BAAK,CAACC,WAAW,CAACT;IACjE,IAAMU,UAAUC,IAAAA,sBAAa,EAACL;IAE9BH,UAAU,wCAAKA;QAASG,QAAAA;;IACxB,IAAMM,WAAW,IAAIC,mBAAQ,CAACb;IAC9BY,SAASE,OAAO,CACd,SAACC,OAAOC;QACN,IAAI,CAACD,MAAME,KAAK,CAACC,MAAM,IAAI,OAAOF;QAClC,IAAI,CAACN,QAAQK,MAAMI,QAAQ,GAAG,OAAOH;QACrCI,IAAAA,sBAAa,EAACL,MAAMI,QAAQ,EAAEE,aAAI,CAACC,OAAO,CAACD,aAAI,CAACE,IAAI,CAACtB,MAAMc,MAAMM,IAAI,IAAInB,MAAMC,SAASa;IAC1F,GACA;QAAEQ,WAAW;QAAMC,aAAatB,QAAQsB,WAAW,IAAI;IAAK,GAC5DrB;AAEJ;AAUe,SAASN,mBAAmBE,GAAG,EAAEC,IAAI,EAAEC,IAAI,EAAEC,OAAO,EAAEC,QAAQ;IAC3E,IAAI,OAAOD,YAAY,YAAY;QACjCC,WAAWD;QACXA,UAAU;IACZ;IACAA,UAAUA,WAAW,CAAC;IAEtB,IAAI,OAAOC,aAAa,YAAY,OAAOL,2BAA2BC,KAAKC,MAAMC,MAAMC,SAASC;IAChG,OAAO,IAAIsB,QAAQ,SAACC,SAASC;QAC3B7B,2BAA2BC,KAAKC,MAAMC,MAAMC,SAAS,SAAS0B,gBAAgBC,GAAG,EAAEC,MAAM;YACvFD,MAAMF,OAAOE,OAAOH,QAAQI;QAC9B;IACF;AACF"}
1
+ {"version":3,"sources":["transformDirectory.ts"],"sourcesContent":["import path from 'path';\nimport Iterator from 'fs-iterator';\nimport getTS from 'get-tsconfig-compat';\n\n// @ts-ignore\nimport createMatcher from './createMatcher.ts';\n// @ts-ignore\nimport transformFile from './transformFile.ts';\n\nfunction transformDirectoryCallback(src, dest, type, options, callback) {\n if (typeof options === 'function') {\n callback = options;\n options = {};\n }\n options = options || {};\n\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 const tsconfig = options.tsconfig ? options.tsconfig : getTS.getTsconfig(src);\n const matcher = createMatcher(tsconfig);\n\n options = { ...options, tsconfig };\n const iterator = new Iterator(src);\n iterator.forEach(\n (entry, cb) => {\n if (!entry.stats.isFile()) return cb();\n if (!matcher(entry.fullPath)) return cb();\n transformFile(entry.fullPath, path.dirname(path.join(dest, entry.path)), type, options, cb);\n },\n { callbacks: true, concurrency: options.concurrency || 1024 },\n callback\n );\n}\n\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, dest, type, options, callback) {\n if (typeof options === 'function') {\n callback = options;\n options = null;\n }\n options = options || {};\n\n if (typeof callback === 'function') return transformDirectoryCallback(src, dest, type, options, callback);\n return new Promise((resolve, reject) => {\n transformDirectoryCallback(src, dest, type, options, function compileCallback(err, result) {\n err ? reject(err) : resolve(result);\n });\n });\n}\n"],"names":["transformDirectory","transformDirectoryCallback","src","dest","type","options","callback","Error","tsconfig","getTS","getTsconfig","matcher","createMatcher","iterator","Iterator","forEach","entry","cb","stats","isFile","fullPath","transformFile","path","dirname","join","callbacks","concurrency","Promise","resolve","reject","compileCallback","err","result"],"mappings":";;;;+BAoCA;;;;;;;CAOC,GACD;;;eAAwBA;;;2DA5CP;iEACI;wEACH;sEAGQ;sEAEA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAE1B,SAASC,2BAA2BC,GAAG,EAAEC,IAAI,EAAEC,IAAI,EAAEC,OAAO,EAAEC,QAAQ;IACpE,IAAI,OAAOD,YAAY,YAAY;QACjCC,WAAWD;QACXA,UAAU,CAAC;IACb;IACAA,UAAUA,WAAW,CAAC;IAEtB,IAAI,OAAOH,QAAQ,UAAU,MAAM,IAAIK,MAAM;IAC7C,IAAI,OAAOJ,SAAS,UAAU,MAAM,IAAII,MAAM;IAC9C,IAAI,OAAOH,SAAS,UAAU,MAAM,IAAIG,MAAM;IAE9C,IAAMC,WAAWH,QAAQG,QAAQ,GAAGH,QAAQG,QAAQ,GAAGC,0BAAK,CAACC,WAAW,CAACR;IACzE,IAAMS,UAAUC,IAAAA,wBAAa,EAACJ;IAE9BH,UAAU,wCAAKA;QAASG,UAAAA;;IACxB,IAAMK,WAAW,IAAIC,mBAAQ,CAACZ;IAC9BW,SAASE,OAAO,CACd,SAACC,OAAOC;QACN,IAAI,CAACD,MAAME,KAAK,CAACC,MAAM,IAAI,OAAOF;QAClC,IAAI,CAACN,QAAQK,MAAMI,QAAQ,GAAG,OAAOH;QACrCI,IAAAA,wBAAa,EAACL,MAAMI,QAAQ,EAAEE,aAAI,CAACC,OAAO,CAACD,aAAI,CAACE,IAAI,CAACrB,MAAMa,MAAMM,IAAI,IAAIlB,MAAMC,SAASY;IAC1F,GACA;QAAEQ,WAAW;QAAMC,aAAarB,QAAQqB,WAAW,IAAI;IAAK,GAC5DpB;AAEJ;AAUe,SAASN,mBAAmBE,GAAG,EAAEC,IAAI,EAAEC,IAAI,EAAEC,OAAO,EAAEC,QAAQ;IAC3E,IAAI,OAAOD,YAAY,YAAY;QACjCC,WAAWD;QACXA,UAAU;IACZ;IACAA,UAAUA,WAAW,CAAC;IAEtB,IAAI,OAAOC,aAAa,YAAY,OAAOL,2BAA2BC,KAAKC,MAAMC,MAAMC,SAASC;IAChG,OAAO,IAAIqB,QAAQ,SAACC,SAASC;QAC3B5B,2BAA2BC,KAAKC,MAAMC,MAAMC,SAAS,SAASyB,gBAAgBC,GAAG,EAAEC,MAAM;YACvFD,MAAMF,OAAOE,OAAOH,QAAQI;QAC9B;IACF;AACF"}
@@ -21,8 +21,7 @@ var _calloncefn = /*#__PURE__*/ _interop_require_default(require("call-once-fn")
21
21
  var _gettsconfigcompat = /*#__PURE__*/ _interop_require_default(require("get-tsconfig-compat"));
22
22
  var _mkdirp = /*#__PURE__*/ _interop_require_default(require("mkdirp"));
23
23
  var _queuecb = /*#__PURE__*/ _interop_require_default(require("queue-cb"));
24
- var _regexDependencies = /*#__PURE__*/ _interop_require_default(require("./lib/regexDependencies.js"));
25
- var _transformSynccjs = /*#__PURE__*/ _interop_require_default(require("./transformSync.js"));
24
+ var _transformSyncts = /*#__PURE__*/ _interop_require_default(require("./transformSync.js"));
26
25
  function _define_property(obj, key, value) {
27
26
  if (key in obj) {
28
27
  Object.defineProperty(obj, key, {
@@ -56,8 +55,10 @@ function _object_spread(target) {
56
55
  }
57
56
  return target;
58
57
  }
59
- var regexESM = (0, _regexDependencies.default)(true);
60
- var regexCJS = (0, _regexDependencies.default)();
58
+ var matchingDeps = '\\s*[\'"`]([^\'"`]+)[\'"`]\\s*';
59
+ var matchingName = '\\s*(?:[\\w${},\\s*]+)\\s*';
60
+ var regexCJS = new RegExp("(?:(?:var|const|let)".concat(matchingName, "=\\s*)?require\\(").concat(matchingDeps, "\\);?"), 'g');
61
+ var regexESM = new RegExp("".concat(regexCJS, "|import(?:").concat(matchingName, "from\\s*)?").concat(matchingDeps, ";?|export(?:").concat(matchingName, "from\\s*)?").concat(matchingDeps, ";?"), 'g');
61
62
  var importReplaceMJS = [
62
63
  '.js',
63
64
  '.ts',
@@ -115,17 +116,17 @@ function transformFileCallback(src, dest, type, options, callback) {
115
116
  if (err) return callback(err);
116
117
  callback = (0, _calloncefn.default)(callback);
117
118
  try {
118
- var config = options.confg ? options.confg : _gettsconfigcompat.default.getTsconfig(src);
119
+ var tsconfig = options.tsconfig ? options.tsconfig : _gettsconfigcompat.default.getTsconfig(src);
119
120
  // overrides for cjs
120
121
  if (type === 'cjs') {
121
- config = _object_spread({}, config);
122
- config.config = _object_spread({}, config.config || {});
123
- config.config.compilerOptions = _object_spread({}, config.config.compilerOptions || {});
124
- config.config.compilerOptions.module = 'CommonJS';
125
- config.config.compilerOptions.target = 'ES5';
122
+ tsconfig = _object_spread({}, tsconfig);
123
+ tsconfig.tsconfig = _object_spread({}, tsconfig.config || {});
124
+ tsconfig.config.compilerOptions = _object_spread({}, tsconfig.config.compilerOptions || {});
125
+ tsconfig.config.compilerOptions.module = 'CommonJS';
126
+ tsconfig.config.compilerOptions.target = 'ES5';
126
127
  }
127
128
  var basename = _path.default.basename(src);
128
- var output = (0, _transformSynccjs.default)(contents, basename, config);
129
+ var output = (0, _transformSyncts.default)(contents, basename, tsconfig);
129
130
  // infer extension and patch .mjs imports
130
131
  var ext = _path.default.extname(basename);
131
132
  if (type === 'esm') {
@@ -1 +1 @@
1
- {"version":3,"sources":["transformFile.mjs"],"sourcesContent":["import fs from 'fs';\nimport path from 'path';\nimport once from 'call-once-fn';\nimport getTS from 'get-tsconfig-compat';\nimport mkdirp from 'mkdirp';\nimport Queue from 'queue-cb';\n\nimport regexDependencies from './lib/regexDependencies.mjs';\nimport transformSync from './transformSync.cjs';\n\nconst regexESM = regexDependencies(true);\nconst regexCJS = regexDependencies();\n\nconst importReplaceMJS = ['.js', '.ts', '.tsx', '.mts', '.mjs'];\nconst importReplaceCJS = ['.cts'];\nconst requireReplaceJS = ['.mjs', '.cjs', '.ts', '.tsx', '.mts', '.cts'];\n\nfunction makeReplacements(code, regex, extensions, extension) {\n let matches = [];\n let match = regex.exec(code);\n while (match) {\n const dependency = match[1] || match[2] || match[3] || match[4];\n const ext = extensions.find((x) => dependency.slice(-x.length) === x);\n if (ext) matches.push({ ext, match, dependency });\n match = regex.exec(code);\n }\n\n matches = matches.reverse();\n for (const index in matches) {\n const match = matches[index];\n const start = match.match.index + match.match[0].indexOf(match.dependency) + match.dependency.indexOf(match.ext);\n code = code.substring(0, start) + extension + code.substring(start + match.ext.length);\n }\n return code;\n}\n\n// https://github.com/vercel/next.js/blob/20b63e13ab2631d6043277895d373aa31a1b327c/packages/next/taskfile-swc.js#L118-L125\nconst interopClientDefaultExport = \"/* 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; }\";\n\nfunction transformFileCallback(src, dest, type, options, callback) {\n if (typeof options === 'function') {\n callback = options;\n options = {};\n }\n options = options || {};\n\n if (typeof src !== 'string') throw new Error('transformFile: unexpected source');\n if (typeof dest !== 'string') throw new Error('transformFile: unexpected destination directory');\n if (typeof type !== 'string') throw new Error('transformFile: unexpected type');\n\n fs.readFile(src, 'utf8', (err, contents) => {\n if (err) return callback(err);\n callback = once(callback);\n\n try {\n let config = options.confg ? options.confg : getTS.getTsconfig(src);\n\n // overrides for cjs\n if (type === 'cjs') {\n config = { ...config };\n config.config = { ...(config.config || {}) };\n config.config.compilerOptions = { ...(config.config.compilerOptions || {}) };\n config.config.compilerOptions.module = 'CommonJS';\n config.config.compilerOptions.target = 'ES5';\n }\n\n const basename = path.basename(src);\n const output = transformSync(contents, basename, config);\n\n // infer extension and patch .mjs imports\n let ext = path.extname(basename);\n if (type === 'esm') {\n ext = importReplaceMJS.indexOf(ext) >= 0 ? '.mjs' : ext;\n output.code = makeReplacements(output.code, regexESM, importReplaceMJS, '.mjs');\n ext = importReplaceCJS.indexOf(ext) >= 0 ? '.cjs' : ext;\n output.code = makeReplacements(output.code, regexESM, importReplaceCJS, '.cjs');\n } else {\n ext = requireReplaceJS.indexOf(ext) >= 0 ? '.js' : ext;\n output.code = makeReplacements(output.code, regexCJS, requireReplaceJS, '.js');\n output.code += interopClientDefaultExport;\n }\n const destFilePath = path.join(dest, basename.replace(/\\.[^/.]+$/, '') + ext);\n\n mkdirp(path.dirname(destFilePath), () => {\n const queue = new Queue();\n queue.defer(fs.writeFile.bind(null, destFilePath, output.code, 'utf8'));\n !options.sourceMaps || queue.defer(fs.writeFile.bind(null, `${destFilePath}.map`, output.map, 'utf8'));\n queue.await(() => (err ? callback(err) : callback(null, destFilePath)));\n });\n } catch (err) {\n callback(err);\n }\n });\n}\n\n/**\n * @param {string} src The source directory to traverse.\n * @param {string} dest The output directory to write the file 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 | null, destFilePath: string) =>} [callback] Optional callback returing the path to the transformed file. Uses promise if callback not provided.\n * @returns {void | Promise<string>} Optional promise returing the path to the transformed file if callback not provided.\n */\nexport default function transformFile(src, dest, type, options, callback) {\n if (typeof options === 'function') {\n callback = options;\n options = null;\n }\n options = options || {};\n\n if (typeof callback === 'function') return transformFileCallback(src, dest, type, options, callback);\n return new Promise((resolve, reject) => {\n transformFileCallback(src, dest, type, options, function compileCallback(err, result) {\n err ? reject(err) : resolve(result);\n });\n });\n}\n"],"names":["transformFile","regexESM","regexDependencies","regexCJS","importReplaceMJS","importReplaceCJS","requireReplaceJS","makeReplacements","code","regex","extensions","extension","dependency","match","ext","find","x","slice","length","matches","push","exec","reverse","index","start","indexOf","substring","interopClientDefaultExport","transformFileCallback","src","dest","type","options","callback","Error","fs","readFile","err","contents","once","config","confg","getTS","getTsconfig","compilerOptions","module","target","basename","path","output","transformSync","extname","destFilePath","join","replace","mkdirp","dirname","queue","Queue","defer","writeFile","bind","sourceMaps","map","await","Promise","resolve","reject","compileCallback","result"],"mappings":";;;;+BA+FA;;;;;;;CAOC,GACD;;;eAAwBA;;;yDAvGT;2DACE;iEACA;wEACC;6DACC;8DACD;wEAEY;uEACJ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAE1B,IAAMC,WAAWC,IAAAA,0BAAiB,EAAC;AACnC,IAAMC,WAAWD,IAAAA,0BAAiB;AAElC,IAAME,mBAAmB;IAAC;IAAO;IAAO;IAAQ;IAAQ;CAAO;AAC/D,IAAMC,mBAAmB;IAAC;CAAO;AACjC,IAAMC,mBAAmB;IAAC;IAAQ;IAAQ;IAAO;IAAQ;IAAQ;CAAO;AAExE,SAASC,iBAAiBC,IAAI,EAAEC,KAAK,EAAEC,UAAU,EAAEC,SAAS;;QAIxD,IAAMC,aAAaC,KAAK,CAAC,EAAE,IAAIA,KAAK,CAAC,EAAE,IAAIA,KAAK,CAAC,EAAE,IAAI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BACjC,IAAMK,QAAQ,IAAIC,gBAAK;gBACvBD,MAAME,KAAK,CAACxB,WAAE,CAACyB,SAAS,CAACC,IAAI,CAAC,MAAMT,cAAcH,OAAOzC,IAAI,EAAE;gBAC/D,CAACwB,QAAQ8B,UAAU,IAAIL,MAAME,KAAK,CAACxB,WAAE,CAACyB,SAAS,CAACC,IAAI,CAAC,MAAM,AAAC,GAAe,OAAbT,cAAa,SAAOH,OAAOc,GAAG,EAAE;gBAC9FN,MAAMO,KAAK,CAAC;2BAAO3B,MAAMJ,SAASI,OAAOJ,SAAS,MAAMmB;;YAC1D;QACF,EAAE,OAAOf,KAAK;YACZJ,SAASI;QACX;IACF;AACF;AAUe,SAASrC,cAAc6B,GAAG,EAAEC,IAAI,EAAEC,IAAI,EAAEC,OAAO,EAAEC,QAAQ;IACtE,IAAI,OAAOD,YAAY,YAAY;QACjCC,WAAWD;QACXA,UAAU;IACZ;IACAA,UAAUA,WAAW,CAAC;IAEtB,IAAI,OAAOC,aAAa,YAAY,OAAOL,sBAAsBC,KAAKC,MAAMC,MAAMC,SAASC;IAC3F,OAAO,IAAIgC,QAAQ,SAACC,SAASC;QAC3BvC,sBAAsBC,KAAKC,MAAMC,MAAMC,SAAS,SAASoC,gBAAgB/B,GAAG,EAAEgC,MAAM;YAClFhC,MAAM8B,OAAO9B,OAAO6B,QAAQG;QAC9B;IACF;AACF"}
1
+ {"version":3,"sources":["transformFile.ts"],"sourcesContent":["import fs from 'fs';\nimport path from 'path';\nimport once from 'call-once-fn';\nimport getTS from 'get-tsconfig-compat';\nimport mkdirp from 'mkdirp';\nimport Queue from 'queue-cb';\n\n// @ts-ignore\nimport transformSync from './transformSync.ts';\n\nconst matchingDeps = '\\\\s*[\\'\"`]([^\\'\"`]+)[\\'\"`]\\\\s*';\nconst matchingName = '\\\\s*(?:[\\\\w${},\\\\s*]+)\\\\s*';\nconst regexCJS = new RegExp(`(?:(?:var|const|let)${matchingName}=\\\\s*)?require\\\\(${matchingDeps}\\\\);?`, 'g');\nconst regexESM = new RegExp(`${regexCJS}|import(?:${matchingName}from\\\\s*)?${matchingDeps};?|export(?:${matchingName}from\\\\s*)?${matchingDeps};?`, 'g');\n\nconst importReplaceMJS = ['.js', '.ts', '.tsx', '.mts', '.mjs'];\nconst importReplaceCJS = ['.cts'];\nconst requireReplaceJS = ['.mjs', '.cjs', '.ts', '.tsx', '.mts', '.cts'];\n\nfunction makeReplacements(code, regex, extensions, extension) {\n let matches = [];\n let match = regex.exec(code);\n while (match) {\n const dependency = match[1] || match[2] || match[3] || match[4];\n const ext = extensions.find((x) => dependency.slice(-x.length) === x);\n if (ext) matches.push({ ext, match, dependency });\n match = regex.exec(code);\n }\n\n matches = matches.reverse();\n for (const index in matches) {\n const match = matches[index];\n const start = match.match.index + match.match[0].indexOf(match.dependency) + match.dependency.indexOf(match.ext);\n code = code.substring(0, start) + extension + code.substring(start + match.ext.length);\n }\n return code;\n}\n\n// https://github.com/vercel/next.js/blob/20b63e13ab2631d6043277895d373aa31a1b327c/packages/next/taskfile-swc.js#L118-L125\nconst interopClientDefaultExport = \"/* 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; }\";\n\nfunction transformFileCallback(src, dest, type, options, callback) {\n if (typeof options === 'function') {\n callback = options;\n options = {};\n }\n options = options || {};\n\n if (typeof src !== 'string') throw new Error('transformFile: unexpected source');\n if (typeof dest !== 'string') throw new Error('transformFile: unexpected destination directory');\n if (typeof type !== 'string') throw new Error('transformFile: unexpected type');\n\n fs.readFile(src, 'utf8', (err, contents) => {\n if (err) return callback(err);\n callback = once(callback);\n\n try {\n let tsconfig = options.tsconfig ? options.tsconfig : getTS.getTsconfig(src);\n\n // overrides for cjs\n if (type === 'cjs') {\n tsconfig = { ...tsconfig };\n tsconfig.tsconfig = { ...(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 basename = path.basename(src);\n const output = transformSync(contents, basename, tsconfig);\n\n // infer extension and patch .mjs imports\n let ext = path.extname(basename);\n if (type === 'esm') {\n ext = importReplaceMJS.indexOf(ext) >= 0 ? '.mjs' : ext;\n output.code = makeReplacements(output.code, regexESM, importReplaceMJS, '.mjs');\n ext = importReplaceCJS.indexOf(ext) >= 0 ? '.cjs' : ext;\n output.code = makeReplacements(output.code, regexESM, importReplaceCJS, '.cjs');\n } else {\n ext = requireReplaceJS.indexOf(ext) >= 0 ? '.js' : ext;\n output.code = makeReplacements(output.code, regexCJS, requireReplaceJS, '.js');\n output.code += interopClientDefaultExport;\n }\n const destFilePath = path.join(dest, basename.replace(/\\.[^/.]+$/, '') + ext);\n\n mkdirp(path.dirname(destFilePath), () => {\n const queue = new Queue();\n queue.defer(fs.writeFile.bind(null, destFilePath, output.code, 'utf8'));\n !options.sourceMaps || queue.defer(fs.writeFile.bind(null, `${destFilePath}.map`, output.map, 'utf8'));\n queue.await(() => (err ? callback(err) : callback(null, destFilePath)));\n });\n } catch (err) {\n callback(err);\n }\n });\n}\n\n/**\n * @param {string} src The source directory to traverse.\n * @param {string} dest The output directory to write the file 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 | null, destFilePath: string) =>} [callback] Optional callback returing the path to the transformed file. Uses promise if callback not provided.\n * @returns {void | Promise<string>} Optional promise returing the path to the transformed file if callback not provided.\n */\nexport default function transformFile(src, dest, type, options, callback) {\n if (typeof options === 'function') {\n callback = options;\n options = null;\n }\n options = options || {};\n\n if (typeof callback === 'function') return transformFileCallback(src, dest, type, options, callback);\n return new Promise((resolve, reject) => {\n transformFileCallback(src, dest, type, options, function compileCallback(err, result) {\n err ? reject(err) : resolve(result);\n });\n });\n}\n"],"names":["transformFile","matchingDeps","matchingName","regexCJS","RegExp","regexESM","importReplaceMJS","importReplaceCJS","requireReplaceJS","makeReplacements","code","regex","extensions","extension","dependency","match","ext","find","x","slice","length","matches","push","exec","reverse","index","start","indexOf","substring","interopClientDefaultExport","transformFileCallback","src","dest","type","options","callback","Error","fs","readFile","err","contents","once","tsconfig","getTS","getTsconfig","config","compilerOptions","module","target","basename","path","output","transformSync","extname","destFilePath","join","replace","mkdirp","dirname","queue","Queue","defer","writeFile","bind","sourceMaps","map","await","Promise","resolve","reject","compileCallback","result"],"mappings":";;;;+BAiGA;;;;;;;CAOC,GACD;;;eAAwBA;;;yDAzGT;2DACE;iEACA;wEACC;6DACC;8DACD;sEAGQ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAE1B,IAAMC,eAAe;AACrB,IAAMC,eAAe;AACrB,IAAMC,WAAW,IAAIC,OAAO,AAAC,uBAAsDH,OAAhCC,cAAa,qBAAgC,OAAbD,cAAa,UAAQ;AACxG,IAAMI,WAAW,IAAID,OAAO,AAAC,GAAuBF,OAArBC,UAAS,cAAqCF,OAAzBC,cAAa,cAAuCA,OAA3BD,cAAa,gBAAuCA,OAAzBC,cAAa,cAAyB,OAAbD,cAAa,OAAK;AAEnJ,IAAMK,mBAAmB;IAAC;IAAO;IAAO;IAAQ;IAAQ;CAAO;AAC/D,IAAMC,mBAAmB;IAAC;CAAO;AACjC,IAAMC,mBAAmB;IAAC;IAAQ;IAAQ;IAAO;IAAQ;IAAQ;CAAO;AAExE,SAASC,iBAAiBC,IAAI,EAAEC,KAAK,EAAEC,UAAU,EAAEC,SAAS;;QAIxD,IAAMC,aAAaC,KAAK,CAAC,EAAE,IAAIA,KAAK,CAAC,EAAE,IAAIA,KAAK,CAAC,EAAE,IAAIA,KAAK,CAAC,EAAE;QAC/D,IAAMC,MAAMJ,WAAWK,IAAI,CAAC,SAACC;mBAAMJ,WAAWK,KAAK,CAAC,CAACD,EAAEE,MAAM,MAAMF;;QACnE,IAAIF,KAAKK,QAAQC,IAAI,CAAC;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UAAU,IAAIL,MAAME,KAAK,CAACxB,WAAE,CAACyB,SAAS,CAACC,IAAI,CAAC,MAAM,AAAC,GAAe,OAAbT,cAAa,SAAOH,OAAOc,GAAG,EAAE;gBAC9FN,MAAMO,KAAK,CAAC;2BAAO3B,MAAMJ,SAASI,OAAOJ,SAAS,MAAMmB;;YAC1D;QACF,EAAE,OAAOf,KAAK;YACZJ,SAASI;QACX;IACF;AACF;AAUe,SAASvC,cAAc+B,GAAG,EAAEC,IAAI,EAAEC,IAAI,EAAEC,OAAO,EAAEC,QAAQ;IACtE,IAAI,OAAOD,YAAY,YAAY;QACjCC,WAAWD;QACXA,UAAU;IACZ;IACAA,UAAUA,WAAW,CAAC;IAEtB,IAAI,OAAOC,aAAa,YAAY,OAAOL,sBAAsBC,KAAKC,MAAMC,MAAMC,SAASC;IAC3F,OAAO,IAAIgC,QAAQ,SAACC,SAASC;QAC3BvC,sBAAsBC,KAAKC,MAAMC,MAAMC,SAAS,SAASoC,gBAAgB/B,GAAG,EAAEgC,MAAM;YAClFhC,MAAM8B,OAAO9B,OAAO6B,QAAQG;QAC9B;IACF;AACF"}
@@ -1,15 +1,32 @@
1
1
  "use strict";
2
- var path = require('path');
3
- var major = +process.versions.node.split('.')[0];
4
- var version = major >= 14 ? 'local' : 'lts';
5
- var worker = path.resolve(__dirname, 'workers', "transformSync".concat(path.extname(__filename)));
6
- var call = null; // break dependencies
7
- /**
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ Object.defineProperty(exports, /**
8
6
  * @param {string} contents The file contents.
9
7
  * @param {string} fileName The filename.
10
8
  * @returns {{ code: string, map?: string }} Returns object with the transformed code and source map if option sourceMaps was provided.
11
- */ module.exports = function transformSync(contents, fileName, config) {
12
- if (!call) call = require('node-version-call'); // break dependencies
13
- return call(version, worker, contents, fileName, config);
14
- };
9
+ */ "default", {
10
+ enumerable: true,
11
+ get: function() {
12
+ return transformSync;
13
+ }
14
+ });
15
+ var _path = /*#__PURE__*/ _interop_require_default(require("path"));
16
+ var _url = /*#__PURE__*/ _interop_require_default(require("url"));
17
+ var _lazycts = /*#__PURE__*/ _interop_require_default(require("./lazy.js"));
18
+ var _processcts = /*#__PURE__*/ _interop_require_default(require("./process.js"));
19
+ function _interop_require_default(obj) {
20
+ return obj && obj.__esModule ? obj : {
21
+ default: obj
22
+ };
23
+ }
24
+ var major = +_processcts.default.versions.node.split('.')[0];
25
+ var version = major >= 14 ? 'local' : 'lts';
26
+ var filename = typeof __filename !== 'undefined' ? __filename : _url.default.fileURLToPath(require("url").pathToFileURL(__filename).toString());
27
+ var worker = _path.default.resolve(_path.default.dirname(filename), 'workers', "transformSync".concat(_path.default.extname(filename) === '.mjs' ? '.cjs' : '.js'));
28
+ var call = (0, _lazycts.default)('node-version-call');
29
+ function transformSync(contents, fileName, config) {
30
+ return call()(version, worker, contents, fileName, config);
31
+ }
15
32
  /* 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":["transformSync.cjs"],"sourcesContent":["const path = require('path');\n\nconst major = +process.versions.node.split('.')[0];\nconst version = major >= 14 ? 'local' : 'lts';\nconst worker = path.resolve(__dirname, 'workers', `transformSync${path.extname(__filename)}`);\n\nlet call = null; // break dependencies\n\n/**\n * @param {string} contents The file contents.\n * @param {string} fileName The filename.\n * @returns {{ code: string, map?: string }} Returns object with the transformed code and source map if option sourceMaps was provided.\n */\nmodule.exports = function transformSync(contents, fileName, config) {\n if (!call) call = require('node-version-call'); // break dependencies\n\n return call(version, worker, contents, fileName, config);\n};\n"],"names":["path","require","major","process","versions","node","split","version","worker","resolve","__dirname","extname","__filename","call","module","exports","transformSync","contents","fileName","config"],"mappings":";AAAA,IAAMA,OAAOC,QAAQ;AAErB,IAAMC,QAAQ,CAACC,QAAQC,QAAQ,CAACC,IAAI,CAACC,KAAK,CAAC,IAAI,CAAC,EAAE;AAClD,IAAMC,UAAUL,SAAS,KAAK,UAAU;AACxC,IAAMM,SAASR,KAAKS,OAAO,CAACC,WAAW,WAAW,AAAC,gBAAwC,OAAzBV,KAAKW,OAAO,CAACC;AAE/E,IAAIC,OAAO,MAAM,qBAAqB;AAEtC;;;;CAIC,GACDC,OAAOC,OAAO,GAAG,SAASC,cAAcC,QAAQ,EAAEC,QAAQ,EAAEC,MAAM;IAChE,IAAI,CAACN,MAAMA,OAAOZ,QAAQ,sBAAsB,qBAAqB;IAErE,OAAOY,KAAKN,SAASC,QAAQS,UAAUC,UAAUC;AACnD"}
1
+ {"version":3,"sources":["transformSync.ts"],"sourcesContent":["import path from 'path';\nimport url from 'url';\n// @ts-ignore\nimport lazy from './lazy.cts';\n// @ts-ignore\nimport process from './process.cts';\n\nconst major = +process.versions.node.split('.')[0];\nconst version = major >= 14 ? 'local' : 'lts';\nconst filename = typeof __filename !== 'undefined' ? __filename : url.fileURLToPath(import.meta.url);\nconst worker = path.resolve(path.dirname(filename), 'workers', `transformSync${path.extname(filename) === '.mjs' ? '.cjs' : '.js'}`);\nconst call = lazy('node-version-call');\n\n/**\n * @param {string} contents The file contents.\n * @param {string} fileName The filename.\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, fileName, config) {\n return call()(version, worker, contents, fileName, config);\n}\n"],"names":["transformSync","major","process","versions","node","split","version","filename","__filename","url","fileURLToPath","worker","path","resolve","dirname","extname","call","lazy","contents","fileName","config"],"mappings":";;;;+BAaA;;;;CAIC,GACD;;;eAAwBA;;;2DAlBP;0DACD;8DAEC;iEAEG;;;;;;AAEpB,IAAMC,QAAQ,CAACC,mBAAO,CAACC,QAAQ,CAACC,IAAI,CAACC,KAAK,CAAC,IAAI,CAAC,EAAE;AAClD,IAAMC,UAAUL,SAAS,KAAK,UAAU;AACxC,IAAMM,WAAW,OAAOC,eAAe,cAAcA,aAAaC,YAAG,CAACC,aAAa,CAAC;AACpF,IAAMC,SAASC,aAAI,CAACC,OAAO,CAACD,aAAI,CAACE,OAAO,CAACP,WAAW,WAAW,AAAC,gBAAkE,OAAnDK,aAAI,CAACG,OAAO,CAACR,cAAc,SAAS,SAAS;AAC5H,IAAMS,OAAOC,IAAAA,gBAAI,EAAC;AAOH,SAASjB,cAAckB,QAAQ,EAAEC,QAAQ,EAAEC,MAAM;IAC9D,OAAOJ,OAAOV,SAASK,QAAQO,UAAUC,UAAUC;AACrD"}
@@ -0,0 +1,73 @@
1
+ "use strict";
2
+ function _array_like_to_array(arr, len) {
3
+ if (len == null || len > arr.length) len = arr.length;
4
+ for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
5
+ return arr2;
6
+ }
7
+ function _array_without_holes(arr) {
8
+ if (Array.isArray(arr)) return _array_like_to_array(arr);
9
+ }
10
+ function _iterable_to_array(iter) {
11
+ if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
12
+ }
13
+ function _non_iterable_spread() {
14
+ throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
15
+ }
16
+ function _to_consumable_array(arr) {
17
+ return _array_without_holes(arr) || _iterable_to_array(arr) || _unsupported_iterable_to_array(arr) || _non_iterable_spread();
18
+ }
19
+ function _unsupported_iterable_to_array(o, minLen) {
20
+ if (!o) return;
21
+ if (typeof o === "string") return _array_like_to_array(o, minLen);
22
+ var n = Object.prototype.toString.call(o).slice(8, -1);
23
+ if (n === "Object" && o.constructor) n = o.constructor.name;
24
+ if (n === "Map" || n === "Set") return Array.from(n);
25
+ if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
26
+ }
27
+ var path = require('path');
28
+ var fs = require('fs');
29
+ var tmpdir = require('os').tmpdir;
30
+ var tempSuffix = require('temp-suffix');
31
+ var mkdirp = require('mkdirp');
32
+ var Queue = require('queue-cb');
33
+ var spawn = require('cross-spawn-cb');
34
+ var once = require('call-once-fn');
35
+ module.exports = function installBindings(name, version, callback) {
36
+ callback = once(callback);
37
+ try {
38
+ var tmp = path.join(tmpdir(), 'ts-swc-transform', tempSuffix());
39
+ var source = path.join.apply(null, [
40
+ tmp,
41
+ 'node_modules'
42
+ ].concat(_to_consumable_array(name.split('/'))));
43
+ var dest = path.join.apply(null, [
44
+ path.dirname(path.dirname(path.dirname(require.resolve('@swc/core/package.json'))))
45
+ ].concat(_to_consumable_array(name.split('/'))));
46
+ var queue = new Queue(1);
47
+ queue.defer(mkdirp.bind(null, tmp));
48
+ queue.defer(fs.writeFile.bind(null, path.join(tmp, 'package.json'), '{}', 'utf8'));
49
+ queue.defer(function(cb) {
50
+ // remove NODE_OPTIONS from ts-dev-stack
51
+ // biome-ignore lint/performance/noDelete: <explanation>
52
+ delete process.env.NODE_OPTIONS;
53
+ spawn('npm', [
54
+ 'install',
55
+ "".concat(name, "@").concat(version)
56
+ ], {
57
+ cwd: tmp
58
+ }, cb);
59
+ });
60
+ queue.defer(fs.rename.bind(null, source, dest));
61
+ queue.await(function(err) {
62
+ fs.rm(tmp, {
63
+ recursive: true,
64
+ force: true
65
+ }, function() {
66
+ return callback(err);
67
+ });
68
+ });
69
+ } catch (err) {
70
+ return callback(err);
71
+ }
72
+ };
73
+ /* 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":["installBinding.cts"],"sourcesContent":["const path = require('path');\nconst fs = require('fs');\nconst { tmpdir } = require('os');\nconst tempSuffix = require('temp-suffix');\nconst mkdirp = require('mkdirp');\n\nconst Queue = require('queue-cb');\nconst spawn = require('cross-spawn-cb');\nconst once = require('call-once-fn');\n\nmodule.exports = function installBindings(name, version, callback) {\n callback = once(callback);\n try {\n const tmp = path.join(tmpdir(), 'ts-swc-transform', tempSuffix());\n const source = path.join.apply(null, [tmp, 'node_modules', ...name.split('/')]);\n const dest = path.join.apply(null, [path.dirname(path.dirname(path.dirname(require.resolve('@swc/core/package.json')))), ...name.split('/')]);\n\n const queue = new Queue(1);\n queue.defer(mkdirp.bind(null, tmp));\n queue.defer(fs.writeFile.bind(null, path.join(tmp, 'package.json'), '{}', 'utf8'));\n queue.defer((cb) => {\n // remove NODE_OPTIONS from ts-dev-stack\n // biome-ignore lint/performance/noDelete: <explanation>\n delete process.env.NODE_OPTIONS;\n spawn('npm', ['install', `${name}@${version}`], { cwd: tmp }, cb);\n });\n queue.defer(fs.rename.bind(null, source, dest));\n queue.await((err) => {\n fs.rm(tmp, { recursive: true, force: true }, () => callback(err));\n });\n } catch (err) {\n return callback(err);\n }\n};\n"],"names":["path","require","fs","tmpdir","tempSuffix","mkdirp","Queue","spawn","once","module","exports","installBindings","name","version","callback","tmp","join","source","apply","split","dest","dirname","resolve","queue","defer","bind","writeFile","cb","process","env","NODE_OPTIONS","cwd","rename","await","err","rm","recursive","force"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,IAAMA,OAAOC,QAAQ;AACrB,IAAMC,KAAKD,QAAQ;AACnB,IAAM,AAAEE,SAAWF,QAAQ,MAAnBE;AACR,IAAMC,aAAaH,QAAQ;AAC3B,IAAMI,SAASJ,QAAQ;AAEvB,IAAMK,QAAQL,QAAQ;AACtB,IAAMM,QAAQN,QAAQ;AACtB,IAAMO,OAAOP,QAAQ;AAErBQ,OAAOC,OAAO,GAAG,SAASC,gBAAgBC,IAAI,EAAEC,OAAO,EAAEC,QAAQ;IAC/DA,WAAWN,KAAKM;IAChB,IAAI;QACF,IAAMC,MAAMf,KAAKgB,IAAI,CAACb,UAAU,oBAAoBC;QACpD,IAAMa,SAASjB,KAAKgB,IAAI,CAACE,KAAK,CAAC,MAAM;YAACH;YAAK;SAAmC,CAAzC,OAAsB,qBAAGH,KAAKO,KAAK,CAAC;QACzE,IAAMC,OAAOpB,KAAKgB,IAAI,CAACE,KAAK,CAAC,MAAM;YAAClB,KAAKqB,OAAO,CAACrB,KAAKqB,OAAO,CAACrB,KAAKqB,OAAO,CAACpB,QAAQqB,OAAO,CAAC;SAAiD,CAAzG,OAAsF,qBAAGV,KAAKO,KAAK,CAAC;QAEvI,IAAMI,QAAQ,IAAIjB,MAAM;QACxBiB,MAAMC,KAAK,CAACnB,OAAOoB,IAAI,CAAC,MAAMV;QAC9BQ,MAAMC,KAAK,CAACtB,GAAGwB,SAAS,CAACD,IAAI,CAAC,MAAMzB,KAAKgB,IAAI,CAACD,KAAK,iBAAiB,MAAM;QAC1EQ,MAAMC,KAAK,CAAC,SAACG;YACX,wCAAwC;YACxC,wDAAwD;YACxD,OAAOC,QAAQC,GAAG,CAACC,YAAY;YAC/BvB,MAAM,OAAO;gBAAC;gBAAY,GAAUM,OAARD,MAAK,KAAW,OAARC;aAAU,EAAE;gBAAEkB,KAAKhB;YAAI,GAAGY;QAChE;QACAJ,MAAMC,KAAK,CAACtB,GAAG8B,MAAM,CAACP,IAAI,CAAC,MAAMR,QAAQG;QACzCG,MAAMU,KAAK,CAAC,SAACC;YACXhC,GAAGiC,EAAE,CAACpB,KAAK;gBAAEqB,WAAW;gBAAMC,OAAO;YAAK,GAAG;uBAAMvB,SAASoB;;QAC9D;IACF,EAAE,OAAOA,KAAK;QACZ,OAAOpB,SAASoB;IAClB;AACF"}
@@ -1,6 +1,12 @@
1
1
  "use strict";
2
2
  var path = require('path');
3
- var swc = require('@swc/core');
3
+ var swc;
4
+ try {
5
+ swc = require('@swc/core');
6
+ } catch (_) {
7
+ require('../lib/installBindings.js');
8
+ swc = require('@swc/core');
9
+ }
4
10
  var ts = require('typescript');
5
11
  var swcTranspiler = require('ts-node/transpilers/swc');
6
12
  module.exports = function transformSync(contents, fileName, config) {
@@ -1 +1 @@
1
- {"version":3,"sources":["transformSync.cjs"],"sourcesContent":["const path = require('path');\nconst swc = require('@swc/core');\nconst ts = require('typescript');\nconst swcTranspiler = require('ts-node/transpilers/swc');\n\nmodule.exports = function transformSync(contents, fileName, config) {\n const parsed = ts.parseJsonConfigFileContent(config.config, ts.sys, path.dirname(config.path));\n const transpile = swcTranspiler.create({ swc: swc, service: { config: { options: parsed.options } } });\n const res = transpile.transpile(contents, { fileName: fileName });\n return { code: res.outputText, map: res.sourceMapText };\n};\n"],"names":["path","require","swc","ts","swcTranspiler","module","exports","transformSync","contents","fileName","config","parsed","parseJsonConfigFileContent","sys","dirname","transpile","create","service","options","res","code","outputText","map","sourceMapText"],"mappings":";AAAA,IAAMA,OAAOC,QAAQ;AACrB,IAAMC,MAAMD,QAAQ;AACpB,IAAME,KAAKF,QAAQ;AACnB,IAAMG,gBAAgBH,QAAQ;AAE9BI,OAAOC,OAAO,GAAG,SAASC,cAAcC,QAAQ,EAAEC,QAAQ,EAAEC,MAAM;IAChE,IAAMC,SAASR,GAAGS,0BAA0B,CAACF,OAAOA,MAAM,EAAEP,GAAGU,GAAG,EAAEb,KAAKc,OAAO,CAACJ,OAAOV,IAAI;IAC5F,IAAMe,YAAYX,cAAcY,MAAM,CAAC;QAAEd,KAAKA;QAAKe,SAAS;YAAEP,QAAQ;gBAAEQ,SAASP,OAAOO,OAAO;YAAC;QAAE;IAAE;IACpG,IAAMC,MAAMJ,UAAUA,SAAS,CAACP,UAAU;QAAEC,UAAUA;IAAS;IAC/D,OAAO;QAAEW,MAAMD,IAAIE,UAAU;QAAEC,KAAKH,IAAII,aAAa;IAAC;AACxD"}
1
+ {"version":3,"sources":["transformSync.cts"],"sourcesContent":["const path = require('path');\nlet swc: string;\ntry {\n swc = require('@swc/core');\n} catch (_) {\n require('../lib/installBindings.cjs');\n swc = require('@swc/core');\n}\nconst ts = require('typescript');\nconst swcTranspiler = require('ts-node/transpilers/swc');\n\nmodule.exports = function transformSync(contents, fileName, config) {\n const parsed = ts.parseJsonConfigFileContent(config.config, ts.sys, path.dirname(config.path));\n const transpile = swcTranspiler.create({ swc: swc, service: { config: { options: parsed.options } } });\n const res = transpile.transpile(contents, { fileName: fileName });\n return { code: res.outputText, map: res.sourceMapText };\n};\n"],"names":["path","require","swc","_","ts","swcTranspiler","module","exports","transformSync","contents","fileName","config","parsed","parseJsonConfigFileContent","sys","dirname","transpile","create","service","options","res","code","outputText","map","sourceMapText"],"mappings":";AAAA,IAAMA,OAAOC,QAAQ;AACrB,IAAIC;AACJ,IAAI;IACFA,MAAMD,QAAQ;AAChB,EAAE,OAAOE,GAAG;IACVF,QAAQ;IACRC,MAAMD,QAAQ;AAChB;AACA,IAAMG,KAAKH,QAAQ;AACnB,IAAMI,gBAAgBJ,QAAQ;AAE9BK,OAAOC,OAAO,GAAG,SAASC,cAAcC,QAAQ,EAAEC,QAAQ,EAAEC,MAAM;IAChE,IAAMC,SAASR,GAAGS,0BAA0B,CAACF,OAAOA,MAAM,EAAEP,GAAGU,GAAG,EAAEd,KAAKe,OAAO,CAACJ,OAAOX,IAAI;IAC5F,IAAMgB,YAAYX,cAAcY,MAAM,CAAC;QAAEf,KAAKA;QAAKgB,SAAS;YAAEP,QAAQ;gBAAEQ,SAASP,OAAOO,OAAO;YAAC;QAAE;IAAE;IACpG,IAAMC,MAAMJ,UAAUA,SAAS,CAACP,UAAU;QAAEC,UAAUA;IAAS;IAC/D,OAAO;QAAEW,MAAMD,IAAIE,UAAU;QAAEC,KAAKH,IAAII,aAAa;IAAC;AACxD"}
@@ -1,13 +1,13 @@
1
1
  import minimatch from 'minimatch';
2
2
  import path from 'path-posix';
3
- import slash from 'slash';
3
+ import unixify from 'unixify';
4
4
  /**
5
5
  * @param {{path: string, config: Object}} config The path to the loaded TS config and typescript config.
6
6
  * @returns {(filePath:string) => boolean} The function to test for typescript files being included or excluded
7
7
  */ export default function createMatcher(config) {
8
- const configPath = path.dirname(slash(config.path));
8
+ const configPath = path.dirname(unixify(config.path));
9
9
  function matchFn(condition) {
10
- let pattern = slash(condition);
10
+ let pattern = unixify(condition);
11
11
  if (!path.isAbsolute(pattern) && !pattern.startsWith('*')) pattern = path.join(configPath, pattern);
12
12
  return function match(filePath) {
13
13
  return filePath.startsWith(pattern) || minimatch(filePath, pattern);
@@ -17,7 +17,7 @@ import slash from 'slash';
17
17
  const excludes = (config.config.exclude || []).map(matchFn);
18
18
  return function matcher(filePath) {
19
19
  if (filePath.endsWith('.json')) return false;
20
- filePath = slash(filePath);
20
+ filePath = unixify(filePath);
21
21
  for(let i = 0; i < excludes.length; ++i){
22
22
  if (excludes[i](filePath)) return false;
23
23
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["createMatcher.mjs"],"sourcesContent":["import minimatch from 'minimatch';\nimport path from 'path-posix';\nimport slash from 'slash';\n\n/**\n * @param {{path: string, config: Object}} config The path to the loaded TS config and typescript config.\n * @returns {(filePath:string) => boolean} The function to test for typescript files being included or excluded\n */\nexport default function createMatcher(config) {\n const configPath = path.dirname(slash(config.path));\n\n function matchFn(condition) {\n let pattern = slash(condition);\n if (!path.isAbsolute(pattern) && !pattern.startsWith('*')) pattern = path.join(configPath, pattern);\n\n return function match(filePath) {\n return filePath.startsWith(pattern) || minimatch(filePath, pattern);\n };\n }\n\n const includes = (config.config.include || []).map(matchFn);\n const excludes = (config.config.exclude || []).map(matchFn);\n\n return function matcher(filePath) {\n if (filePath.endsWith('.json')) return false;\n\n filePath = slash(filePath);\n for (let i = 0; i < excludes.length; ++i) {\n if (excludes[i](filePath)) return false;\n }\n for (let j = 0; j < includes.length; ++j) {\n if (includes[j](filePath)) return true;\n }\n return !includes.length;\n };\n}\n"],"names":["minimatch","path","slash","createMatcher","config","configPath","dirname","matchFn","condition","pattern","isAbsolute","startsWith","join","match","filePath","includes","include","map","excludes","exclude","matcher","endsWith","i","length","j"],"mappings":"AAAA,OAAOA,eAAe,YAAY;AAClC,OAAOC,UAAU,aAAa;AAC9B,OAAOC,WAAW,QAAQ;AAE1B;;;CAGC,GACD,eAAe,SAASC,cAAcC,MAAM;IAC1C,MAAMC,aAAaJ,KAAKK,OAAO,CAACJ,MAAME,OAAOH,IAAI;IAEjD,SAASM,QAAQC,SAAS;QACxB,IAAIC,UAAUP,MAAMM;QACpB,IAAI,CAACP,KAAKS,UAAU,CAACD,YAAY,CAACA,QAAQE,UAAU,CAAC,MAAMF,UAAUR,KAAKW,IAAI,CAACP,YAAYI;QAE3F,OAAO,SAASI,MAAMC,QAAQ;YAC5B,OAAOA,SAASH,UAAU,CAACF,YAAYT,UAAUc,UAAUL;QAC7D;IACF;IAEA,MAAMM,WAAW,AAACX,CAAAA,OAAOA,MAAM,CAACY,OAAO,IAAI,EAAE,AAAD,EAAGC,GAAG,CAACV;IACnD,MAAMW,WAAW,AAACd,CAAAA,OAAOA,MAAM,CAACe,OAAO,IAAI,EAAE,AAAD,EAAGF,GAAG,CAACV;IAEnD,OAAO,SAASa,QAAQN,QAAQ;QAC9B,IAAIA,SAASO,QAAQ,CAAC,UAAU,OAAO;QAEvCP,WAAWZ,MAAMY;QACjB,IAAK,IAAIQ,IAAI,GAAGA,IAAIJ,SAASK,MAAM,EAAE,EAAED,EAAG;YACxC,IAAIJ,QAAQ,CAACI,EAAE,CAACR,WAAW,OAAO;QACpC;QACA,IAAK,IAAIU,IAAI,GAAGA,IAAIT,SAASQ,MAAM,EAAE,EAAEC,EAAG;YACxC,IAAIT,QAAQ,CAACS,EAAE,CAACV,WAAW,OAAO;QACpC;QACA,OAAO,CAACC,SAASQ,MAAM;IACzB;AACF"}
1
+ {"version":3,"sources":["createMatcher.ts"],"sourcesContent":["import minimatch from 'minimatch';\nimport path from 'path-posix';\nimport unixify from 'unixify';\n\n/**\n * @param {{path: string, config: Object}} config The path to the loaded TS config and typescript config.\n * @returns {(filePath:string) => boolean} The function to test for typescript files being included or excluded\n */\nexport default function createMatcher(config) {\n const configPath = path.dirname(unixify(config.path));\n\n function matchFn(condition) {\n let pattern = unixify(condition);\n if (!path.isAbsolute(pattern) && !pattern.startsWith('*')) pattern = path.join(configPath, pattern);\n\n return function match(filePath) {\n return filePath.startsWith(pattern) || minimatch(filePath, pattern);\n };\n }\n\n const includes = (config.config.include || []).map(matchFn);\n const excludes = (config.config.exclude || []).map(matchFn);\n\n return function matcher(filePath) {\n if (filePath.endsWith('.json')) return false;\n\n filePath = unixify(filePath);\n for (let i = 0; i < excludes.length; ++i) {\n if (excludes[i](filePath)) return false;\n }\n for (let j = 0; j < includes.length; ++j) {\n if (includes[j](filePath)) return true;\n }\n return !includes.length;\n };\n}\n"],"names":["minimatch","path","unixify","createMatcher","config","configPath","dirname","matchFn","condition","pattern","isAbsolute","startsWith","join","match","filePath","includes","include","map","excludes","exclude","matcher","endsWith","i","length","j"],"mappings":"AAAA,OAAOA,eAAe,YAAY;AAClC,OAAOC,UAAU,aAAa;AAC9B,OAAOC,aAAa,UAAU;AAE9B;;;CAGC,GACD,eAAe,SAASC,cAAcC,MAAM;IAC1C,MAAMC,aAAaJ,KAAKK,OAAO,CAACJ,QAAQE,OAAOH,IAAI;IAEnD,SAASM,QAAQC,SAAS;QACxB,IAAIC,UAAUP,QAAQM;QACtB,IAAI,CAACP,KAAKS,UAAU,CAACD,YAAY,CAACA,QAAQE,UAAU,CAAC,MAAMF,UAAUR,KAAKW,IAAI,CAACP,YAAYI;QAE3F,OAAO,SAASI,MAAMC,QAAQ;YAC5B,OAAOA,SAASH,UAAU,CAACF,YAAYT,UAAUc,UAAUL;QAC7D;IACF;IAEA,MAAMM,WAAW,AAACX,CAAAA,OAAOA,MAAM,CAACY,OAAO,IAAI,EAAE,AAAD,EAAGC,GAAG,CAACV;IACnD,MAAMW,WAAW,AAACd,CAAAA,OAAOA,MAAM,CAACe,OAAO,IAAI,EAAE,AAAD,EAAGF,GAAG,CAACV;IAEnD,OAAO,SAASa,QAAQN,QAAQ;QAC9B,IAAIA,SAASO,QAAQ,CAAC,UAAU,OAAO;QAEvCP,WAAWZ,QAAQY;QACnB,IAAK,IAAIQ,IAAI,GAAGA,IAAIJ,SAASK,MAAM,EAAE,EAAED,EAAG;YACxC,IAAIJ,QAAQ,CAACI,EAAE,CAACR,WAAW,OAAO;QACpC;QACA,IAAK,IAAIU,IAAI,GAAGA,IAAIT,SAASQ,MAAM,EAAE,EAAEC,EAAG;YACxC,IAAIT,QAAQ,CAACS,EAAE,CAACV,WAAW,OAAO;QACpC;QACA,OAAO,CAACC,SAASQ,MAAM;IACzB;AACF"}
@@ -1,4 +1,4 @@
1
1
  export { default as createMatcher } from './createMatcher.mjs';
2
2
  export { default as transformFile } from './transformFile.mjs';
3
3
  export { default as transformDirectory } from './transformDirectory.mjs';
4
- export { default as transformSync } from './transformSync.cjs';
4
+ export { default as transformSync } from './transformSync.mjs';
@@ -1 +1 @@
1
- {"version":3,"sources":["index.mjs"],"sourcesContent":["export { default as createMatcher } from './createMatcher.mjs';\nexport { default as transformFile } from './transformFile.mjs';\nexport { default as transformDirectory } from './transformDirectory.mjs';\nexport { default as transformSync } from './transformSync.cjs';\n"],"names":["default","createMatcher","transformFile","transformDirectory","transformSync"],"mappings":"AAAA,SAASA,WAAWC,aAAa,QAAQ,sBAAsB;AAC/D,SAASD,WAAWE,aAAa,QAAQ,sBAAsB;AAC/D,SAASF,WAAWG,kBAAkB,QAAQ,2BAA2B;AACzE,SAASH,WAAWI,aAAa,QAAQ,sBAAsB"}
1
+ {"version":3,"sources":["index.ts"],"sourcesContent":["export { default as createMatcher } from './createMatcher.js';\nexport { default as transformFile } from './transformFile.js';\nexport { default as transformDirectory } from './transformDirectory.js';\nexport { default as transformSync } from './transformSync.js';\n"],"names":["default","createMatcher","transformFile","transformDirectory","transformSync"],"mappings":"AAAA,SAASA,WAAWC,aAAa,QAAQ,qBAAqB;AAC9D,SAASD,WAAWE,aAAa,QAAQ,qBAAqB;AAC9D,SAASF,WAAWG,kBAAkB,QAAQ,0BAA0B;AACxE,SAASH,WAAWI,aAAa,QAAQ,qBAAqB"}
@@ -0,0 +1 @@
1
+ module.exports = require('lazy-cache')(require);
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["lazy.cts"],"sourcesContent":["module.exports = require('lazy-cache')(require);\n"],"names":["module","exports","require"],"mappings":"AAAAA,OAAOC,OAAO,GAAGC,QAAQ,cAAcA"}
@@ -0,0 +1,9 @@
1
+ const accessSync = require('fs-access-sync-compat');
2
+ module.exports = function existsSync(path) {
3
+ try {
4
+ accessSync(path);
5
+ return true;
6
+ } catch (_) {
7
+ return false;
8
+ }
9
+ };
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["existsSync.cts"],"sourcesContent":["const accessSync = require('fs-access-sync-compat');\n\nmodule.exports = function existsSync(path) {\n try {\n accessSync(path);\n return true;\n } catch (_) {\n return false;\n }\n};\n"],"names":["accessSync","require","module","exports","existsSync","path","_"],"mappings":"AAAA,MAAMA,aAAaC,QAAQ;AAE3BC,OAAOC,OAAO,GAAG,SAASC,WAAWC,IAAI;IACvC,IAAI;QACFL,WAAWK;QACX,OAAO;IACT,EAAE,OAAOC,GAAG;QACV,OAAO;IACT;AACF"}
@@ -0,0 +1,22 @@
1
+ const path = require('path');
2
+ const existsSync = require('./existsSync.cjs');
3
+ const lazy = require('../lazy.cjs');
4
+ const major = +process.versions.node.split('.')[0];
5
+ const version = major >= 14 ? 'local' : 'lts';
6
+ const worker = path.resolve(path.dirname(__dirname), 'workers', `installBinding${path.extname(__filename)}`);
7
+ const call = lazy('node-version-call');
8
+ const installDir = path.dirname(path.dirname(path.dirname(require.resolve('@swc/core/package.json'))));
9
+ const { optionalDependencies } = require('@swc/core/package.json');
10
+ const depKey = `${process.platform}-${process.arch}`;
11
+ for(const key in optionalDependencies){
12
+ const depPath = path.join(installDir, key);
13
+ if (key.indexOf(depKey) < 0 || existsSync(depPath)) continue;
14
+ try {
15
+ call()({
16
+ version,
17
+ callbacks: true
18
+ }, worker, key, optionalDependencies[key]);
19
+ } catch (err) {
20
+ console.log(`Failed to install ${key}@${optionalDependencies[key]}. Error: ${err.message}`);
21
+ }
22
+ }
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["installBindings.cts"],"sourcesContent":["const path = require('path');\nconst existsSync = require('./existsSync.cjs');\nconst lazy = require('../lazy.cjs');\n\nconst major = +process.versions.node.split('.')[0];\nconst version = major >= 14 ? 'local' : 'lts';\nconst worker = path.resolve(path.dirname(__dirname), 'workers', `installBinding${path.extname(__filename)}`);\nconst call = lazy('node-version-call');\n\nconst installDir = path.dirname(path.dirname(path.dirname(require.resolve('@swc/core/package.json'))));\nconst { optionalDependencies } = require('@swc/core/package.json');\nconst depKey = `${process.platform}-${process.arch}`;\n\nfor (const key in optionalDependencies) {\n const depPath = path.join(installDir, key);\n if (key.indexOf(depKey) < 0 || existsSync(depPath)) continue;\n\n try {\n call()({ version, callbacks: true }, worker, key, optionalDependencies[key]);\n } catch (err) {\n console.log(`Failed to install ${key}@${optionalDependencies[key]}. Error: ${err.message}`);\n }\n}\n"],"names":["path","require","existsSync","lazy","major","process","versions","node","split","version","worker","resolve","dirname","__dirname","extname","__filename","call","installDir","optionalDependencies","depKey","platform","arch","key","depPath","join","indexOf","callbacks","err","console","log","message"],"mappings":"AAAA,MAAMA,OAAOC,QAAQ;AACrB,MAAMC,aAAaD,QAAQ;AAC3B,MAAME,OAAOF,QAAQ;AAErB,MAAMG,QAAQ,CAACC,QAAQC,QAAQ,CAACC,IAAI,CAACC,KAAK,CAAC,IAAI,CAAC,EAAE;AAClD,MAAMC,UAAUL,SAAS,KAAK,UAAU;AACxC,MAAMM,SAASV,KAAKW,OAAO,CAACX,KAAKY,OAAO,CAACC,YAAY,WAAW,CAAC,cAAc,EAAEb,KAAKc,OAAO,CAACC,aAAa;AAC3G,MAAMC,OAAOb,KAAK;AAElB,MAAMc,aAAajB,KAAKY,OAAO,CAACZ,KAAKY,OAAO,CAACZ,KAAKY,OAAO,CAACX,QAAQU,OAAO,CAAC;AAC1E,MAAM,EAAEO,oBAAoB,EAAE,GAAGjB,QAAQ;AACzC,MAAMkB,SAAS,GAAGd,QAAQe,QAAQ,CAAC,CAAC,EAAEf,QAAQgB,IAAI,EAAE;AAEpD,IAAK,MAAMC,OAAOJ,qBAAsB;IACtC,MAAMK,UAAUvB,KAAKwB,IAAI,CAACP,YAAYK;IACtC,IAAIA,IAAIG,OAAO,CAACN,UAAU,KAAKjB,WAAWqB,UAAU;IAEpD,IAAI;QACFP,OAAO;YAAEP;YAASiB,WAAW;QAAK,GAAGhB,QAAQY,KAAKJ,oBAAoB,CAACI,IAAI;IAC7E,EAAE,OAAOK,KAAK;QACZC,QAAQC,GAAG,CAAC,CAAC,kBAAkB,EAAEP,IAAI,CAAC,EAAEJ,oBAAoB,CAACI,IAAI,CAAC,SAAS,EAAEK,IAAIG,OAAO,EAAE;IAC5F;AACF"}
@@ -0,0 +1 @@
1
+ module.exports = process;
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["process.cts"],"sourcesContent":["module.exports = process;\n"],"names":["module","exports","process"],"mappings":"AAAAA,OAAOC,OAAO,GAAGC"}
@@ -1,7 +1,9 @@
1
1
  import path from 'path';
2
2
  import Iterator from 'fs-iterator';
3
3
  import getTS from 'get-tsconfig-compat';
4
+ // @ts-ignore
4
5
  import createMatcher from './createMatcher.mjs';
6
+ // @ts-ignore
5
7
  import transformFile from './transformFile.mjs';
6
8
  function transformDirectoryCallback(src, dest, type, options, callback) {
7
9
  if (typeof options === 'function') {
@@ -12,11 +14,11 @@ function transformDirectoryCallback(src, dest, type, options, callback) {
12
14
  if (typeof src !== 'string') throw new Error('transformDirectory: unexpected source');
13
15
  if (typeof dest !== 'string') throw new Error('transformDirectory: unexpected destination directory');
14
16
  if (typeof type !== 'string') throw new Error('transformDirectory: unexpected type');
15
- const config = options.confg ? options.confg : getTS.getTsconfig(src);
16
- const matcher = createMatcher(config);
17
+ const tsconfig = options.tsconfig ? options.tsconfig : getTS.getTsconfig(src);
18
+ const matcher = createMatcher(tsconfig);
17
19
  options = {
18
20
  ...options,
19
- config
21
+ tsconfig
20
22
  };
21
23
  const iterator = new Iterator(src);
22
24
  iterator.forEach((entry, cb)=>{
@@ -1 +1 @@
1
- {"version":3,"sources":["transformDirectory.mjs"],"sourcesContent":["import path from 'path';\nimport Iterator from 'fs-iterator';\nimport getTS from 'get-tsconfig-compat';\n\nimport createMatcher from './createMatcher.mjs';\nimport transformFile from './transformFile.mjs';\n\nfunction transformDirectoryCallback(src, dest, type, options, callback) {\n if (typeof options === 'function') {\n callback = options;\n options = {};\n }\n options = options || {};\n\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 const config = options.confg ? options.confg : getTS.getTsconfig(src);\n const matcher = createMatcher(config);\n\n options = { ...options, config };\n const iterator = new Iterator(src);\n iterator.forEach(\n (entry, cb) => {\n if (!entry.stats.isFile()) return cb();\n if (!matcher(entry.fullPath)) return cb();\n transformFile(entry.fullPath, path.dirname(path.join(dest, entry.path)), type, options, cb);\n },\n { callbacks: true, concurrency: options.concurrency || 1024 },\n callback\n );\n}\n\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, dest, type, options, callback) {\n if (typeof options === 'function') {\n callback = options;\n options = null;\n }\n options = options || {};\n\n if (typeof callback === 'function') return transformDirectoryCallback(src, dest, type, options, callback);\n return new Promise((resolve, reject) => {\n transformDirectoryCallback(src, dest, type, options, function compileCallback(err, result) {\n err ? reject(err) : resolve(result);\n });\n });\n}\n"],"names":["path","Iterator","getTS","createMatcher","transformFile","transformDirectoryCallback","src","dest","type","options","callback","Error","config","confg","getTsconfig","matcher","iterator","forEach","entry","cb","stats","isFile","fullPath","dirname","join","callbacks","concurrency","transformDirectory","Promise","resolve","reject","compileCallback","err","result"],"mappings":"AAAA,OAAOA,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Y,OAAOL,2BAA2BC,KAAKC,MAAMC,MAAMC,SAASC;IAChG,OAAO,IAAIkB,QAAQ,CAACC,SAASC;QAC3BzB,2BAA2BC,KAAKC,MAAMC,MAAMC,SAAS,SAASsB,gBAAgBC,GAAG,EAAEC,MAAM;YACvFD,MAAMF,OAAOE,OAAOH,QAAQI;QAC9B;IACF;AACF"}
1
+ {"version":3,"sources":["transformDirectory.ts"],"sourcesContent":["import path from 'path';\nimport Iterator from 'fs-iterator';\nimport getTS from 'get-tsconfig-compat';\n\n// @ts-ignore\nimport createMatcher from './createMatcher.ts';\n// @ts-ignore\nimport transformFile from './transformFile.ts';\n\nfunction transformDirectoryCallback(src, dest, type, options, callback) {\n if (typeof options === 'function') {\n callback = options;\n options = {};\n }\n options = options || {};\n\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 const tsconfig = options.tsconfig ? options.tsconfig : getTS.getTsconfig(src);\n const matcher = createMatcher(tsconfig);\n\n options = { ...options, tsconfig };\n const iterator = new Iterator(src);\n iterator.forEach(\n (entry, cb) => {\n if (!entry.stats.isFile()) return cb();\n if (!matcher(entry.fullPath)) return cb();\n transformFile(entry.fullPath, path.dirname(path.join(dest, entry.path)), type, options, cb);\n },\n { callbacks: true, concurrency: options.concurrency || 1024 },\n callback\n );\n}\n\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, dest, type, options, callback) {\n if (typeof options === 'function') {\n callback = options;\n options = null;\n }\n options = options || {};\n\n if (typeof callback === 'function') return transformDirectoryCallback(src, dest, type, options, callback);\n return new Promise((resolve, reject) => {\n transformDirectoryCallback(src, dest, type, options, function compileCallback(err, result) {\n err ? reject(err) : resolve(result);\n });\n });\n}\n"],"names":["path","Iterator","getTS","createMatcher","transformFile","transformDirectoryCallback","src","dest","type","options","callback","Error","tsconfig","getTsconfig","matcher","iterator","forEach","entry","cb","stats","isFile","fullPath","dirname","join","callbacks","concurrency","transformDirectory","Promise","resolve","reject","compileCallback","err","result"],"mappings":"AAAA,OAAOA,UAAU,OAAO;AACxB,OAAOC,cAAc,cAAc;AACnC,OAAOC,WAAW,sBAAsB;AAExC,aAAa;AACb,OAAOC,mBAAmB,qBAAqB;AAC/C,aAAa;AACb,OAAOC,mBAAmB,qBAAqB;AAE/C,SAASC,2BAA2BC,GAAG,EAAEC,IAAI,EAAEC,IAAI,EAAEC,OAAO,EAAEC,QAAQ;IACpE,IAAI,OAAOD,YAAY,YAAY;QACjCC,WAAWD;QACXA,UAAU,CAAC;IACb;IACAA,UAAUA,WAAW,CAAC;IAEtB,IAAI,OAAOH,QAAQ,UAAU,MAAM,IAAIK,MAAM;IAC7C,IAAI,OAAOJ,SAAS,UAAU,MAAM,IAAII,MAAM;IAC9C,IAAI,OAAOH,SAAS,UAAU,MAAM,IAAIG,MAAM;IAE9C,MAAMC,WAAWH,QAAQG,QAAQ,GAAGH,QAAQG,QAAQ,GAAGV,MAAMW,WAAW,CAACP;IACzE,MAAMQ,UAAUX,cAAcS;IAE9BH,UAAU;QAAE,GAAGA,OAAO;QAAEG;IAAS;IACjC,MAAMG,WAAW,IAAId,SAASK;IAC9BS,SAASC,OAAO,CACd,CAACC,OAAOC;QACN,IAAI,CAACD,MAAME,KAAK,CAACC,MAAM,IAAI,OAAOF;QAClC,IAAI,CAACJ,QAAQG,MAAMI,QAAQ,GAAG,OAAOH;QACrCd,cAAca,MAAMI,QAAQ,EAAErB,KAAKsB,OAAO,CAACtB,KAAKuB,IAAI,CAAChB,MAAMU,MAAMjB,IAAI,IAAIQ,MAAMC,SAASS;IAC1F,GACA;QAAEM,WAAW;QAAMC,aAAahB,QAAQgB,WAAW,IAAI;IAAK,GAC5Df;AAEJ;AAEA;;;;;;;CAOC,GACD,eAAe,SAASgB,mBAAmBpB,GAAG,EAAEC,IAAI,EAAEC,IAAI,EAAEC,OAAO,EAAEC,QAAQ;IAC3E,IAAI,OAAOD,YAAY,YAAY;QACjCC,WAAWD;QACXA,UAAU;IACZ;IACAA,UAAUA,WAAW,CAAC;IAEtB,IAAI,OAAOC,aAAa,YAAY,OAAOL,2BAA2BC,KAAKC,MAAMC,MAAMC,SAASC;IAChG,OAAO,IAAIiB,QAAQ,CAACC,SAASC;QAC3BxB,2BAA2BC,KAAKC,MAAMC,MAAMC,SAAS,SAASqB,gBAAgBC,GAAG,EAAEC,MAAM;YACvFD,MAAMF,OAAOE,OAAOH,QAAQI;QAC9B;IACF;AACF"}
@@ -4,10 +4,12 @@ import once from 'call-once-fn';
4
4
  import getTS from 'get-tsconfig-compat';
5
5
  import mkdirp from 'mkdirp';
6
6
  import Queue from 'queue-cb';
7
- import regexDependencies from './lib/regexDependencies.mjs';
8
- import transformSync from './transformSync.cjs';
9
- const regexESM = regexDependencies(true);
10
- const regexCJS = regexDependencies();
7
+ // @ts-ignore
8
+ import transformSync from './transformSync.mjs';
9
+ const matchingDeps = '\\s*[\'"`]([^\'"`]+)[\'"`]\\s*';
10
+ const matchingName = '\\s*(?:[\\w${},\\s*]+)\\s*';
11
+ const regexCJS = new RegExp(`(?:(?:var|const|let)${matchingName}=\\s*)?require\\(${matchingDeps}\\);?`, 'g');
12
+ const regexESM = new RegExp(`${regexCJS}|import(?:${matchingName}from\\s*)?${matchingDeps};?|export(?:${matchingName}from\\s*)?${matchingDeps};?`, 'g');
11
13
  const importReplaceMJS = [
12
14
  '.js',
13
15
  '.ts',
@@ -62,23 +64,23 @@ function transformFileCallback(src, dest, type, options, callback) {
62
64
  if (err) return callback(err);
63
65
  callback = once(callback);
64
66
  try {
65
- let config = options.confg ? options.confg : getTS.getTsconfig(src);
67
+ let tsconfig = options.tsconfig ? options.tsconfig : getTS.getTsconfig(src);
66
68
  // overrides for cjs
67
69
  if (type === 'cjs') {
68
- config = {
69
- ...config
70
+ tsconfig = {
71
+ ...tsconfig
70
72
  };
71
- config.config = {
72
- ...config.config || {}
73
+ tsconfig.tsconfig = {
74
+ ...tsconfig.config || {}
73
75
  };
74
- config.config.compilerOptions = {
75
- ...config.config.compilerOptions || {}
76
+ tsconfig.config.compilerOptions = {
77
+ ...tsconfig.config.compilerOptions || {}
76
78
  };
77
- config.config.compilerOptions.module = 'CommonJS';
78
- config.config.compilerOptions.target = 'ES5';
79
+ tsconfig.config.compilerOptions.module = 'CommonJS';
80
+ tsconfig.config.compilerOptions.target = 'ES5';
79
81
  }
80
82
  const basename = path.basename(src);
81
- const output = transformSync(contents, basename, config);
83
+ const output = transformSync(contents, basename, tsconfig);
82
84
  // infer extension and patch .mjs imports
83
85
  let ext = path.extname(basename);
84
86
  if (type === 'esm') {
@@ -1 +1 @@
1
- {"version":3,"sources":["transformFile.mjs"],"sourcesContent":["import fs from 'fs';\nimport path from 'path';\nimport once from 'call-once-fn';\nimport getTS from 'get-tsconfig-compat';\nimport mkdirp from 'mkdirp';\nimport Queue from 'queue-cb';\n\nimport regexDependencies from './lib/regexDependencies.mjs';\nimport transformSync from './transformSync.cjs';\n\nconst regexESM = regexDependencies(true);\nconst regexCJS = regexDependencies();\n\nconst importReplaceMJS = ['.js', '.ts', '.tsx', '.mts', '.mjs'];\nconst importReplaceCJS = ['.cts'];\nconst requireReplaceJS = ['.mjs', '.cjs', '.ts', '.tsx', '.mts', '.cts'];\n\nfunction makeReplacements(code, regex, extensions, extension) {\n let matches = [];\n let match = regex.exec(code);\n while (match) {\n const dependency = match[1] || match[2] || match[3] || match[4];\n const ext = extensions.find((x) => dependency.slice(-x.length) === x);\n if (ext) matches.push({ ext, match, dependency });\n match = regex.exec(code);\n }\n\n matches = matches.reverse();\n for (const index in matches) {\n const match = matches[index];\n const start = match.match.index + match.match[0].indexOf(match.dependency) + match.dependency.indexOf(match.ext);\n code = code.substring(0, start) + extension + code.substring(start + match.ext.length);\n }\n return code;\n}\n\n// https://github.com/vercel/next.js/blob/20b63e13ab2631d6043277895d373aa31a1b327c/packages/next/taskfile-swc.js#L118-L125\nconst interopClientDefaultExport = \"/* 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; }\";\n\nfunction transformFileCallback(src, dest, type, options, callback) {\n if (typeof options === 'function') {\n callback = options;\n options = {};\n }\n options = options || {};\n\n if (typeof src !== 'string') throw new Error('transformFile: unexpected source');\n if (typeof dest !== 'string') throw new Error('transformFile: unexpected destination directory');\n if (typeof type !== 'string') throw new Error('transformFile: unexpected type');\n\n fs.readFile(src, 'utf8', (err, contents) => {\n if (err) return callback(err);\n callback = once(callback);\n\n try {\n let config = options.confg ? options.confg : getTS.getTsconfig(src);\n\n // overrides for cjs\n if (type === 'cjs') {\n config = { ...config };\n config.config = { ...(config.config || {}) };\n config.config.compilerOptions = { ...(config.config.compilerOptions || {}) };\n config.config.compilerOptions.module = 'CommonJS';\n config.config.compilerOptions.target = 'ES5';\n }\n\n const basename = path.basename(src);\n const output = transformSync(contents, basename, config);\n\n // infer extension and patch .mjs imports\n let ext = path.extname(basename);\n if (type === 'esm') {\n ext = importReplaceMJS.indexOf(ext) >= 0 ? '.mjs' : ext;\n output.code = makeReplacements(output.code, regexESM, importReplaceMJS, '.mjs');\n ext = importReplaceCJS.indexOf(ext) >= 0 ? '.cjs' : ext;\n output.code = makeReplacements(output.code, regexESM, importReplaceCJS, '.cjs');\n } else {\n ext = requireReplaceJS.indexOf(ext) >= 0 ? '.js' : ext;\n output.code = makeReplacements(output.code, regexCJS, requireReplaceJS, '.js');\n output.code += interopClientDefaultExport;\n }\n const destFilePath = path.join(dest, basename.replace(/\\.[^/.]+$/, '') + ext);\n\n mkdirp(path.dirname(destFilePath), () => {\n const queue = new Queue();\n queue.defer(fs.writeFile.bind(null, destFilePath, output.code, 'utf8'));\n !options.sourceMaps || queue.defer(fs.writeFile.bind(null, `${destFilePath}.map`, output.map, 'utf8'));\n queue.await(() => (err ? callback(err) : callback(null, destFilePath)));\n });\n } catch (err) {\n callback(err);\n }\n });\n}\n\n/**\n * @param {string} src The source directory to traverse.\n * @param {string} dest The output directory to write the file 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 | null, destFilePath: string) =>} [callback] Optional callback returing the path to the transformed file. Uses promise if callback not provided.\n * @returns {void | Promise<string>} Optional promise returing the path to the transformed file if callback not provided.\n */\nexport default function transformFile(src, dest, type, options, callback) {\n if (typeof options === 'function') {\n callback = options;\n options = null;\n }\n options = options || {};\n\n if (typeof callback === 'function') return transformFileCallback(src, dest, type, options, callback);\n return new Promise((resolve, reject) => {\n transformFileCallback(src, dest, type, options, function compileCallback(err, result) {\n err ? reject(err) : resolve(result);\n });\n });\n}\n"],"names":["fs","path","once","getTS","mkdirp","Queue","regexDependencies","transformSync","regexESM","regexCJS","importReplaceMJS","importReplaceCJS","requireReplaceJS","makeReplacements","code","regex","extensions","extension","matches","match","exec","dependency","ext","find","x","slice","length","push","reverse","index","start","indexOf","substring","interopClientDefaultExport","transformFileCallback","src","dest","type","options","callback","Error","readFile","err","contents","config","confg","getTsconfig","compilerOptions","module","target","basename","output","extname","destFilePath","join","replace","dirname","queue","defer","writeFile","bind","sourceMaps","map","await","transformFile","Promise","resolve","reject","compileCallback","result"],"mappings":"AAAA,OAAOA,QAAQ,KAAK;AACpB,OAAOC,UAAU,OAAO;AACxB,OAAOC,UAAU,eAAe;AAChC,OAAOC,WAAW,sBAAsB;AACxC,OAAOC,YAAY,SAAS;AAC5B,OAAOC,WAAW,WAAW;AAE7B,OAAOC,uBAAuB,8BAA8B;AAC5D,OAAOC,mBAAmB,sBAAsB;AAEhD,MAAMC,WAAWF,kBAAkB;AAC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\nimport path from 'path';\nimport once from 'call-once-fn';\nimport getTS from 'get-tsconfig-compat';\nimport mkdirp from 'mkdirp';\nimport Queue from 'queue-cb';\n\n// @ts-ignore\nimport transformSync from './transformSync.ts';\n\nconst matchingDeps = '\\\\s*[\\'\"`]([^\\'\"`]+)[\\'\"`]\\\\s*';\nconst matchingName = '\\\\s*(?:[\\\\w${},\\\\s*]+)\\\\s*';\nconst regexCJS = new RegExp(`(?:(?:var|const|let)${matchingName}=\\\\s*)?require\\\\(${matchingDeps}\\\\);?`, 'g');\nconst regexESM = new RegExp(`${regexCJS}|import(?:${matchingName}from\\\\s*)?${matchingDeps};?|export(?:${matchingName}from\\\\s*)?${matchingDeps};?`, 'g');\n\nconst importReplaceMJS = ['.js', '.ts', '.tsx', '.mts', '.mjs'];\nconst importReplaceCJS = ['.cts'];\nconst requireReplaceJS = ['.mjs', '.cjs', '.ts', '.tsx', '.mts', '.cts'];\n\nfunction makeReplacements(code, regex, extensions, extension) {\n let matches = [];\n let match = regex.exec(code);\n while (match) {\n const dependency = match[1] || match[2] || match[3] || match[4];\n const ext = extensions.find((x) => dependency.slice(-x.length) === x);\n if (ext) matches.push({ ext, match, dependency });\n match = regex.exec(code);\n }\n\n matches = matches.reverse();\n for (const index in matches) {\n const match = matches[index];\n const start = match.match.index + match.match[0].indexOf(match.dependency) + match.dependency.indexOf(match.ext);\n code = code.substring(0, start) + extension + code.substring(start + match.ext.length);\n }\n return code;\n}\n\n// https://github.com/vercel/next.js/blob/20b63e13ab2631d6043277895d373aa31a1b327c/packages/next/taskfile-swc.js#L118-L125\nconst interopClientDefaultExport = \"/* 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; }\";\n\nfunction transformFileCallback(src, dest, type, options, callback) {\n if (typeof options === 'function') {\n callback = options;\n options = {};\n }\n options = options || {};\n\n if (typeof src !== 'string') throw new Error('transformFile: unexpected source');\n if (typeof dest !== 'string') throw new Error('transformFile: unexpected destination directory');\n if (typeof type !== 'string') throw new Error('transformFile: unexpected type');\n\n fs.readFile(src, 'utf8', (err, contents) => {\n if (err) return callback(err);\n callback = once(callback);\n\n try {\n let tsconfig = options.tsconfig ? options.tsconfig : getTS.getTsconfig(src);\n\n // overrides for cjs\n if (type === 'cjs') {\n tsconfig = { ...tsconfig };\n tsconfig.tsconfig = { ...(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 basename = path.basename(src);\n const output = transformSync(contents, basename, tsconfig);\n\n // infer extension and patch .mjs imports\n let ext = path.extname(basename);\n if (type === 'esm') {\n ext = importReplaceMJS.indexOf(ext) >= 0 ? '.mjs' : ext;\n output.code = makeReplacements(output.code, regexESM, importReplaceMJS, '.mjs');\n ext = importReplaceCJS.indexOf(ext) >= 0 ? '.cjs' : ext;\n output.code = makeReplacements(output.code, regexESM, importReplaceCJS, '.cjs');\n } else {\n ext = requireReplaceJS.indexOf(ext) >= 0 ? '.js' : ext;\n output.code = makeReplacements(output.code, regexCJS, requireReplaceJS, '.js');\n output.code += interopClientDefaultExport;\n }\n const destFilePath = path.join(dest, basename.replace(/\\.[^/.]+$/, '') + ext);\n\n mkdirp(path.dirname(destFilePath), () => {\n const queue = new Queue();\n queue.defer(fs.writeFile.bind(null, destFilePath, output.code, 'utf8'));\n !options.sourceMaps || queue.defer(fs.writeFile.bind(null, `${destFilePath}.map`, output.map, 'utf8'));\n queue.await(() => (err ? callback(err) : callback(null, destFilePath)));\n });\n } catch (err) {\n callback(err);\n }\n });\n}\n\n/**\n * @param {string} src The source directory to traverse.\n * @param {string} dest The output directory to write the file 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 | null, destFilePath: string) =>} [callback] Optional callback returing the path to the transformed file. Uses promise if callback not provided.\n * @returns {void | Promise<string>} Optional promise returing the path to the transformed file if callback not provided.\n */\nexport default function transformFile(src, dest, type, options, callback) {\n if (typeof options === 'function') {\n callback = options;\n options = null;\n }\n options = options || {};\n\n if (typeof callback === 'function') return transformFileCallback(src, dest, type, options, callback);\n return new Promise((resolve, reject) => {\n transformFileCallback(src, dest, type, options, function compileCallback(err, result) {\n err ? reject(err) : resolve(result);\n });\n });\n}\n"],"names":["fs","path","once","getTS","mkdirp","Queue","transformSync","matchingDeps","matchingName","regexCJS","RegExp","regexESM","importReplaceMJS","importReplaceCJS","requireReplaceJS","makeReplacements","code","regex","extensions","extension","matches","match","exec","dependency","ext","find","x","slice","length","push","reverse","index","start","indexOf","substring","interopClientDefaultExport","transformFileCallback","src","dest","type","options","callback","Error","readFile","err","contents","tsconfig","getTsconfig","config","compilerOptions","module","target","basename","output","extname","destFilePath","join","replace","dirname","queue","defer","writeFile","bind","sourceMaps","map","await","transformFile","Promise","resolve","reject","compileCallback","result"],"mappings":"AAAA,OAAOA,QAAQ,KAAK;AACpB,OAAOC,UAAU,OAAO;AACxB,OAAOC,UAAU,eAAe;AAChC,OAAOC,WAAW,sBAAsB;AACxC,OAAOC,YAAY,SAAS;AAC5B,OAAOC,WAAW,WAAW;AAE7B,aAAa;AACb,OAAOC,mBAAmB,qBAAqB;AAE/C,MAAMC,eAAe;AACrB,MAAMC,eAAe;AACrB,MAAMC,WAAW,IAAIC,OAAO,CAAC,oBAAoB,EAAEF,aAAa,iBAAiB,EAAED,aAAa,KAAK,CAAC,EAAE;AACxG,MAAMI,WAAW,IAAID,OAAO,GAAGD,SAAS,UAAU,EAAED,aAAa,UAAU,EAAED,aAAa,YAAY,EAAEC,aAAa,UAAU,EAAED,aAAa,EAAE,CAAC,EAAE;AAEnJ,MAAMK,mBAAmB;IAAC;IAAO;IAAO;IAAQ;IAAQ;CAAO;AAC/D,MAAMC,mBAAmB;IAAC;CAAO;AACjC,MAAMC,mBA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AEP,UAAUK,kBAAkB;gBACxEuC,OAAOrC,IAAI,IAAImB;YACjB;YACA,MAAMoB,eAAetD,KAAKuD,IAAI,CAAClB,MAAMc,SAASK,OAAO,CAAC,aAAa,MAAMjC;YAEzEpB,OAAOH,KAAKyD,OAAO,CAACH,eAAe;gBACjC,MAAMI,QAAQ,IAAItD;gBAClBsD,MAAMC,KAAK,CAAC5D,GAAG6D,SAAS,CAACC,IAAI,CAAC,MAAMP,cAAcF,OAAOrC,IAAI,EAAE;gBAC/D,CAACwB,QAAQuB,UAAU,IAAIJ,MAAMC,KAAK,CAAC5D,GAAG6D,SAAS,CAACC,IAAI,CAAC,MAAM,GAAGP,aAAa,IAAI,CAAC,EAAEF,OAAOW,GAAG,EAAE;gBAC9FL,MAAMM,KAAK,CAAC,IAAOrB,MAAMH,SAASG,OAAOH,SAAS,MAAMc;YAC1D;QACF,EAAE,OAAOX,KAAK;YACZH,SAASG;QACX;IACF;AACF;AAEA;;;;;;;CAOC,GACD,eAAe,SAASsB,cAAc7B,GAAG,EAAEC,IAAI,EAAEC,IAAI,EAAEC,OAAO,EAAEC,QAAQ;IACtE,IAAI,OAAOD,YAAY,YAAY;QACjCC,WAAWD;QACXA,UAAU;IACZ;IACAA,UAAUA,WAAW,CAAC;IAEtB,IAAI,OAAOC,aAAa,YAAY,OAAOL,sBAAsBC,KAAKC,MAAMC,MAAMC,SAASC;IAC3F,OAAO,IAAI0B,QAAQ,CAACC,SAASC;QAC3BjC,sBAAsBC,KAAKC,MAAMC,MAAMC,SAAS,SAAS8B,gBAAgB1B,GAAG,EAAE2B,MAAM;YAClF3B,MAAMyB,OAAOzB,OAAOwB,QAAQG;QAC9B;IACF;AACF"}
@@ -0,0 +1,18 @@
1
+ import path from 'path';
2
+ import url from 'url';
3
+ // @ts-ignore
4
+ import lazy from './lazy.cjs';
5
+ // @ts-ignore
6
+ import process from './process.cjs';
7
+ const major = +process.versions.node.split('.')[0];
8
+ const version = major >= 14 ? 'local' : 'lts';
9
+ const filename = typeof __filename !== 'undefined' ? __filename : url.fileURLToPath(import.meta.url);
10
+ const worker = path.resolve(path.dirname(filename), 'workers', `transformSync${path.extname(filename) === '.mjs' ? '.cjs' : '.js'}`);
11
+ const call = lazy('node-version-call');
12
+ /**
13
+ * @param {string} contents The file contents.
14
+ * @param {string} fileName The filename.
15
+ * @returns {{ code: string, map?: string }} Returns object with the transformed code and source map if option sourceMaps was provided.
16
+ */ export default function transformSync(contents, fileName, config) {
17
+ return call()(version, worker, contents, fileName, config);
18
+ }
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["transformSync.ts"],"sourcesContent":["import path from 'path';\nimport url from 'url';\n// @ts-ignore\nimport lazy from './lazy.cts';\n// @ts-ignore\nimport process from './process.cts';\n\nconst major = +process.versions.node.split('.')[0];\nconst version = major >= 14 ? 'local' : 'lts';\nconst filename = typeof __filename !== 'undefined' ? __filename : url.fileURLToPath(import.meta.url);\nconst worker = path.resolve(path.dirname(filename), 'workers', `transformSync${path.extname(filename) === '.mjs' ? '.cjs' : '.js'}`);\nconst call = lazy('node-version-call');\n\n/**\n * @param {string} contents The file contents.\n * @param {string} fileName The filename.\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, fileName, config) {\n return call()(version, worker, contents, fileName, config);\n}\n"],"names":["path","url","lazy","process","major","versions","node","split","version","filename","__filename","fileURLToPath","worker","resolve","dirname","extname","call","transformSync","contents","fileName","config"],"mappings":"AAAA,OAAOA,UAAU,OAAO;AACxB,OAAOC,SAAS,MAAM;AACtB,aAAa;AACb,OAAOC,UAAU,aAAa;AAC9B,aAAa;AACb,OAAOC,aAAa,gBAAgB;AAEpC,MAAMC,QAAQ,CAACD,QAAQE,QAAQ,CAACC,IAAI,CAACC,KAAK,CAAC,IAAI,CAAC,EAAE;AAClD,MAAMC,UAAUJ,SAAS,KAAK,UAAU;AACxC,MAAMK,WAAW,OAAOC,eAAe,cAAcA,aAAaT,IAAIU,aAAa,CAAC,YAAYV,GAAG;AACnG,MAAMW,SAASZ,KAAKa,OAAO,CAACb,KAAKc,OAAO,CAACL,WAAW,WAAW,CAAC,aAAa,EAAET,KAAKe,OAAO,CAACN,cAAc,SAAS,SAAS,OAAO;AACnI,MAAMO,OAAOd,KAAK;AAElB;;;;CAIC,GACD,eAAe,SAASe,cAAcC,QAAQ,EAAEC,QAAQ,EAAEC,MAAM;IAC9D,OAAOJ,OAAOR,SAASI,QAAQM,UAAUC,UAAUC;AACrD"}
@@ -0,0 +1,46 @@
1
+ const path = require('path');
2
+ const fs = require('fs');
3
+ const { tmpdir } = require('os');
4
+ const tempSuffix = require('temp-suffix');
5
+ const mkdirp = require('mkdirp');
6
+ const Queue = require('queue-cb');
7
+ const spawn = require('cross-spawn-cb');
8
+ const once = require('call-once-fn');
9
+ module.exports = function installBindings(name, version, callback) {
10
+ callback = once(callback);
11
+ try {
12
+ const tmp = path.join(tmpdir(), 'ts-swc-transform', tempSuffix());
13
+ const source = path.join.apply(null, [
14
+ tmp,
15
+ 'node_modules',
16
+ ...name.split('/')
17
+ ]);
18
+ const dest = path.join.apply(null, [
19
+ path.dirname(path.dirname(path.dirname(require.resolve('@swc/core/package.json')))),
20
+ ...name.split('/')
21
+ ]);
22
+ const queue = new Queue(1);
23
+ queue.defer(mkdirp.bind(null, tmp));
24
+ queue.defer(fs.writeFile.bind(null, path.join(tmp, 'package.json'), '{}', 'utf8'));
25
+ queue.defer((cb)=>{
26
+ // remove NODE_OPTIONS from ts-dev-stack
27
+ // biome-ignore lint/performance/noDelete: <explanation>
28
+ delete process.env.NODE_OPTIONS;
29
+ spawn('npm', [
30
+ 'install',
31
+ `${name}@${version}`
32
+ ], {
33
+ cwd: tmp
34
+ }, cb);
35
+ });
36
+ queue.defer(fs.rename.bind(null, source, dest));
37
+ queue.await((err)=>{
38
+ fs.rm(tmp, {
39
+ recursive: true,
40
+ force: true
41
+ }, ()=>callback(err));
42
+ });
43
+ } catch (err) {
44
+ return callback(err);
45
+ }
46
+ };
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["installBinding.cts"],"sourcesContent":["const path = require('path');\nconst fs = require('fs');\nconst { tmpdir } = require('os');\nconst tempSuffix = require('temp-suffix');\nconst mkdirp = require('mkdirp');\n\nconst Queue = require('queue-cb');\nconst spawn = require('cross-spawn-cb');\nconst once = require('call-once-fn');\n\nmodule.exports = function installBindings(name, version, callback) {\n callback = once(callback);\n try {\n const tmp = path.join(tmpdir(), 'ts-swc-transform', tempSuffix());\n const source = path.join.apply(null, [tmp, 'node_modules', ...name.split('/')]);\n const dest = path.join.apply(null, [path.dirname(path.dirname(path.dirname(require.resolve('@swc/core/package.json')))), ...name.split('/')]);\n\n const queue = new Queue(1);\n queue.defer(mkdirp.bind(null, tmp));\n queue.defer(fs.writeFile.bind(null, path.join(tmp, 'package.json'), '{}', 'utf8'));\n queue.defer((cb) => {\n // remove NODE_OPTIONS from ts-dev-stack\n // biome-ignore lint/performance/noDelete: <explanation>\n delete process.env.NODE_OPTIONS;\n spawn('npm', ['install', `${name}@${version}`], { cwd: tmp }, cb);\n });\n queue.defer(fs.rename.bind(null, source, dest));\n queue.await((err) => {\n fs.rm(tmp, { recursive: true, force: true }, () => callback(err));\n });\n } catch (err) {\n return callback(err);\n }\n};\n"],"names":["path","require","fs","tmpdir","tempSuffix","mkdirp","Queue","spawn","once","module","exports","installBindings","name","version","callback","tmp","join","source","apply","split","dest","dirname","resolve","queue","defer","bind","writeFile","cb","process","env","NODE_OPTIONS","cwd","rename","await","err","rm","recursive","force"],"mappings":"AAAA,MAAMA,OAAOC,QAAQ;AACrB,MAAMC,KAAKD,QAAQ;AACnB,MAAM,EAAEE,MAAM,EAAE,GAAGF,QAAQ;AAC3B,MAAMG,aAAaH,QAAQ;AAC3B,MAAMI,SAASJ,QAAQ;AAEvB,MAAMK,QAAQL,QAAQ;AACtB,MAAMM,QAAQN,QAAQ;AACtB,MAAMO,OAAOP,QAAQ;AAErBQ,OAAOC,OAAO,GAAG,SAASC,gBAAgBC,IAAI,EAAEC,OAAO,EAAEC,QAAQ;IAC/DA,WAAWN,KAAKM;IAChB,IAAI;QACF,MAAMC,MAAMf,KAAKgB,IAAI,CAACb,UAAU,oBAAoBC;QACpD,MAAMa,SAASjB,KAAKgB,IAAI,CAACE,KAAK,CAAC,MAAM;YAACH;YAAK;eAAmBH,KAAKO,KAAK,CAAC;SAAK;QAC9E,MAAMC,OAAOpB,KAAKgB,IAAI,CAACE,KAAK,CAAC,MAAM;YAAClB,KAAKqB,OAAO,CAACrB,KAAKqB,OAAO,CAACrB,KAAKqB,OAAO,CAACpB,QAAQqB,OAAO,CAAC;eAAiCV,KAAKO,KAAK,CAAC;SAAK;QAE5I,MAAMI,QAAQ,IAAIjB,MAAM;QACxBiB,MAAMC,KAAK,CAACnB,OAAOoB,IAAI,CAAC,MAAMV;QAC9BQ,MAAMC,KAAK,CAACtB,GAAGwB,SAAS,CAACD,IAAI,CAAC,MAAMzB,KAAKgB,IAAI,CAACD,KAAK,iBAAiB,MAAM;QAC1EQ,MAAMC,KAAK,CAAC,CAACG;YACX,wCAAwC;YACxC,wDAAwD;YACxD,OAAOC,QAAQC,GAAG,CAACC,YAAY;YAC/BvB,MAAM,OAAO;gBAAC;gBAAW,GAAGK,KAAK,CAAC,EAAEC,SAAS;aAAC,EAAE;gBAAEkB,KAAKhB;YAAI,GAAGY;QAChE;QACAJ,MAAMC,KAAK,CAACtB,GAAG8B,MAAM,CAACP,IAAI,CAAC,MAAMR,QAAQG;QACzCG,MAAMU,KAAK,CAAC,CAACC;YACXhC,GAAGiC,EAAE,CAACpB,KAAK;gBAAEqB,WAAW;gBAAMC,OAAO;YAAK,GAAG,IAAMvB,SAASoB;QAC9D;IACF,EAAE,OAAOA,KAAK;QACZ,OAAOpB,SAASoB;IAClB;AACF"}
@@ -1,5 +1,11 @@
1
1
  const path = require('path');
2
- const swc = require('@swc/core');
2
+ let swc;
3
+ try {
4
+ swc = require('@swc/core');
5
+ } catch (_) {
6
+ require('../lib/installBindings.cjs');
7
+ swc = require('@swc/core');
8
+ }
3
9
  const ts = require('typescript');
4
10
  const swcTranspiler = require('ts-node/transpilers/swc');
5
11
  module.exports = function transformSync(contents, fileName, config) {
@@ -1 +1 @@
1
- {"version":3,"sources":["transformSync.cjs"],"sourcesContent":["const path = require('path');\nconst swc = require('@swc/core');\nconst ts = require('typescript');\nconst swcTranspiler = require('ts-node/transpilers/swc');\n\nmodule.exports = function transformSync(contents, fileName, config) {\n const parsed = ts.parseJsonConfigFileContent(config.config, ts.sys, path.dirname(config.path));\n const transpile = swcTranspiler.create({ swc: swc, service: { config: { options: parsed.options } } });\n const res = transpile.transpile(contents, { fileName: fileName });\n return { code: res.outputText, map: res.sourceMapText };\n};\n"],"names":["path","require","swc","ts","swcTranspiler","module","exports","transformSync","contents","fileName","config","parsed","parseJsonConfigFileContent","sys","dirname","transpile","create","service","options","res","code","outputText","map","sourceMapText"],"mappings":"AAAA,MAAMA,OAAOC,QAAQ;AACrB,MAAMC,MAAMD,QAAQ;AACpB,MAAME,KAAKF,QAAQ;AACnB,MAAMG,gBAAgBH,QAAQ;AAE9BI,OAAOC,OAAO,GAAG,SAASC,cAAcC,QAAQ,EAAEC,QAAQ,EAAEC,MAAM;IAChE,MAAMC,SAASR,GAAGS,0BAA0B,CAACF,OAAOA,MAAM,EAAEP,GAAGU,GAAG,EAAEb,KAAKc,OAAO,CAACJ,OAAOV,IAAI;IAC5F,MAAMe,YAAYX,cAAcY,MAAM,CAAC;QAAEd,KAAKA;QAAKe,SAAS;YAAEP,QAAQ;gBAAEQ,SAASP,OAAOO,OAAO;YAAC;QAAE;IAAE;IACpG,MAAMC,MAAMJ,UAAUA,SAAS,CAACP,UAAU;QAAEC,UAAUA;IAAS;IAC/D,OAAO;QAAEW,MAAMD,IAAIE,UAAU;QAAEC,KAAKH,IAAII,aAAa;IAAC;AACxD"}
1
+ {"version":3,"sources":["transformSync.cts"],"sourcesContent":["const path = require('path');\nlet swc: string;\ntry {\n swc = require('@swc/core');\n} catch (_) {\n require('../lib/installBindings.cjs');\n swc = require('@swc/core');\n}\nconst ts = require('typescript');\nconst swcTranspiler = require('ts-node/transpilers/swc');\n\nmodule.exports = function transformSync(contents, fileName, config) {\n const parsed = ts.parseJsonConfigFileContent(config.config, ts.sys, path.dirname(config.path));\n const transpile = swcTranspiler.create({ swc: swc, service: { config: { options: parsed.options } } });\n const res = transpile.transpile(contents, { fileName: fileName });\n return { code: res.outputText, map: res.sourceMapText };\n};\n"],"names":["path","require","swc","_","ts","swcTranspiler","module","exports","transformSync","contents","fileName","config","parsed","parseJsonConfigFileContent","sys","dirname","transpile","create","service","options","res","code","outputText","map","sourceMapText"],"mappings":"AAAA,MAAMA,OAAOC,QAAQ;AACrB,IAAIC;AACJ,IAAI;IACFA,MAAMD,QAAQ;AAChB,EAAE,OAAOE,GAAG;IACVF,QAAQ;IACRC,MAAMD,QAAQ;AAChB;AACA,MAAMG,KAAKH,QAAQ;AACnB,MAAMI,gBAAgBJ,QAAQ;AAE9BK,OAAOC,OAAO,GAAG,SAASC,cAAcC,QAAQ,EAAEC,QAAQ,EAAEC,MAAM;IAChE,MAAMC,SAASR,GAAGS,0BAA0B,CAACF,OAAOA,MAAM,EAAEP,GAAGU,GAAG,EAAEd,KAAKe,OAAO,CAACJ,OAAOX,IAAI;IAC5F,MAAMgB,YAAYX,cAAcY,MAAM,CAAC;QAAEf,KAAKA;QAAKgB,SAAS;YAAEP,QAAQ;gBAAEQ,SAASP,OAAOO,OAAO;YAAC;QAAE;IAAE;IACpG,MAAMC,MAAMJ,UAAUA,SAAS,CAACP,UAAU;QAAEC,UAAUA;IAAS;IAC/D,OAAO;QAAEW,MAAMD,IAAIE,UAAU;QAAEC,KAAKH,IAAII,aAAa;IAAC;AACxD"}
@@ -2,7 +2,4 @@
2
2
  * @param {{path: string, config: Object}} config The path to the loaded TS config and typescript config.
3
3
  * @returns {(filePath:string) => boolean} The function to test for typescript files being included or excluded
4
4
  */
5
- export default function createMatcher(config: {
6
- path: string;
7
- config: any;
8
- }): (filePath: string) => boolean;
5
+ export default function createMatcher(config: any): (filePath: any) => boolean;
@@ -0,0 +1,4 @@
1
+ export { default as createMatcher } from './createMatcher.js';
2
+ export { default as transformFile } from './transformFile.js';
3
+ export { default as transformDirectory } from './transformDirectory.js';
4
+ export { default as transformSync } from './transformSync.js';
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -6,6 +6,4 @@
6
6
  * @param {(err?: Error) =>} [callback] Optional callback. Uses promise if callback not provided.
7
7
  * @returns {void | Promise<any>} Optional promise if callback not provided.
8
8
  */
9
- export default function transformDirectory(src: string, dest: string, type: string, options: {
10
- sourceMaps: boolean;
11
- }, callback?: (err?: Error) => any): void | Promise<any>;
9
+ export default function transformDirectory(src: any, dest: any, type: any, options: any, callback: any): void | Promise<unknown>;
@@ -6,6 +6,4 @@
6
6
  * @param {(err: Error | null, destFilePath: string) =>} [callback] Optional callback returing the path to the transformed file. Uses promise if callback not provided.
7
7
  * @returns {void | Promise<string>} Optional promise returing the path to the transformed file if callback not provided.
8
8
  */
9
- export default function transformFile(src: string, dest: string, type: string, options: {
10
- sourceMaps: boolean;
11
- }, callback?: (err: Error | null, destFilePath: string) => any): void | Promise<string>;
9
+ export default function transformFile(src: any, dest: any, type: any, options: any, callback: any): void | Promise<unknown>;
@@ -0,0 +1,6 @@
1
+ /**
2
+ * @param {string} contents The file contents.
3
+ * @param {string} fileName The filename.
4
+ * @returns {{ code: string, map?: string }} Returns object with the transformed code and source map if option sourceMaps was provided.
5
+ */
6
+ export default function transformSync(contents: any, fileName: any, config: any): any;
@@ -0,0 +1 @@
1
+ export {};
@@ -1,5 +1 @@
1
- declare function _exports(contents: any, fileName: any, config: any): {
2
- code: any;
3
- map: any;
4
- };
5
- export = _exports;
1
+ export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ts-swc-transform",
3
- "version": "1.0.3",
3
+ "version": "1.1.1",
4
4
  "description": "Typescript transformers for swc. Supports Node >= 0.8",
5
5
  "keywords": [
6
6
  "matcher",
@@ -50,29 +50,32 @@
50
50
  "dependencies": {
51
51
  "@swc/core": "*",
52
52
  "call-once-fn": "^1.0.1",
53
+ "cross-spawn-cb": "^1.1.2",
53
54
  "exit": "^0.1.2",
55
+ "fs-access-sync-compat": "^1.0.2",
54
56
  "fs-iterator": "^5.1.1",
55
- "get-tsconfig-compat": "^0.1.0",
57
+ "get-tsconfig-compat": "^1.1.0",
58
+ "lazy-cache": "^2.0.2",
56
59
  "minimatch": "^3.1.2",
57
60
  "mkdirp": "^0.5.6",
58
- "node-version-call": "^1.1.0",
61
+ "node-version-call": "^1.1.1",
59
62
  "path-posix": "^1.0.0",
60
- "queue-cb": "^1.2.1",
61
- "slash": "^1.0.0",
63
+ "queue-cb": "^1.4.2",
64
+ "temp-suffix": "^0.1.1",
62
65
  "ts-node": "*",
63
- "typescript": "*"
66
+ "typescript": "*",
67
+ "unixify": "^1.0.0"
64
68
  },
65
69
  "devDependencies": {
66
70
  "@biomejs/biome": "^1.9.4",
67
71
  "@swc/core": "^1.9.3",
68
72
  "@types/mocha": "^10.0.10",
69
- "@types/node": "^22.10.1",
73
+ "@types/node": "^22.10.2",
70
74
  "core-js": "^3.39.0",
71
75
  "cr": "^0.1.0",
72
- "cross-spawn-cb": "^1.1.2",
73
- "react": "^18.3.1",
76
+ "react": "^19.0.0",
74
77
  "rimraf2": "^2.8.2",
75
- "ts-dev-stack": "^1.0.1",
78
+ "ts-dev-stack": "^1.2.1",
76
79
  "ts-node": "^10.8.2",
77
80
  "typescript": "^5.7.2"
78
81
  },
@@ -80,7 +83,7 @@
80
83
  "node": ">=0.8"
81
84
  },
82
85
  "tsds": {
83
- "source": "src/index.mjs",
86
+ "source": "src/index.ts",
84
87
  "targets": [
85
88
  "cjs",
86
89
  "esm"
@@ -1,21 +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 regexDependencies;
9
- }
10
- });
11
- function regexDependencies(esm) {
12
- var matchingDeps = '\\s*[\'"`]([^\'"`]+)[\'"`]\\s*';
13
- var matchingName = '\\s*(?:[\\w${},\\s*]+)\\s*';
14
- var regex = "(?:(?:var|const|let)".concat(matchingName, "=\\s*)?require\\(").concat(matchingDeps, "\\);?");
15
- if (esm) {
16
- regex += "|import(?:".concat(matchingName, "from\\s*)?").concat(matchingDeps, ";?");
17
- regex += "|export(?:".concat(matchingName, "from\\s*)?").concat(matchingDeps, ";?");
18
- }
19
- return new RegExp(regex, 'g');
20
- }
21
- /* 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":["regexDependencies.mjs"],"sourcesContent":["export default function regexDependencies(esm) {\n const matchingDeps = '\\\\s*[\\'\"`]([^\\'\"`]+)[\\'\"`]\\\\s*';\n const matchingName = '\\\\s*(?:[\\\\w${},\\\\s*]+)\\\\s*';\n\n let regex = `(?:(?:var|const|let)${matchingName}=\\\\s*)?require\\\\(${matchingDeps}\\\\);?`;\n if (esm) {\n regex += `|import(?:${matchingName}from\\\\s*)?${matchingDeps};?`;\n regex += `|export(?:${matchingName}from\\\\s*)?${matchingDeps};?`;\n }\n return new RegExp(regex, 'g');\n}\n"],"names":["regexDependencies","esm","matchingDeps","matchingName","regex","RegExp"],"mappings":";;;;+BAAA;;;eAAwBA;;;AAAT,SAASA,kBAAkBC,GAAG;IAC3C,IAAMC,eAAe;IACrB,IAAMC,eAAe;IAErB,IAAIC,QAAQ,AAAC,uBAAsDF,OAAhCC,cAAa,qBAAgC,OAAbD,cAAa;IAChF,IAAID,KAAK;QACPG,SAAS,AAAC,aAAqCF,OAAzBC,cAAa,cAAyB,OAAbD,cAAa;QAC5DE,SAAS,AAAC,aAAqCF,OAAzBC,cAAa,cAAyB,OAAbD,cAAa;IAC9D;IACA,OAAO,IAAIG,OAAOD,OAAO;AAC3B"}
@@ -1,10 +0,0 @@
1
- export default function regexDependencies(esm) {
2
- const matchingDeps = '\\s*[\'"`]([^\'"`]+)[\'"`]\\s*';
3
- const matchingName = '\\s*(?:[\\w${},\\s*]+)\\s*';
4
- let regex = `(?:(?:var|const|let)${matchingName}=\\s*)?require\\(${matchingDeps}\\);?`;
5
- if (esm) {
6
- regex += `|import(?:${matchingName}from\\s*)?${matchingDeps};?`;
7
- regex += `|export(?:${matchingName}from\\s*)?${matchingDeps};?`;
8
- }
9
- return new RegExp(regex, 'g');
10
- }
@@ -1 +0,0 @@
1
- {"version":3,"sources":["regexDependencies.mjs"],"sourcesContent":["export default function regexDependencies(esm) {\n const matchingDeps = '\\\\s*[\\'\"`]([^\\'\"`]+)[\\'\"`]\\\\s*';\n const matchingName = '\\\\s*(?:[\\\\w${},\\\\s*]+)\\\\s*';\n\n let regex = `(?:(?:var|const|let)${matchingName}=\\\\s*)?require\\\\(${matchingDeps}\\\\);?`;\n if (esm) {\n regex += `|import(?:${matchingName}from\\\\s*)?${matchingDeps};?`;\n regex += `|export(?:${matchingName}from\\\\s*)?${matchingDeps};?`;\n }\n return new RegExp(regex, 'g');\n}\n"],"names":["regexDependencies","esm","matchingDeps","matchingName","regex","RegExp"],"mappings":"AAAA,eAAe,SAASA,kBAAkBC,GAAG;IAC3C,MAAMC,eAAe;IACrB,MAAMC,eAAe;IAErB,IAAIC,QAAQ,CAAC,oBAAoB,EAAED,aAAa,iBAAiB,EAAED,aAAa,KAAK,CAAC;IACtF,IAAID,KAAK;QACPG,SAAS,CAAC,UAAU,EAAED,aAAa,UAAU,EAAED,aAAa,EAAE,CAAC;QAC/DE,SAAS,CAAC,UAAU,EAAED,aAAa,UAAU,EAAED,aAAa,EAAE,CAAC;IACjE;IACA,OAAO,IAAIG,OAAOD,OAAO;AAC3B"}
@@ -1,13 +0,0 @@
1
- const path = require('path');
2
- const major = +process.versions.node.split('.')[0];
3
- const version = major >= 14 ? 'local' : 'lts';
4
- const worker = path.resolve(__dirname, 'workers', `transformSync${path.extname(__filename)}`);
5
- let call = null; // break dependencies
6
- /**
7
- * @param {string} contents The file contents.
8
- * @param {string} fileName The filename.
9
- * @returns {{ code: string, map?: string }} Returns object with the transformed code and source map if option sourceMaps was provided.
10
- */ module.exports = function transformSync(contents, fileName, config) {
11
- if (!call) call = require('node-version-call'); // break dependencies
12
- return call(version, worker, contents, fileName, config);
13
- };
@@ -1 +0,0 @@
1
- {"version":3,"sources":["transformSync.cjs"],"sourcesContent":["const path = require('path');\n\nconst major = +process.versions.node.split('.')[0];\nconst version = major >= 14 ? 'local' : 'lts';\nconst worker = path.resolve(__dirname, 'workers', `transformSync${path.extname(__filename)}`);\n\nlet call = null; // break dependencies\n\n/**\n * @param {string} contents The file contents.\n * @param {string} fileName The filename.\n * @returns {{ code: string, map?: string }} Returns object with the transformed code and source map if option sourceMaps was provided.\n */\nmodule.exports = function transformSync(contents, fileName, config) {\n if (!call) call = require('node-version-call'); // break dependencies\n\n return call(version, worker, contents, fileName, config);\n};\n"],"names":["path","require","major","process","versions","node","split","version","worker","resolve","__dirname","extname","__filename","call","module","exports","transformSync","contents","fileName","config"],"mappings":"AAAA,MAAMA,OAAOC,QAAQ;AAErB,MAAMC,QAAQ,CAACC,QAAQC,QAAQ,CAACC,IAAI,CAACC,KAAK,CAAC,IAAI,CAAC,EAAE;AAClD,MAAMC,UAAUL,SAAS,KAAK,UAAU;AACxC,MAAMM,SAASR,KAAKS,OAAO,CAACC,WAAW,WAAW,CAAC,aAAa,EAAEV,KAAKW,OAAO,CAACC,aAAa;AAE5F,IAAIC,OAAO,MAAM,qBAAqB;AAEtC;;;;CAIC,GACDC,OAAOC,OAAO,GAAG,SAASC,cAAcC,QAAQ,EAAEC,QAAQ,EAAEC,MAAM;IAChE,IAAI,CAACN,MAAMA,OAAOZ,QAAQ,sBAAsB,qBAAqB;IAErE,OAAOY,KAAKN,SAASC,QAAQS,UAAUC,UAAUC;AACnD"}
@@ -1,4 +0,0 @@
1
- export { default as createMatcher } from "./createMatcher.mjs";
2
- export { default as transformFile } from "./transformFile.mjs";
3
- export { default as transformDirectory } from "./transformDirectory.mjs";
4
- export { default as transformSync } from "./transformSync.cjs";
@@ -1 +0,0 @@
1
- export default function regexDependencies(esm: any): RegExp;
@@ -1,5 +0,0 @@
1
- declare function _exports(contents: string, fileName: string, config: any): {
2
- code: string;
3
- map?: string;
4
- };
5
- export = _exports;