ts-swc-transform 2.11.12 → 2.11.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cjs/index.js CHANGED
@@ -52,18 +52,12 @@ function _getRequireWildcardCache(nodeInterop) {
52
52
  })(nodeInterop);
53
53
  }
54
54
  function _interop_require_wildcard(obj, nodeInterop) {
55
- if (!nodeInterop && obj && obj.__esModule) {
56
- return obj;
57
- }
58
- if (obj === null || typeof obj !== "object" && typeof obj !== "function") {
59
- return {
60
- default: obj
61
- };
62
- }
55
+ if (!nodeInterop && obj && obj.__esModule) return obj;
56
+ if (obj === null || typeof obj !== "object" && typeof obj !== "function") return {
57
+ default: obj
58
+ };
63
59
  var cache = _getRequireWildcardCache(nodeInterop);
64
- if (cache && cache.has(obj)) {
65
- return cache.get(obj);
66
- }
60
+ if (cache && cache.has(obj)) return cache.get(obj);
67
61
  var newObj = {
68
62
  __proto__: null
69
63
  };
@@ -71,17 +65,12 @@ function _interop_require_wildcard(obj, nodeInterop) {
71
65
  for(var key in obj){
72
66
  if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
73
67
  var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;
74
- if (desc && (desc.get || desc.set)) {
75
- Object.defineProperty(newObj, key, desc);
76
- } else {
77
- newObj[key] = obj[key];
78
- }
68
+ if (desc && (desc.get || desc.set)) Object.defineProperty(newObj, key, desc);
69
+ else newObj[key] = obj[key];
79
70
  }
80
71
  }
81
72
  newObj.default = obj;
82
- if (cache) {
83
- cache.set(obj, newObj);
84
- }
73
+ if (cache) cache.set(obj, newObj);
85
74
  return newObj;
86
75
  }
87
76
  /* CJS INTEROP */ if (exports.__esModule && exports.default) { try { Object.defineProperty(exports.default, '__esModule', { value: true }); for (var key in exports) { exports.default[key] = exports[key]; } } catch (_) {}; module.exports = exports.default; }
@@ -22,18 +22,14 @@ function _define_property(obj, key, value) {
22
22
  configurable: true,
23
23
  writable: true
24
24
  });
25
- } else {
26
- obj[key] = value;
27
- }
25
+ } else obj[key] = value;
28
26
  return obj;
29
27
  }
30
28
  function _instanceof(left, right) {
31
29
  "@swc/helpers - instanceof";
32
30
  if (right != null && typeof Symbol !== "undefined" && right[Symbol.hasInstance]) {
33
31
  return !!right[Symbol.hasInstance](left);
34
- } else {
35
- return left instanceof right;
36
- }
32
+ } else return left instanceof right;
37
33
  }
38
34
  function _interop_require_default(obj) {
39
35
  return obj && obj.__esModule ? obj : {
@@ -70,9 +66,8 @@ function ownKeys(object, enumerableOnly) {
70
66
  }
71
67
  function _object_spread_props(target, source) {
72
68
  source = source != null ? source : {};
73
- if (Object.getOwnPropertyDescriptors) {
74
- Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
75
- } else {
69
+ if (Object.getOwnPropertyDescriptors) Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
70
+ else {
76
71
  ownKeys(Object(source)).forEach(function(key) {
77
72
  Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
78
73
  });
@@ -1 +1 @@
1
- {"version":3,"sources":["/Users/kevin/Dev/OpenSource/typescript/ts-swc-transform/src/lib/prepareSWCOptions.ts"],"sourcesContent":["import type { Options } from '@swc/core';\nimport { installSync, matchesLibc } from 'install-optional';\nimport debounce from 'lodash.debounce';\nimport Module from 'module';\nimport path from 'path';\nimport tsConstants from 'ts-constants';\nimport url from 'url';\n\nconst _require = typeof require === 'undefined' ? Module.createRequire(import.meta.url) : require;\nconst __dirname = path.dirname(typeof __filename !== 'undefined' ? __filename : url.fileURLToPath(import.meta.url));\n\nimport type { TSConfig } from '../types.ts';\n\nexport interface TranspilerOptions {\n tsxOptions: Options;\n nonTsxOptions: Options;\n}\n\nconst installSyncSWC = debounce(installSync, 300, { leading: true, trailing: false });\n\n// tsconfig spells enums as strings (\"es2019\", \"react-jsx\"); swc needs the numbers.\nfunction enumValue(map: Record<string, unknown>, value: unknown): unknown {\n if (typeof value !== 'string') return value;\n const wanted = value.replace(/-/g, '').toLowerCase();\n const names = Object.keys(map);\n for (let i = 0; i < names.length; i++) {\n if (typeof map[names[i]] === 'number' && names[i].toLowerCase() === wanted) return map[names[i]];\n }\n return undefined;\n}\n\nfunction normalizeCompilerOptions(raw: Record<string, unknown>): Record<string, unknown> {\n return {\n ...raw,\n target: enumValue(tsConstants.ScriptTarget as unknown as Record<string, unknown>, raw.target),\n module: enumValue(tsConstants.ModuleKind as unknown as Record<string, unknown>, raw.module),\n jsx: enumValue(tsConstants.JsxEmit as unknown as Record<string, unknown>, raw.jsx),\n };\n}\n\nexport default function prepareSWCOptions(tsconfig: TSConfig): TranspilerOptions {\n installSyncSWC('@swc/core', `${process.platform}-${process.arch}`, { cwd: __dirname, filter: matchesLibc });\n try {\n const ts = _require('typescript');\n const swc = _require('@swc/core');\n const transpiler = _require('ts-node/transpilers/swc');\n // TypeScript 7 dropped the compiler API from the package root, so fall back\n // to resolving the enum-valued fields directly.\n const options = typeof ts.parseJsonConfigFileContent === 'function' ? ts.parseJsonConfigFileContent(tsconfig.config, ts.sys, path.dirname(tsconfig.path)).options : normalizeCompilerOptions((tsconfig.config.compilerOptions || {}) as Record<string, unknown>);\n return transpiler.createSwcOptions(options, undefined, swc, 'swc');\n } catch (err) {\n console.log(`prepareSWCOptions failed: ${err instanceof Error ? err.message : String(err)}`);\n return {} as TranspilerOptions;\n }\n}\n"],"names":["prepareSWCOptions","_require","require","Module","createRequire","__dirname","path","dirname","__filename","url","fileURLToPath","installSyncSWC","debounce","installSync","leading","trailing","enumValue","map","value","wanted","replace","toLowerCase","names","Object","keys","i","length","undefined","normalizeCompilerOptions","raw","target","tsConstants","ScriptTarget","module","ModuleKind","jsx","JsxEmit","tsconfig","process","platform","arch","cwd","filter","matchesLibc","ts","swc","transpiler","options","parseJsonConfigFileContent","config","sys","compilerOptions","createSwcOptions","err","console","log","Error","message","String"],"mappings":";;;;+BAwCA;;;eAAwBA;;;+BAvCiB;qEACpB;6DACF;2DACF;kEACO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AAMC,KAAK3C,SAAS;QACpB,IAAM4C,MAAM5C,SAAS;QACrB,IAAM6C,aAAa7C,SAAS;QAC5B,4EAA4E;QAC5E,gDAAgD;QAChD,IAAM8C,UAAU,OAAOH,GAAGI,0BAA0B,KAAK,aAAaJ,GAAGI,0BAA0B,CAACX,SAASY,MAAM,EAAEL,GAAGM,GAAG,EAAE5C,aAAI,CAACC,OAAO,CAAC8B,SAAS/B,IAAI,GAAGyC,OAAO,GAAGnB,yBAA0BS,SAASY,MAAM,CAACE,eAAe,IAAI,CAAC;QAClO,OAAOL,WAAWM,gBAAgB,CAACL,SAASpB,WAAWkB,KAAK;IAC9D,EAAE,OAAOQ,KAAK;QACZC,QAAQC,GAAG,CAAC,AAAC,6BAA6E,OAAjDF,AAAG,YAAHA,KAAeG,SAAQH,IAAII,OAAO,GAAGC,OAAOL;QACrF,OAAO,CAAC;IACV;AACF"}
1
+ {"version":3,"sources":["/Users/kevin/Dev/OpenSource/typescript/ts-swc-transform/src/lib/prepareSWCOptions.ts"],"sourcesContent":["import type { Options } from '@swc/core';\nimport { installSync, matchesLibc } from 'install-optional';\nimport debounce from 'lodash.debounce';\nimport Module from 'module';\nimport path from 'path';\nimport tsConstants from 'ts-constants';\nimport url from 'url';\n\nconst _require = typeof require === 'undefined' ? Module.createRequire(import.meta.url) : require;\nconst __dirname = path.dirname(typeof __filename !== 'undefined' ? __filename : url.fileURLToPath(import.meta.url));\n\nimport type { TSConfig } from '../types.ts';\n\nexport interface TranspilerOptions {\n tsxOptions: Options;\n nonTsxOptions: Options;\n}\n\nconst installSyncSWC = debounce(installSync, 300, { leading: true, trailing: false });\n\n// tsconfig spells enums as strings (\"es2019\", \"react-jsx\"); swc needs the numbers.\nfunction enumValue(map: Record<string, unknown>, value: unknown): unknown {\n if (typeof value !== 'string') return value;\n const wanted = value.replace(/-/g, '').toLowerCase();\n const names = Object.keys(map);\n for (let i = 0; i < names.length; i++) {\n if (typeof map[names[i]] === 'number' && names[i].toLowerCase() === wanted) return map[names[i]];\n }\n return undefined;\n}\n\nfunction normalizeCompilerOptions(raw: Record<string, unknown>): Record<string, unknown> {\n return {\n ...raw,\n target: enumValue(tsConstants.ScriptTarget as unknown as Record<string, unknown>, raw.target),\n module: enumValue(tsConstants.ModuleKind as unknown as Record<string, unknown>, raw.module),\n jsx: enumValue(tsConstants.JsxEmit as unknown as Record<string, unknown>, raw.jsx),\n };\n}\n\nexport default function prepareSWCOptions(tsconfig: TSConfig): TranspilerOptions {\n installSyncSWC('@swc/core', `${process.platform}-${process.arch}`, { cwd: __dirname, filter: matchesLibc });\n try {\n const ts = _require('typescript');\n const swc = _require('@swc/core');\n const transpiler = _require('ts-node/transpilers/swc');\n // TypeScript 7 dropped the compiler API from the package root, so fall back\n // to resolving the enum-valued fields directly.\n const options = typeof ts.parseJsonConfigFileContent === 'function' ? ts.parseJsonConfigFileContent(tsconfig.config, ts.sys, path.dirname(tsconfig.path)).options : normalizeCompilerOptions((tsconfig.config.compilerOptions || {}) as Record<string, unknown>);\n return transpiler.createSwcOptions(options, undefined, swc, 'swc');\n } catch (err) {\n console.log(`prepareSWCOptions failed: ${err instanceof Error ? err.message : String(err)}`);\n return {} as TranspilerOptions;\n }\n}\n"],"names":["prepareSWCOptions","_require","require","Module","createRequire","__dirname","path","dirname","__filename","url","fileURLToPath","installSyncSWC","debounce","installSync","leading","trailing","enumValue","map","value","wanted","replace","toLowerCase","names","Object","keys","i","length","undefined","normalizeCompilerOptions","raw","target","tsConstants","ScriptTarget","module","ModuleKind","jsx","JsxEmit","tsconfig","process","platform","arch","cwd","filter","matchesLibc","ts","swc","transpiler","options","parseJsonConfigFileContent","config","sys","compilerOptions","createSwcOptions","err","console","log","Error","message","String"],"mappings":";;;;+BAwCA;;;eAAwBA;;;+BAvCiB;qEACpB;6DACF;2DACF;kEACO;0DACR;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEhB,IAAMC,WAAW,OAAOC,Y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,IAAM8C,UAAU,OAAOH,GAAGI,0BAA0B,KAAK,aAAaJ,GAAGI,0BAA0B,CAACX,SAASY,MAAM,EAAEL,GAAGM,GAAG,EAAE5C,aAAI,CAACC,OAAO,CAAC8B,SAAS/B,IAAI,GAAGyC,OAAO,GAAGnB,yBAA0BS,SAASY,MAAM,CAACE,eAAe,IAAI,CAAC;QAClO,OAAOL,WAAWM,gBAAgB,CAACL,SAASpB,WAAWkB,KAAK;IAC9D,EAAE,OAAOQ,KAAK;QACZC,QAAQC,GAAG,CAAC,AAAC,6BAA6E,OAAjDF,AAAG,YAAHA,KAAeG,SAAQH,IAAII,OAAO,GAAGC,OAAOL;QACrF,OAAO,CAAC;IACV;AACF"}
@@ -32,18 +32,12 @@ function _getRequireWildcardCache(nodeInterop) {
32
32
  })(nodeInterop);
33
33
  }
34
34
  function _interop_require_wildcard(obj, nodeInterop) {
35
- if (!nodeInterop && obj && obj.__esModule) {
36
- return obj;
37
- }
38
- if (obj === null || typeof obj !== "object" && typeof obj !== "function") {
39
- return {
40
- default: obj
41
- };
42
- }
35
+ if (!nodeInterop && obj && obj.__esModule) return obj;
36
+ if (obj === null || typeof obj !== "object" && typeof obj !== "function") return {
37
+ default: obj
38
+ };
43
39
  var cache = _getRequireWildcardCache(nodeInterop);
44
- if (cache && cache.has(obj)) {
45
- return cache.get(obj);
46
- }
40
+ if (cache && cache.has(obj)) return cache.get(obj);
47
41
  var newObj = {
48
42
  __proto__: null
49
43
  };
@@ -51,17 +45,12 @@ function _interop_require_wildcard(obj, nodeInterop) {
51
45
  for(var key in obj){
52
46
  if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
53
47
  var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;
54
- if (desc && (desc.get || desc.set)) {
55
- Object.defineProperty(newObj, key, desc);
56
- } else {
57
- newObj[key] = obj[key];
58
- }
48
+ if (desc && (desc.get || desc.set)) Object.defineProperty(newObj, key, desc);
49
+ else newObj[key] = obj[key];
59
50
  }
60
51
  }
61
52
  newObj.default = obj;
62
- if (cache) {
63
- cache.set(obj, newObj);
64
- }
53
+ if (cache) cache.set(obj, newObj);
65
54
  return newObj;
66
55
  }
67
56
  var _resolve_default;
@@ -1 +1 @@
1
- {"version":3,"sources":["/Users/kevin/Dev/OpenSource/typescript/ts-swc-transform/src/lib/resolveCJS.ts"],"sourcesContent":["/**\n * CJS resolver\n *\n * Uses the `resolve` npm package for CommonJS-style module resolution.\n * Handles main field, index.js, etc.\n *\n * Note: CJS does not support subpath imports (#prefix) - those are ESM-only.\n */\n\nimport * as resolve from 'resolve';\n\nconst resolveSync = (resolve.default ?? resolve).sync;\n\n/**\n * Resolve a CJS specifier to an absolute file path\n *\n * @param specifier - The require specifier (e.g., 'lodash', 'lodash/get')\n * @param basedir - The directory to resolve from\n * @returns The resolved absolute file path\n * @throws Error if module cannot be found\n */\nexport default function resolveCJS(specifier: string, basedir: string): string {\n return resolveSync(specifier, {\n basedir,\n extensions: ['.js', '.json', '.node', '.mjs'],\n });\n}\n"],"names":["resolveCJS","resolve","resolveSync","default","sync","specifier","basedir","extensions"],"mappings":"AAAA;;;;;;;CAOC;;;;+BAMD;;;;;;;CAOC,GACD;;;eAAwBA;;;+DAZC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAEJC;AAArB,IAAMC,cAAc,EAACD,mBAAAA,SAAQE,OAAO,cAAfF,8BAAAA,mBAAmBA,UAASG,IAAI;AAUtC,SAASJ,WAAWK,SAAiB,EAAEC,OAAe;IACnE,OAAOJ,YAAYG,WAAW;QAC5BC,SAAAA;QACAC,YAAY;YAAC;YAAO;YAAS;YAAS;SAAO;IAC/C;AACF"}
1
+ {"version":3,"sources":["/Users/kevin/Dev/OpenSource/typescript/ts-swc-transform/src/lib/resolveCJS.ts"],"sourcesContent":["/**\n * CJS resolver\n *\n * Uses the `resolve` npm package for CommonJS-style module resolution.\n * Handles main field, index.js, etc.\n *\n * Note: CJS does not support subpath imports (#prefix) - those are ESM-only.\n */\n\nimport * as resolve from 'resolve';\n\nconst resolveSync = (resolve.default ?? resolve).sync;\n\n/**\n * Resolve a CJS specifier to an absolute file path\n *\n * @param specifier - The require specifier (e.g., 'lodash', 'lodash/get')\n * @param basedir - The directory to resolve from\n * @returns The resolved absolute file path\n * @throws Error if module cannot be found\n */\nexport default function resolveCJS(specifier: string, basedir: string): string {\n return resolveSync(specifier, {\n basedir,\n extensions: ['.js', '.json', '.node', '.mjs'],\n });\n}\n"],"names":["resolveCJS","resolve","resolveSync","default","sync","specifier","basedir","extensions"],"mappings":"AAAA;;;;;;;CAOC;;;;+BAMD;;;;;;;CAOC,GACD;;;eAAwBA;;;+DAZC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAEJC;AAArB,IAAMC,cAAc,EAACD,mBAAAA,SAAQE,OAAO,cAAfF,8BAAAA,mBAAmBA,UAASG,IAAI;AAUtC,SAASJ,WAAWK,SAAiB,EAAEC,OAAe;IACnE,OAAOJ,YAAYG,WAAW;QAC5BC,SAAAA;QACAC,YAAY;YAAC;YAAO;YAAS;YAAS;SAAO;IAC/C;AACF"}
@@ -24,9 +24,7 @@ function _define_property(obj, key, value) {
24
24
  configurable: true,
25
25
  writable: true
26
26
  });
27
- } else {
28
- obj[key] = value;
29
- }
27
+ } else obj[key] = value;
30
28
  return obj;
31
29
  }
32
30
  function _interop_require_default(obj) {
@@ -64,9 +62,8 @@ function ownKeys(object, enumerableOnly) {
64
62
  }
65
63
  function _object_spread_props(target, source) {
66
64
  source = source != null ? source : {};
67
- if (Object.getOwnPropertyDescriptors) {
68
- Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
69
- } else {
65
+ if (Object.getOwnPropertyDescriptors) Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
66
+ else {
70
67
  ownKeys(Object(source)).forEach(function(key) {
71
68
  Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
72
69
  });
@@ -1 +1 @@
1
- {"version":3,"sources":["/Users/kevin/Dev/OpenSource/typescript/ts-swc-transform/src/lib/transformFile.ts"],"sourcesContent":["import type { Output } from '@swc/core';\nimport fs from 'fs';\nimport type { Entry } from 'fs-iterator';\nimport mkdirp from 'mkdirp-classic';\nimport Module from 'module';\nimport path from 'path';\nimport Queue from 'queue-cb';\n\nimport patchCJS from '../lib/patchCJS.ts';\nimport patchESM from '../lib/patchESM.ts';\nimport prepareSWCOptions from '../lib/prepareSWCOptions.ts';\n\nconst _require = typeof require === 'undefined' ? Module.createRequire(import.meta.url) : require;\n\nimport type { InternalConfigOptions, TargetType, TransformFileCallback } from '../types.ts';\n\nexport default function transformFile(entry: Entry, dest: string, type: TargetType, options: InternalConfigOptions, mode: number | undefined, callback: TransformFileCallback): void {\n let tsconfig = options.tsconfig;\n\n // overrides for cjs\n if (type === 'cjs') {\n const compilerOptions = { ...(tsconfig.config.compilerOptions || {}), module: 'commonjs' as const, target: 'es5' as const };\n tsconfig = { ...tsconfig, config: { ...tsconfig.config, compilerOptions } };\n }\n\n const swcOptions = prepareSWCOptions(tsconfig);\n const swc = _require('@swc/core');\n const ext = path.extname(entry.basename as string);\n\n swc\n .transformFile(entry.fullPath, {\n ...(ext === '.tsx' || ext === '.jsx' ? swcOptions.tsxOptions : swcOptions.nonTsxOptions),\n filename: entry.basename,\n })\n .then((output: Output) => {\n const extTarget = type === 'esm' ? patchESM(entry, output, options) : patchCJS(entry, output, options);\n const ext = path.extname(entry.path);\n const outPath = path.join(dest, (ext ? entry.path.slice(0, -ext.length) : entry.path) + extTarget);\n\n mkdirp(path.dirname(outPath), () => {\n const queue = new Queue();\n queue.defer((cb) => fs.writeFile(outPath, output.code, 'utf8', (err) => cb(err)));\n if (output.map && options.sourceMaps) queue.defer((cb) => fs.writeFile(`${outPath}.map`, output.map as string, 'utf8', (err) => cb(err)));\n queue.await((err) => {\n if (err) return callback(err);\n\n if (mode) {\n const execBits = mode & 0o111;\n if (execBits) {\n fs.chmod(outPath, 0o644 | execBits, (_chmodErr) => {\n callback(null, outPath);\n });\n return;\n }\n }\n callback(null, outPath);\n });\n });\n })\n .catch(callback);\n}\n"],"names":["transformFile","_require","require","Module","createRequire","entry","dest","type","options","mode","callback","tsconfig","compilerOptions","config","module","target","swcOptions","prepareSWCOptions","swc","ext","path","extname","basename","fullPath","tsxOptions","nonTsxOptions","filename","then","output","extTarget","patchESM","patchCJS","outPath","join","slice","length","mkdirp","dirname","queue","Queue","defer","cb","fs","writeFile","code","err","map","sourceMaps","await","execBits","chmod","_chmodErr","catch"],"mappings":";;;;+BAgBA;;;eAAwBA;;;yDAfT;oEAEI;6DACA;2DACF;8DACC;iEAEG;iEACA;0EACS;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAE9B,IAAMC,WAAW,OAAOC,YAAY,cAAcC,eAAM,CAACC,aAAa,CAAC,uDAAmBF;AAI3E,SAASF,cAAcK,KAAY,EAAEC,IAAY,EAAEC,IAAgB,EAAEC,OAA8B,EAAEC,IAAwB,EAAEC,QAA+B;IAC3K,IAAIC,WAAWH,QAAQG,QAAQ;IAE/B,oBAAoB;IACpB,IAAIJ,SAAS,OAAO;QAClB,IAAMK,kBAAkB,wCAAMD,SAASE,MAAM,CAACD,eAAe,IAAI,CAAC;YAAIE,QAAQ;YAAqBC,QAAQ;;QAC3GJ,WAAW,wCAAKA;YAAUE,QAAQ,wCAAKF,SAASE,MAAM;gBAAED,iBAAAA;;;IAC1D;IAEA,IAAMI,aAAaC,IAAAA,4BAAiB,EAACN;IACrC,IAAMO,MAAMjB,SAAS;IACrB,IAAMkB,MAAMC,aAAI,CAACC,OAAO,CAAChB,MAAMiB,QAAQ;IAEvCJ,IACGlB,aAAa,CAACK,MAAMkB,QAAQ,EAAE,wCACzBJ,QAAQ,UAAUA,QAAQ,SAASH,WAAWQ,UAAU,GAAGR,WAAWS,aAAa;QACvFC,UAAUrB,MAAMiB,QAAQ;QAEzBK,IAAI,CAAC,SAACC;QACL,IAAMC,YAAYtB,SAAS,QAAQuB,IAAAA,mBAAQ,EAACzB,OAAOuB,QAAQpB,WAAWuB,IAAAA,mBAAQ,EAAC1B,OAAOuB,QAAQpB;QAC9F,IAAMW,MAAMC,aAAI,CAACC,OAAO,CAAChB,MAAMe,IAAI;QACnC,IAAMY,UAAUZ,aAAI,CAACa,IAAI,CAAC3B,MAAM,AAACa,CAAAA,MAAMd,MAAMe,IAAI,CAACc,KAAK,CAAC,GAAG,CAACf,IAAIgB,MAAM,IAAI9B,MAAMe,IAAI,AAAD,IAAKS;QAExFO,IAAAA,sBAAM,EAAChB,aAAI,CAACiB,OAAO,CAACL,UAAU;YAC5B,IAAMM,QAAQ,IAAIC,gBAAK;YACvBD,MAAME,KAAK,CAAC,SAACC;uBAAOC,WAAE,CAACC,SAAS,CAACX,SAASJ,OAAOgB,IAAI,EAAE,QAAQ,SAACC;2BAAQJ,GAAGI;;;YAC3E,IAAIjB,OAAOkB,GAAG,IAAItC,QAAQuC,UAAU,EAAET,MAAME,KAAK,CAAC,SAACC;uBAAOC,WAAE,CAACC,SAAS,CAAC,AAAC,GAAU,OAARX,SAAQ,SAAOJ,OAAOkB,GAAG,EAAY,QAAQ,SAACD;2BAAQJ,GAAGI;;;YACnIP,MAAMU,KAAK,CAAC,SAACH;gBACX,IAAIA,KAAK,OAAOnC,SAASmC;gBAEzB,IAAIpC,MAAM;oBACR,IAAMwC,WAAWxC,OAAO;oBACxB,IAAIwC,UAAU;wBACZP,WAAE,CAACQ,KAAK,CAAClB,SAAS,MAAQiB,UAAU,SAACE;4BACnCzC,SAAS,MAAMsB;wBACjB;wBACA;oBACF;gBACF;gBACAtB,SAAS,MAAMsB;YACjB;QACF;IACF,GACCoB,KAAK,CAAC1C;AACX"}
1
+ {"version":3,"sources":["/Users/kevin/Dev/OpenSource/typescript/ts-swc-transform/src/lib/transformFile.ts"],"sourcesContent":["import type { Output } from '@swc/core';\nimport fs from 'fs';\nimport type { Entry } from 'fs-iterator';\nimport mkdirp from 'mkdirp-classic';\nimport Module from 'module';\nimport path from 'path';\nimport Queue from 'queue-cb';\n\nimport patchCJS from '../lib/patchCJS.ts';\nimport patchESM from '../lib/patchESM.ts';\nimport prepareSWCOptions from '../lib/prepareSWCOptions.ts';\n\nconst _require = typeof require === 'undefined' ? Module.createRequire(import.meta.url) : require;\n\nimport type { InternalConfigOptions, TargetType, TransformFileCallback } from '../types.ts';\n\nexport default function transformFile(entry: Entry, dest: string, type: TargetType, options: InternalConfigOptions, mode: number | undefined, callback: TransformFileCallback): void {\n let tsconfig = options.tsconfig;\n\n // overrides for cjs\n if (type === 'cjs') {\n const compilerOptions = { ...(tsconfig.config.compilerOptions || {}), module: 'commonjs' as const, target: 'es5' as const };\n tsconfig = { ...tsconfig, config: { ...tsconfig.config, compilerOptions } };\n }\n\n const swcOptions = prepareSWCOptions(tsconfig);\n const swc = _require('@swc/core');\n const ext = path.extname(entry.basename as string);\n\n swc\n .transformFile(entry.fullPath, {\n ...(ext === '.tsx' || ext === '.jsx' ? swcOptions.tsxOptions : swcOptions.nonTsxOptions),\n filename: entry.basename,\n })\n .then((output: Output) => {\n const extTarget = type === 'esm' ? patchESM(entry, output, options) : patchCJS(entry, output, options);\n const ext = path.extname(entry.path);\n const outPath = path.join(dest, (ext ? entry.path.slice(0, -ext.length) : entry.path) + extTarget);\n\n mkdirp(path.dirname(outPath), () => {\n const queue = new Queue();\n queue.defer((cb) => fs.writeFile(outPath, output.code, 'utf8', (err) => cb(err)));\n if (output.map && options.sourceMaps) queue.defer((cb) => fs.writeFile(`${outPath}.map`, output.map as string, 'utf8', (err) => cb(err)));\n queue.await((err) => {\n if (err) return callback(err);\n\n if (mode) {\n const execBits = mode & 0o111;\n if (execBits) {\n fs.chmod(outPath, 0o644 | execBits, (_chmodErr) => {\n callback(null, outPath);\n });\n return;\n }\n }\n callback(null, outPath);\n });\n });\n })\n .catch(callback);\n}\n"],"names":["transformFile","_require","require","Module","createRequire","entry","dest","type","options","mode","callback","tsconfig","compilerOptions","config","module","target","swcOptions","prepareSWCOptions","swc","ext","path","extname","basename","fullPath","tsxOptions","nonTsxOptions","filename","then","output","extTarget","patchESM","patchCJS","outPath","join","slice","length","mkdirp","dirname","queue","Queue","defer","cb","fs","writeFile","code","err","map","sourceMaps","await","execBits","chmod","_chmodErr","catch"],"mappings":";;;;+BAgBA;;;eAAwBA;;;yDAfT;oEAEI;6DACA;2DACF;8DACC;iEAEG;iEACA;0EACS;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAE9B,IAAMC,WAAW,OAAOC,YAAY,cAAcC,eAAM,CAACC,aAAa,CAAC,uDAAmBF;AAI3E,SAASF,cAAcK,KAAY,EAAEC,IAAY,EAAEC,IAAgB,EAAEC,OAA8B,EAAEC,IAAwB,EAAEC,QAA+B;IAC3K,IAAIC,WAAWH,QAAQG,QAAQ;IAE/B,oBAAoB;IACpB,IAAIJ,SAAS,OAAO;QAClB,IAAMK,kBAAkB,wCAAMD,SAASE,MAAM,CAACD,eAAe,IAAI,CAAC;YAAIE,QAAQ;YAAqBC,QAAQ;;QAC3GJ,WAAW,wCAAKA;YAAUE,QAAQ,wCAAKF,SAASE,MAAM;gBAAED,iBAAAA;;;IAC1D;IAEA,IAAMI,aAAaC,IAAAA,4BAAiB,EAACN;IACrC,IAAMO,MAAMjB,SAAS;IACrB,IAAMkB,MAAMC,aAAI,CAACC,OAAO,CAAChB,MAAMiB,QAAQ;IAEvCJ,IACGlB,aAAa,CAACK,MAAMkB,QAAQ,EAAE,wCACzBJ,QAAQ,UAAUA,QAAQ,SAASH,WAAWQ,UAAU,GAAGR,WAAWS,aAAa;QACvFC,UAAUrB,MAAMiB,QAAQ;QAEzBK,IAAI,CAAC,SAACC;QACL,IAAMC,YAAYtB,SAAS,QAAQuB,IAAAA,mBAAQ,EAACzB,OAAOuB,QAAQpB,WAAWuB,IAAAA,mBAAQ,EAAC1B,OAAOuB,QAAQpB;QAC9F,IAAMW,MAAMC,aAAI,CAACC,OAAO,CAAChB,MAAMe,IAAI;QACnC,IAAMY,UAAUZ,aAAI,CAACa,IAAI,CAAC3B,MAAM,AAACa,CAAAA,MAAMd,MAAMe,IAAI,CAACc,KAAK,CAAC,GAAG,CAACf,IAAIgB,MAAM,IAAI9B,MAAMe,IAAI,AAAD,IAAKS;QAExFO,IAAAA,sBAAM,EAAChB,aAAI,CAACiB,OAAO,CAACL,UAAU;YAC5B,IAAMM,QAAQ,IAAIC,gBAAK;YACvBD,MAAME,KAAK,CAAC,SAACC;uBAAOC,WAAE,CAACC,SAAS,CAACX,SAASJ,OAAOgB,IAAI,EAAE,QAAQ,SAACC;2BAAQJ,GAAGI;;;YAC3E,IAAIjB,OAAOkB,GAAG,IAAItC,QAAQuC,UAAU,EAAET,MAAME,KAAK,CAAC,SAACC;uBAAOC,WAAE,CAACC,SAAS,CAAC,AAAC,GAAU,OAARX,SAAQ,SAAOJ,OAAOkB,GAAG,EAAY,QAAQ,SAACD;2BAAQJ,GAAGI;;;YACnIP,MAAMU,KAAK,CAAC,SAACH;gBACX,IAAIA,KAAK,OAAOnC,SAASmC;gBAEzB,IAAIpC,MAAM;oBACR,IAAMwC,WAAWxC,OAAO;oBACxB,IAAIwC,UAAU;wBACZP,WAAE,CAACQ,KAAK,CAAClB,SAAS,MAAQiB,UAAU,SAACE;4BACnCzC,SAAS,MAAMsB;wBACjB;wBACA;oBACF;gBACF;gBACAtB,SAAS,MAAMsB;YACjB;QACF;IACF,GACCoB,KAAK,CAAC1C;AACX"}
@@ -31,18 +31,12 @@ function _getRequireWildcardCache(nodeInterop) {
31
31
  })(nodeInterop);
32
32
  }
33
33
  function _interop_require_wildcard(obj, nodeInterop) {
34
- if (!nodeInterop && obj && obj.__esModule) {
35
- return obj;
36
- }
37
- if (obj === null || typeof obj !== "object" && typeof obj !== "function") {
38
- return {
39
- default: obj
40
- };
41
- }
34
+ if (!nodeInterop && obj && obj.__esModule) return obj;
35
+ if (obj === null || typeof obj !== "object" && typeof obj !== "function") return {
36
+ default: obj
37
+ };
42
38
  var cache = _getRequireWildcardCache(nodeInterop);
43
- if (cache && cache.has(obj)) {
44
- return cache.get(obj);
45
- }
39
+ if (cache && cache.has(obj)) return cache.get(obj);
46
40
  var newObj = {
47
41
  __proto__: null
48
42
  };
@@ -50,17 +44,12 @@ function _interop_require_wildcard(obj, nodeInterop) {
50
44
  for(var key in obj){
51
45
  if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
52
46
  var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;
53
- if (desc && (desc.get || desc.set)) {
54
- Object.defineProperty(newObj, key, desc);
55
- } else {
56
- newObj[key] = obj[key];
57
- }
47
+ if (desc && (desc.get || desc.set)) Object.defineProperty(newObj, key, desc);
48
+ else newObj[key] = obj[key];
58
49
  }
59
50
  }
60
51
  newObj.default = obj;
61
- if (cache) {
62
- cache.set(obj, newObj);
63
- }
52
+ if (cache) cache.set(obj, newObj);
64
53
  return newObj;
65
54
  }
66
55
  var useCJS = !_module.default.createRequire;
@@ -1 +1 @@
1
- {"version":3,"sources":["/Users/kevin/Dev/OpenSource/typescript/ts-swc-transform/src/toPath.ts"],"sourcesContent":["import isAbsolute from 'is-absolute';\nimport module from 'module';\nimport path from 'path';\nimport url from 'url';\n\nimport { stringStartsWith } from './compat.ts';\nimport { moduleRegEx } from './constants.ts';\nimport resolveCJS from './lib/resolveCJS.ts';\nimport resolveESM from './lib/resolveESM.ts';\nimport * as urlPolyfills from './lib/urlFileUrl.ts';\nimport type { Context } from './types.ts';\n\nconst useCJS = !module.createRequire;\nconst fileURLToPath = url.fileURLToPath || urlPolyfills.fileURLToPath;\n\nfunction getParentPath(context: Context): string {\n if (context.parentPath) return path.dirname(context.parentPath);\n return context.parentURL ? path.dirname(toPath(context.parentURL)) : process.cwd();\n}\n\nfunction getParentFilePath(context?: Context): string {\n if (context?.parentPath) return context.parentPath;\n if (context?.parentURL) return fileURLToPath(context.parentURL);\n return path.join(process.cwd(), 'index.js');\n}\n\nexport default function toPath(specifier: string, context?: Context): string {\n // Handle file:// URLs\n if (stringStartsWith(specifier, 'file:')) return fileURLToPath(specifier);\n\n // Handle absolute paths\n if (isAbsolute(specifier)) return specifier;\n\n // Handle relative paths\n if (specifier[0] === '.') {\n const parentPath = context ? getParentPath(context) : process.cwd();\n return path.join(parentPath, specifier);\n }\n\n // Handle module specifiers (bare specifiers and # imports)\n // moduleRegEx matches: bare specifiers like 'lodash', '@scope/pkg'\n // specifier[0] === '#' matches: subpath imports like '#internal'\n if (moduleRegEx.test(specifier) || specifier[0] === '#') {\n const parentFilePath = getParentFilePath(context);\n const parentDir = path.dirname(parentFilePath);\n\n if (useCJS) {\n // CJS: use resolve package (does not support # imports)\n if (specifier[0] === '#') {\n throw new Error(`Cannot find module '${specifier}' from '${parentDir}' (subpath imports not supported in CJS mode)`);\n }\n return resolveCJS(specifier, parentDir);\n }\n // ESM: use unified resolver that handles both exports and imports\n const entryPath = resolveESM(specifier, parentFilePath);\n if (entryPath) return entryPath;\n\n // If ESM resolver failed, throw meaningful error\n throw new Error(`Cannot find module '${specifier}' from '${parentDir}'`);\n }\n\n return specifier;\n}\n"],"names":["toPath","useCJS","module","createRequire","fileURLToPath","url","urlPolyfills","getParentPath","context","parentPath","path","dirname","parentURL","process","cwd","getParentFilePath","join","specifier","stringStartsWith","isAbsolute","moduleRegEx","test","parentFilePath","parentDir","Error","resolveCJS","entryPath","resolveESM"],"mappings":";;;;+BA0BA;;;eAAwBA;;;iEA1BD;6DACJ;2DACF;0DACD;wBAEiB;2BACL;mEACL;mEACA;oEACO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAG9B,IAAMC,SAAS,CAACC,eAAM,CAACC,aAAa;AACpC,IAAMC,gBAAgBC,YAAG,CAACD,aAAa,IAAIE,cAAaF,aAAa;AAErE,SAASG,cAAcC,OAAgB;IACrC,IAAIA,QAAQC,UAAU,EAAE,OAAOC,aAAI,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ACjD,MAAM,IAAIF,MAAM,AAAC,uBAA0CD,OAApBN,WAAU,YAAoB,OAAVM,WAAU;IACvE;IAEA,OAAON;AACT"}
1
+ {"version":3,"sources":["/Users/kevin/Dev/OpenSource/typescript/ts-swc-transform/src/toPath.ts"],"sourcesContent":["import isAbsolute from 'is-absolute';\nimport module from 'module';\nimport path from 'path';\nimport url from 'url';\n\nimport { stringStartsWith } from './compat.ts';\nimport { moduleRegEx } from './constants.ts';\nimport resolveCJS from './lib/resolveCJS.ts';\nimport resolveESM from './lib/resolveESM.ts';\nimport * as urlPolyfills from './lib/urlFileUrl.ts';\nimport type { Context } from './types.ts';\n\nconst useCJS = !module.createRequire;\nconst fileURLToPath = url.fileURLToPath || urlPolyfills.fileURLToPath;\n\nfunction getParentPath(context: Context): string {\n if (context.parentPath) return path.dirname(context.parentPath);\n return context.parentURL ? path.dirname(toPath(context.parentURL)) : process.cwd();\n}\n\nfunction getParentFilePath(context?: Context): string {\n if (context?.parentPath) return context.parentPath;\n if (context?.parentURL) return fileURLToPath(context.parentURL);\n return path.join(process.cwd(), 'index.js');\n}\n\nexport default function toPath(specifier: string, context?: Context): string {\n // Handle file:// URLs\n if (stringStartsWith(specifier, 'file:')) return fileURLToPath(specifier);\n\n // Handle absolute paths\n if (isAbsolute(specifier)) return specifier;\n\n // Handle relative paths\n if (specifier[0] === '.') {\n const parentPath = context ? getParentPath(context) : process.cwd();\n return path.join(parentPath, specifier);\n }\n\n // Handle module specifiers (bare specifiers and # imports)\n // moduleRegEx matches: bare specifiers like 'lodash', '@scope/pkg'\n // specifier[0] === '#' matches: subpath imports like '#internal'\n if (moduleRegEx.test(specifier) || specifier[0] === '#') {\n const parentFilePath = getParentFilePath(context);\n const parentDir = path.dirname(parentFilePath);\n\n if (useCJS) {\n // CJS: use resolve package (does not support # imports)\n if (specifier[0] === '#') {\n throw new Error(`Cannot find module '${specifier}' from '${parentDir}' (subpath imports not supported in CJS mode)`);\n }\n return resolveCJS(specifier, parentDir);\n }\n // ESM: use unified resolver that handles both exports and imports\n const entryPath = resolveESM(specifier, parentFilePath);\n if (entryPath) return entryPath;\n\n // If ESM resolver failed, throw meaningful error\n throw new Error(`Cannot find module '${specifier}' from '${parentDir}'`);\n }\n\n return specifier;\n}\n"],"names":["toPath","useCJS","module","createRequire","fileURLToPath","url","urlPolyfills","getParentPath","context","parentPath","path","dirname","parentURL","process","cwd","getParentFilePath","join","specifier","stringStartsWith","isAbsolute","moduleRegEx","test","parentFilePath","parentDir","Error","resolveCJS","entryPath","resolveESM"],"mappings":";;;;+BA0BA;;;eAAwBA;;;iEA1BD;6DACJ;2DACF;0DACD;wBAEiB;2BACL;mEACL;mEACA;oEACO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAG9B,IAAMC,SAAS,CAACC,eAAM,CAACC,aAAa;AACpC,IAAMC,gBAAgBC,YAAG,CAACD,aAAa,IAAIE,cAAaF,aAAa;AAErE,SAASG,cAAcC,OAAgB;IACrC,IAAIA,QAAQC,UAAU,EAAE,OAAOC,aAAI,CAACC,OAAO,CAACH,QAAQC,UAAU;IAC9D,OAAOD,QAAQI,SAAS,GAAGF,aAAI,CAACC,OAAO,CAACX,OAAOQ,QAAQI,SAAS,KAAKC,QAAQC,GAAG;AAClF;AAEA,SAASC,kBAAkBP,OAAiB;IAC1C,IAAIA,oBAAAA,8BAAAA,QAASC,UAAU,EAAE,OAAOD,QAAQC,UAAU;IAClD,IAAID,oBAAAA,8BAAAA,QAASI,SAAS,EAAE,OAAOR,cAAcI,QAAQI,SAAS;IAC9D,OAAOF,aAAI,CAACM,IAAI,CAACH,QAAQC,GAAG,IAAI;AAClC;AAEe,SAASd,OAAOiB,SAAiB,EAAET,OAAiB;IACjE,sBAAsB;IACtB,IAAIU,IAAAA,0BAAgB,EAACD,WAAW,UAAU,OAAOb,cAAca;IAE/D,wBAAwB;IACxB,IAAIE,IAAAA,mBAAU,EAACF,YAAY,OAAOA;IAElC,wBAAwB;IACxB,IAAIA,SAAS,CAAC,EAAE,KAAK,KAAK;QACxB,IAAMR,aAAaD,UAAUD,cAAcC,WAAWK,QAAQC,GAAG;QACjE,OAAOJ,aAAI,CAACM,IAAI,CAACP,YAAYQ;IAC/B;IAEA,2DAA2D;IAC3D,mEAAmE;IACnE,iEAAiE;IACjE,IAAIG,wBAAW,CAACC,IAAI,CAACJ,cAAcA,SAAS,CAAC,EAAE,KAAK,KAAK;QACvD,IAAMK,iBAAiBP,kBAAkBP;QACzC,IAAMe,YAAYb,aAAI,CAACC,OAAO,CAACW;QAE/B,IAAIrB,QAAQ;YACV,wDAAwD;YACxD,IAAIgB,SAAS,CAAC,EAAE,KAAK,KAAK;gBACxB,MAAM,IAAIO,MAAM,AAAC,uBAA0CD,OAApBN,WAAU,YAAoB,OAAVM,WAAU;YACvE;YACA,OAAOE,IAAAA,qBAAU,EAACR,WAAWM;QAC/B;QACA,kEAAkE;QAClE,IAAMG,YAAYC,IAAAA,qBAAU,EAACV,WAAWK;QACxC,IAAII,WAAW,OAAOA;QAEtB,iDAAiD;QACjD,MAAM,IAAIF,MAAM,AAAC,uBAA0CD,OAApBN,WAAU,YAAoB,OAAVM,WAAU;IACvE;IAEA,OAAON;AACT"}
@@ -21,9 +21,7 @@ function _define_property(obj, key, value) {
21
21
  configurable: true,
22
22
  writable: true
23
23
  });
24
- } else {
25
- obj[key] = value;
26
- }
24
+ } else obj[key] = value;
27
25
  return obj;
28
26
  }
29
27
  function _interop_require_default(obj) {
@@ -61,9 +59,8 @@ function ownKeys(object, enumerableOnly) {
61
59
  }
62
60
  function _object_spread_props(target, source) {
63
61
  source = source != null ? source : {};
64
- if (Object.getOwnPropertyDescriptors) {
65
- Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
66
- } else {
62
+ if (Object.getOwnPropertyDescriptors) Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
63
+ else {
67
64
  ownKeys(Object(source)).forEach(function(key) {
68
65
  Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
69
66
  });
@@ -1 +1 @@
1
- {"version":3,"sources":["/Users/kevin/Dev/OpenSource/typescript/ts-swc-transform/src/transformDirectory.ts"],"sourcesContent":["import Module from 'module';\nimport { bind } from 'node-version-call';\nimport path from 'path';\nimport loadConfigSync from 'read-tsconfig-sync';\nimport url from 'url';\n\nimport type { ConfigOptions, InternalConfigOptions, TargetType, TransformDirectoryCallback } from './types.ts';\n\nconst major = +process.versions.node.split('.')[0];\nconst _require = typeof require === 'undefined' ? Module.createRequire(import.meta.url) : require;\nconst __dirname = path.dirname(typeof __filename === 'undefined' ? url.fileURLToPath(import.meta.url) : __filename);\nconst workerPath = path.join(__dirname, '..', 'cjs', 'workers', 'transformDirectory.js');\n\nfunction run(src: string, dest: string, type: TargetType, options: ConfigOptions, callback: TransformDirectoryCallback) {\n return _require(workerPath)(src, dest, type, options, callback);\n}\n\n// spawnOptions: false - no node/npm spawn (library call only)\nconst worker = major >= 20 ? run : bind('>=20', workerPath, { callbacks: true, spawnOptions: false });\n\nexport default function transformDirectory(src: string, dest: string, type: TargetType, callback: TransformDirectoryCallback): void;\nexport default function transformDirectory(src: string, dest: string, type: TargetType, options: ConfigOptions, callback: TransformDirectoryCallback): void;\nexport default function transformDirectory(src: string, dest: string, type: TargetType): Promise<string[]>;\nexport default function transformDirectory(src: string, dest: string, type: TargetType, options: ConfigOptions): Promise<string[]>;\nexport default function transformDirectory(src: string, dest: string, type: TargetType, options?: ConfigOptions | TransformDirectoryCallback, callback?: TransformDirectoryCallback): void | Promise<string[]> {\n try {\n if (typeof src !== 'string') throw new Error('transformDirectory: unexpected source');\n if (typeof dest !== 'string') throw new Error('transformDirectory: unexpected destination directory');\n if (typeof type !== 'string') throw new Error('transformDirectory: unexpected type');\n\n callback = typeof options === 'function' ? options : callback;\n options = typeof options === 'function' ? {} : ((options || {}) as ConfigOptions);\n const tsconfig = options.tsconfig ? options.tsconfig : (loadConfigSync(src) ?? undefined);\n if (!tsconfig) throw new Error('transformDirectory: failed to load tsconfig');\n const opts: InternalConfigOptions = { ...options, tsconfig };\n\n if (typeof callback === 'function') return worker(src, dest, type, opts, callback);\n return new Promise<string[]>((resolve, reject) => worker(src, dest, type, opts, (err, result) => (err ? reject(err) : resolve(result ?? []))));\n } catch (err) {\n if (typeof callback === 'function') return callback(err as Error);\n return Promise.reject(err);\n }\n}\n"],"names":["transformDirectory","major","process","versions","node","split","_require","require","Module","createRequire","__dirname","path","dirname","__filename","url","fileURLToPath","workerPath","join","run","src","dest","type","options","callback","worker","bind","callbacks","spawnOptions","loadConfigSync","Error","tsconfig","undefined","opts","Promise","resolve","reject","err","result"],"mappings":";;;;+BAwBA;;;eAAwBA;;;6DAxBL;+BACE;2DACJ;uEACU;0DACX;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAIhB,IAAMC,QAAQ,CAACC,QAAQC,QAAQ,CAACC,IAAI,CAACC,KAAK,CAAC,IAAI,CAAC,EAAE;AAClD,IAAMC,WAAW,OAAOC,YAAY,cAAcC,eAAM,CAACC,aAAa,CAAC,uDAAmBF;AAC1F,IAAMG,YAAYC,aAAI,CAACC,OAAO,CAAC,OAAOC,eAAe,cAAcC,YAAG,CAACC,aAAa,CAAC,uDAAmBF;AACxG,IAAMG,aAAaL,aAAI,CAACM,IAAI,CAACP,WAAW,MAAM,OAAO,WAAW;AAEhE,SAASQ,IAAIC,GAAW,EAAEC,IAAY,EAAEC,IAAgB,EAAEC,OAAsB,EAAEC,QAAoC;IACpH,OAAOjB,SAASU,YAAYG,KAAKC,MAAMC,MAAMC,SAASC;AACxD;AAEA,8DAA8D;AAC9D,IAAMC,SAASvB,SAAS,KAAKiB,MAAMO,IAAAA,qBAAI,EAAC,QAAQT,YAAY;IAAEU,WAAW;IAAMC,cAAc;AAAM;AAMpF,SAAS3B,mBAAmBmB,GAAW,EAAEC,IAAY,EAAEC,IAAgB,EAAEC,OAAoD,EAAEC,QAAqC;IACjL,IAAI;YAOsDK;QANxD,IAAI,OAAOT,QAAQ,UAAU,MAAM,IAAIU,MAAM;QAC7C,IAAI,OAAOT,SAAS,UAAU,MAAM,IAAIS,MAAM;QAC9C,IAAI,OAAOR,SAAS,UAAU,MAAM,IAAIQ,MAAM;QAE9CN,WAAW,OAAOD,YAAY,aAAaA,UAAUC;QACrDD,UAAU,OAAOA,YAAY,aAAa,CAAC,IAAMA,WAAW,CAAC;QAC7D,IAAMQ,WAAWR,QAAQQ,QAAQ,GAAGR,QAAQQ,QAAQ,IAAIF,kBAAAA,IAAAA,yBAAc,EAACT,kBAAfS,6BAAAA,kBAAuBG;QAC/E,IAAI,CAACD,UAAU,MAAM,IAAID,MAAM;QAC/B,IAAMG,OAA8B,wCAAKV;YAASQ,UAAAA;;QAElD,IAAI,OAAOP,aAAa,YAAY,OAAOC,OAAOL,KAAKC,MAAMC,MAAMW,MAAMT;QACzE,OAAO,IAAIU,QAAkB,SAACC,SAASC;mBAAWX,OAAOL,KAAKC,MAAMC,MAAMW,MAAM,SAACI,KAAKC;uBAAYD,MAAMD,OAAOC,OAAOF,QAAQG,mBAAAA,oBAAAA,SAAU,EAAE;;;IAC5I,EAAE,OAAOD,KAAK;QACZ,IAAI,OAAOb,aAAa,YAAY,OAAOA,SAASa;QACpD,OAAOH,QAAQE,MAAM,CAACC;IACxB;AACF"}
1
+ {"version":3,"sources":["/Users/kevin/Dev/OpenSource/typescript/ts-swc-transform/src/transformDirectory.ts"],"sourcesContent":["import Module from 'module';\nimport { bind } from 'node-version-call';\nimport path from 'path';\nimport loadConfigSync from 'read-tsconfig-sync';\nimport url from 'url';\n\nimport type { ConfigOptions, InternalConfigOptions, TargetType, TransformDirectoryCallback } from './types.ts';\n\nconst major = +process.versions.node.split('.')[0];\nconst _require = typeof require === 'undefined' ? Module.createRequire(import.meta.url) : require;\nconst __dirname = path.dirname(typeof __filename === 'undefined' ? url.fileURLToPath(import.meta.url) : __filename);\nconst workerPath = path.join(__dirname, '..', 'cjs', 'workers', 'transformDirectory.js');\n\nfunction run(src: string, dest: string, type: TargetType, options: ConfigOptions, callback: TransformDirectoryCallback) {\n return _require(workerPath)(src, dest, type, options, callback);\n}\n\n// spawnOptions: false - no node/npm spawn (library call only)\nconst worker = major >= 20 ? run : bind('>=20', workerPath, { callbacks: true, spawnOptions: false });\n\nexport default function transformDirectory(src: string, dest: string, type: TargetType, callback: TransformDirectoryCallback): void;\nexport default function transformDirectory(src: string, dest: string, type: TargetType, options: ConfigOptions, callback: TransformDirectoryCallback): void;\nexport default function transformDirectory(src: string, dest: string, type: TargetType): Promise<string[]>;\nexport default function transformDirectory(src: string, dest: string, type: TargetType, options: ConfigOptions): Promise<string[]>;\nexport default function transformDirectory(src: string, dest: string, type: TargetType, options?: ConfigOptions | TransformDirectoryCallback, callback?: TransformDirectoryCallback): void | Promise<string[]> {\n try {\n if (typeof src !== 'string') throw new Error('transformDirectory: unexpected source');\n if (typeof dest !== 'string') throw new Error('transformDirectory: unexpected destination directory');\n if (typeof type !== 'string') throw new Error('transformDirectory: unexpected type');\n\n callback = typeof options === 'function' ? options : callback;\n options = typeof options === 'function' ? {} : ((options || {}) as ConfigOptions);\n const tsconfig = options.tsconfig ? options.tsconfig : (loadConfigSync(src) ?? undefined);\n if (!tsconfig) throw new Error('transformDirectory: failed to load tsconfig');\n const opts: InternalConfigOptions = { ...options, tsconfig };\n\n if (typeof callback === 'function') return worker(src, dest, type, opts, callback);\n return new Promise<string[]>((resolve, reject) => worker(src, dest, type, opts, (err, result) => (err ? reject(err) : resolve(result ?? []))));\n } catch (err) {\n if (typeof callback === 'function') return callback(err as Error);\n return Promise.reject(err);\n }\n}\n"],"names":["transformDirectory","major","process","versions","node","split","_require","require","Module","createRequire","__dirname","path","dirname","__filename","url","fileURLToPath","workerPath","join","run","src","dest","type","options","callback","worker","bind","callbacks","spawnOptions","loadConfigSync","Error","tsconfig","undefined","opts","Promise","resolve","reject","err","result"],"mappings":";;;;+BAwBA;;;eAAwBA;;;6DAxBL;+BACE;2DACJ;uEACU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AKV;YAASQ,UAAAA;;QAElD,IAAI,OAAOP,aAAa,YAAY,OAAOC,OAAOL,KAAKC,MAAMC,MAAMW,MAAMT;QACzE,OAAO,IAAIU,QAAkB,SAACC,SAASC;mBAAWX,OAAOL,KAAKC,MAAMC,MAAMW,MAAM,SAACI,KAAKC;uBAAYD,MAAMD,OAAOC,OAAOF,QAAQG,mBAAAA,oBAAAA,SAAU,EAAE;;;IAC5I,EAAE,OAAOD,KAAK;QACZ,IAAI,OAAOb,aAAa,YAAY,OAAOA,SAASa;QACpD,OAAOH,QAAQE,MAAM,CAACC;IACxB;AACF"}
@@ -21,9 +21,7 @@ function _define_property(obj, key, value) {
21
21
  configurable: true,
22
22
  writable: true
23
23
  });
24
- } else {
25
- obj[key] = value;
26
- }
24
+ } else obj[key] = value;
27
25
  return obj;
28
26
  }
29
27
  function _interop_require_default(obj) {
@@ -61,9 +59,8 @@ function ownKeys(object, enumerableOnly) {
61
59
  }
62
60
  function _object_spread_props(target, source) {
63
61
  source = source != null ? source : {};
64
- if (Object.getOwnPropertyDescriptors) {
65
- Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
66
- } else {
62
+ if (Object.getOwnPropertyDescriptors) Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
63
+ else {
67
64
  ownKeys(Object(source)).forEach(function(key) {
68
65
  Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
69
66
  });
@@ -1 +1 @@
1
- {"version":3,"sources":["/Users/kevin/Dev/OpenSource/typescript/ts-swc-transform/src/transformTypes.ts"],"sourcesContent":["import Module from 'module';\nimport { bind } from 'node-version-call';\nimport path from 'path';\nimport loadConfigSync from 'read-tsconfig-sync';\nimport url from 'url';\n\nimport type { ConfigOptions, InternalConfigOptions, TransformTypesCallback } from './types.ts';\n\nconst major = +process.versions.node.split('.')[0];\nconst _require = typeof require === 'undefined' ? Module.createRequire(import.meta.url) : require;\nconst __dirname = path.dirname(typeof __filename === 'undefined' ? url.fileURLToPath(import.meta.url) : __filename);\nconst workerPath = path.join(__dirname, '..', 'cjs', 'workers', 'transformTypes.js');\n\nfunction run(src: string, dest: string, options: ConfigOptions, callback: TransformTypesCallback) {\n return _require(workerPath)(src, dest, options, callback);\n}\n\n// spawnOptions: false - no node/npm spawn (library call only)\nconst worker = major >= 20 ? run : bind('>=20', workerPath, { callbacks: true, spawnOptions: false });\n\nexport default function transformTypes(src: string, dest: string, callback: TransformTypesCallback): void;\nexport default function transformTypes(src: string, dest: string, options: ConfigOptions, callback: TransformTypesCallback): void;\nexport default function transformTypes(src: string, dest: string): Promise<string[]>;\nexport default function transformTypes(src: string, dest: string, options: ConfigOptions): Promise<string[]>;\nexport default function transformTypes(src: string, dest: string, options?: ConfigOptions | TransformTypesCallback, callback?: TransformTypesCallback): void | Promise<string[]> {\n try {\n if (typeof src !== 'string') throw new Error('transformTypes: unexpected source');\n if (typeof dest !== 'string') throw new Error('transformTypes: unexpected destination directory');\n\n callback = typeof options === 'function' ? options : callback;\n options = typeof options === 'function' ? {} : ((options || {}) as ConfigOptions);\n const tsconfig = options.tsconfig ? options.tsconfig : (loadConfigSync(src) ?? undefined);\n if (!tsconfig) throw new Error('transformTypes: failed to load tsconfig');\n const opts: InternalConfigOptions = { ...options, tsconfig };\n\n if (typeof callback === 'function') return worker(src, dest, opts, callback);\n return new Promise<string[]>((resolve, reject) => worker(src, dest, opts, (err, result) => (err ? reject(err) : resolve(result ?? []))));\n } catch (err) {\n if (typeof callback === 'function') return callback(err as Error);\n return Promise.reject(err);\n }\n}\n"],"names":["transformTypes","major","process","versions","node","split","_require","require","Module","createRequire","__dirname","path","dirname","__filename","url","fileURLToPath","workerPath","join","run","src","dest","options","callback","worker","bind","callbacks","spawnOptions","loadConfigSync","Error","tsconfig","undefined","opts","Promise","resolve","reject","err","result"],"mappings":";;;;+BAwBA;;;eAAwBA;;;6DAxBL;+BACE;2DACJ;uEACU;0DACX;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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C,MAAMW,MAAM,SAACI,KAAKC;uBAAYD,MAAMD,OAAOC,OAAOF,QAAQG,mBAAAA,oBAAAA,SAAU,EAAE;;;IACtI,EAAE,OAAOD,KAAK;QACZ,IAAI,OAAOb,aAAa,YAAY,OAAOA,SAASa;QACpD,OAAOH,QAAQE,MAAM,CAACC;IACxB;AACF"}
1
+ {"version":3,"sources":["/Users/kevin/Dev/OpenSource/typescript/ts-swc-transform/src/transformTypes.ts"],"sourcesContent":["import Module from 'module';\nimport { bind } from 'node-version-call';\nimport path from 'path';\nimport loadConfigSync from 'read-tsconfig-sync';\nimport url from 'url';\n\nimport type { ConfigOptions, InternalConfigOptions, TransformTypesCallback } from './types.ts';\n\nconst major = +process.versions.node.split('.')[0];\nconst _require = typeof require === 'undefined' ? Module.createRequire(import.meta.url) : require;\nconst __dirname = path.dirname(typeof __filename === 'undefined' ? url.fileURLToPath(import.meta.url) : __filename);\nconst workerPath = path.join(__dirname, '..', 'cjs', 'workers', 'transformTypes.js');\n\nfunction run(src: string, dest: string, options: ConfigOptions, callback: TransformTypesCallback) {\n return _require(workerPath)(src, dest, options, callback);\n}\n\n// spawnOptions: false - no node/npm spawn (library call only)\nconst worker = major >= 20 ? run : bind('>=20', workerPath, { callbacks: true, spawnOptions: false });\n\nexport default function transformTypes(src: string, dest: string, callback: TransformTypesCallback): void;\nexport default function transformTypes(src: string, dest: string, options: ConfigOptions, callback: TransformTypesCallback): void;\nexport default function transformTypes(src: string, dest: string): Promise<string[]>;\nexport default function transformTypes(src: string, dest: string, options: ConfigOptions): Promise<string[]>;\nexport default function transformTypes(src: string, dest: string, options?: ConfigOptions | TransformTypesCallback, callback?: TransformTypesCallback): void | Promise<string[]> {\n try {\n if (typeof src !== 'string') throw new Error('transformTypes: unexpected source');\n if (typeof dest !== 'string') throw new Error('transformTypes: unexpected destination directory');\n\n callback = typeof options === 'function' ? options : callback;\n options = typeof options === 'function' ? {} : ((options || {}) as ConfigOptions);\n const tsconfig = options.tsconfig ? options.tsconfig : (loadConfigSync(src) ?? undefined);\n if (!tsconfig) throw new Error('transformTypes: failed to load tsconfig');\n const opts: InternalConfigOptions = { ...options, tsconfig };\n\n if (typeof callback === 'function') return worker(src, dest, opts, callback);\n return new Promise<string[]>((resolve, reject) => worker(src, dest, opts, (err, result) => (err ? reject(err) : resolve(result ?? []))));\n } catch (err) {\n if (typeof callback === 'function') return callback(err as Error);\n return Promise.reject(err);\n }\n}\n"],"names":["transformTypes","major","process","versions","node","split","_require","require","Module","createRequire","__dirname","path","dirname","__filename","url","fileURLToPath","workerPath","join","run","src","dest","options","callback","worker","bind","callbacks","spawnOptions","loadConfigSync","Error","tsconfig","undefined","opts","Promise","resolve","reject","err","result"],"mappings":";;;;+BAwBA;;;eAAwBA;;;6DAxBL;+BACE;2DACJ;uEACU;0DACX;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAIhB,IAAMC,QAAQ,CAACC,QAAQC,QAAQ,CAACC,IAAI,CAACC,KAAK,CAAC,IAAI,CAAC,EAAE;AAClD,IAAMC,WAAW,OAAOC,YAAY,cAAcC,eAAM,CAACC,aAAa,CAAC,uDAAmBF;AAC1F,IAAMG,YAAYC,aAAI,CAACC,OAAO,CAAC,OAAOC,eAAe,cAAcC,YAAG,CAACC,aAAa,CAAC,uDAAmBF;AACxG,IAAMG,aAAaL,aAAI,CAACM,IAAI,CAACP,WAAW,MAAM,OAAO,WAAW;AAEhE,SAASQ,IAAIC,GAAW,EAAEC,IAAY,EAAEC,OAAsB,EAAEC,QAAgC;IAC9F,OAAOhB,SAASU,YAAYG,KAAKC,MAAMC,SAASC;AAClD;AAEA,8DAA8D;AAC9D,IAAMC,SAAStB,SAAS,KAAKiB,MAAMM,IAAAA,qBAAI,EAAC,QAAQR,YAAY;IAAES,WAAW;IAAMC,cAAc;AAAM;AAMpF,SAAS1B,eAAemB,GAAW,EAAEC,IAAY,EAAEC,OAAgD,EAAEC,QAAiC;IACnJ,IAAI;YAMsDK;QALxD,IAAI,OAAOR,QAAQ,UAAU,MAAM,IAAIS,MAAM;QAC7C,IAAI,OAAOR,SAAS,UAAU,MAAM,IAAIQ,MAAM;QAE9CN,WAAW,OAAOD,YAAY,aAAaA,UAAUC;QACrDD,UAAU,OAAOA,YAAY,aAAa,CAAC,IAAMA,WAAW,CAAC;QAC7D,IAAMQ,WAAWR,QAAQQ,QAAQ,GAAGR,QAAQQ,QAAQ,IAAIF,kBAAAA,IAAAA,yBAAc,EAACR,kBAAfQ,6BAAAA,kBAAuBG;QAC/E,IAAI,CAACD,UAAU,MAAM,IAAID,MAAM;QAC/B,IAAMG,OAA8B,wCAAKV;YAASQ,UAAAA;;QAElD,IAAI,OAAOP,aAAa,YAAY,OAAOC,OAAOJ,KAAKC,MAAMW,MAAMT;QACnE,OAAO,IAAIU,QAAkB,SAACC,SAASC;mBAAWX,OAAOJ,KAAKC,MAAMW,MAAM,SAACI,KAAKC;uBAAYD,MAAMD,OAAOC,OAAOF,QAAQG,mBAAAA,oBAAAA,SAAU,EAAE;;;IACtI,EAAE,OAAOD,KAAK;QACZ,IAAI,OAAOb,aAAa,YAAY,OAAOA,SAASa;QACpD,OAAOH,QAAQE,MAAM,CAACC;IACxB;AACF"}
@@ -22,9 +22,7 @@ function _define_property(obj, key, value) {
22
22
  configurable: true,
23
23
  writable: true
24
24
  });
25
- } else {
26
- obj[key] = value;
27
- }
25
+ } else obj[key] = value;
28
26
  return obj;
29
27
  }
30
28
  function _interop_require_default(obj) {
@@ -62,9 +60,8 @@ function ownKeys(object, enumerableOnly) {
62
60
  }
63
61
  function _object_spread_props(target, source) {
64
62
  source = source != null ? source : {};
65
- if (Object.getOwnPropertyDescriptors) {
66
- Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
67
- } else {
63
+ if (Object.getOwnPropertyDescriptors) Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
64
+ else {
68
65
  ownKeys(Object(source)).forEach(function(key) {
69
66
  Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
70
67
  });
@@ -1 +1 @@
1
- {"version":3,"sources":["/Users/kevin/Dev/OpenSource/typescript/ts-swc-transform/src/workers/transformDirectory.ts"],"sourcesContent":["import type fs from 'fs';\nimport Iterator, { type Entry } from 'fs-iterator';\nimport path from 'path';\nimport Queue from 'queue-cb';\n\nimport { extensions, typeFileRegEx } from '../constants.ts';\nimport createMatcher from '../createMatcher.ts';\nimport transformFile from '../lib/transformFile.ts';\n\nimport type { InternalConfigOptions, TargetType, TransformDirectoryCallback } from '../types.ts';\n\nexport default function transformDirectoryWorker(src: string, dest: string, type: TargetType, options: InternalConfigOptions, callback: TransformDirectoryCallback) {\n const tsconfig = options.tsconfig;\n const matcher = createMatcher(tsconfig);\n\n const entries: Entry[] = [];\n const modeByPath = new Map<string, number>();\n const iterator = new Iterator(src, { alwaysStat: true });\n iterator.forEach(\n (entry: Entry): void => {\n const stats = entry.stats as fs.Stats | undefined;\n if (!stats || !stats.isFile()) return;\n const basename = entry.basename as string;\n if (basename[0] === '.') return;\n if (typeFileRegEx.test(basename)) return;\n if (!matcher(entry.fullPath)) return;\n const ext = path.extname(basename);\n if (ext && extensions.indexOf(ext) < 0) return;\n entries.push(entry);\n\n if (stats.mode) {\n modeByPath.set(entry.fullPath, stats.mode);\n }\n },\n (err) => {\n if (err) return callback(err);\n const results: string[] = [];\n const opts: InternalConfigOptions = { ...options, tsconfig };\n\n const queue = new Queue();\n entries.forEach((entry: Entry) => {\n const mode = modeByPath.get(entry.fullPath);\n queue.defer((cb) =>\n transformFile(entry, dest, type, opts, mode, (err, outPath) => {\n if (err) return cb(err);\n if (outPath) {\n results.push(path.normalize(outPath));\n if (opts.sourceMaps) results.push(`${path.normalize(outPath)}.map`);\n }\n cb();\n })\n );\n });\n queue.await((err) => (err ? callback(err) : callback(null, results)));\n }\n );\n}\n"],"names":["transformDirectoryWorker","src","dest","type","options","callback","tsconfig","matcher","createMatcher","entries","modeByPath","Map","iterator","Iterator","alwaysStat","forEach","entry","stats","isFile","basename","typeFileRegEx","test","fullPath","ext","path","extname","extensions","indexOf","push","mode","set","err","results","opts","queue","Queue","get","defer","cb","transformFile","outPath","normalize","sourceMaps","await"],"mappings":";;;;+BAWA;;;eAAwBA;;;iEAVa;2DACpB;8DACC;2BAEwB;sEAChB;sEACA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAIX,SAASA,yBAAyBC,GAAW,EAAEC,IAAY,EAAEC,IAAgB,EAAEC,OAA8B,EAAEC,QAAoC;IAChK,IAAMC,WAAWF,QAAQE,QAAQ;IACjC,IAAMC,UAAUC,IAAAA,wBAAa,EAACF;IAE9B,IAAMG,UAAmB,EAAE;IAC3B,IAAMC,aAAa,IAAIC;IACvB,IAAMC,WAAW,IAAIC,mBAAQ,CAACZ,KAAK;QAAEa,YAAY;IAAK;IACtDF,SAASG,OAAO,CACd,SAACC;QACC,IAAMC,QAAQD,MAAMC,KAAK;QACzB,IAAI,CAACA,SAAS,CAACA,MAAMC,MAAM,IAAI;QAC/B,IAAMC,WAAWH,MAAMG,QAAQ;QAC/B,IAAIA,QAAQ,CAAC,EAAE,KAAK,KAAK;QACzB,IAAIC,0BAAa,CAACC,IAAI,CAACF,WAAW;QAClC,IAAI,CAACZ,QAAQS,MAAMM,QAAQ,GAAG;QAC9B,IAAMC,MAAMC,aAAI,CAACC,OAAO,CAACN;QACzB,IAAII,OAAOG,uBAAU,CAACC,OAAO,CAACJ,OAAO,GAAG;QACxCd,QAAQmB,IAAI,CAACZ;QAEb,IAAIC,MAAMY,IAAI,EAAE;YACdnB,WAAWoB,GAAG,CAACd,MAAMM,QAAQ,EAAEL,MAAMY,IAAI;QAC3C;IACF,GACA,SAACE;QACC,IAAIA,KAAK,OAAO1B,SAAS0B;QACzB,IAAMC,UAAoB,EAAE;QAC5B,IAAMC,OAA8B,wCAAK7B;YAASE,UAAAA;;QAElD,IAAM4B,QAAQ,IAAIC,gBAAK;QACvB1B,QAAQM,OAAO,CAAC,SAACC;YACf,IAAMa,OAAOnB,WAAW0B,GAAG,CAACpB,MAAMM,QAAQ;YAC1CY,MAAMG,KAAK,CAAC,SAACC;uBACXC,IAAAA,wBAAa,EAACvB,OAAOd,MAAMC,MAAM8B,MAAMJ,MAAM,SAACE,KAAKS;oBACjD,IAAIT,KAAK,OAAOO,GAAGP;oBACnB,IAAIS,SAAS;wBACXR,QAAQJ,IAAI,CAACJ,aAAI,CAACiB,SAAS,CAACD;wBAC5B,IAAIP,KAAKS,UAAU,EAAEV,QAAQJ,IAAI,CAAC,AAAC,GAA0B,OAAxBJ,aAAI,CAACiB,SAAS,CAACD,UAAS;oBAC/D;oBACAF;gBACF;;QAEJ;QACAJ,MAAMS,KAAK,CAAC,SAACZ;mBAASA,MAAM1B,SAAS0B,OAAO1B,SAAS,MAAM2B;;IAC7D;AAEJ"}
1
+ {"version":3,"sources":["/Users/kevin/Dev/OpenSource/typescript/ts-swc-transform/src/workers/transformDirectory.ts"],"sourcesContent":["import type fs from 'fs';\nimport Iterator, { type Entry } from 'fs-iterator';\nimport path from 'path';\nimport Queue from 'queue-cb';\n\nimport { extensions, typeFileRegEx } from '../constants.ts';\nimport createMatcher from '../createMatcher.ts';\nimport transformFile from '../lib/transformFile.ts';\n\nimport type { InternalConfigOptions, TargetType, TransformDirectoryCallback } from '../types.ts';\n\nexport default function transformDirectoryWorker(src: string, dest: string, type: TargetType, options: InternalConfigOptions, callback: TransformDirectoryCallback) {\n const tsconfig = options.tsconfig;\n const matcher = createMatcher(tsconfig);\n\n const entries: Entry[] = [];\n const modeByPath = new Map<string, number>();\n const iterator = new Iterator(src, { alwaysStat: true });\n iterator.forEach(\n (entry: Entry): void => {\n const stats = entry.stats as fs.Stats | undefined;\n if (!stats || !stats.isFile()) return;\n const basename = entry.basename as string;\n if (basename[0] === '.') return;\n if (typeFileRegEx.test(basename)) return;\n if (!matcher(entry.fullPath)) return;\n const ext = path.extname(basename);\n if (ext && extensions.indexOf(ext) < 0) return;\n entries.push(entry);\n\n if (stats.mode) {\n modeByPath.set(entry.fullPath, stats.mode);\n }\n },\n (err) => {\n if (err) return callback(err);\n const results: string[] = [];\n const opts: InternalConfigOptions = { ...options, tsconfig };\n\n const queue = new Queue();\n entries.forEach((entry: Entry) => {\n const mode = modeByPath.get(entry.fullPath);\n queue.defer((cb) =>\n transformFile(entry, dest, type, opts, mode, (err, outPath) => {\n if (err) return cb(err);\n if (outPath) {\n results.push(path.normalize(outPath));\n if (opts.sourceMaps) results.push(`${path.normalize(outPath)}.map`);\n }\n cb();\n })\n );\n });\n queue.await((err) => (err ? callback(err) : callback(null, results)));\n }\n );\n}\n"],"names":["transformDirectoryWorker","src","dest","type","options","callback","tsconfig","matcher","createMatcher","entries","modeByPath","Map","iterator","Iterator","alwaysStat","forEach","entry","stats","isFile","basename","typeFileRegEx","test","fullPath","ext","path","extname","extensions","indexOf","push","mode","set","err","results","opts","queue","Queue","get","defer","cb","transformFile","outPath","normalize","sourceMaps","await"],"mappings":";;;;+BAWA;;;eAAwBA;;;iEAVa;2DACpB;8DACC;2BAEwB;sEAChB;sEACA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAIX,SAASA,yBAAyBC,GAAW,EAAEC,IAAY,EAAEC,IAAgB,EAAEC,OAA8B,EAAEC,QAAoC;IAChK,IAAMC,WAAWF,QAAQE,QAAQ;IACjC,IAAMC,UAAUC,IAAAA,wBAAa,EAACF;IAE9B,IAAMG,UAAmB,EAAE;IAC3B,IAAMC,aAAa,IAAIC;IACvB,IAAMC,WAAW,IAAIC,mBAAQ,CAACZ,KAAK;QAAEa,YAAY;IAAK;IACtDF,SAASG,OAAO,CACd,SAACC;QACC,IAAMC,QAAQD,MAAMC,KAAK;QACzB,IAAI,CAACA,SAAS,CAACA,MAAMC,MAAM,IAAI;QAC/B,IAAMC,WAAWH,MAAMG,QAAQ;QAC/B,IAAIA,QAAQ,CAAC,EAAE,KAAK,KAAK;QACzB,IAAIC,0BAAa,CAACC,IAAI,CAACF,WAAW;QAClC,IAAI,CAACZ,QAAQS,MAAMM,QAAQ,GAAG;QAC9B,IAAMC,MAAMC,aAAI,CAACC,OAAO,CAACN;QACzB,IAAII,OAAOG,uBAAU,CAACC,OAAO,CAACJ,OAAO,GAAG;QACxCd,QAAQmB,IAAI,CAACZ;QAEb,IAAIC,MAAMY,IAAI,EAAE;YACdnB,WAAWoB,GAAG,CAACd,MAAMM,QAAQ,EAAEL,MAAMY,IAAI;QAC3C;IACF,GACA,SAACE;QACC,IAAIA,KAAK,OAAO1B,SAAS0B;QACzB,IAAMC,UAAoB,EAAE;QAC5B,IAAMC,OAA8B,wCAAK7B;YAASE,UAAAA;;QAElD,IAAM4B,QAAQ,IAAIC,gBAAK;QACvB1B,QAAQM,OAAO,CAAC,SAACC;YACf,IAAMa,OAAOnB,WAAW0B,GAAG,CAACpB,MAAMM,QAAQ;YAC1CY,MAAMG,KAAK,CAAC,SAACC;uBACXC,IAAAA,wBAAa,EAACvB,OAAOd,MAAMC,MAAM8B,MAAMJ,MAAM,SAACE,KAAKS;oBACjD,IAAIT,KAAK,OAAOO,GAAGP;oBACnB,IAAIS,SAAS;wBACXR,QAAQJ,IAAI,CAACJ,aAAI,CAACiB,SAAS,CAACD;wBAC5B,IAAIP,KAAKS,UAAU,EAAEV,QAAQJ,IAAI,CAAC,AAAC,GAA0B,OAAxBJ,aAAI,CAACiB,SAAS,CAACD,UAAS;oBAC/D;oBACAF;gBACF;;QAEJ;QACAJ,MAAMS,KAAK,CAAC,SAACZ;mBAASA,MAAM1B,SAAS0B,OAAO1B,SAAS,MAAM2B;;IAC7D;AAEJ"}
@@ -19,9 +19,7 @@ function _define_property(obj, key, value) {
19
19
  configurable: true,
20
20
  writable: true
21
21
  });
22
- } else {
23
- obj[key] = value;
24
- }
22
+ } else obj[key] = value;
25
23
  return obj;
26
24
  }
27
25
  function _interop_require_default(obj) {
@@ -59,9 +57,8 @@ function ownKeys(object, enumerableOnly) {
59
57
  }
60
58
  function _object_spread_props(target, source) {
61
59
  source = source != null ? source : {};
62
- if (Object.getOwnPropertyDescriptors) {
63
- Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
64
- } else {
60
+ if (Object.getOwnPropertyDescriptors) Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
61
+ else {
65
62
  ownKeys(Object(source)).forEach(function(key) {
66
63
  Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
67
64
  });
@@ -1 +1 @@
1
- {"version":3,"sources":["/Users/kevin/Dev/OpenSource/typescript/ts-swc-transform/src/workers/transformSync.ts"],"sourcesContent":["import type { Output } from '@swc/core';\nimport Module from 'module';\nimport path from 'path';\nimport prepareSWCOptions from '../lib/prepareSWCOptions.ts';\nimport type { TSConfig } from '../types.ts';\n\nconst _require = typeof require === 'undefined' ? Module.createRequire(import.meta.url) : require;\n\nexport default function transformSyncWorker(contents: string, fileName: string, tsconfig: TSConfig): Output {\n const swcOptions = prepareSWCOptions(tsconfig);\n const swc = _require('@swc/core');\n const ext = path.extname(fileName);\n\n return swc.transformSync(contents, {\n ...(ext === '.tsx' || ext === '.jsx' ? swcOptions.tsxOptions : swcOptions.nonTsxOptions),\n filename: fileName,\n });\n}\n"],"names":["transformSyncWorker","_require","require","Module","createRequire","contents","fileName","tsconfig","swcOptions","prepareSWCOptions","swc","ext","path","extname","transformSync","tsxOptions","nonTsxOptions","filename"],"mappings":";;;;+BAQA;;;eAAwBA;;;6DAPL;2DACF;0EACa;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAG9B,IAAMC,WAAW,OAAOC,YAAY,cAAcC,eAAM,CAACC,aAAa,CAAC,uDAAmBF;AAE3E,SAASF,oBAAoBK,QAAgB,EAAEC,QAAgB,EAAEC,QAAkB;IAChG,IAAMC,aAAaC,IAAAA,4BAAiB,EAACF;IACrC,IAAMG,MAAMT,SAAS;IACrB,IAAMU,MAAMC,aAAI,CAACC,OAAO,CAACP;IAEzB,OAAOI,IAAII,aAAa,CAACT,UAAU,wCAC7BM,QAAQ,UAAUA,QAAQ,SAASH,WAAWO,UAAU,GAAGP,WAAWQ,aAAa;QACvFC,UAAUX;;AAEd"}
1
+ {"version":3,"sources":["/Users/kevin/Dev/OpenSource/typescript/ts-swc-transform/src/workers/transformSync.ts"],"sourcesContent":["import type { Output } from '@swc/core';\nimport Module from 'module';\nimport path from 'path';\nimport prepareSWCOptions from '../lib/prepareSWCOptions.ts';\nimport type { TSConfig } from '../types.ts';\n\nconst _require = typeof require === 'undefined' ? Module.createRequire(import.meta.url) : require;\n\nexport default function transformSyncWorker(contents: string, fileName: string, tsconfig: TSConfig): Output {\n const swcOptions = prepareSWCOptions(tsconfig);\n const swc = _require('@swc/core');\n const ext = path.extname(fileName);\n\n return swc.transformSync(contents, {\n ...(ext === '.tsx' || ext === '.jsx' ? swcOptions.tsxOptions : swcOptions.nonTsxOptions),\n filename: fileName,\n });\n}\n"],"names":["transformSyncWorker","_require","require","Module","createRequire","contents","fileName","tsconfig","swcOptions","prepareSWCOptions","swc","ext","path","extname","transformSync","tsxOptions","nonTsxOptions","filename"],"mappings":";;;;+BAQA;;;eAAwBA;;;6DAPL;2DACF;0EACa;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAG9B,IAAMC,WAAW,OAAOC,YAAY,cAAcC,eAAM,CAACC,aAAa,CAAC,uDAAmBF;AAE3E,SAASF,oBAAoBK,QAAgB,EAAEC,QAAgB,EAAEC,QAAkB;IAChG,IAAMC,aAAaC,IAAAA,4BAAiB,EAACF;IACrC,IAAMG,MAAMT,SAAS;IACrB,IAAMU,MAAMC,aAAI,CAACC,OAAO,CAACP;IAEzB,OAAOI,IAAII,aAAa,CAACT,UAAU,wCAC7BM,QAAQ,UAAUA,QAAQ,SAASH,WAAWO,UAAU,GAAGP,WAAWQ,aAAa;QACvFC,UAAUX;;AAEd"}
@@ -34,9 +34,7 @@ function _define_property(obj, key, value) {
34
34
  configurable: true,
35
35
  writable: true
36
36
  });
37
- } else {
38
- obj[key] = value;
39
- }
37
+ } else obj[key] = value;
40
38
  return obj;
41
39
  }
42
40
  function _interop_require_default(obj) {
@@ -45,10 +43,12 @@ function _interop_require_default(obj) {
45
43
  };
46
44
  }
47
45
  function _iterable_to_array(iter) {
48
- if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
46
+ if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) {
47
+ return Array.from(iter);
48
+ }
49
49
  }
50
50
  function _non_iterable_spread() {
51
- throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
51
+ throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
52
52
  }
53
53
  function _object_spread(target) {
54
54
  for(var i = 1; i < arguments.length; i++){
@@ -80,9 +80,8 @@ function ownKeys(object, enumerableOnly) {
80
80
  }
81
81
  function _object_spread_props(target, source) {
82
82
  source = source != null ? source : {};
83
- if (Object.getOwnPropertyDescriptors) {
84
- Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
85
- } else {
83
+ if (Object.getOwnPropertyDescriptors) Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
84
+ else {
86
85
  ownKeys(Object(source)).forEach(function(key) {
87
86
  Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
88
87
  });
@@ -1 +1 @@
1
- {"version":3,"sources":["/Users/kevin/Dev/OpenSource/typescript/ts-swc-transform/src/workers/transformTypes.ts"],"sourcesContent":["import spawn, { type SpawnCallback, type SpawnResult } from 'cross-spawn-cb';\nimport fs from 'fs';\nimport Iterator, { type Entry } from 'fs-iterator';\nimport { safeRm } from 'fs-remove-compat';\nimport os from 'os';\nimport path from 'path';\nimport Queue from 'queue-cb';\nimport resolveBin from 'resolve-bin-sync';\n\nconst concurrency = Math.min(64, Math.max(8, (os.cpus()?.length ?? 4) * 8));\n\nconst tscPath = resolveBin('typescript', 'tsc');\n\nfunction compilerMajor(): number {\n try {\n const pkg = JSON.parse(fs.readFileSync(path.join(path.dirname(tscPath), '..', 'package.json'), 'utf8'));\n return +String(pkg.version).split('.')[0] || 0;\n } catch {\n return 0;\n }\n}\n\n// TypeScript 7 removed options that only ever affected JS emit, which swc handles.\n// Older compilers still accept them, so only rewrite when the installed tsc would reject them.\nfunction sanitizeForCompiler(options: Record<string, unknown>): Record<string, unknown> {\n if (compilerMajor() < 7) return options;\n const sanitized = { ...options };\n delete sanitized.downlevelIteration;\n if (sanitized.moduleResolution === 'node' || sanitized.moduleResolution === 'node10') sanitized.moduleResolution = 'bundler';\n if (typeof sanitized.target === 'string' && /^es[35]$/i.test(sanitized.target)) sanitized.target = 'es2015';\n return sanitized;\n}\n\nimport createMatcher from '../createMatcher.ts';\nimport { rewriteExtensions } from '../lib/rewriteExtensions.ts';\n\nimport type { InternalConfigOptions, TransformTypesCallback } from '../types.ts';\n\n/* ---------------- root file filtering ---------------- */\n\nfunction isAllowedRootFile(basename: string): boolean {\n return (\n basename.endsWith('.d.ts') ||\n basename.endsWith('.d.mts') ||\n basename.endsWith('.d.cts') ||\n basename.endsWith('.ts') ||\n basename.endsWith('.tsx') ||\n basename.endsWith('.mts') ||\n basename.endsWith('.cts') ||\n basename.endsWith('.js') ||\n basename.endsWith('.jsx') ||\n basename.endsWith('.mjs') ||\n basename.endsWith('.cjs')\n );\n}\n\n/* ---------------- compiler execution ---------------- */\n\nfunction runCompiler(cmdPath: string, args: string[], cb: SpawnCallback): void {\n spawn(process.execPath, [cmdPath, ...args], { encoding: 'utf8' }, cb);\n}\n\n/* ---------------- emitted file parsing ---------------- */\n\nfunction parseEmittedFiles(res: SpawnResult, dest: string): string[] {\n const out: string[] = [];\n const seen = new Set<string>();\n const lines = `${res.stdout}\\n${res.stderr}`.split(/\\r?\\n/);\n\n for (let line of lines) {\n line = line.trim();\n if (!line) continue;\n\n if (/^TSFILE:\\s+/i.test(line)) line = line.replace(/^TSFILE:\\s+/i, '').trim();\n\n if (!path.isAbsolute(line)) continue;\n if (!(line.endsWith('.d.ts') || line.endsWith('.d.mts') || line.endsWith('.d.cts'))) continue;\n\n // Optional safety: only accept outputs under dest\n const rel = path.relative(dest, line);\n if (rel.startsWith('..') || path.isAbsolute(rel)) continue;\n\n if (!seen.has(line)) {\n seen.add(line);\n out.push(line);\n }\n }\n\n return out;\n}\n\nexport default function transformTypesWorker(src: string, dest: string, options: InternalConfigOptions, callback: TransformTypesCallback) {\n const tsconfig = options.tsconfig;\n const matcher = createMatcher(tsconfig);\n\n const rootFiles: string[] = [];\n const iterator = new Iterator(src);\n\n iterator.forEach(\n (entry: Entry): void => {\n const stats = entry.stats as fs.Stats | undefined;\n if (!stats || !stats.isFile()) return;\n const basename = entry.basename as string;\n if (basename[0] === '.') return;\n if (!isAllowedRootFile(basename)) return;\n if (!matcher(entry.fullPath)) return;\n\n rootFiles.push(entry.fullPath);\n },\n { concurrency },\n (err) => {\n if (err) return callback(err);\n if (rootFiles.length === 0) return callback(null, []);\n\n const compilerOptions = sanitizeForCompiler({\n ...tsconfig.config.compilerOptions,\n rootDir: src,\n outDir: dest,\n noEmit: false,\n allowJs: true,\n declaration: true,\n emitDeclarationOnly: true,\n // Suppress TS6 deprecation warnings (TS5101/TS5107) for consumers still on legacy Node-targeted options.\n ignoreDeprecations: '6.0',\n });\n\n const rewrite = (tsconfig.config.compilerOptions as { rewriteRelativeImportExtensions?: boolean } | undefined)?.rewriteRelativeImportExtensions === true;\n\n // Avoid collisions across concurrent runs.\n const tempDir = path.join(dest, '.ts-swc-transform-temp', String(process.pid), String(Date.now()));\n const tempConfigPath = path.join(tempDir, 'tsconfig.json');\n\n const tempConfig = {\n compilerOptions,\n files: rootFiles,\n include: [],\n exclude: [],\n ...(tsconfig.config.references && { references: tsconfig.config.references }),\n };\n\n fs.mkdir(tempDir, { recursive: true }, (mkdirErr) => {\n if (mkdirErr) return callback(mkdirErr);\n\n fs.writeFile(tempConfigPath, JSON.stringify(tempConfig, null, 2), 'utf8', (writeErr) => {\n if (writeErr) {\n safeRm(tempDir, { recursive: true, force: true }, () => callback(writeErr));\n return;\n }\n\n const args = ['--project', tempConfigPath, '--listEmittedFiles', '--pretty', 'false'];\n\n runCompiler(tscPath, args, (runErr, res) => {\n if (runErr || !res || res.status !== 0) {\n // cross-spawn-cb sets runErr (with stdout/stderr/status copied onto it) on non-zero exit\n // and does NOT pass res — read from runErr first, then fall back to res.\n const source = (runErr as unknown as SpawnResult | undefined) ?? res;\n const status = source?.status;\n const stdout = String(source?.stdout ?? '');\n const stderr = String(source?.stderr ?? '');\n const detail = `TypeScript compiler failed (status=${status}).\\nstdout:\\n${stdout.slice(0, 100_000)}\\nstderr:\\n${stderr.slice(0, 20_000)}`;\n safeRm(tempDir, { recursive: true, force: true }, () => callback(new Error(detail)));\n return;\n }\n\n const emittedFiles = parseEmittedFiles(res, dest);\n if (emittedFiles.length === 0) {\n safeRm(tempDir, { recursive: true, force: true }, () => callback(new Error('TypeScript compiler produced no emitted declaration files')));\n return;\n }\n\n const postQueue = new Queue();\n\n if (rewrite) {\n for (const file of emittedFiles) {\n postQueue.defer((cb) => {\n fs.readFile(file, 'utf8', (readErr, content) => {\n if (readErr) return cb();\n const updated = rewriteExtensions(content);\n if (updated === content) cb();\n else fs.writeFile(file, updated, 'utf8', (err) => cb(err));\n });\n });\n }\n }\n\n postQueue.await(() => {\n safeRm(tempDir, { recursive: true, force: true }, (rmErr) => callback(rmErr || null, emittedFiles));\n });\n });\n });\n });\n }\n );\n}\n"],"names":["transformTypesWorker","os","concurrency","Math","min","max","cpus","length","tscPath","resolveBin","compilerMajor","pkg","JSON","parse","fs","readFileSync","path","join","dirname","String","version","split","sanitizeForCompiler","options","sanitized","downlevelIteration","moduleResolution","target","test","isAllowedRootFile","basename","endsWith","runCompiler","cmdPath","args","cb","spawn","process","execPath","encoding","parseEmittedFiles","res","dest","out","seen","Set","lines","stdout","stderr","line","trim","replace","isAbsolute","rel","relative","startsWith","has","add","push","src","callback","tsconfig","matcher","createMatcher","rootFiles","iterator","Iterator","forEach","entry","stats","isFile","fullPath","err","compilerOptions","config","rootDir","outDir","noEmit","allowJs","declaration","emitDeclarationOnly","ignoreDeprecations","rewrite","rewriteRelativeImportExtensions","tempDir","pid","Date","now","tempConfigPath","tempConfig","files","include","exclude","references","mkdir","recursive","mkdirErr","writeFile","stringify","writeErr","safeRm","force","runErr","status","source","detail","slice","Error","emittedFiles","postQueue","Queue","file","defer","readFile","readErr","content","updated","rewriteExtensions","await","rmErr"],"mappings":";;;;+BA2FA;;;eAAwBA;;;mEA3FoC;yDAC7C;iEACsB;8BACd;yDACR;2DACE;8DACC;qEACK;sEA0BG;mCACQ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAzBYC;AAA9C,IAAMC,cAAcC,KAAKC,GAAG,CAAC,IAAID,KAAKE,GAAG,CAAC,GAAG,UAACJ,WAAAA,WAAE,CAACK,IAAI,gBAAPL,+BAAAA,SAAWM,MAAM,uCAAI,KAAK;AAExE,IAAMC,UAAUC,IAAAA,uBAAU,EAAC,cAAc;AAEzC,SAASC;IACP,IAAI;QACF,IAAMC,MAAMC,KAAKC,KAAK,CAACC,WAAE,CAACC,YAAY,CAACC,aAAI,CAACC,IAAI,CAACD,aAAI,CAACE,OAAO,CAACV,UAAU,MAAM,iBAAiB;QAC/F,OAAO,CAACW,OAAOR,IAAIS,OAAO,EAAEC,KAAK,CAAC,IAAI,CAAC,EAAE,IAAI;IAC/C,EAAE,eAAM;QACN,OAAO;IACT;AACF;AAEA,mFAAmF;AACnF,+FAA+F;AAC/F,SAASC,oBAAoBC,OAAgC;IAC3D,IAAIb,kBAAkB,GAAG,OAAOa;IAChC,IAAMC,YAAY,m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AC;wBACdlB,IAAAA,sBAAM,EAAChB,SAAS;4BAAEW,WAAW;4BAAMM,OAAO;wBAAK,GAAG,SAACkB;mCAAU3D,SAAS2D,SAAS,MAAMX;;oBACvF;gBACF;YACF;QACF;IACF;AAEJ"}
1
+ {"version":3,"sources":["/Users/kevin/Dev/OpenSource/typescript/ts-swc-transform/src/workers/transformTypes.ts"],"sourcesContent":["import spawn, { type SpawnCallback, type SpawnResult } from 'cross-spawn-cb';\nimport fs from 'fs';\nimport Iterator, { type Entry } from 'fs-iterator';\nimport { safeRm } from 'fs-remove-compat';\nimport os from 'os';\nimport path from 'path';\nimport Queue from 'queue-cb';\nimport resolveBin from 'resolve-bin-sync';\n\nconst concurrency = Math.min(64, Math.max(8, (os.cpus()?.length ?? 4) * 8));\n\nconst tscPath = resolveBin('typescript', 'tsc');\n\nfunction compilerMajor(): number {\n try {\n const pkg = JSON.parse(fs.readFileSync(path.join(path.dirname(tscPath), '..', 'package.json'), 'utf8'));\n return +String(pkg.version).split('.')[0] || 0;\n } catch {\n return 0;\n }\n}\n\n// TypeScript 7 removed options that only ever affected JS emit, which swc handles.\n// Older compilers still accept them, so only rewrite when the installed tsc would reject them.\nfunction sanitizeForCompiler(options: Record<string, unknown>): Record<string, unknown> {\n if (compilerMajor() < 7) return options;\n const sanitized = { ...options };\n delete sanitized.downlevelIteration;\n if (sanitized.moduleResolution === 'node' || sanitized.moduleResolution === 'node10') sanitized.moduleResolution = 'bundler';\n if (typeof sanitized.target === 'string' && /^es[35]$/i.test(sanitized.target)) sanitized.target = 'es2015';\n return sanitized;\n}\n\nimport createMatcher from '../createMatcher.ts';\nimport { rewriteExtensions } from '../lib/rewriteExtensions.ts';\n\nimport type { InternalConfigOptions, TransformTypesCallback } from '../types.ts';\n\n/* ---------------- root file filtering ---------------- */\n\nfunction isAllowedRootFile(basename: string): boolean {\n return (\n basename.endsWith('.d.ts') ||\n basename.endsWith('.d.mts') ||\n basename.endsWith('.d.cts') ||\n basename.endsWith('.ts') ||\n basename.endsWith('.tsx') ||\n basename.endsWith('.mts') ||\n basename.endsWith('.cts') ||\n basename.endsWith('.js') ||\n basename.endsWith('.jsx') ||\n basename.endsWith('.mjs') ||\n basename.endsWith('.cjs')\n );\n}\n\n/* ---------------- compiler execution ---------------- */\n\nfunction runCompiler(cmdPath: string, args: string[], cb: SpawnCallback): void {\n spawn(process.execPath, [cmdPath, ...args], { encoding: 'utf8' }, cb);\n}\n\n/* ---------------- emitted file parsing ---------------- */\n\nfunction parseEmittedFiles(res: SpawnResult, dest: string): string[] {\n const out: string[] = [];\n const seen = new Set<string>();\n const lines = `${res.stdout}\\n${res.stderr}`.split(/\\r?\\n/);\n\n for (let line of lines) {\n line = line.trim();\n if (!line) continue;\n\n if (/^TSFILE:\\s+/i.test(line)) line = line.replace(/^TSFILE:\\s+/i, '').trim();\n\n if (!path.isAbsolute(line)) continue;\n if (!(line.endsWith('.d.ts') || line.endsWith('.d.mts') || line.endsWith('.d.cts'))) continue;\n\n // Optional safety: only accept outputs under dest\n const rel = path.relative(dest, line);\n if (rel.startsWith('..') || path.isAbsolute(rel)) continue;\n\n if (!seen.has(line)) {\n seen.add(line);\n out.push(line);\n }\n }\n\n return out;\n}\n\nexport default function transformTypesWorker(src: string, dest: string, options: InternalConfigOptions, callback: TransformTypesCallback) {\n const tsconfig = options.tsconfig;\n const matcher = createMatcher(tsconfig);\n\n const rootFiles: string[] = [];\n const iterator = new Iterator(src);\n\n iterator.forEach(\n (entry: Entry): void => {\n const stats = entry.stats as fs.Stats | undefined;\n if (!stats || !stats.isFile()) return;\n const basename = entry.basename as string;\n if (basename[0] === '.') return;\n if (!isAllowedRootFile(basename)) return;\n if (!matcher(entry.fullPath)) return;\n\n rootFiles.push(entry.fullPath);\n },\n { concurrency },\n (err) => {\n if (err) return callback(err);\n if (rootFiles.length === 0) return callback(null, []);\n\n const compilerOptions = sanitizeForCompiler({\n ...tsconfig.config.compilerOptions,\n rootDir: src,\n outDir: dest,\n noEmit: false,\n allowJs: true,\n declaration: true,\n emitDeclarationOnly: true,\n // Suppress TS6 deprecation warnings (TS5101/TS5107) for consumers still on legacy Node-targeted options.\n ignoreDeprecations: '6.0',\n });\n\n const rewrite = (tsconfig.config.compilerOptions as { rewriteRelativeImportExtensions?: boolean } | undefined)?.rewriteRelativeImportExtensions === true;\n\n // Avoid collisions across concurrent runs.\n const tempDir = path.join(dest, '.ts-swc-transform-temp', String(process.pid), String(Date.now()));\n const tempConfigPath = path.join(tempDir, 'tsconfig.json');\n\n const tempConfig = {\n compilerOptions,\n files: rootFiles,\n include: [],\n exclude: [],\n ...(tsconfig.config.references && { references: tsconfig.config.references }),\n };\n\n fs.mkdir(tempDir, { recursive: true }, (mkdirErr) => {\n if (mkdirErr) return callback(mkdirErr);\n\n fs.writeFile(tempConfigPath, JSON.stringify(tempConfig, null, 2), 'utf8', (writeErr) => {\n if (writeErr) {\n safeRm(tempDir, { recursive: true, force: true }, () => callback(writeErr));\n return;\n }\n\n const args = ['--project', tempConfigPath, '--listEmittedFiles', '--pretty', 'false'];\n\n runCompiler(tscPath, args, (runErr, res) => {\n if (runErr || !res || res.status !== 0) {\n // cross-spawn-cb sets runErr (with stdout/stderr/status copied onto it) on non-zero exit\n // and does NOT pass res — read from runErr first, then fall back to res.\n const source = (runErr as unknown as SpawnResult | undefined) ?? res;\n const status = source?.status;\n const stdout = String(source?.stdout ?? '');\n const stderr = String(source?.stderr ?? '');\n const detail = `TypeScript compiler failed (status=${status}).\\nstdout:\\n${stdout.slice(0, 100_000)}\\nstderr:\\n${stderr.slice(0, 20_000)}`;\n safeRm(tempDir, { recursive: true, force: true }, () => callback(new Error(detail)));\n return;\n }\n\n const emittedFiles = parseEmittedFiles(res, dest);\n if (emittedFiles.length === 0) {\n safeRm(tempDir, { recursive: true, force: true }, () => callback(new Error('TypeScript compiler produced no emitted declaration files')));\n return;\n }\n\n const postQueue = new Queue();\n\n if (rewrite) {\n for (const file of emittedFiles) {\n postQueue.defer((cb) => {\n fs.readFile(file, 'utf8', (readErr, content) => {\n if (readErr) return cb();\n const updated = rewriteExtensions(content);\n if (updated === content) cb();\n else fs.writeFile(file, updated, 'utf8', (err) => cb(err));\n });\n });\n }\n }\n\n postQueue.await(() => {\n safeRm(tempDir, { recursive: true, force: true }, (rmErr) => callback(rmErr || null, emittedFiles));\n });\n });\n });\n });\n }\n );\n}\n"],"names":["transformTypesWorker","os","concurrency","Math","min","max","cpus","length","tscPath","resolveBin","compilerMajor","pkg","JSON","parse","fs","readFileSync","path","join","dirname","String","version","split","sanitizeForCompiler","options","sanitized","downlevelIteration","moduleResolution","target","test","isAllowedRootFile","basename","endsWith","runCompiler","cmdPath","args","cb","spawn","process","execPath","encoding","parseEmittedFiles","res","dest","out","seen","Set","lines","stdout","stderr","line","trim","replace","isAbsolute","rel","relative","startsWith","has","add","push","src","callback","tsconfig","matcher","createMatcher","rootFiles","iterator","Iterator","forEach","entry","stats","isFile","fullPath","err","compilerOptions","config","rootDir","outDir","noEmit","allowJs","declaration","emitDeclarationOnly","ignoreDeprecations","rewrite","rewriteRelativeImportExtensions","tempDir","pid","Date","now","tempConfigPath","tempConfig","files","include","exclude","references","mkdir","recursive","mkdirErr","writeFile","stringify","writeErr","safeRm","force","runErr","status","source","detail","slice","Error","emittedFiles","postQueue","Queue","file","defer","readFile","readErr","content","updated","rewriteExtensions","await","rmErr"],"mappings":";;;;+BA2FA;;;eAAwBA;;;mEA3FoC;yDAC7C;iEACsB;8BACd;yDACR;2DACE;8DACC;qEACK;sEA0BG;mCACQ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAzBYC;AAA9C,IAAMC,cAAcC,KAAKC,GAAG,CAAC,IAAID,KAAKE,GAAG,CAAC,GAAG,UAACJ,WAAAA,WAAE,CAACK,IAAI,gBAAPL,+BAAAA,SAAWM,MAAM,uCAAI,KAAK;AAExE,IAAMC,UAAUC,IAAAA,uBAAU,E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rB,WAAE,CAACmG,QAAQ,CAACF,MAAM,QAAQ,SAACG,SAASC;wCAClC,IAAID,SAAS,OAAO/E;wCACpB,IAAMiF,UAAUC,IAAAA,sCAAiB,EAACF;wCAClC,IAAIC,YAAYD,SAAShF;6CACpBrB,WAAE,CAACmF,SAAS,CAACc,MAAMK,SAAS,QAAQ,SAAC5C;mDAAQrC,GAAGqC;;oCACvD;gCACF;4BACF;4BATA,QAAK,YAAcoC,iCAAd,SAAA,6BAAA,QAAA,yBAAA;;4BAAA;4BAAA;;;qCAAA,6BAAA;oCAAA;;;oCAAA;0CAAA;;;;oBAUP;oBAEAC,UAAUS,KAAK,CAAC;wBACdlB,IAAAA,sBAAM,EAAChB,SAAS;4BAAEW,WAAW;4BAAMM,OAAO;wBAAK,GAAG,SAACkB;mCAAU3D,SAAS2D,SAAS,MAAMX;;oBACvF;gBACF;YACF;QACF;IACF;AAEJ"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ts-swc-transform",
3
- "version": "2.11.12",
3
+ "version": "2.11.13",
4
4
  "description": "Typescript transformers for swc. Supports Node >= 0.8",
5
5
  "keywords": [
6
6
  "matcher",
@@ -62,7 +62,7 @@
62
62
  "test-match": "^1.0.0",
63
63
  "ts-constants": "^1.1.13",
64
64
  "ts-node": "^10.9.0",
65
- "typescript": "^7.0.2"
65
+ "typescript": "^6.0.0"
66
66
  },
67
67
  "devDependencies": {
68
68
  "@types/is-absolute": "^1.0.2",