ts-swc-transform 2.5.3 → 2.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,4 @@
1
1
  export * as constants from './constants.ts';
2
- export { default as createMatcher } from './createMatcher.ts';
3
2
  export { default as resolveFileSync } from './resolveFileSync.ts';
4
3
  export { default as toPath } from './toPath.ts';
5
4
  export { default as transformDirectory } from './transformDirectory.ts';
@@ -1,5 +1,4 @@
1
1
  export * as constants from './constants.ts';
2
- export { default as createMatcher } from './createMatcher.ts';
3
2
  export { default as resolveFileSync } from './resolveFileSync.ts';
4
3
  export { default as toPath } from './toPath.ts';
5
4
  export { default as transformDirectory } from './transformDirectory.ts';
package/dist/cjs/index.js CHANGED
@@ -12,9 +12,6 @@ _export(exports, {
12
12
  get constants () {
13
13
  return _constantsts;
14
14
  },
15
- get createMatcher () {
16
- return _createMatcherts.default;
17
- },
18
15
  get resolveFileSync () {
19
16
  return _resolveFileSyncts.default;
20
17
  },
@@ -32,7 +29,6 @@ _export(exports, {
32
29
  }
33
30
  });
34
31
  var _constantsts = /*#__PURE__*/ _interop_require_wildcard(require("./constants.js"));
35
- var _createMatcherts = /*#__PURE__*/ _interop_require_default(require("./createMatcher.js"));
36
32
  var _resolveFileSyncts = /*#__PURE__*/ _interop_require_default(require("./resolveFileSync.js"));
37
33
  var _toPathts = /*#__PURE__*/ _interop_require_default(require("./toPath.js"));
38
34
  var _transformDirectoryts = /*#__PURE__*/ _interop_require_default(require("./transformDirectory.js"));
@@ -1 +1 @@
1
- {"version":3,"sources":["/Users/kevin/Dev/OpenSource/typescript/ts-swc-transform/src/index.ts"],"sourcesContent":["export * as constants from './constants.ts';\nexport { default as createMatcher } from './createMatcher.ts';\nexport { default as resolveFileSync } from './resolveFileSync.ts';\nexport { default as toPath } from './toPath.ts';\nexport { default as transformDirectory } from './transformDirectory.ts';\nexport { default as transformSync } from './transformSync.ts';\nexport { default as transformTypes } from './transformTypes.ts';\nexport type * from './types.ts';\n"],"names":["constants","createMatcher","resolveFileSync","toPath","transformDirectory","transformSync","transformTypes"],"mappings":";;;;;;;;;;;QAAYA;;;QACQC;eAAAA,wBAAa;;QACbC;eAAAA,0BAAe;;QACfC;eAAAA,iBAAM;;QACNC;eAAAA,6BAAkB;;QAClBC;eAAAA,wBAAa;;QACbC;eAAAA,yBAAc;;;mEANP;sEACc;wEACE;+DACT;2EACY;sEACL;uEACC"}
1
+ {"version":3,"sources":["/Users/kevin/Dev/OpenSource/typescript/ts-swc-transform/src/index.ts"],"sourcesContent":["export * as constants from './constants.ts';\nexport { default as resolveFileSync } from './resolveFileSync.ts';\nexport { default as toPath } from './toPath.ts';\nexport { default as transformDirectory } from './transformDirectory.ts';\nexport { default as transformSync } from './transformSync.ts';\nexport { default as transformTypes } from './transformTypes.ts';\nexport type * from './types.ts';\n"],"names":["constants","resolveFileSync","toPath","transformDirectory","transformSync","transformTypes"],"mappings":";;;;;;;;;;;QAAYA;;;QACQC;eAAAA,0BAAe;;QACfC;eAAAA,iBAAM;;QACNC;eAAAA,6BAAkB;;QAClBC;eAAAA,wBAAa;;QACbC;eAAAA,yBAAc;;;mEALP;wEACgB;+DACT;2EACY;sEACL;uEACC"}
@@ -11,8 +11,8 @@ Object.defineProperty(exports, "default", {
11
11
  var _fsiterator = /*#__PURE__*/ _interop_require_default(require("fs-iterator"));
12
12
  var _path = /*#__PURE__*/ _interop_require_default(require("path"));
13
13
  var _queuecb = /*#__PURE__*/ _interop_require_default(require("queue-cb"));
14
+ var _testmatch = /*#__PURE__*/ _interop_require_default(require("test-match"));
14
15
  var _constantsts = require("../constants.js");
15
- var _createMatcherts = /*#__PURE__*/ _interop_require_default(require("../createMatcher.js"));
16
16
  var _transformFilets = /*#__PURE__*/ _interop_require_default(require("../lib/transformFile.js"));
17
17
  function _define_property(obj, key, value) {
18
18
  if (key in obj) {
@@ -73,7 +73,11 @@ function _object_spread_props(target, source) {
73
73
  }
74
74
  function transformDirectoryWorker(src, dest, type, options, callback) {
75
75
  var tsconfig = options.tsconfig;
76
- var matcher = (0, _createMatcherts.default)(tsconfig);
76
+ var matcher = (0, _testmatch.default)({
77
+ cwd: _path.default.dirname(tsconfig.path),
78
+ include: tsconfig.config.include,
79
+ exclude: tsconfig.config.exclude
80
+ });
77
81
  var entries = [];
78
82
  var iterator = new _fsiterator.default(src);
79
83
  iterator.forEach(function(entry) {
@@ -1 +1 @@
1
- {"version":3,"sources":["/Users/kevin/Dev/OpenSource/typescript/ts-swc-transform/src/workers/transformDirectory.ts"],"sourcesContent":["import 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 { ConfigOptions, TargetType, TransformDirectoryCallback } from '../types.ts';\n\nexport default function transformDirectoryWorker(src: string, dest: string, type: TargetType, options: ConfigOptions, callback: TransformDirectoryCallback): undefined {\n const tsconfig = options.tsconfig;\n const matcher = createMatcher(tsconfig);\n\n const entries: Entry[] = [];\n const iterator = new Iterator(src);\n iterator.forEach(\n (entry: Entry): undefined => {\n if (!entry.stats.isFile()) return;\n if (entry.basename[0] === '.') return;\n if (typeFileRegEx.test(entry.basename)) return;\n if (!matcher(entry.fullPath)) return;\n const ext = path.extname(entry.basename);\n if (ext && extensions.indexOf(ext) < 0) return;\n entries.push(entry);\n },\n (err): undefined => {\n if (err) {\n callback(err);\n return;\n }\n const results = [];\n options = { ...options, tsconfig };\n\n const queue = new Queue();\n entries.forEach((entry: Entry) => {\n queue.defer((cb) =>\n transformFile(entry, dest, type, options, (err, outPath) => {\n if (err) return cb(err);\n results.push(path.normalize(outPath));\n if (options.sourceMaps) results.push(`${path.normalize(outPath)}.map`);\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","iterator","Iterator","forEach","entry","stats","isFile","basename","typeFileRegEx","test","fullPath","ext","path","extname","extensions","indexOf","push","err","results","queue","Queue","defer","cb","transformFile","outPath","normalize","sourceMaps","await"],"mappings":";;;;+BAUA;;;eAAwBA;;;iEAVa;2DACpB;8DACC;2BAEwB;sEAChB;sEACA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAIX,SAASA,yBAAyBC,GAAW,EAAEC,IAAY,EAAEC,IAAgB,EAAEC,OAAsB,EAAEC,QAAoC;IACxJ,IAAMC,WAAWF,QAAQE,QAAQ;IACjC,IAAMC,UAAUC,IAAAA,wBAAa,EAACF;IAE9B,IAAMG,UAAmB,EAAE;IAC3B,IAAMC,WAAW,IAAIC,mBAAQ,CAACV;IAC9BS,SAASE,OAAO,CACd,SAACC;QACC,IAAI,CAACA,MAAMC,KAAK,CAACC,MAAM,IAAI;QAC3B,IAAIF,MAAMG,QAAQ,CAAC,EAAE,KAAK,KAAK;QAC/B,IAAIC,0BAAa,CAACC,IAAI,CAACL,MAAMG,QAAQ,GAAG;QACxC,IAAI,CAACT,QAAQM,MAAMM,QAAQ,GAAG;QAC9B,IAAMC,MAAMC,aAAI,CAACC,OAAO,CAACT,MAAMG,QAAQ;QACvC,IAAII,OAAOG,uBAAU,CAACC,OAAO,CAACJ,OAAO,GAAG;QACxCX,QAAQgB,IAAI,CAACZ;IACf,GACA,SAACa;QACC,IAAIA,KAAK;YACPrB,SAASqB;YACT;QACF;QACA,IAAMC,UAAU,EAAE;QAClBvB,UAAU,wCAAKA;YAASE,UAAAA;;QAExB,IAAMsB,QAAQ,IAAIC,gBAAK;QACvBpB,QAAQG,OAAO,CAAC,SAACC;YACfe,MAAME,KAAK,CAAC,SAACC;uBACXC,IAAAA,wBAAa,EAACnB,OAAOX,MAAMC,MAAMC,SAAS,SAACsB,KAAKO;oBAC9C,IAAIP,KAAK,OAAOK,GAAGL;oBACnBC,QAAQF,IAAI,CAACJ,aAAI,CAACa,SAAS,CAACD;oBAC5B,IAAI7B,QAAQ+B,UAAU,EAAER,QAAQF,IAAI,CAAC,AAAC,GAA0B,OAAxBJ,aAAI,CAACa,SAAS,CAACD,UAAS;oBAChEF;gBACF;;QAEJ;QACAH,MAAMQ,KAAK,CAAC,SAACV;mBAASA,MAAMrB,SAASqB,OAAOrB,SAAS,MAAMsB;;IAC7D;AAEJ"}
1
+ {"version":3,"sources":["/Users/kevin/Dev/OpenSource/typescript/ts-swc-transform/src/workers/transformDirectory.ts"],"sourcesContent":["import Iterator, { type Entry } from 'fs-iterator';\nimport path from 'path';\nimport Queue from 'queue-cb';\nimport match from 'test-match';\nimport { extensions, typeFileRegEx } from '../constants.ts';\nimport transformFile from '../lib/transformFile.ts';\n\nimport type { ConfigOptions, TargetType, TransformDirectoryCallback } from '../types.ts';\n\nexport default function transformDirectoryWorker(src: string, dest: string, type: TargetType, options: ConfigOptions, callback: TransformDirectoryCallback): undefined {\n const tsconfig = options.tsconfig;\n const matcher = match({ cwd: path.dirname(tsconfig.path), include: tsconfig.config.include as string[], exclude: tsconfig.config.exclude as string[] });\n\n const entries: Entry[] = [];\n const iterator = new Iterator(src);\n iterator.forEach(\n (entry: Entry): undefined => {\n if (!entry.stats.isFile()) return;\n if (entry.basename[0] === '.') return;\n if (typeFileRegEx.test(entry.basename)) return;\n if (!matcher(entry.fullPath)) return;\n const ext = path.extname(entry.basename);\n if (ext && extensions.indexOf(ext) < 0) return;\n entries.push(entry);\n },\n (err): undefined => {\n if (err) {\n callback(err);\n return;\n }\n const results = [];\n options = { ...options, tsconfig };\n\n const queue = new Queue();\n entries.forEach((entry: Entry) => {\n queue.defer((cb) =>\n transformFile(entry, dest, type, options, (err, outPath) => {\n if (err) return cb(err);\n results.push(path.normalize(outPath));\n if (options.sourceMaps) results.push(`${path.normalize(outPath)}.map`);\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","match","cwd","path","dirname","include","config","exclude","entries","iterator","Iterator","forEach","entry","stats","isFile","basename","typeFileRegEx","test","fullPath","ext","extname","extensions","indexOf","push","err","results","queue","Queue","defer","cb","transformFile","outPath","normalize","sourceMaps","await"],"mappings":";;;;+BASA;;;eAAwBA;;;iEATa;2DACpB;8DACC;gEACA;2BACwB;sEAChB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAIX,SAASA,yBAAyBC,GAAW,EAAEC,IAAY,EAAEC,IAAgB,EAAEC,OAAsB,EAAEC,QAAoC;IACxJ,IAAMC,WAAWF,QAAQE,QAAQ;IACjC,IAAMC,UAAUC,IAAAA,kBAAK,EAAC;QAAEC,KAAKC,aAAI,CAACC,OAAO,CAACL,SAASI,IAAI;QAAGE,SAASN,SAASO,MAAM,CAACD,OAAO;QAAcE,SAASR,SAASO,MAAM,CAACC,OAAO;IAAa;IAErJ,IAAMC,UAAmB,EAAE;IAC3B,IAAMC,WAAW,IAAIC,mBAAQ,CAAChB;IAC9Be,SAASE,OAAO,CACd,SAACC;QACC,IAAI,CAACA,MAAMC,KAAK,CAACC,MAAM,IAAI;QAC3B,IAAIF,MAAMG,QAAQ,CAAC,EAAE,KAAK,KAAK;QAC/B,IAAIC,0BAAa,CAACC,IAAI,CAACL,MAAMG,QAAQ,GAAG;QACxC,IAAI,CAACf,QAAQY,MAAMM,QAAQ,GAAG;QAC9B,IAAMC,MAAMhB,aAAI,CAACiB,OAAO,CAACR,MAAMG,QAAQ;QACvC,IAAII,OAAOE,uBAAU,CAACC,OAAO,CAACH,OAAO,GAAG;QACxCX,QAAQe,IAAI,CAACX;IACf,GACA,SAACY;QACC,IAAIA,KAAK;YACP1B,SAAS0B;YACT;QACF;QACA,IAAMC,UAAU,EAAE;QAClB5B,UAAU,wCAAKA;YAASE,UAAAA;;QAExB,IAAM2B,QAAQ,IAAIC,gBAAK;QACvBnB,QAAQG,OAAO,CAAC,SAACC;YACfc,MAAME,KAAK,CAAC,SAACC;uBACXC,IAAAA,wBAAa,EAAClB,OAAOjB,MAAMC,MAAMC,SAAS,SAAC2B,KAAKO;oBAC9C,IAAIP,KAAK,OAAOK,GAAGL;oBACnBC,QAAQF,IAAI,CAACpB,aAAI,CAAC6B,SAAS,CAACD;oBAC5B,IAAIlC,QAAQoC,UAAU,EAAER,QAAQF,IAAI,CAAC,AAAC,GAA0B,OAAxBpB,aAAI,CAAC6B,SAAS,CAACD,UAAS;oBAChEF;gBACF;;QAEJ;QACAH,MAAMQ,KAAK,CAAC,SAACV;mBAASA,MAAM1B,SAAS0B,OAAO1B,SAAS,MAAM2B;;IAC7D;AAEJ"}
@@ -10,8 +10,9 @@ Object.defineProperty(exports, "default", {
10
10
  });
11
11
  var _fsiterator = /*#__PURE__*/ _interop_require_default(require("fs-iterator"));
12
12
  var _module = /*#__PURE__*/ _interop_require_default(require("module"));
13
+ var _path = /*#__PURE__*/ _interop_require_default(require("path"));
14
+ var _testmatch = /*#__PURE__*/ _interop_require_default(require("test-match"));
13
15
  var _constantsts = require("../constants.js");
14
- var _createMatcherts = /*#__PURE__*/ _interop_require_default(require("../createMatcher.js"));
15
16
  function _define_property(obj, key, value) {
16
17
  if (key in obj) {
17
18
  Object.defineProperty(obj, key, {
@@ -72,7 +73,11 @@ function _object_spread_props(target, source) {
72
73
  var _require = typeof require === 'undefined' ? _module.default.createRequire(require("url").pathToFileURL(__filename).toString()) : require;
73
74
  function transformTypesWorker(src, dest, options, callback) {
74
75
  var tsconfig = options.tsconfig;
75
- var matcher = (0, _createMatcherts.default)(tsconfig);
76
+ var matcher = (0, _testmatch.default)({
77
+ cwd: _path.default.dirname(tsconfig.path),
78
+ include: tsconfig.config.include,
79
+ exclude: tsconfig.config.exclude
80
+ });
76
81
  var ts = _require('typescript');
77
82
  var entries = [];
78
83
  var iterator = new _fsiterator.default(src);
@@ -1 +1 @@
1
- {"version":3,"sources":["/Users/kevin/Dev/OpenSource/typescript/ts-swc-transform/src/workers/transformTypes.ts"],"sourcesContent":["import Iterator, { type Entry } from 'fs-iterator';\n\nimport Module from 'module';\n\nconst _require = typeof require === 'undefined' ? Module.createRequire(import.meta.url) : require;\n\nimport { typeFileRegEx } from '../constants.ts';\nimport createMatcher from '../createMatcher.ts';\n\nimport type { ConfigOptions, TransformTypesCallback } from '../types.ts';\n\nexport default function transformTypesWorker(src: string, dest: string, options: ConfigOptions, callback: TransformTypesCallback): undefined {\n const tsconfig = options.tsconfig;\n const matcher = createMatcher(tsconfig);\n const ts = _require('typescript');\n\n const entries = [];\n const iterator = new Iterator(src);\n iterator.forEach(\n (entry: Entry): undefined => {\n if (!entry.stats.isFile()) return;\n if (entry.basename[0] === '.') return;\n if (typeFileRegEx.test(entry.basename)) return;\n if (!matcher(entry.fullPath)) return;\n entries.push(entry);\n },\n { concurrency: Infinity },\n (err): undefined => {\n if (err) {\n callback(err);\n return;\n }\n\n const compilerOptions = ts.convertCompilerOptionsFromJson(tsconfig.config.compilerOptions, '');\n const config = {\n fileNames: entries.map((entry) => entry.fullPath),\n options: {\n ...compilerOptions,\n outDir: dest,\n allowJs: true,\n declaration: true,\n emitDeclarationOnly: true,\n listEmittedFiles: true,\n },\n projectReferences: tsconfig.config.references,\n };\n const { fileNames, options, projectReferences } = config;\n const host = ts.createCompilerHostWorker(options, /*setParentNodes*/ undefined, ts.sys);\n const programOptions = {\n rootNames: fileNames,\n options,\n projectReferences,\n host,\n configFileParsingDiagnostics: ts.getConfigFileParsingDiagnostics({ fileNames, options }),\n };\n const program = ts.createProgram(programOptions);\n const res = program.emit();\n callback(null, res.emittedFiles);\n }\n );\n}\n"],"names":["transformTypesWorker","_require","require","Module","createRequire","src","dest","options","callback","tsconfig","matcher","createMatcher","ts","entries","iterator","Iterator","forEach","entry","stats","isFile","basename","typeFileRegEx","test","fullPath","push","concurrency","Infinity","err","compilerOptions","convertCompilerOptionsFromJson","config","fileNames","map","outDir","allowJs","declaration","emitDeclarationOnly","listEmittedFiles","projectReferences","references","host","createCompilerHostWorker","undefined","sys","programOptions","rootNames","configFileParsingDiagnostics","getConfigFileParsingDiagnostics","program","createProgram","res","emit","emittedFiles"],"mappings":";;;;+BAWA;;;eAAwBA;;;iEAXa;6DAElB;2BAIW;sEACJ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAH1B,IAAMC,WAAW,OAAOC,YAAY,cAAcC,eAAM,CAACC,aAAa,CAAC,uDAAmBF;AAO3E,SAASF,qBAAqBK,GAAW,EAAEC,IAAY,EAAEC,OAAsB,EAAEC,QAAgC;IAC9H,IAAMC,WAAWF,QAAQE,QAAQ;IACjC,IAAMC,UAAUC,IAAAA,wBAAa,EAACF;IAC9B,IAAMG,KAAKX,SAAS;IAEpB,IAAMY,UAAU,EAAE;IAClB,IAAMC,WAAW,IAAIC,mBAAQ,CAACV;IAC9BS,SAASE,OAAO,CACd,SAACC;QACC,IAAI,CAACA,MAAMC,KAAK,CAACC,MAAM,IAAI;QAC3B,IAAIF,MAAMG,QAAQ,CAAC,EAAE,KAAK,KAAK;QAC/B,IAAIC,0BAAa,CAACC,IAAI,CAACL,MAAMG,QAAQ,GAAG;QACxC,IAAI,CAACV,QAAQO,MAAMM,QAAQ,GAAG;QAC9BV,QAAQW,IAAI,CAACP;IACf,GACA;QAAEQ,aAAaC;IAAS,GACxB,SAACC;QACC,IAAIA,KAAK;YACPnB,SAASmB;YACT;QACF;QAEA,IAAMC,kBAAkBhB,GAAGiB,8BAA8B,CAACpB,SAASqB,MAAM,CAACF,eAAe,EAAE;QAC3F,IAAME,SAAS;YACbC,WAAWlB,QAAQmB,GAAG,CAAC,SAACf;uBAAUA,MAAMM,QAAQ;;YAChDhB,SAAS,wCACJqB;gBACHK,QAAQ3B;gBACR4B,SAAS;gBACTC,aAAa;gBACbC,qBAAqB;gBACrBC,kBAAkB;;YAEpBC,mBAAmB7B,SAASqB,MAAM,CAACS,UAAU;QAC/C;QACA,IAAQR,YAA0CD,OAA1CC,WAAWxB,YAA+BuB,OAA/BvB,SAAS+B,oBAAsBR,OAAtBQ;QAC5B,IAAME,OAAO5B,GAAG6B,wBAAwB,CAAClC,WAAS,gBAAgB,GAAGmC,WAAW9B,GAAG+B,GAAG;QACtF,IAAMC,iBAAiB;YACrBC,WAAWd;YACXxB,SAAAA;YACA+B,mBAAAA;YACAE,MAAAA;YACAM,8BAA8BlC,GAAGmC,+BAA+B,CAAC;gBAAEhB,WAAAA;gBAAWxB,SAAAA;YAAQ;QACxF;QACA,IAAMyC,UAAUpC,GAAGqC,aAAa,CAACL;QACjC,IAAMM,MAAMF,QAAQG,IAAI;QACxB3C,SAAS,MAAM0C,IAAIE,YAAY;IACjC;AAEJ"}
1
+ {"version":3,"sources":["/Users/kevin/Dev/OpenSource/typescript/ts-swc-transform/src/workers/transformTypes.ts"],"sourcesContent":["import Iterator, { type Entry } from 'fs-iterator';\nimport Module from 'module';\nimport path from 'path';\nimport match from 'test-match';\n\nconst _require = typeof require === 'undefined' ? Module.createRequire(import.meta.url) : require;\n\nimport { typeFileRegEx } from '../constants.ts';\n\nimport type { ConfigOptions, TransformTypesCallback } from '../types.ts';\n\nexport default function transformTypesWorker(src: string, dest: string, options: ConfigOptions, callback: TransformTypesCallback): undefined {\n const tsconfig = options.tsconfig;\n const matcher = match({ cwd: path.dirname(tsconfig.path), include: tsconfig.config.include as string[], exclude: tsconfig.config.exclude as string[] });\n const ts = _require('typescript');\n\n const entries = [];\n const iterator = new Iterator(src);\n iterator.forEach(\n (entry: Entry): undefined => {\n if (!entry.stats.isFile()) return;\n if (entry.basename[0] === '.') return;\n if (typeFileRegEx.test(entry.basename)) return;\n if (!matcher(entry.fullPath)) return;\n entries.push(entry);\n },\n { concurrency: Infinity },\n (err): undefined => {\n if (err) {\n callback(err);\n return;\n }\n\n const compilerOptions = ts.convertCompilerOptionsFromJson(tsconfig.config.compilerOptions, '');\n const config = {\n fileNames: entries.map((entry) => entry.fullPath),\n options: {\n ...compilerOptions,\n outDir: dest,\n allowJs: true,\n declaration: true,\n emitDeclarationOnly: true,\n listEmittedFiles: true,\n },\n projectReferences: tsconfig.config.references,\n };\n const { fileNames, options, projectReferences } = config;\n const host = ts.createCompilerHostWorker(options, /*setParentNodes*/ undefined, ts.sys);\n const programOptions = {\n rootNames: fileNames,\n options,\n projectReferences,\n host,\n configFileParsingDiagnostics: ts.getConfigFileParsingDiagnostics({ fileNames, options }),\n };\n const program = ts.createProgram(programOptions);\n const res = program.emit();\n callback(null, res.emittedFiles);\n }\n );\n}\n"],"names":["transformTypesWorker","_require","require","Module","createRequire","src","dest","options","callback","tsconfig","matcher","match","cwd","path","dirname","include","config","exclude","ts","entries","iterator","Iterator","forEach","entry","stats","isFile","basename","typeFileRegEx","test","fullPath","push","concurrency","Infinity","err","compilerOptions","convertCompilerOptionsFromJson","fileNames","map","outDir","allowJs","declaration","emitDeclarationOnly","listEmittedFiles","projectReferences","references","host","createCompilerHostWorker","undefined","sys","programOptions","rootNames","configFileParsingDiagnostics","getConfigFileParsingDiagnostics","program","createProgram","res","emit","emittedFiles"],"mappings":";;;;+BAWA;;;eAAwBA;;;iEAXa;6DAClB;2DACF;gEACC;2BAIY;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAF9B,IAAMC,WAAW,OAAOC,YAAY,cAAcC,eAAM,CAACC,aAAa,CAAC,uDAAmBF;AAM3E,SAASF,qBAAqBK,GAAW,EAAEC,IAAY,EAAEC,OAAsB,EAAEC,QAAgC;IAC9H,IAAMC,WAAWF,QAAQE,QAAQ;IACjC,IAAMC,UAAUC,IAAAA,kBAAK,EAAC;QAAEC,KAAKC,aAAI,CAACC,OAAO,CAACL,SAASI,IAAI;QAAGE,SAASN,SAASO,MAAM,CAACD,OAAO;QAAcE,SAASR,SAASO,MAAM,CAACC,OAAO;IAAa;IACrJ,IAAMC,KAAKjB,SAAS;IAEpB,IAAMkB,UAAU,EAAE;IAClB,IAAMC,WAAW,IAAIC,mBAAQ,CAAChB;IAC9Be,SAASE,OAAO,CACd,SAACC;QACC,IAAI,CAACA,MAAMC,KAAK,CAACC,MAAM,IAAI;QAC3B,IAAIF,MAAMG,QAAQ,CAAC,EAAE,KAAK,KAAK;QAC/B,IAAIC,0BAAa,CAACC,IAAI,CAACL,MAAMG,QAAQ,GAAG;QACxC,IAAI,CAAChB,QAAQa,MAAMM,QAAQ,GAAG;QAC9BV,QAAQW,IAAI,CAACP;IACf,GACA;QAAEQ,aAAaC;IAAS,GACxB,SAACC;QACC,IAAIA,KAAK;YACPzB,SAASyB;YACT;QACF;QAEA,IAAMC,kBAAkBhB,GAAGiB,8BAA8B,CAAC1B,SAASO,MAAM,CAACkB,eAAe,EAAE;QAC3F,IAAMlB,SAAS;YACboB,WAAWjB,QAAQkB,GAAG,CAAC,SAACd;uBAAUA,MAAMM,QAAQ;;YAChDtB,SAAS,wCACJ2B;gBACHI,QAAQhC;gBACRiC,SAAS;gBACTC,aAAa;gBACbC,qBAAqB;gBACrBC,kBAAkB;;YAEpBC,mBAAmBlC,SAASO,MAAM,CAAC4B,UAAU;QAC/C;QACA,IAAQR,YAA0CpB,OAA1CoB,WAAW7B,YAA+BS,OAA/BT,SAASoC,oBAAsB3B,OAAtB2B;QAC5B,IAAME,OAAO3B,GAAG4B,wBAAwB,CAACvC,WAAS,gBAAgB,GAAGwC,WAAW7B,GAAG8B,GAAG;QACtF,IAAMC,iBAAiB;YACrBC,WAAWd;YACX7B,SAAAA;YACAoC,mBAAAA;YACAE,MAAAA;YACAM,8BAA8BjC,GAAGkC,+BAA+B,CAAC;gBAAEhB,WAAAA;gBAAW7B,SAAAA;YAAQ;QACxF;QACA,IAAM8C,UAAUnC,GAAGoC,aAAa,CAACL;QACjC,IAAMM,MAAMF,QAAQG,IAAI;QACxBhD,SAAS,MAAM+C,IAAIE,YAAY;IACjC;AAEJ"}
@@ -1,5 +1,4 @@
1
1
  export * as constants from './constants.ts';
2
- export { default as createMatcher } from './createMatcher.ts';
3
2
  export { default as resolveFileSync } from './resolveFileSync.ts';
4
3
  export { default as toPath } from './toPath.ts';
5
4
  export { default as transformDirectory } from './transformDirectory.ts';
package/dist/esm/index.js CHANGED
@@ -1,6 +1,5 @@
1
1
  import * as _constants from './constants.js';
2
2
  export { _constants as constants };
3
- export { default as createMatcher } from './createMatcher.js';
4
3
  export { default as resolveFileSync } from './resolveFileSync.js';
5
4
  export { default as toPath } from './toPath.js';
6
5
  export { default as transformDirectory } from './transformDirectory.js';
@@ -1 +1 @@
1
- {"version":3,"sources":["/Users/kevin/Dev/OpenSource/typescript/ts-swc-transform/src/index.ts"],"sourcesContent":["export * as constants from './constants.ts';\nexport { default as createMatcher } from './createMatcher.ts';\nexport { default as resolveFileSync } from './resolveFileSync.ts';\nexport { default as toPath } from './toPath.ts';\nexport { default as transformDirectory } from './transformDirectory.ts';\nexport { default as transformSync } from './transformSync.ts';\nexport { default as transformTypes } from './transformTypes.ts';\nexport type * from './types.ts';\n"],"names":["constants","default","createMatcher","resolveFileSync","toPath","transformDirectory","transformSync","transformTypes"],"mappings":"AAAA,4BAA2B,iBAAiB;AAA5C,SAAO,cAAKA,SAAS,GAAuB;AAC5C,SAASC,WAAWC,aAAa,QAAQ,qBAAqB;AAC9D,SAASD,WAAWE,eAAe,QAAQ,uBAAuB;AAClE,SAASF,WAAWG,MAAM,QAAQ,cAAc;AAChD,SAASH,WAAWI,kBAAkB,QAAQ,0BAA0B;AACxE,SAASJ,WAAWK,aAAa,QAAQ,qBAAqB;AAC9D,SAASL,WAAWM,cAAc,QAAQ,sBAAsB"}
1
+ {"version":3,"sources":["/Users/kevin/Dev/OpenSource/typescript/ts-swc-transform/src/index.ts"],"sourcesContent":["export * as constants from './constants.ts';\nexport { default as resolveFileSync } from './resolveFileSync.ts';\nexport { default as toPath } from './toPath.ts';\nexport { default as transformDirectory } from './transformDirectory.ts';\nexport { default as transformSync } from './transformSync.ts';\nexport { default as transformTypes } from './transformTypes.ts';\nexport type * from './types.ts';\n"],"names":["constants","default","resolveFileSync","toPath","transformDirectory","transformSync","transformTypes"],"mappings":"AAAA,4BAA2B,iBAAiB;AAA5C,SAAO,cAAKA,SAAS,GAAuB;AAC5C,SAASC,WAAWC,eAAe,QAAQ,uBAAuB;AAClE,SAASD,WAAWE,MAAM,QAAQ,cAAc;AAChD,SAASF,WAAWG,kBAAkB,QAAQ,0BAA0B;AACxE,SAASH,WAAWI,aAAa,QAAQ,qBAAqB;AAC9D,SAASJ,WAAWK,cAAc,QAAQ,sBAAsB"}
@@ -1,12 +1,16 @@
1
1
  import Iterator from 'fs-iterator';
2
2
  import path from 'path';
3
3
  import Queue from 'queue-cb';
4
+ import match from 'test-match';
4
5
  import { extensions, typeFileRegEx } from '../constants.js';
5
- import createMatcher from '../createMatcher.js';
6
6
  import transformFile from '../lib/transformFile.js';
7
7
  export default function transformDirectoryWorker(src, dest, type, options, callback) {
8
8
  const tsconfig = options.tsconfig;
9
- const matcher = createMatcher(tsconfig);
9
+ const matcher = match({
10
+ cwd: path.dirname(tsconfig.path),
11
+ include: tsconfig.config.include,
12
+ exclude: tsconfig.config.exclude
13
+ });
10
14
  const entries = [];
11
15
  const iterator = new Iterator(src);
12
16
  iterator.forEach((entry)=>{
@@ -1 +1 @@
1
- {"version":3,"sources":["/Users/kevin/Dev/OpenSource/typescript/ts-swc-transform/src/workers/transformDirectory.ts"],"sourcesContent":["import 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 { ConfigOptions, TargetType, TransformDirectoryCallback } from '../types.ts';\n\nexport default function transformDirectoryWorker(src: string, dest: string, type: TargetType, options: ConfigOptions, callback: TransformDirectoryCallback): undefined {\n const tsconfig = options.tsconfig;\n const matcher = createMatcher(tsconfig);\n\n const entries: Entry[] = [];\n const iterator = new Iterator(src);\n iterator.forEach(\n (entry: Entry): undefined => {\n if (!entry.stats.isFile()) return;\n if (entry.basename[0] === '.') return;\n if (typeFileRegEx.test(entry.basename)) return;\n if (!matcher(entry.fullPath)) return;\n const ext = path.extname(entry.basename);\n if (ext && extensions.indexOf(ext) < 0) return;\n entries.push(entry);\n },\n (err): undefined => {\n if (err) {\n callback(err);\n return;\n }\n const results = [];\n options = { ...options, tsconfig };\n\n const queue = new Queue();\n entries.forEach((entry: Entry) => {\n queue.defer((cb) =>\n transformFile(entry, dest, type, options, (err, outPath) => {\n if (err) return cb(err);\n results.push(path.normalize(outPath));\n if (options.sourceMaps) results.push(`${path.normalize(outPath)}.map`);\n cb();\n })\n );\n });\n queue.await((err) => (err ? callback(err) : callback(null, results)));\n }\n );\n}\n"],"names":["Iterator","path","Queue","extensions","typeFileRegEx","createMatcher","transformFile","transformDirectoryWorker","src","dest","type","options","callback","tsconfig","matcher","entries","iterator","forEach","entry","stats","isFile","basename","test","fullPath","ext","extname","indexOf","push","err","results","queue","defer","cb","outPath","normalize","sourceMaps","await"],"mappings":"AAAA,OAAOA,cAA8B,cAAc;AACnD,OAAOC,UAAU,OAAO;AACxB,OAAOC,WAAW,WAAW;AAE7B,SAASC,UAAU,EAAEC,aAAa,QAAQ,kBAAkB;AAC5D,OAAOC,mBAAmB,sBAAsB;AAChD,OAAOC,mBAAmB,0BAA0B;AAIpD,eAAe,SAASC,yBAAyBC,GAAW,EAAEC,IAAY,EAAEC,IAAgB,EAAEC,OAAsB,EAAEC,QAAoC;IACxJ,MAAMC,WAAWF,QAAQE,QAAQ;IACjC,MAAMC,UAAUT,cAAcQ;IAE9B,MAAME,UAAmB,EAAE;IAC3B,MAAMC,WAAW,IAAIhB,SAASQ;IAC9BQ,SAASC,OAAO,CACd,CAACC;QACC,IAAI,CAACA,MAAMC,KAAK,CAACC,MAAM,IAAI;QAC3B,IAAIF,MAAMG,QAAQ,CAAC,EAAE,KAAK,KAAK;QAC/B,IAAIjB,cAAckB,IAAI,CAACJ,MAAMG,QAAQ,GAAG;QACxC,IAAI,CAACP,QAAQI,MAAMK,QAAQ,GAAG;QAC9B,MAAMC,MAAMvB,KAAKwB,OAAO,CAACP,MAAMG,QAAQ;QACvC,IAAIG,OAAOrB,WAAWuB,OAAO,CAACF,OAAO,GAAG;QACxCT,QAAQY,IAAI,CAACT;IACf,GACA,CAACU;QACC,IAAIA,KAAK;YACPhB,SAASgB;YACT;QACF;QACA,MAAMC,UAAU,EAAE;QAClBlB,UAAU;YAAE,GAAGA,OAAO;YAAEE;QAAS;QAEjC,MAAMiB,QAAQ,IAAI5B;QAClBa,QAAQE,OAAO,CAAC,CAACC;YACfY,MAAMC,KAAK,CAAC,CAACC,KACX1B,cAAcY,OAAOT,MAAMC,MAAMC,SAAS,CAACiB,KAAKK;oBAC9C,IAAIL,KAAK,OAAOI,GAAGJ;oBACnBC,QAAQF,IAAI,CAAC1B,KAAKiC,SAAS,CAACD;oBAC5B,IAAItB,QAAQwB,UAAU,EAAEN,QAAQF,IAAI,CAAC,GAAG1B,KAAKiC,SAAS,CAACD,SAAS,IAAI,CAAC;oBACrED;gBACF;QAEJ;QACAF,MAAMM,KAAK,CAAC,CAACR,MAASA,MAAMhB,SAASgB,OAAOhB,SAAS,MAAMiB;IAC7D;AAEJ"}
1
+ {"version":3,"sources":["/Users/kevin/Dev/OpenSource/typescript/ts-swc-transform/src/workers/transformDirectory.ts"],"sourcesContent":["import Iterator, { type Entry } from 'fs-iterator';\nimport path from 'path';\nimport Queue from 'queue-cb';\nimport match from 'test-match';\nimport { extensions, typeFileRegEx } from '../constants.ts';\nimport transformFile from '../lib/transformFile.ts';\n\nimport type { ConfigOptions, TargetType, TransformDirectoryCallback } from '../types.ts';\n\nexport default function transformDirectoryWorker(src: string, dest: string, type: TargetType, options: ConfigOptions, callback: TransformDirectoryCallback): undefined {\n const tsconfig = options.tsconfig;\n const matcher = match({ cwd: path.dirname(tsconfig.path), include: tsconfig.config.include as string[], exclude: tsconfig.config.exclude as string[] });\n\n const entries: Entry[] = [];\n const iterator = new Iterator(src);\n iterator.forEach(\n (entry: Entry): undefined => {\n if (!entry.stats.isFile()) return;\n if (entry.basename[0] === '.') return;\n if (typeFileRegEx.test(entry.basename)) return;\n if (!matcher(entry.fullPath)) return;\n const ext = path.extname(entry.basename);\n if (ext && extensions.indexOf(ext) < 0) return;\n entries.push(entry);\n },\n (err): undefined => {\n if (err) {\n callback(err);\n return;\n }\n const results = [];\n options = { ...options, tsconfig };\n\n const queue = new Queue();\n entries.forEach((entry: Entry) => {\n queue.defer((cb) =>\n transformFile(entry, dest, type, options, (err, outPath) => {\n if (err) return cb(err);\n results.push(path.normalize(outPath));\n if (options.sourceMaps) results.push(`${path.normalize(outPath)}.map`);\n cb();\n })\n );\n });\n queue.await((err) => (err ? callback(err) : callback(null, results)));\n }\n );\n}\n"],"names":["Iterator","path","Queue","match","extensions","typeFileRegEx","transformFile","transformDirectoryWorker","src","dest","type","options","callback","tsconfig","matcher","cwd","dirname","include","config","exclude","entries","iterator","forEach","entry","stats","isFile","basename","test","fullPath","ext","extname","indexOf","push","err","results","queue","defer","cb","outPath","normalize","sourceMaps","await"],"mappings":"AAAA,OAAOA,cAA8B,cAAc;AACnD,OAAOC,UAAU,OAAO;AACxB,OAAOC,WAAW,WAAW;AAC7B,OAAOC,WAAW,aAAa;AAC/B,SAASC,UAAU,EAAEC,aAAa,QAAQ,kBAAkB;AAC5D,OAAOC,mBAAmB,0BAA0B;AAIpD,eAAe,SAASC,yBAAyBC,GAAW,EAAEC,IAAY,EAAEC,IAAgB,EAAEC,OAAsB,EAAEC,QAAoC;IACxJ,MAAMC,WAAWF,QAAQE,QAAQ;IACjC,MAAMC,UAAUX,MAAM;QAAEY,KAAKd,KAAKe,OAAO,CAACH,SAASZ,IAAI;QAAGgB,SAASJ,SAASK,MAAM,CAACD,OAAO;QAAcE,SAASN,SAASK,MAAM,CAACC,OAAO;IAAa;IAErJ,MAAMC,UAAmB,EAAE;IAC3B,MAAMC,WAAW,IAAIrB,SAASQ;IAC9Ba,SAASC,OAAO,CACd,CAACC;QACC,IAAI,CAACA,MAAMC,KAAK,CAACC,MAAM,IAAI;QAC3B,IAAIF,MAAMG,QAAQ,CAAC,EAAE,KAAK,KAAK;QAC/B,IAAIrB,cAAcsB,IAAI,CAACJ,MAAMG,QAAQ,GAAG;QACxC,IAAI,CAACZ,QAAQS,MAAMK,QAAQ,GAAG;QAC9B,MAAMC,MAAM5B,KAAK6B,OAAO,CAACP,MAAMG,QAAQ;QACvC,IAAIG,OAAOzB,WAAW2B,OAAO,CAACF,OAAO,GAAG;QACxCT,QAAQY,IAAI,CAACT;IACf,GACA,CAACU;QACC,IAAIA,KAAK;YACPrB,SAASqB;YACT;QACF;QACA,MAAMC,UAAU,EAAE;QAClBvB,UAAU;YAAE,GAAGA,OAAO;YAAEE;QAAS;QAEjC,MAAMsB,QAAQ,IAAIjC;QAClBkB,QAAQE,OAAO,CAAC,CAACC;YACfY,MAAMC,KAAK,CAAC,CAACC,KACX/B,cAAciB,OAAOd,MAAMC,MAAMC,SAAS,CAACsB,KAAKK;oBAC9C,IAAIL,KAAK,OAAOI,GAAGJ;oBACnBC,QAAQF,IAAI,CAAC/B,KAAKsC,SAAS,CAACD;oBAC5B,IAAI3B,QAAQ6B,UAAU,EAAEN,QAAQF,IAAI,CAAC,GAAG/B,KAAKsC,SAAS,CAACD,SAAS,IAAI,CAAC;oBACrED;gBACF;QAEJ;QACAF,MAAMM,KAAK,CAAC,CAACR,MAASA,MAAMrB,SAASqB,OAAOrB,SAAS,MAAMsB;IAC7D;AAEJ"}
@@ -1,11 +1,16 @@
1
1
  import Iterator from 'fs-iterator';
2
2
  import Module from 'module';
3
+ import path from 'path';
4
+ import match from 'test-match';
3
5
  const _require = typeof require === 'undefined' ? Module.createRequire(import.meta.url) : require;
4
6
  import { typeFileRegEx } from '../constants.js';
5
- import createMatcher from '../createMatcher.js';
6
7
  export default function transformTypesWorker(src, dest, options, callback) {
7
8
  const tsconfig = options.tsconfig;
8
- const matcher = createMatcher(tsconfig);
9
+ const matcher = match({
10
+ cwd: path.dirname(tsconfig.path),
11
+ include: tsconfig.config.include,
12
+ exclude: tsconfig.config.exclude
13
+ });
9
14
  const ts = _require('typescript');
10
15
  const entries = [];
11
16
  const iterator = new Iterator(src);
@@ -1 +1 @@
1
- {"version":3,"sources":["/Users/kevin/Dev/OpenSource/typescript/ts-swc-transform/src/workers/transformTypes.ts"],"sourcesContent":["import Iterator, { type Entry } from 'fs-iterator';\n\nimport Module from 'module';\n\nconst _require = typeof require === 'undefined' ? Module.createRequire(import.meta.url) : require;\n\nimport { typeFileRegEx } from '../constants.ts';\nimport createMatcher from '../createMatcher.ts';\n\nimport type { ConfigOptions, TransformTypesCallback } from '../types.ts';\n\nexport default function transformTypesWorker(src: string, dest: string, options: ConfigOptions, callback: TransformTypesCallback): undefined {\n const tsconfig = options.tsconfig;\n const matcher = createMatcher(tsconfig);\n const ts = _require('typescript');\n\n const entries = [];\n const iterator = new Iterator(src);\n iterator.forEach(\n (entry: Entry): undefined => {\n if (!entry.stats.isFile()) return;\n if (entry.basename[0] === '.') return;\n if (typeFileRegEx.test(entry.basename)) return;\n if (!matcher(entry.fullPath)) return;\n entries.push(entry);\n },\n { concurrency: Infinity },\n (err): undefined => {\n if (err) {\n callback(err);\n return;\n }\n\n const compilerOptions = ts.convertCompilerOptionsFromJson(tsconfig.config.compilerOptions, '');\n const config = {\n fileNames: entries.map((entry) => entry.fullPath),\n options: {\n ...compilerOptions,\n outDir: dest,\n allowJs: true,\n declaration: true,\n emitDeclarationOnly: true,\n listEmittedFiles: true,\n },\n projectReferences: tsconfig.config.references,\n };\n const { fileNames, options, projectReferences } = config;\n const host = ts.createCompilerHostWorker(options, /*setParentNodes*/ undefined, ts.sys);\n const programOptions = {\n rootNames: fileNames,\n options,\n projectReferences,\n host,\n configFileParsingDiagnostics: ts.getConfigFileParsingDiagnostics({ fileNames, options }),\n };\n const program = ts.createProgram(programOptions);\n const res = program.emit();\n callback(null, res.emittedFiles);\n }\n );\n}\n"],"names":["Iterator","Module","_require","require","createRequire","url","typeFileRegEx","createMatcher","transformTypesWorker","src","dest","options","callback","tsconfig","matcher","ts","entries","iterator","forEach","entry","stats","isFile","basename","test","fullPath","push","concurrency","Infinity","err","compilerOptions","convertCompilerOptionsFromJson","config","fileNames","map","outDir","allowJs","declaration","emitDeclarationOnly","listEmittedFiles","projectReferences","references","host","createCompilerHostWorker","undefined","sys","programOptions","rootNames","configFileParsingDiagnostics","getConfigFileParsingDiagnostics","program","createProgram","res","emit","emittedFiles"],"mappings":"AAAA,OAAOA,cAA8B,cAAc;AAEnD,OAAOC,YAAY,SAAS;AAE5B,MAAMC,WAAW,OAAOC,YAAY,cAAcF,OAAOG,aAAa,CAAC,YAAYC,GAAG,IAAIF;AAE1F,SAASG,aAAa,QAAQ,kBAAkB;AAChD,OAAOC,mBAAmB,sBAAsB;AAIhD,eAAe,SAASC,qBAAqBC,GAAW,EAAEC,IAAY,EAAEC,OAAsB,EAAEC,QAAgC;IAC9H,MAAMC,WAAWF,QAAQE,QAAQ;IACjC,MAAMC,UAAUP,cAAcM;IAC9B,MAAME,KAAKb,SAAS;IAEpB,MAAMc,UAAU,EAAE;IAClB,MAAMC,WAAW,IAAIjB,SAASS;IAC9BQ,SAASC,OAAO,CACd,CAACC;QACC,IAAI,CAACA,MAAMC,KAAK,CAACC,MAAM,IAAI;QAC3B,IAAIF,MAAMG,QAAQ,CAAC,EAAE,KAAK,KAAK;QAC/B,IAAIhB,cAAciB,IAAI,CAACJ,MAAMG,QAAQ,GAAG;QACxC,IAAI,CAACR,QAAQK,MAAMK,QAAQ,GAAG;QAC9BR,QAAQS,IAAI,CAACN;IACf,GACA;QAAEO,aAAaC;IAAS,GACxB,CAACC;QACC,IAAIA,KAAK;YACPhB,SAASgB;YACT;QACF;QAEA,MAAMC,kBAAkBd,GAAGe,8BAA8B,CAACjB,SAASkB,MAAM,CAACF,eAAe,EAAE;QAC3F,MAAME,SAAS;YACbC,WAAWhB,QAAQiB,GAAG,CAAC,CAACd,QAAUA,MAAMK,QAAQ;YAChDb,SAAS;gBACP,GAAGkB,eAAe;gBAClBK,QAAQxB;gBACRyB,SAAS;gBACTC,aAAa;gBACbC,qBAAqB;gBACrBC,kBAAkB;YACpB;YACAC,mBAAmB1B,SAASkB,MAAM,CAACS,UAAU;QAC/C;QACA,MAAM,EAAER,SAAS,EAAErB,OAAO,EAAE4B,iBAAiB,EAAE,GAAGR;QAClD,MAAMU,OAAO1B,GAAG2B,wBAAwB,CAAC/B,SAAS,gBAAgB,GAAGgC,WAAW5B,GAAG6B,GAAG;QACtF,MAAMC,iBAAiB;YACrBC,WAAWd;YACXrB;YACA4B;YACAE;YACAM,8BAA8BhC,GAAGiC,+BAA+B,CAAC;gBAAEhB;gBAAWrB;YAAQ;QACxF;QACA,MAAMsC,UAAUlC,GAAGmC,aAAa,CAACL;QACjC,MAAMM,MAAMF,QAAQG,IAAI;QACxBxC,SAAS,MAAMuC,IAAIE,YAAY;IACjC;AAEJ"}
1
+ {"version":3,"sources":["/Users/kevin/Dev/OpenSource/typescript/ts-swc-transform/src/workers/transformTypes.ts"],"sourcesContent":["import Iterator, { type Entry } from 'fs-iterator';\nimport Module from 'module';\nimport path from 'path';\nimport match from 'test-match';\n\nconst _require = typeof require === 'undefined' ? Module.createRequire(import.meta.url) : require;\n\nimport { typeFileRegEx } from '../constants.ts';\n\nimport type { ConfigOptions, TransformTypesCallback } from '../types.ts';\n\nexport default function transformTypesWorker(src: string, dest: string, options: ConfigOptions, callback: TransformTypesCallback): undefined {\n const tsconfig = options.tsconfig;\n const matcher = match({ cwd: path.dirname(tsconfig.path), include: tsconfig.config.include as string[], exclude: tsconfig.config.exclude as string[] });\n const ts = _require('typescript');\n\n const entries = [];\n const iterator = new Iterator(src);\n iterator.forEach(\n (entry: Entry): undefined => {\n if (!entry.stats.isFile()) return;\n if (entry.basename[0] === '.') return;\n if (typeFileRegEx.test(entry.basename)) return;\n if (!matcher(entry.fullPath)) return;\n entries.push(entry);\n },\n { concurrency: Infinity },\n (err): undefined => {\n if (err) {\n callback(err);\n return;\n }\n\n const compilerOptions = ts.convertCompilerOptionsFromJson(tsconfig.config.compilerOptions, '');\n const config = {\n fileNames: entries.map((entry) => entry.fullPath),\n options: {\n ...compilerOptions,\n outDir: dest,\n allowJs: true,\n declaration: true,\n emitDeclarationOnly: true,\n listEmittedFiles: true,\n },\n projectReferences: tsconfig.config.references,\n };\n const { fileNames, options, projectReferences } = config;\n const host = ts.createCompilerHostWorker(options, /*setParentNodes*/ undefined, ts.sys);\n const programOptions = {\n rootNames: fileNames,\n options,\n projectReferences,\n host,\n configFileParsingDiagnostics: ts.getConfigFileParsingDiagnostics({ fileNames, options }),\n };\n const program = ts.createProgram(programOptions);\n const res = program.emit();\n callback(null, res.emittedFiles);\n }\n );\n}\n"],"names":["Iterator","Module","path","match","_require","require","createRequire","url","typeFileRegEx","transformTypesWorker","src","dest","options","callback","tsconfig","matcher","cwd","dirname","include","config","exclude","ts","entries","iterator","forEach","entry","stats","isFile","basename","test","fullPath","push","concurrency","Infinity","err","compilerOptions","convertCompilerOptionsFromJson","fileNames","map","outDir","allowJs","declaration","emitDeclarationOnly","listEmittedFiles","projectReferences","references","host","createCompilerHostWorker","undefined","sys","programOptions","rootNames","configFileParsingDiagnostics","getConfigFileParsingDiagnostics","program","createProgram","res","emit","emittedFiles"],"mappings":"AAAA,OAAOA,cAA8B,cAAc;AACnD,OAAOC,YAAY,SAAS;AAC5B,OAAOC,UAAU,OAAO;AACxB,OAAOC,WAAW,aAAa;AAE/B,MAAMC,WAAW,OAAOC,YAAY,cAAcJ,OAAOK,aAAa,CAAC,YAAYC,GAAG,IAAIF;AAE1F,SAASG,aAAa,QAAQ,kBAAkB;AAIhD,eAAe,SAASC,qBAAqBC,GAAW,EAAEC,IAAY,EAAEC,OAAsB,EAAEC,QAAgC;IAC9H,MAAMC,WAAWF,QAAQE,QAAQ;IACjC,MAAMC,UAAUZ,MAAM;QAAEa,KAAKd,KAAKe,OAAO,CAACH,SAASZ,IAAI;QAAGgB,SAASJ,SAASK,MAAM,CAACD,OAAO;QAAcE,SAASN,SAASK,MAAM,CAACC,OAAO;IAAa;IACrJ,MAAMC,KAAKjB,SAAS;IAEpB,MAAMkB,UAAU,EAAE;IAClB,MAAMC,WAAW,IAAIvB,SAASU;IAC9Ba,SAASC,OAAO,CACd,CAACC;QACC,IAAI,CAACA,MAAMC,KAAK,CAACC,MAAM,IAAI;QAC3B,IAAIF,MAAMG,QAAQ,CAAC,EAAE,KAAK,KAAK;QAC/B,IAAIpB,cAAcqB,IAAI,CAACJ,MAAMG,QAAQ,GAAG;QACxC,IAAI,CAACb,QAAQU,MAAMK,QAAQ,GAAG;QAC9BR,QAAQS,IAAI,CAACN;IACf,GACA;QAAEO,aAAaC;IAAS,GACxB,CAACC;QACC,IAAIA,KAAK;YACPrB,SAASqB;YACT;QACF;QAEA,MAAMC,kBAAkBd,GAAGe,8BAA8B,CAACtB,SAASK,MAAM,CAACgB,eAAe,EAAE;QAC3F,MAAMhB,SAAS;YACbkB,WAAWf,QAAQgB,GAAG,CAAC,CAACb,QAAUA,MAAMK,QAAQ;YAChDlB,SAAS;gBACP,GAAGuB,eAAe;gBAClBI,QAAQ5B;gBACR6B,SAAS;gBACTC,aAAa;gBACbC,qBAAqB;gBACrBC,kBAAkB;YACpB;YACAC,mBAAmB9B,SAASK,MAAM,CAAC0B,UAAU;QAC/C;QACA,MAAM,EAAER,SAAS,EAAEzB,OAAO,EAAEgC,iBAAiB,EAAE,GAAGzB;QAClD,MAAM2B,OAAOzB,GAAG0B,wBAAwB,CAACnC,SAAS,gBAAgB,GAAGoC,WAAW3B,GAAG4B,GAAG;QACtF,MAAMC,iBAAiB;YACrBC,WAAWd;YACXzB;YACAgC;YACAE;YACAM,8BAA8B/B,GAAGgC,+BAA+B,CAAC;gBAAEhB;gBAAWzB;YAAQ;QACxF;QACA,MAAM0C,UAAUjC,GAAGkC,aAAa,CAACL;QACjC,MAAMM,MAAMF,QAAQG,IAAI;QACxB5C,SAAS,MAAM2C,IAAIE,YAAY;IACjC;AAEJ"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ts-swc-transform",
3
- "version": "2.5.3",
3
+ "version": "2.6.0",
4
4
  "description": "Typescript transformers for swc. Supports Node >= 0.8",
5
5
  "keywords": [
6
6
  "matcher",
@@ -51,17 +51,15 @@
51
51
  "is-absolute": "^1.0.0",
52
52
  "lodash.debounce": "^4.0.8",
53
53
  "lodash.find": "^4.6.0",
54
- "minimatch": "^3.1.2",
55
54
  "mkdirp-classic": "^0.5.3",
56
- "node-version-call": "^1.9.3",
57
- "path-posix": "^1.0.0",
55
+ "node-version-call": "^1.9.4",
58
56
  "queue-cb": "^1.5.5",
59
57
  "read-tsconfig-sync": "^1.0.2",
60
58
  "resolve": "^1.22.10",
61
59
  "rimraf2": "^2.8.2",
60
+ "test-match": "^1.0.0",
62
61
  "ts-node": "*",
63
- "typescript": "*",
64
- "unixify": "^1.0.0"
62
+ "typescript": "*"
65
63
  },
66
64
  "devDependencies": {
67
65
  "@types/mocha": "*",
@@ -1,2 +0,0 @@
1
- import type { Matcher, TSConfig } from './types.ts';
2
- export default function createMatcher(tsconfig: TSConfig): Matcher;
@@ -1,2 +0,0 @@
1
- import type { Matcher, TSConfig } from './types.ts';
2
- export default function createMatcher(tsconfig: TSConfig): Matcher;
@@ -1,43 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", {
3
- value: true
4
- });
5
- Object.defineProperty(exports, "default", {
6
- enumerable: true,
7
- get: function() {
8
- return createMatcher;
9
- }
10
- });
11
- var _minimatch = /*#__PURE__*/ _interop_require_default(require("minimatch"));
12
- var _pathposix = /*#__PURE__*/ _interop_require_default(require("path-posix"));
13
- var _unixify = /*#__PURE__*/ _interop_require_default(require("unixify"));
14
- function _interop_require_default(obj) {
15
- return obj && obj.__esModule ? obj : {
16
- default: obj
17
- };
18
- }
19
- function createMatcher(tsconfig) {
20
- var tsconfigPath = _pathposix.default.dirname((0, _unixify.default)(tsconfig.path));
21
- function matchFn(condition) {
22
- var pattern = (0, _unixify.default)(condition);
23
- if (!_pathposix.default.isAbsolute(pattern) && pattern.indexOf('*') !== 0) pattern = _pathposix.default.join(tsconfigPath, pattern);
24
- return function match(filePath) {
25
- return filePath.indexOf(pattern) === 0 || (0, _minimatch.default)(filePath, pattern);
26
- };
27
- }
28
- var includes = (tsconfig.config.include || []).map(matchFn);
29
- var excludes = (tsconfig.config.exclude || []).map(matchFn);
30
- return function matcher(filePath) {
31
- var ext = _pathposix.default.extname(filePath);
32
- if (ext === '.json') return false;
33
- filePath = (0, _unixify.default)(filePath);
34
- for(var i = 0; i < excludes.length; ++i){
35
- if (excludes[i](filePath)) return false;
36
- }
37
- for(var j = 0; j < includes.length; ++j){
38
- if (includes[j](filePath)) return true;
39
- }
40
- return !includes.length;
41
- };
42
- }
43
- /* CJS INTEROP */ if (exports.__esModule && exports.default) { try { Object.defineProperty(exports.default, '__esModule', { value: true }); for (var key in exports) { exports.default[key] = exports[key]; } } catch (_) {}; module.exports = exports.default; }
@@ -1 +0,0 @@
1
- {"version":3,"sources":["/Users/kevin/Dev/OpenSource/typescript/ts-swc-transform/src/createMatcher.ts"],"sourcesContent":["import minimatch from 'minimatch';\nimport path from 'path-posix';\nimport unixify from 'unixify';\nimport type { Matcher, TSConfig } from './types.ts';\n\nexport default function createMatcher(tsconfig: TSConfig): Matcher {\n const tsconfigPath = path.dirname(unixify(tsconfig.path));\n\n function matchFn(condition) {\n let pattern = unixify(condition);\n if (!path.isAbsolute(pattern) && pattern.indexOf('*') !== 0) pattern = path.join(tsconfigPath, pattern);\n\n return function match(filePath) {\n return filePath.indexOf(pattern) === 0 || minimatch(filePath, pattern);\n };\n }\n\n const includes = ((tsconfig.config.include as string[]) || []).map(matchFn);\n const excludes = ((tsconfig.config.exclude as string[]) || []).map(matchFn);\n\n return function matcher(filePath) {\n const ext = path.extname(filePath);\n if (ext === '.json') return false;\n\n filePath = unixify(filePath);\n for (let i = 0; i < excludes.length; ++i) {\n if (excludes[i](filePath)) return false;\n }\n for (let j = 0; j < includes.length; ++j) {\n if (includes[j](filePath)) return true;\n }\n return !includes.length;\n };\n}\n"],"names":["createMatcher","tsconfig","tsconfigPath","path","dirname","unixify","matchFn","condition","pattern","isAbsolute","indexOf","join","match","filePath","minimatch","includes","config","include","map","excludes","exclude","matcher","ext","extname","i","length","j"],"mappings":";;;;+BAKA;;;eAAwBA;;;gEALF;gEACL;8DACG;;;;;;AAGL,SAASA,cAAcC,QAAkB;IACtD,IAAMC,eAAeC,kBAAI,CAACC,OAAO,CAACC,IAAAA,gBAAO,EAACJ,SAASE,IAAI;IAEvD,SAASG,QAAQC,SAAS;QACxB,IAAIC,UAAUH,IAAAA,gBAAO,EAACE;QACtB,IAAI,CAACJ,kBAAI,CAACM,UAAU,CAACD,YAAYA,QAAQE,OAAO,CAAC,SAAS,GAAGF,UAAUL,kBAAI,CAACQ,IAAI,CAACT,cAAcM;QAE/F,OAAO,SAASI,MAAMC,QAAQ;YAC5B,OAAOA,SAASH,OAAO,CAACF,aAAa,KAAKM,IAAAA,kBAAS,EAACD,UAAUL;QAChE;IACF;IAEA,IAAMO,WAAW,AAAC,CAAA,AAACd,SAASe,MAAM,CAACC,OAAO,IAAiB,EAAE,AAAD,EAAGC,GAAG,CAACZ;IACnE,IAAMa,WAAW,AAAC,CAAA,AAAClB,SAASe,MAAM,CAACI,OAAO,IAAiB,EAAE,AAAD,EAAGF,GAAG,CAACZ;IAEnE,OAAO,SAASe,QAAQR,QAAQ;QAC9B,IAAMS,MAAMnB,kBAAI,CAACoB,OAAO,CAACV;QACzB,IAAIS,QAAQ,SAAS,OAAO;QAE5BT,WAAWR,IAAAA,gBAAO,EAACQ;QACnB,IAAK,IAAIW,IAAI,GAAGA,IAAIL,SAASM,MAAM,EAAE,EAAED,EAAG;YACxC,IAAIL,QAAQ,CAACK,EAAE,CAACX,WAAW,OAAO;QACpC;QACA,IAAK,IAAIa,IAAI,GAAGA,IAAIX,SAASU,MAAM,EAAE,EAAEC,EAAG;YACxC,IAAIX,QAAQ,CAACW,EAAE,CAACb,WAAW,OAAO;QACpC;QACA,OAAO,CAACE,SAASU,MAAM;IACzB;AACF"}
@@ -1,2 +0,0 @@
1
- import type { Matcher, TSConfig } from './types.ts';
2
- export default function createMatcher(tsconfig: TSConfig): Matcher;
@@ -1,27 +0,0 @@
1
- import minimatch from 'minimatch';
2
- import path from 'path-posix';
3
- import unixify from 'unixify';
4
- export default function createMatcher(tsconfig) {
5
- const tsconfigPath = path.dirname(unixify(tsconfig.path));
6
- function matchFn(condition) {
7
- let pattern = unixify(condition);
8
- if (!path.isAbsolute(pattern) && pattern.indexOf('*') !== 0) pattern = path.join(tsconfigPath, pattern);
9
- return function match(filePath) {
10
- return filePath.indexOf(pattern) === 0 || minimatch(filePath, pattern);
11
- };
12
- }
13
- const includes = (tsconfig.config.include || []).map(matchFn);
14
- const excludes = (tsconfig.config.exclude || []).map(matchFn);
15
- return function matcher(filePath) {
16
- const ext = path.extname(filePath);
17
- if (ext === '.json') return false;
18
- filePath = unixify(filePath);
19
- for(let i = 0; i < excludes.length; ++i){
20
- if (excludes[i](filePath)) return false;
21
- }
22
- for(let j = 0; j < includes.length; ++j){
23
- if (includes[j](filePath)) return true;
24
- }
25
- return !includes.length;
26
- };
27
- }
@@ -1 +0,0 @@
1
- {"version":3,"sources":["/Users/kevin/Dev/OpenSource/typescript/ts-swc-transform/src/createMatcher.ts"],"sourcesContent":["import minimatch from 'minimatch';\nimport path from 'path-posix';\nimport unixify from 'unixify';\nimport type { Matcher, TSConfig } from './types.ts';\n\nexport default function createMatcher(tsconfig: TSConfig): Matcher {\n const tsconfigPath = path.dirname(unixify(tsconfig.path));\n\n function matchFn(condition) {\n let pattern = unixify(condition);\n if (!path.isAbsolute(pattern) && pattern.indexOf('*') !== 0) pattern = path.join(tsconfigPath, pattern);\n\n return function match(filePath) {\n return filePath.indexOf(pattern) === 0 || minimatch(filePath, pattern);\n };\n }\n\n const includes = ((tsconfig.config.include as string[]) || []).map(matchFn);\n const excludes = ((tsconfig.config.exclude as string[]) || []).map(matchFn);\n\n return function matcher(filePath) {\n const ext = path.extname(filePath);\n if (ext === '.json') return false;\n\n filePath = unixify(filePath);\n for (let i = 0; i < excludes.length; ++i) {\n if (excludes[i](filePath)) return false;\n }\n for (let j = 0; j < includes.length; ++j) {\n if (includes[j](filePath)) return true;\n }\n return !includes.length;\n };\n}\n"],"names":["minimatch","path","unixify","createMatcher","tsconfig","tsconfigPath","dirname","matchFn","condition","pattern","isAbsolute","indexOf","join","match","filePath","includes","config","include","map","excludes","exclude","matcher","ext","extname","i","length","j"],"mappings":"AAAA,OAAOA,eAAe,YAAY;AAClC,OAAOC,UAAU,aAAa;AAC9B,OAAOC,aAAa,UAAU;AAG9B,eAAe,SAASC,cAAcC,QAAkB;IACtD,MAAMC,eAAeJ,KAAKK,OAAO,CAACJ,QAAQE,SAASH,IAAI;IAEvD,SAASM,QAAQC,SAAS;QACxB,IAAIC,UAAUP,QAAQM;QACtB,IAAI,CAACP,KAAKS,UAAU,CAACD,YAAYA,QAAQE,OAAO,CAAC,SAAS,GAAGF,UAAUR,KAAKW,IAAI,CAACP,cAAcI;QAE/F,OAAO,SAASI,MAAMC,QAAQ;YAC5B,OAAOA,SAASH,OAAO,CAACF,aAAa,KAAKT,UAAUc,UAAUL;QAChE;IACF;IAEA,MAAMM,WAAW,AAAC,CAAA,AAACX,SAASY,MAAM,CAACC,OAAO,IAAiB,EAAE,AAAD,EAAGC,GAAG,CAACX;IACnE,MAAMY,WAAW,AAAC,CAAA,AAACf,SAASY,MAAM,CAACI,OAAO,IAAiB,EAAE,AAAD,EAAGF,GAAG,CAACX;IAEnE,OAAO,SAASc,QAAQP,QAAQ;QAC9B,MAAMQ,MAAMrB,KAAKsB,OAAO,CAACT;QACzB,IAAIQ,QAAQ,SAAS,OAAO;QAE5BR,WAAWZ,QAAQY;QACnB,IAAK,IAAIU,IAAI,GAAGA,IAAIL,SAASM,MAAM,EAAE,EAAED,EAAG;YACxC,IAAIL,QAAQ,CAACK,EAAE,CAACV,WAAW,OAAO;QACpC;QACA,IAAK,IAAIY,IAAI,GAAGA,IAAIX,SAASU,MAAM,EAAE,EAAEC,EAAG;YACxC,IAAIX,QAAQ,CAACW,EAAE,CAACZ,WAAW,OAAO;QACpC;QACA,OAAO,CAACC,SAASU,MAAM;IACzB;AACF"}