ts-swc-transform 1.4.2 → 1.4.3

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 (41) hide show
  1. package/dist/cjs/lib/loadSWC.js +15 -3
  2. package/dist/cjs/lib/loadSWC.js.map +1 -1
  3. package/dist/cjs/lib/transformVersion.js +20 -0
  4. package/dist/cjs/lib/transformVersion.js.map +1 -0
  5. package/dist/cjs/transformDirectory.js +19 -77
  6. package/dist/cjs/transformDirectory.js.map +1 -1
  7. package/dist/cjs/transformFile.js +22 -132
  8. package/dist/cjs/transformFile.js.map +1 -1
  9. package/dist/cjs/transformSync.js +3 -4
  10. package/dist/cjs/transformSync.js.map +1 -1
  11. package/dist/cjs/workers/transformDirectory.js +89 -0
  12. package/dist/cjs/workers/transformDirectory.js.map +1 -0
  13. package/dist/cjs/workers/transformFile.js +143 -0
  14. package/dist/cjs/workers/transformFile.js.map +1 -0
  15. package/dist/cjs/workers/transformSync.js +2 -2
  16. package/dist/cjs/workers/transformSync.js.map +1 -1
  17. package/dist/esm/lib/loadSWC.mjs +15 -3
  18. package/dist/esm/lib/loadSWC.mjs.map +1 -1
  19. package/dist/esm/lib/transformVersion.mjs +4 -0
  20. package/dist/esm/lib/transformVersion.mjs.map +1 -0
  21. package/dist/esm/transformDirectory.mjs +20 -26
  22. package/dist/esm/transformDirectory.mjs.map +1 -1
  23. package/dist/esm/transformFile.mjs +23 -105
  24. package/dist/esm/transformFile.mjs.map +1 -1
  25. package/dist/esm/transformSync.mjs +2 -4
  26. package/dist/esm/transformSync.mjs.map +1 -1
  27. package/dist/esm/workers/transformDirectory.mjs +22 -0
  28. package/dist/esm/workers/transformDirectory.mjs.map +1 -0
  29. package/dist/esm/workers/transformFile.mjs +100 -0
  30. package/dist/esm/workers/transformFile.mjs.map +1 -0
  31. package/dist/esm/workers/transformSync.mjs +1 -1
  32. package/dist/esm/workers/transformSync.mjs.map +1 -1
  33. package/dist/types/lib/loadSWC.d.ts +1 -1
  34. package/dist/types/lib/transformVersion.d.ts +2 -0
  35. package/dist/types/transformDirectory.d.ts +1 -1
  36. package/dist/types/transformFile.d.ts +4 -4
  37. package/dist/types/transformSync.d.ts +3 -1
  38. package/dist/types/workers/transformDirectory.d.ts +1 -0
  39. package/dist/types/workers/transformFile.d.ts +1 -0
  40. package/dist/types/workers/transformSync.d.ts +1 -1
  41. package/package.json +3 -3
@@ -0,0 +1,100 @@
1
+ import fs from 'fs';
2
+ import path from 'path';
3
+ import once from 'call-once-fn';
4
+ import getTS from 'get-tsconfig-compat';
5
+ import mkdirp from 'mkdirp-classic';
6
+ import Queue from 'queue-cb';
7
+ import transformSync from './transformSync.mjs';
8
+ const matchingDeps = '\\s*[\'"`]([^\'"`]+)[\'"`]\\s*';
9
+ const matchingName = '\\s*(?:[\\w${},\\s*]+)\\s*';
10
+ const regexCJS = new RegExp(`(?:(?:var|const|let)${matchingName}=\\s*)?require\\(${matchingDeps}\\);?`, 'g');
11
+ const regexESM = new RegExp(`${regexCJS}|import(?:${matchingName}from\\s*)?${matchingDeps};?|export(?:${matchingName}from\\s*)?${matchingDeps};?`, 'g');
12
+ const importReplaceMJS = [
13
+ '.js',
14
+ '.ts',
15
+ '.tsx',
16
+ '.mts',
17
+ '.mjs'
18
+ ];
19
+ const importReplaceCJS = [
20
+ '.cts'
21
+ ];
22
+ const requireReplaceJS = [
23
+ '.mjs',
24
+ '.cjs',
25
+ '.ts',
26
+ '.tsx',
27
+ '.mts',
28
+ '.cts'
29
+ ];
30
+ function makeReplacements(code, regex, extensions, extension) {
31
+ let matches = [];
32
+ let match = regex.exec(code);
33
+ while(match){
34
+ const dependency = match[1] || match[2] || match[3] || match[4];
35
+ const ext = extensions.find((x)=>dependency.slice(-x.length) === x);
36
+ if (ext) matches.push({
37
+ ext,
38
+ match,
39
+ dependency
40
+ });
41
+ match = regex.exec(code);
42
+ }
43
+ matches = matches.reverse();
44
+ for(const index in matches){
45
+ const match = matches[index];
46
+ const start = match.match.index + match.match[0].indexOf(match.dependency) + match.dependency.indexOf(match.ext);
47
+ code = code.substring(0, start) + extension + code.substring(start + match.ext.length);
48
+ }
49
+ return code;
50
+ }
51
+ // https://github.com/vercel/next.js/blob/20b63e13ab2631d6043277895d373aa31a1b327c/packages/next/taskfile-swc.js#L118-L125
52
+ const 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; }";
53
+ export default function transformFileWorker(src, dest, type, options, callback) {
54
+ fs.readFile(src, 'utf8', (err, contents)=>{
55
+ if (err) return callback(err);
56
+ callback = once(callback);
57
+ try {
58
+ let tsconfig = options.tsconfig ? options.tsconfig : getTS.getTsconfig(src);
59
+ // overrides for cjs
60
+ if (type === 'cjs') {
61
+ tsconfig = {
62
+ ...tsconfig
63
+ };
64
+ tsconfig.tsconfig = {
65
+ ...tsconfig.config || {}
66
+ };
67
+ tsconfig.config.compilerOptions = {
68
+ ...tsconfig.config.compilerOptions || {}
69
+ };
70
+ tsconfig.config.compilerOptions.module = 'CommonJS';
71
+ tsconfig.config.compilerOptions.target = 'ES5';
72
+ }
73
+ const basename = path.basename(src);
74
+ transformSync(contents, basename, tsconfig, (err, output)=>{
75
+ if (err) return callback(err);
76
+ // infer extension and patch .mjs imports
77
+ let ext = path.extname(basename);
78
+ if (type === 'esm') {
79
+ ext = importReplaceMJS.indexOf(ext) >= 0 ? '.mjs' : ext;
80
+ output.code = makeReplacements(output.code, regexESM, importReplaceMJS, '.mjs');
81
+ ext = importReplaceCJS.indexOf(ext) >= 0 ? '.cjs' : ext;
82
+ output.code = makeReplacements(output.code, regexESM, importReplaceCJS, '.cjs');
83
+ } else {
84
+ ext = requireReplaceJS.indexOf(ext) >= 0 ? '.js' : ext;
85
+ output.code = makeReplacements(output.code, regexCJS, requireReplaceJS, '.js');
86
+ output.code += interopClientDefaultExport;
87
+ }
88
+ const destFilePath = path.join(dest, basename.replace(/\.[^/.]+$/, '') + ext);
89
+ mkdirp(path.dirname(destFilePath), ()=>{
90
+ const queue = new Queue();
91
+ queue.defer(fs.writeFile.bind(null, destFilePath, output.code, 'utf8'));
92
+ !options.sourceMaps || queue.defer(fs.writeFile.bind(null, `${destFilePath}.map`, output.map, 'utf8'));
93
+ queue.await(()=>err ? callback(err) : callback(null, destFilePath));
94
+ });
95
+ });
96
+ } catch (err) {
97
+ callback(err);
98
+ }
99
+ });
100
+ }
@@ -0,0 +1 @@
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-classic';\nimport Queue from 'queue-cb';\n\nimport transformSync from './transformSync.js';\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\nexport default function transformFileWorker(src, dest, type, options, callback) {\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 transformSync(contents, basename, tsconfig, (err, output) => {\n if (err) return callback(err);\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 });\n } catch (err) {\n callback(err);\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","transformFileWorker","src","dest","type","options","callback","readFile","err","contents","tsconfig","getTsconfig","config","compilerOptions","module","target","basename","output","extname","destFilePath","join","replace","dirname","queue","defer","writeFile","bind","sourceMaps","map","await"],"mappings":"AAAA,OAAOA,QAAQ,KAAK;AACpB,OAAOC,UAAU,OAAO;AACxB,OAAOC,UAAU,eAAe;AAChC,OAAOC,WAAW,sBAAsB;AACxC,OAAOC,YAAY,iBAAiB;AACpC,OAAOC,WAAW,WAAW;AAE7B,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,mBAAmB;IAAC;IAAQ;IAAQ;IAAO;IAAQ;IAAQ;CAAO;AAExE,SAASC,iBAAiBC,IAAI,EAAEC,KAAK,EAAEC,UAAU,EAAEC,SAAS;IAC1D,IAAIC,UAAU,EAAE;IAChB,IAAIC,QAAQJ,MAAMK,IAAI,CAACN;IACvB,MAAOK,MAAO;QACZ,MAAME,aAAaF,KAAK,CAAC,EAAE,IAAIA,KAAK,C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EAAE;oBAC9FL,MAAMM,KAAK,CAAC,IAAOrB,MAAMF,SAASE,OAAOF,SAAS,MAAMa;gBAC1D;YACF;QACF,EAAE,OAAOX,KAAK;YACZF,SAASE;QACX;IACF;AACF"}
@@ -3,7 +3,7 @@ import * as transpiler from 'ts-node/transpilers/swc';
3
3
  import * as ts from 'typescript';
4
4
  // @ts-ignore
5
5
  import loadSWC from '../lib/loadSWC.mjs';
6
- export default function transformSync(contents, fileName, config, callback) {
6
+ export default function transformSyncWorker(contents, fileName, config, callback) {
7
7
  loadSWC((err, swc)=>{
8
8
  if (err) return callback(err);
9
9
  const parsed = ts.parseJsonConfigFileContent(config.config, ts.sys, path.dirname(config.path));
@@ -1 +1 @@
1
- {"version":3,"sources":["transformSync.ts"],"sourcesContent":["import path from 'path';\nimport type { TsConfigResult } from 'get-tsconfig-compat';\nimport * as transpiler from 'ts-node/transpilers/swc';\nimport * as ts from 'typescript';\n// @ts-ignore\nimport loadSWC from '../lib/loadSWC.js';\n\nexport default function transformSync(contents: string, fileName: string, config: TsConfigResult, callback) {\n loadSWC((err, swc) => {\n if (err) return callback(err);\n const parsed = ts.parseJsonConfigFileContent(config.config, ts.sys, path.dirname(config.path));\n const transpile = transpiler.create({ swc: swc, service: { config: { options: parsed.options } } });\n const res = transpile.transpile(contents, { fileName });\n callback(null, { code: res.outputText, map: res.sourceMapText });\n });\n}\n"],"names":["path","transpiler","ts","loadSWC","transformSync","contents","fileName","config","callback","err","swc","parsed","parseJsonConfigFileContent","sys","dirname","transpile","create","service","options","res","code","outputText","map","sourceMapText"],"mappings":"AAAA,OAAOA,UAAU,OAAO;AAExB,YAAYC,gBAAgB,0BAA0B;AACtD,YAAYC,QAAQ,aAAa;AACjC,aAAa;AACb,OAAOC,aAAa,oBAAoB;AAExC,eAAe,SAASC,cAAcC,QAAgB,EAAEC,QAAgB,EAAEC,MAAsB,EAAEC,QAAQ;IACxGL,QAAQ,CAACM,KAAKC;QACZ,IAAID,KAAK,OAAOD,SAASC;QACzB,MAAME,SAAST,GAAGU,0BAA0B,CAACL,OAAOA,MAAM,EAAEL,GAAGW,GAAG,EAAEb,KAAKc,OAAO,CAACP,OAAOP,IAAI;QAC5F,MAAMe,YAAYd,WAAWe,MAAM,CAAC;YAAEN,KAAKA;YAAKO,SAAS;gBAAEV,QAAQ;oBAAEW,SAASP,OAAOO,OAAO;gBAAC;YAAE;QAAE;QACjG,MAAMC,MAAMJ,UAAUA,SAAS,CAACV,UAAU;YAAEC;QAAS;QACrDE,SAAS,MAAM;YAAEY,MAAMD,IAAIE,UAAU;YAAEC,KAAKH,IAAII,aAAa;QAAC;IAChE;AACF"}
1
+ {"version":3,"sources":["transformSync.ts"],"sourcesContent":["import path from 'path';\nimport type { TsConfigResult } from 'get-tsconfig-compat';\nimport * as transpiler from 'ts-node/transpilers/swc';\nimport * as ts from 'typescript';\n// @ts-ignore\nimport loadSWC from '../lib/loadSWC.js';\n\nexport default function transformSyncWorker(contents: string, fileName: string, config: TsConfigResult, callback) {\n loadSWC((err, swc) => {\n if (err) return callback(err);\n const parsed = ts.parseJsonConfigFileContent(config.config, ts.sys, path.dirname(config.path));\n const transpile = transpiler.create({ swc: swc, service: { config: { options: parsed.options } } });\n const res = transpile.transpile(contents, { fileName });\n callback(null, { code: res.outputText, map: res.sourceMapText });\n });\n}\n"],"names":["path","transpiler","ts","loadSWC","transformSyncWorker","contents","fileName","config","callback","err","swc","parsed","parseJsonConfigFileContent","sys","dirname","transpile","create","service","options","res","code","outputText","map","sourceMapText"],"mappings":"AAAA,OAAOA,UAAU,OAAO;AAExB,YAAYC,gBAAgB,0BAA0B;AACtD,YAAYC,QAAQ,aAAa;AACjC,aAAa;AACb,OAAOC,aAAa,oBAAoB;AAExC,eAAe,SAASC,oBAAoBC,QAAgB,EAAEC,QAAgB,EAAEC,MAAsB,EAAEC,QAAQ;IAC9GL,QAAQ,CAACM,KAAKC;QACZ,IAAID,KAAK,OAAOD,SAASC;QACzB,MAAME,SAAST,GAAGU,0BAA0B,CAACL,OAAOA,MAAM,EAAEL,GAAGW,GAAG,EAAEb,KAAKc,OAAO,CAACP,OAAOP,IAAI;QAC5F,MAAMe,YAAYd,WAAWe,MAAM,CAAC;YAAEN,KAAKA;YAAKO,SAAS;gBAAEV,QAAQ;oBAAEW,SAASP,OAAOO,OAAO;gBAAC;YAAE;QAAE;QACjG,MAAMC,MAAMJ,UAAUA,SAAS,CAACV,UAAU;YAAEC;QAAS;QACrDE,SAAS,MAAM;YAAEY,MAAMD,IAAIE,UAAU;YAAEC,KAAKH,IAAII,aAAa;QAAC;IAChE;AACF"}
@@ -1 +1 @@
1
- export default function loadSWC(callback: any): void;
1
+ export default function loadSWC(callback: any): any;
@@ -0,0 +1,2 @@
1
+ declare const _default: "14" | "local";
2
+ export default _default;
@@ -6,4 +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: any, dest: any, type: any, options: any, callback: any): void | Promise<unknown>;
9
+ export default function transformDirectory(src: any, dest: any, type: any, options: any, callback: any): any;
@@ -1,9 +1,9 @@
1
1
  /**
2
2
  * @param {string} src The source directory to traverse.
3
- * @param {string} dest The output directory to write the file to.
3
+ * @param {string} dest The output directory to write files to.
4
4
  * @param {string} type The type of transform ('esm' or 'cjs').
5
5
  * @param {{sourceMaps: boolean}} options Options to pass to swc.
6
- * @param {(err: Error | null, destFilePath: string) =>} [callback] Optional callback returing the path to the transformed file. Uses promise if callback not provided.
7
- * @returns {void | Promise<string>} Optional promise returing the path to the transformed file if callback not provided.
6
+ * @param {(err?: Error) =>} [callback] Optional callback. Uses promise if callback not provided.
7
+ * @returns {void | Promise<any>} Optional promise if callback not provided.
8
8
  */
9
- export default function transformFile(src: any, dest: any, type: any, options: any, callback: any): void | Promise<unknown>;
9
+ export default function transformFile(src: any, dest: any, type: any, options: any, callback: any): any;
@@ -1,6 +1,8 @@
1
+ import type { TsConfigResult } from 'get-tsconfig-compat';
1
2
  /**
2
3
  * @param {string} contents The file contents.
3
4
  * @param {string} fileName The filename.
5
+ * @param {TsConfigResult} config The configuration.
4
6
  * @returns {{ code: string, map?: string }} Returns object with the transformed code and source map if option sourceMaps was provided.
5
7
  */
6
- export default function transformSync(contents: any, fileName: any, config: any): any;
8
+ export default function transformSync(contents: string, fileName: string, config: TsConfigResult): any;
@@ -0,0 +1 @@
1
+ export default function transformDirectoryWorker(src: any, dest: any, type: any, options: any, callback: any): void;
@@ -0,0 +1 @@
1
+ export default function transformFileWorker(src: any, dest: any, type: any, options: any, callback: any): void;
@@ -1,2 +1,2 @@
1
1
  import type { TsConfigResult } from 'get-tsconfig-compat';
2
- export default function transformSync(contents: string, fileName: string, config: TsConfigResult, callback: any): void;
2
+ export default function transformSyncWorker(contents: string, fileName: string, config: TsConfigResult, callback: any): void;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ts-swc-transform",
3
- "version": "1.4.2",
3
+ "version": "1.4.3",
4
4
  "description": "Typescript transformers for swc. Supports Node >= 0.8",
5
5
  "keywords": [
6
6
  "matcher",
@@ -59,7 +59,7 @@
59
59
  "lazy-cache": "^2.0.2",
60
60
  "minimatch": "^3.1.2",
61
61
  "mkdirp-classic": "^0.5.3",
62
- "node-version-call": "^1.2.2",
62
+ "node-version-call": "^1.2.4",
63
63
  "path-posix": "^1.0.0",
64
64
  "queue-cb": "^1.4.4",
65
65
  "resolve": "^1.22.10",
@@ -77,7 +77,7 @@
77
77
  "core-js": "^3.39.0",
78
78
  "cr": "^0.1.0",
79
79
  "react": "^19.0.0",
80
- "ts-dev-stack": "^1.4.3",
80
+ "ts-dev-stack": "^1.4.4",
81
81
  "ts-node": "^10.8.2",
82
82
  "typescript": "^5.7.2"
83
83
  },