ts-swc-transform 2.4.1 → 2.4.2

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.
@@ -28,7 +28,8 @@ function createMatcher(tsconfig) {
28
28
  var includes = (tsconfig.config.include || []).map(matchFn);
29
29
  var excludes = (tsconfig.config.exclude || []).map(matchFn);
30
30
  return function matcher(filePath) {
31
- if (filePath.endsWith('.json')) return false;
31
+ var ext = _pathposix.default.extname(filePath);
32
+ if (ext === '.json') return false;
32
33
  filePath = (0, _unixify.default)(filePath);
33
34
  for(var i = 0; i < excludes.length; ++i){
34
35
  if (excludes[i](filePath)) return false;
@@ -1 +1 @@
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 if (filePath.endsWith('.json')) return false;\n\n filePath = unixify(filePath);\n for (let i = 0; i < excludes.length; ++i) {\n if (excludes[i](filePath)) return false;\n }\n for (let j = 0; j < includes.length; ++j) {\n if (includes[j](filePath)) return true;\n }\n return !includes.length;\n };\n}\n"],"names":["createMatcher","tsconfig","tsconfigPath","path","dirname","unixify","matchFn","condition","pattern","isAbsolute","indexOf","join","match","filePath","minimatch","includes","config","include","map","excludes","exclude","matcher","endsWith","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,IAAIA,SAASS,QAAQ,CAAC,UAAU,OAAO;QAEvCT,WAAWR,IAAAA,gBAAO,EAACQ;QACnB,IAAK,IAAIU,IAAI,GAAGA,IAAIJ,SAASK,MAAM,EAAE,EAAED,EAAG;YACxC,IAAIJ,QAAQ,CAACI,EAAE,CAACV,WAAW,OAAO;QACpC;QACA,IAAK,IAAIY,IAAI,GAAGA,IAAIV,SAASS,MAAM,EAAE,EAAEC,EAAG;YACxC,IAAIV,QAAQ,CAACU,EAAE,CAACZ,WAAW,OAAO;QACpC;QACA,OAAO,CAACE,SAASS,MAAM;IACzB;AACF"}
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"}
@@ -86,7 +86,8 @@ function transformFile(entry, dest, type, options, callback) {
86
86
  }
87
87
  var swcOptions = (0, _prepareSWCOptionsts.default)(tsconfig);
88
88
  var swc = _require('@swc/core');
89
- swc.transformFile(entry.fullPath, _object_spread_props(_object_spread({}, entry.basename.endsWith('.tsx') || entry.basename.endsWith('.jsx') ? swcOptions.tsxOptions : swcOptions.nonTsxOptions), {
89
+ var ext = _path.default.extname(entry.basename);
90
+ swc.transformFile(entry.fullPath, _object_spread_props(_object_spread({}, ext === '.tsx' || ext === '.jsx' ? swcOptions.tsxOptions : swcOptions.nonTsxOptions), {
90
91
  filename: entry.basename
91
92
  })).then(function(output) {
92
93
  var extTarget = type === 'esm' ? (0, _patchESMts.default)(entry, output, options) : (0, _patchCJSts.default)(entry, output, options);
@@ -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';\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 { ConfigOptions, TargetType, TransformFileCallback } from '../types.ts';\n\nexport default function transformFile(entry: Entry, dest: string, type: TargetType, options: ConfigOptions, callback: TransformFileCallback): undefined {\n let tsconfig = options.tsconfig;\n\n // overrides for cjs\n if (type === 'cjs') {\n tsconfig = { ...tsconfig };\n tsconfig.config = { ...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 swcOptions = prepareSWCOptions(tsconfig);\n const swc = _require('@swc/core');\n\n swc\n .transformFile(entry.fullPath, {\n ...(entry.basename.endsWith('.tsx') || entry.basename.endsWith('.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(fs.writeFile.bind(null, outPath, output.code, 'utf8'));\n !options.sourceMaps || queue.defer(fs.writeFile.bind(null, `${outPath}.map`, output.map, 'utf8'));\n queue.await((err) => (err ? callback(err) : callback(null, outPath)));\n });\n })\n .catch(callback);\n}\n"],"names":["transformFile","_require","require","Module","createRequire","entry","dest","type","options","callback","tsconfig","config","compilerOptions","module","target","swcOptions","prepareSWCOptions","swc","fullPath","basename","endsWith","tsxOptions","nonTsxOptions","filename","then","output","extTarget","patchESM","patchCJS","ext","path","extname","outPath","join","slice","length","mkdirp","dirname","queue","Queue","defer","fs","writeFile","bind","code","sourceMaps","map","await","err","catch"],"m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AG,CAACL,IAAIM,MAAM,IAAI9B,MAAMyB,IAAI,AAAD,IAAKJ;QAExFU,IAAAA,sBAAM,EAACN,aAAI,CAACO,OAAO,CAACL,UAAU;YAC5B,IAAMM,QAAQ,IAAIC,gBAAK;YACvBD,MAAME,KAAK,CAACC,WAAE,CAACC,SAAS,CAACC,IAAI,CAAC,MAAMX,SAASP,OAAOmB,IAAI,EAAE;YAC1D,CAACpC,QAAQqC,UAAU,IAAIP,MAAME,KAAK,CAACC,WAAE,CAACC,SAAS,CAACC,IAAI,CAAC,MAAM,AAAC,GAAU,OAARX,SAAQ,SAAOP,OAAOqB,GAAG,EAAE;YACzFR,MAAMS,KAAK,CAAC,SAACC;uBAASA,MAAMvC,SAASuC,OAAOvC,SAAS,MAAMuB;;QAC7D;IACF,GACCiB,KAAK,CAACxC;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';\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 { ConfigOptions, TargetType, TransformFileCallback } from '../types.ts';\n\nexport default function transformFile(entry: Entry, dest: string, type: TargetType, options: ConfigOptions, callback: TransformFileCallback): undefined {\n let tsconfig = options.tsconfig;\n\n // overrides for cjs\n if (type === 'cjs') {\n tsconfig = { ...tsconfig };\n tsconfig.config = { ...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 swcOptions = prepareSWCOptions(tsconfig);\n const swc = _require('@swc/core');\n const ext = path.extname(entry.basename);\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(fs.writeFile.bind(null, outPath, output.code, 'utf8'));\n !options.sourceMaps || queue.defer(fs.writeFile.bind(null, `${outPath}.map`, output.map, 'utf8'));\n queue.await((err) => (err ? callback(err) : callback(null, outPath)));\n });\n })\n .catch(callback);\n}\n"],"names":["transformFile","_require","require","Module","createRequire","entry","dest","type","options","callback","tsconfig","config","compilerOptions","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","fs","writeFile","bind","code","sourceMaps","map","await","err","catch"],"mappings":";;;;+BAeA;;;eAAwBA;;;yDAdT;oEAEI;6DACA;2DACF;8DACC;iEACG;iEACA;0EACS;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAE9B,IAAMC,WAAW,OAAOC,YAAY,cAAcC,eAAM,CAACC,aAAa,CAAC,uDAAmBF;AAI3E,SAASF,cAAcK,KAAY,EAAEC,IAAY,EAAEC,IAAgB,EAAEC,OAAsB,EAAEC,QAA+B;IACzI,IAAIC,WAAWF,QAAQE,QAAQ;IAE/B,oBAAoB;IACpB,IAAIH,SAAS,OAAO;QAClBG,WAAW,mBAAKA;QAChBA,SAASC,MAAM,GAAG,mBAAKD,SAASC,MAAM;QACtCD,SAASC,MAAM,CAACC,eAAe,GAAG,mBAAMF,SAASC,MAAM,CAACC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K,CAACvC;AACX"}
@@ -28,7 +28,7 @@ function resolveFileSync(specifier, context) {
28
28
  stat = _fs.default.statSync(filePath);
29
29
  } catch (_err) {}
30
30
  try {
31
- if (stat && stat.isDirectory() || specifier.endsWith('/')) {
31
+ if (stat && stat.isDirectory() || specifier[specifier.length - 1] === '/') {
32
32
  var items = _fs.default.readdirSync(filePath);
33
33
  var item = (0, _lodashfind.default)(items, function(x) {
34
34
  return indexExtensions.indexOf(x) >= 0;
@@ -1 +1 @@
1
- {"version":3,"sources":["/Users/kevin/Dev/OpenSource/typescript/ts-swc-transform/src/resolveFileSync.ts"],"sourcesContent":["import fs from 'fs';\nimport find from 'lodash.find';\nimport path from 'path';\nimport { extensions, moduleRegEx, typeFileRegEx } from './constants.ts';\nimport toPath from './toPath.ts';\nimport type { Context } from './types.ts';\n\nconst indexExtensions = extensions.map((x) => `index${x}`);\n\nexport default function resolveFileSync(specifier: string, context?: Context): string {\n const filePath = toPath(specifier, context);\n let stat: fs.Stats;\n try {\n stat = fs.statSync(filePath);\n } catch (_err) {}\n try {\n if ((stat && stat.isDirectory()) || specifier.endsWith('/')) {\n const items = fs.readdirSync(filePath);\n const item = find(items, (x) => indexExtensions.indexOf(x) >= 0);\n if (item) return path.join(filePath, item);\n } else if (!stat && !moduleRegEx.test(specifier)) {\n const ext = path.extname(filePath);\n const basename = ext ? path.basename(filePath).slice(0, -ext.length) : path.basename(filePath);\n const items = fs.readdirSync(path.dirname(filePath));\n const item = find(items, (x) => {\n if (typeFileRegEx.test(x)) return false;\n const extTest = path.extname(x);\n const basenameTest = extTest ? path.basename(x).slice(0, -extTest.length) : path.basename(x);\n return basename === basenameTest;\n });\n if (item) return path.join(path.dirname(filePath), item);\n }\n // return what was found\n return stat ? filePath : null;\n } catch (_err) {\n return null;\n }\n}\n"],"names":["resolveFileSync","indexExtensions","extensions","map","x","specifier","context","filePath","toPath","stat","fs","statSync","_err","isDirectory","endsWith","items","readdirSync","item","find","indexOf","path","join","moduleRegEx","test","ext","extname","basename","slice","length","dirname","typeFileRegEx","extTest","basenameTest"],"mappings":";;;;+BASA;;;eAAwBA;;;yDATT;iEACE;2DACA;2BACsC;+DACpC;;;;;;AAGnB,IAAMC,kBAAkBC,uBAAU,CAACC,GAAG,CAAC,SAACC;WAAM,AAAC,QAAS,OAAFA;;AAEvC,SAASJ,gBAAgBK,SAAiB,EAAEC,OAAiB;IAC1E,IAAMC,WAAWC,IAAAA,iBAAM,EAACH,WAAWC;IACnC,IAAIG;IACJ,IAAI;QACFA,OAAOC,WAAE,CAACC,QAAQ,CAACJ;IACrB,EAAE,OAAOK,MAAM,CAAC;IAChB,IAAI;QACF,IAAI,AAACH,QAAQA,KAAKI,WAAW,MAAOR,UAAUS,QAAQ,CAAC,MAAM;YAC3D,IAAMC,QAAQL,WAAE,CAACM,WAAW,CAACT;YAC7B,IAAMU,OAAOC,IAAAA,mBAAI,EAACH,OAAO,SAACX;uBAAMH,gBAAgBkB,OAAO,CAACf,MAAM;;YAC9D,IAAIa,MAAM,OAAOG,aAAI,CAACC,IAAI,CAACd,UAAUU;QACvC,OAAO,IAAI,CAACR,QAAQ,CAACa,wBAAW,CAACC,IAAI,CAAClB,YAAY;YAChD,IAAMmB,MAAMJ,aAAI,CAACK,OAAO,CAAClB;YACzB,IAAMmB,WAAWF,MAAMJ,aAAI,CAACM,QAAQ,CAACnB,UAAUoB,KAAK,CAAC,GAAG,CAACH,IAAII,MAAM,IAAIR,aAAI,CAACM,QAAQ,CAACnB;YACrF,IAAMQ,SAAQL,WAAE,CAACM,WAAW,CAACI,aAAI,CAACS,OAAO,CAACtB;YAC1C,IAAMU,QAAOC,IAAAA,mBAAI,EAACH,QAAO,SAACX;gBACxB,IAAI0B,0BAAa,CAACP,IAAI,CAACnB,IAAI,OAAO;gBAClC,IAAM2B,UAAUX,aAAI,CAACK,OAAO,CAACrB;gBAC7B,IAAM4B,eAAeD,UAAUX,aAAI,CAACM,QAAQ,CAACtB,GAAGuB,KAAK,CAAC,GAAG,CAACI,QAAQH,MAAM,IAAIR,aAAI,CAACM,QAAQ,CAACtB;gBAC1F,OAAOsB,aAAaM;YACtB;YACA,IAAIf,OAAM,OAAOG,aAAI,CAACC,IAAI,CAACD,aAAI,CAACS,OAAO,CAACtB,WAAWU;QACrD;QACA,wBAAwB;QACxB,OAAOR,OAAOF,WAAW;IAC3B,EAAE,OAAOK,MAAM;QACb,OAAO;IACT;AACF"}
1
+ {"version":3,"sources":["/Users/kevin/Dev/OpenSource/typescript/ts-swc-transform/src/resolveFileSync.ts"],"sourcesContent":["import fs from 'fs';\nimport find from 'lodash.find';\nimport path from 'path';\nimport { extensions, moduleRegEx, typeFileRegEx } from './constants.ts';\nimport toPath from './toPath.ts';\nimport type { Context } from './types.ts';\n\nconst indexExtensions = extensions.map((x) => `index${x}`);\n\nexport default function resolveFileSync(specifier: string, context?: Context): string {\n const filePath = toPath(specifier, context);\n let stat: fs.Stats;\n try {\n stat = fs.statSync(filePath);\n } catch (_err) {}\n try {\n if ((stat && stat.isDirectory()) || specifier[specifier.length - 1] === '/') {\n const items = fs.readdirSync(filePath);\n const item = find(items, (x) => indexExtensions.indexOf(x) >= 0);\n if (item) return path.join(filePath, item);\n } else if (!stat && !moduleRegEx.test(specifier)) {\n const ext = path.extname(filePath);\n const basename = ext ? path.basename(filePath).slice(0, -ext.length) : path.basename(filePath);\n const items = fs.readdirSync(path.dirname(filePath));\n const item = find(items, (x) => {\n if (typeFileRegEx.test(x)) return false;\n const extTest = path.extname(x);\n const basenameTest = extTest ? path.basename(x).slice(0, -extTest.length) : path.basename(x);\n return basename === basenameTest;\n });\n if (item) return path.join(path.dirname(filePath), item);\n }\n // return what was found\n return stat ? filePath : null;\n } catch (_err) {\n return null;\n }\n}\n"],"names":["resolveFileSync","indexExtensions","extensions","map","x","specifier","context","filePath","toPath","stat","fs","statSync","_err","isDirectory","length","items","readdirSync","item","find","indexOf","path","join","moduleRegEx","test","ext","extname","basename","slice","dirname","typeFileRegEx","extTest","basenameTest"],"m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AIM,aAAI,CAACM,QAAQ,CAACtB;gBAC1F,OAAOsB,aAAaK;YACtB;YACA,IAAId,OAAM,OAAOG,aAAI,CAACC,IAAI,CAACD,aAAI,CAACQ,OAAO,CAACrB,WAAWU;QACrD;QACA,wBAAwB;QACxB,OAAOR,OAAOF,WAAW;IAC3B,EAAE,OAAOK,MAAM;QACb,OAAO;IACT;AACF"}
@@ -9,6 +9,7 @@ Object.defineProperty(exports, "default", {
9
9
  }
10
10
  });
11
11
  var _module = /*#__PURE__*/ _interop_require_default(require("module"));
12
+ var _path = /*#__PURE__*/ _interop_require_default(require("path"));
12
13
  var _prepareSWCOptionsts = /*#__PURE__*/ _interop_require_default(require("../lib/prepareSWCOptions.js"));
13
14
  function _define_property(obj, key, value) {
14
15
  if (key in obj) {
@@ -71,7 +72,8 @@ var _require = typeof require === 'undefined' ? _module.default.createRequire(re
71
72
  function transformSyncWorker(contents, fileName, tsconfig) {
72
73
  var swcOptions = (0, _prepareSWCOptionsts.default)(tsconfig);
73
74
  var swc = _require('@swc/core');
74
- return swc.transformSync(contents, _object_spread_props(_object_spread({}, fileName.endsWith('.tsx') || fileName.endsWith('.jsx') ? swcOptions.tsxOptions : swcOptions.nonTsxOptions), {
75
+ var ext = _path.default.extname(fileName);
76
+ return swc.transformSync(contents, _object_spread_props(_object_spread({}, ext === '.tsx' || ext === '.jsx' ? swcOptions.tsxOptions : swcOptions.nonTsxOptions), {
75
77
  filename: fileName
76
78
  }));
77
79
  }
@@ -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 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 return swc.transformSync(contents, {\n ...(fileName.endsWith('.tsx') || fileName.endsWith('.jsx') ? swcOptions.tsxOptions : swcOptions.nonTsxOptions),\n filename: fileName,\n });\n}\n"],"names":["transformSyncWorker","_require","require","Module","createRequire","contents","fileName","tsconfig","swcOptions","prepareSWCOptions","swc","transformSync","endsWith","tsxOptions","nonTsxOptions","filename"],"mappings":";;;;+BAOA;;;eAAwBA;;;6DANL;0EACW;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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,OAAOS,IAAIC,aAAa,CAACN,UAAU,wCAC7BC,SAASM,QAAQ,CAAC,WAAWN,SAASM,QAAQ,CAAC,UAAUJ,WAAWK,UAAU,GAAGL,WAAWM,aAAa;QAC7GC,UAAUT;;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"}
@@ -13,7 +13,8 @@ export default function createMatcher(tsconfig) {
13
13
  const includes = (tsconfig.config.include || []).map(matchFn);
14
14
  const excludes = (tsconfig.config.exclude || []).map(matchFn);
15
15
  return function matcher(filePath) {
16
- if (filePath.endsWith('.json')) return false;
16
+ const ext = path.extname(filePath);
17
+ if (ext === '.json') return false;
17
18
  filePath = unixify(filePath);
18
19
  for(let i = 0; i < excludes.length; ++i){
19
20
  if (excludes[i](filePath)) return false;
@@ -1 +1 @@
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 if (filePath.endsWith('.json')) return false;\n\n filePath = unixify(filePath);\n for (let i = 0; i < excludes.length; ++i) {\n if (excludes[i](filePath)) return false;\n }\n for (let j = 0; j < includes.length; ++j) {\n if (includes[j](filePath)) return true;\n }\n return !includes.length;\n };\n}\n"],"names":["minimatch","path","unixify","createMatcher","tsconfig","tsconfigPath","dirname","matchFn","condition","pattern","isAbsolute","indexOf","join","match","filePath","includes","config","include","map","excludes","exclude","matcher","endsWith","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,IAAIA,SAASQ,QAAQ,CAAC,UAAU,OAAO;QAEvCR,WAAWZ,QAAQY;QACnB,IAAK,IAAIS,IAAI,GAAGA,IAAIJ,SAASK,MAAM,EAAE,EAAED,EAAG;YACxC,IAAIJ,QAAQ,CAACI,EAAE,CAACT,WAAW,OAAO;QACpC;QACA,IAAK,IAAIW,IAAI,GAAGA,IAAIV,SAASS,MAAM,EAAE,EAAEC,EAAG;YACxC,IAAIV,QAAQ,CAACU,EAAE,CAACX,WAAW,OAAO;QACpC;QACA,OAAO,CAACC,SAASS,MAAM;IACzB;AACF"}
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"}
@@ -25,8 +25,9 @@ export default function transformFile(entry, dest, type, options, callback) {
25
25
  }
26
26
  const swcOptions = prepareSWCOptions(tsconfig);
27
27
  const swc = _require('@swc/core');
28
+ const ext = path.extname(entry.basename);
28
29
  swc.transformFile(entry.fullPath, {
29
- ...entry.basename.endsWith('.tsx') || entry.basename.endsWith('.jsx') ? swcOptions.tsxOptions : swcOptions.nonTsxOptions,
30
+ ...ext === '.tsx' || ext === '.jsx' ? swcOptions.tsxOptions : swcOptions.nonTsxOptions,
30
31
  filename: entry.basename
31
32
  }).then((output)=>{
32
33
  const extTarget = type === 'esm' ? patchESM(entry, output, options) : patchCJS(entry, output, options);
@@ -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';\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 { ConfigOptions, TargetType, TransformFileCallback } from '../types.ts';\n\nexport default function transformFile(entry: Entry, dest: string, type: TargetType, options: ConfigOptions, callback: TransformFileCallback): undefined {\n let tsconfig = options.tsconfig;\n\n // overrides for cjs\n if (type === 'cjs') {\n tsconfig = { ...tsconfig };\n tsconfig.config = { ...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 swcOptions = prepareSWCOptions(tsconfig);\n const swc = _require('@swc/core');\n\n swc\n .transformFile(entry.fullPath, {\n ...(entry.basename.endsWith('.tsx') || entry.basename.endsWith('.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(fs.writeFile.bind(null, outPath, output.code, 'utf8'));\n !options.sourceMaps || queue.defer(fs.writeFile.bind(null, `${outPath}.map`, output.map, 'utf8'));\n queue.await((err) => (err ? callback(err) : callback(null, outPath)));\n });\n })\n .catch(callback);\n}\n"],"names":["fs","mkdirp","Module","path","Queue","patchCJS","patchESM","prepareSWCOptions","_require","require","createRequire","url","transformFile","entry","dest","type","options","callback","tsconfig","config","compilerOptions","module","target","swcOptions","swc","fullPath","basename","endsWith","tsxOptions","nonTsxOptions","filename","then","output","extTarget","ext","extname","outPath","join","slice","length","dirname","queue","defer","writeFile","bind","code","sourceMaps","map","await","err","catch"],"mappings":"AACA,OAAOA,QAAQ,KAAK;AAEpB,OAAOC,YAAY,iBAAiB;AACpC,OAAOC,YAAY,SAAS;AAC5B,OAAOC,UAAU,OAAO;AACxB,OAAOC,WAAW,WAAW;AAC7B,OAAOC,cAAc,qBAAqB;AAC1C,OAAOC,cAAc,qBAAqB;AAC1C,OAAOC,uBAAuB,8BAA8B;AAE5D,MAAMC,WAAW,OAAOC,YAAY,cAAcP,OAAOQ,aAAa,CAAC,YAAYC,GAAG,IAAIF;AAI1F,eAAe,SAASG,cAAcC,KAAY,EAAEC,IAAY,EAAEC,IAAgB,EAAEC,OAAsB,EAAEC,QAA+B;IACzI,IAAIC,WAAWF,QAAQE,QAAQ;IAE/B,oBAAoB;IACpB,IAAIH,SAAS,OAAO;QAClBG,WAAW;YAAE,GAAGA,QAAQ;QAAC;QACzBA,SAASC,MAAM,GAAG;YAAE,GAAGD,SAASC,MAAM;QAAC;QACvCD,SAASC,MAAM,CAACC,eAAe,GAAG;YAAE,GAAIF,SAASC,MAAM,CAACC,eAAe,IAAI,CAAC,CAAC;QAAE;QAC/EF,SAASC,MAAM,CAACC,eAAe,CAACC,MAAM,GAAG;QACzCH,SAASC,MAAM,CAACC,eAAe,CAACE,MAAM,GAAG;IAC3C;IAEA,MAAMC,aAAahB,kBAAkBW;IACrC,MAAMM,MAAMhB,SAAS;IAErBgB,IACGZ,aAAa,CAACC,MAAMY,QAAQ,EAAE;QAC7B,GAAIZ,MAAMa,QAAQ,CAACC,QAAQ,CAAC,WAAWd,MAAMa,QAAQ,CAACC,QAAQ,CAAC,UAAUJ,WAAWK,UAAU,GAAGL,WAAWM,aAAa;QACzHC,UAAUjB,MAAMa,QAAQ;IAC1B,GACCK,IAAI,CAAC,CAACC;QACL,MAAMC,YAAYlB,SAAS,QAAQT,SAASO,OAAOmB,QAAQhB,WAAWX,SAASQ,OAAOmB,QAAQhB;QAC9F,MAAMkB,MAAM/B,KAAKgC,OAAO,CAACtB,MAAMV,IAAI;QACnC,MAAMiC,UAAUjC,KAAKkC,IAAI,CAACvB,MAAM,AAACoB,CAAAA,MAAMrB,MAAMV,IAAI,CAACmC,KAAK,CAAC,GAAG,CAACJ,IAAIK,MAAM,IAAI1B,MAAMV,IAAI,AAAD,IAAK8B;QAExFhC,OAAOE,KAAKqC,OAAO,CAACJ,UAAU;YAC5B,MAAMK,QAAQ,IAAIrC;YAClBqC,MAAMC,KAAK,CAAC1C,GAAG2C,SAAS,CAACC,IAAI,CAAC,MAAMR,SAASJ,OAAOa,IAAI,EAAE;YAC1D,CAAC7B,QAAQ8B,UAAU,IAAIL,MAAMC,KAAK,CAAC1C,GAAG2C,SAAS,CAACC,IAAI,CAAC,MAAM,GAAGR,QAAQ,IAAI,CAAC,EAAEJ,OAAOe,GAAG,EAAE;YACzFN,MAAMO,KAAK,CAAC,CAACC,MAASA,MAAMhC,SAASgC,OAAOhC,SAAS,MAAMmB;QAC7D;IACF,GACCc,KAAK,CAACjC;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';\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 { ConfigOptions, TargetType, TransformFileCallback } from '../types.ts';\n\nexport default function transformFile(entry: Entry, dest: string, type: TargetType, options: ConfigOptions, callback: TransformFileCallback): undefined {\n let tsconfig = options.tsconfig;\n\n // overrides for cjs\n if (type === 'cjs') {\n tsconfig = { ...tsconfig };\n tsconfig.config = { ...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 swcOptions = prepareSWCOptions(tsconfig);\n const swc = _require('@swc/core');\n const ext = path.extname(entry.basename);\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(fs.writeFile.bind(null, outPath, output.code, 'utf8'));\n !options.sourceMaps || queue.defer(fs.writeFile.bind(null, `${outPath}.map`, output.map, 'utf8'));\n queue.await((err) => (err ? callback(err) : callback(null, outPath)));\n });\n })\n .catch(callback);\n}\n"],"names":["fs","mkdirp","Module","path","Queue","patchCJS","patchESM","prepareSWCOptions","_require","require","createRequire","url","transformFile","entry","dest","type","options","callback","tsconfig","config","compilerOptions","module","target","swcOptions","swc","ext","extname","basename","fullPath","tsxOptions","nonTsxOptions","filename","then","output","extTarget","outPath","join","slice","length","dirname","queue","defer","writeFile","bind","code","sourceMaps","map","await","err","catch"],"mappings":"AACA,OAAOA,QAAQ,KAAK;AAEpB,OAAOC,YAAY,iBAAiB;AACpC,OAAOC,YAAY,SAAS;AAC5B,OAAOC,UAAU,OAAO;AACxB,OAAOC,WAAW,WAAW;AAC7B,OAAOC,cAAc,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ExFjC,OAAOE,KAAKoC,OAAO,CAACJ,UAAU;YAC5B,MAAMK,QAAQ,IAAIpC;YAClBoC,MAAMC,KAAK,CAACzC,GAAG0C,SAAS,CAACC,IAAI,CAAC,MAAMR,SAASF,OAAOW,IAAI,EAAE;YAC1D,CAAC5B,QAAQ6B,UAAU,IAAIL,MAAMC,KAAK,CAACzC,GAAG0C,SAAS,CAACC,IAAI,CAAC,MAAM,GAAGR,QAAQ,IAAI,CAAC,EAAEF,OAAOa,GAAG,EAAE;YACzFN,MAAMO,KAAK,CAAC,CAACC,MAASA,MAAM/B,SAAS+B,OAAO/B,SAAS,MAAMkB;QAC7D;IACF,GACCc,KAAK,CAAChC;AACX"}
@@ -11,7 +11,7 @@ export default function resolveFileSync(specifier, context) {
11
11
  stat = fs.statSync(filePath);
12
12
  } catch (_err) {}
13
13
  try {
14
- if (stat && stat.isDirectory() || specifier.endsWith('/')) {
14
+ if (stat && stat.isDirectory() || specifier[specifier.length - 1] === '/') {
15
15
  const items = fs.readdirSync(filePath);
16
16
  const item = find(items, (x)=>indexExtensions.indexOf(x) >= 0);
17
17
  if (item) return path.join(filePath, item);
@@ -1 +1 @@
1
- {"version":3,"sources":["/Users/kevin/Dev/OpenSource/typescript/ts-swc-transform/src/resolveFileSync.ts"],"sourcesContent":["import fs from 'fs';\nimport find from 'lodash.find';\nimport path from 'path';\nimport { extensions, moduleRegEx, typeFileRegEx } from './constants.ts';\nimport toPath from './toPath.ts';\nimport type { Context } from './types.ts';\n\nconst indexExtensions = extensions.map((x) => `index${x}`);\n\nexport default function resolveFileSync(specifier: string, context?: Context): string {\n const filePath = toPath(specifier, context);\n let stat: fs.Stats;\n try {\n stat = fs.statSync(filePath);\n } catch (_err) {}\n try {\n if ((stat && stat.isDirectory()) || specifier.endsWith('/')) {\n const items = fs.readdirSync(filePath);\n const item = find(items, (x) => indexExtensions.indexOf(x) >= 0);\n if (item) return path.join(filePath, item);\n } else if (!stat && !moduleRegEx.test(specifier)) {\n const ext = path.extname(filePath);\n const basename = ext ? path.basename(filePath).slice(0, -ext.length) : path.basename(filePath);\n const items = fs.readdirSync(path.dirname(filePath));\n const item = find(items, (x) => {\n if (typeFileRegEx.test(x)) return false;\n const extTest = path.extname(x);\n const basenameTest = extTest ? path.basename(x).slice(0, -extTest.length) : path.basename(x);\n return basename === basenameTest;\n });\n if (item) return path.join(path.dirname(filePath), item);\n }\n // return what was found\n return stat ? filePath : null;\n } catch (_err) {\n return null;\n }\n}\n"],"names":["fs","find","path","extensions","moduleRegEx","typeFileRegEx","toPath","indexExtensions","map","x","resolveFileSync","specifier","context","filePath","stat","statSync","_err","isDirectory","endsWith","items","readdirSync","item","indexOf","join","test","ext","extname","basename","slice","length","dirname","extTest","basenameTest"],"mappings":"AAAA,OAAOA,QAAQ,KAAK;AACpB,OAAOC,UAAU,cAAc;AAC/B,OAAOC,UAAU,OAAO;AACxB,SAASC,UAAU,EAAEC,WAAW,EAAEC,aAAa,QAAQ,iBAAiB;AACxE,OAAOC,YAAY,cAAc;AAGjC,MAAMC,kBAAkBJ,WAAWK,GAAG,CAAC,CAACC,IAAM,CAAC,KAAK,EAAEA,GAAG;AAEzD,eAAe,SAASC,gBAAgBC,SAAiB,EAAEC,OAAiB;IAC1E,MAAMC,WAAWP,OAAOK,WAAWC;IACnC,IAAIE;IACJ,IAAI;QACFA,OAAOd,GAAGe,QAAQ,CAACF;IACrB,EAAE,OAAOG,MAAM,CAAC;IAChB,IAAI;QACF,IAAI,AAACF,QAAQA,KAAKG,WAAW,MAAON,UAAUO,QAAQ,CAAC,MAAM;YAC3D,MAAMC,QAAQnB,GAAGoB,WAAW,CAACP;YAC7B,MAAMQ,OAAOpB,KAAKkB,OAAO,CAACV,IAAMF,gBAAgBe,OAAO,CAACb,MAAM;YAC9D,IAAIY,MAAM,OAAOnB,KAAKqB,IAAI,CAACV,UAAUQ;QACvC,OAAO,IAAI,CAACP,QAAQ,CAACV,YAAYoB,IAAI,CAACb,YAAY;YAChD,MAAMc,MAAMvB,KAAKwB,OAAO,CAACb;YACzB,MAAMc,WAAWF,MAAMvB,KAAKyB,QAAQ,CAACd,UAAUe,KAAK,CAAC,GAAG,CAACH,IAAII,MAAM,IAAI3B,KAAKyB,QAAQ,CAACd;YACrF,MAAMM,QAAQnB,GAAGoB,WAAW,CAAClB,KAAK4B,OAAO,CAACjB;YAC1C,MAAMQ,OAAOpB,KAAKkB,OAAO,CAACV;gBACxB,IAAIJ,cAAcmB,IAAI,CAACf,IAAI,OAAO;gBAClC,MAAMsB,UAAU7B,KAAKwB,OAAO,CAACjB;gBAC7B,MAAMuB,eAAeD,UAAU7B,KAAKyB,QAAQ,CAAClB,GAAGmB,KAAK,CAAC,GAAG,CAACG,QAAQF,MAAM,IAAI3B,KAAKyB,QAAQ,CAAClB;gBAC1F,OAAOkB,aAAaK;YACtB;YACA,IAAIX,MAAM,OAAOnB,KAAKqB,IAAI,CAACrB,KAAK4B,OAAO,CAACjB,WAAWQ;QACrD;QACA,wBAAwB;QACxB,OAAOP,OAAOD,WAAW;IAC3B,EAAE,OAAOG,MAAM;QACb,OAAO;IACT;AACF"}
1
+ {"version":3,"sources":["/Users/kevin/Dev/OpenSource/typescript/ts-swc-transform/src/resolveFileSync.ts"],"sourcesContent":["import fs from 'fs';\nimport find from 'lodash.find';\nimport path from 'path';\nimport { extensions, moduleRegEx, typeFileRegEx } from './constants.ts';\nimport toPath from './toPath.ts';\nimport type { Context } from './types.ts';\n\nconst indexExtensions = extensions.map((x) => `index${x}`);\n\nexport default function resolveFileSync(specifier: string, context?: Context): string {\n const filePath = toPath(specifier, context);\n let stat: fs.Stats;\n try {\n stat = fs.statSync(filePath);\n } catch (_err) {}\n try {\n if ((stat && stat.isDirectory()) || specifier[specifier.length - 1] === '/') {\n const items = fs.readdirSync(filePath);\n const item = find(items, (x) => indexExtensions.indexOf(x) >= 0);\n if (item) return path.join(filePath, item);\n } else if (!stat && !moduleRegEx.test(specifier)) {\n const ext = path.extname(filePath);\n const basename = ext ? path.basename(filePath).slice(0, -ext.length) : path.basename(filePath);\n const items = fs.readdirSync(path.dirname(filePath));\n const item = find(items, (x) => {\n if (typeFileRegEx.test(x)) return false;\n const extTest = path.extname(x);\n const basenameTest = extTest ? path.basename(x).slice(0, -extTest.length) : path.basename(x);\n return basename === basenameTest;\n });\n if (item) return path.join(path.dirname(filePath), item);\n }\n // return what was found\n return stat ? filePath : null;\n } catch (_err) {\n return null;\n }\n}\n"],"names":["fs","find","path","extensions","moduleRegEx","typeFileRegEx","toPath","indexExtensions","map","x","resolveFileSync","specifier","context","filePath","stat","statSync","_err","isDirectory","length","items","readdirSync","item","indexOf","join","test","ext","extname","basename","slice","dirname","extTest","basenameTest"],"mappings":"AAAA,OAAOA,QAAQ,KAAK;AACpB,OAAOC,UAAU,cAAc;AAC/B,OAAOC,UAAU,OAAO;AACxB,SAASC,UAAU,EAAEC,WAAW,EAAEC,aAAa,QAAQ,iBAAiB;AACxE,OAAOC,YAAY,cAAc;AAGjC,MAAMC,kBAAkBJ,WAAWK,GAAG,CAAC,CAACC,IAAM,CAAC,KAAK,EAAEA,GAAG;AAEzD,eAAe,SAASC,gBAAgBC,SAAiB,EAAEC,OAAiB;IAC1E,MAAMC,WAAWP,OAAOK,WAAWC;IACnC,IAAIE;IACJ,IAAI;QACFA,OAAOd,GAAGe,QAAQ,CAACF;IACrB,EAAE,OAAOG,MAAM,CAAC;IAChB,IAAI;QACF,IAAI,AAACF,QAAQA,KAAKG,WAAW,MAAON,SAAS,CAACA,UAAUO,MAAM,GAAG,EAAE,KAAK,KAAK;YAC3E,MAAMC,QAAQnB,GAAGoB,WAAW,CAACP;YAC7B,MAAMQ,OAAOpB,KAAKkB,OAAO,CAACV,IAAMF,gBAAgBe,OAAO,CAACb,MAAM;YAC9D,IAAIY,MAAM,OAAOnB,KAAKqB,IAAI,CAACV,UAAUQ;QACvC,OAAO,IAAI,CAACP,QAAQ,CAACV,YAAYoB,IAAI,CAACb,YAAY;YAChD,MAAMc,MAAMvB,KAAKwB,OAAO,CAACb;YACzB,MAAMc,WAAWF,MAAMvB,KAAKyB,QAAQ,CAACd,UAAUe,KAAK,CAAC,GAAG,CAACH,IAAIP,MAAM,IAAIhB,KAAKyB,QAAQ,CAACd;YACrF,MAAMM,QAAQnB,GAAGoB,WAAW,CAAClB,KAAK2B,OAAO,CAAChB;YAC1C,MAAMQ,OAAOpB,KAAKkB,OAAO,CAACV;gBACxB,IAAIJ,cAAcmB,IAAI,CAACf,IAAI,OAAO;gBAClC,MAAMqB,UAAU5B,KAAKwB,OAAO,CAACjB;gBAC7B,MAAMsB,eAAeD,UAAU5B,KAAKyB,QAAQ,CAAClB,GAAGmB,KAAK,CAAC,GAAG,CAACE,QAAQZ,MAAM,IAAIhB,KAAKyB,QAAQ,CAAClB;gBAC1F,OAAOkB,aAAaI;YACtB;YACA,IAAIV,MAAM,OAAOnB,KAAKqB,IAAI,CAACrB,KAAK2B,OAAO,CAAChB,WAAWQ;QACrD;QACA,wBAAwB;QACxB,OAAOP,OAAOD,WAAW;IAC3B,EAAE,OAAOG,MAAM;QACb,OAAO;IACT;AACF"}
@@ -1,11 +1,13 @@
1
1
  import Module from 'module';
2
+ import path from 'path';
2
3
  import prepareSWCOptions from '../lib/prepareSWCOptions.js';
3
4
  const _require = typeof require === 'undefined' ? Module.createRequire(import.meta.url) : require;
4
5
  export default function transformSyncWorker(contents, fileName, tsconfig) {
5
6
  const swcOptions = prepareSWCOptions(tsconfig);
6
7
  const swc = _require('@swc/core');
8
+ const ext = path.extname(fileName);
7
9
  return swc.transformSync(contents, {
8
- ...fileName.endsWith('.tsx') || fileName.endsWith('.jsx') ? swcOptions.tsxOptions : swcOptions.nonTsxOptions,
10
+ ...ext === '.tsx' || ext === '.jsx' ? swcOptions.tsxOptions : swcOptions.nonTsxOptions,
9
11
  filename: fileName
10
12
  });
11
13
  }
@@ -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 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 return swc.transformSync(contents, {\n ...(fileName.endsWith('.tsx') || fileName.endsWith('.jsx') ? swcOptions.tsxOptions : swcOptions.nonTsxOptions),\n filename: fileName,\n });\n}\n"],"names":["Module","prepareSWCOptions","_require","require","createRequire","url","transformSyncWorker","contents","fileName","tsconfig","swcOptions","swc","transformSync","endsWith","tsxOptions","nonTsxOptions","filename"],"mappings":"AACA,OAAOA,YAAY,SAAS;AAC5B,OAAOC,uBAAuB,8BAA8B;AAG5D,MAAMC,WAAW,OAAOC,YAAY,cAAcH,OAAOI,aAAa,CAAC,YAAYC,GAAG,IAAIF;AAE1F,eAAe,SAASG,oBAAoBC,QAAgB,EAAEC,QAAgB,EAAEC,QAAkB;IAChG,MAAMC,aAAaT,kBAAkBQ;IACrC,MAAME,MAAMT,SAAS;IACrB,OAAOS,IAAIC,aAAa,CAACL,UAAU;QACjC,GAAIC,SAASK,QAAQ,CAAC,WAAWL,SAASK,QAAQ,CAAC,UAAUH,WAAWI,UAAU,GAAGJ,WAAWK,aAAa;QAC7GC,UAAUR;IACZ;AACF"}
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":["Module","path","prepareSWCOptions","_require","require","createRequire","url","transformSyncWorker","contents","fileName","tsconfig","swcOptions","swc","ext","extname","transformSync","tsxOptions","nonTsxOptions","filename"],"mappings":"AACA,OAAOA,YAAY,SAAS;AAC5B,OAAOC,UAAU,OAAO;AACxB,OAAOC,uBAAuB,8BAA8B;AAG5D,MAAMC,WAAW,OAAOC,YAAY,cAAcJ,OAAOK,aAAa,CAAC,YAAYC,GAAG,IAAIF;AAE1F,eAAe,SAASG,oBAAoBC,QAAgB,EAAEC,QAAgB,EAAEC,QAAkB;IAChG,MAAMC,aAAaT,kBAAkBQ;IACrC,MAAME,MAAMT,SAAS;IACrB,MAAMU,MAAMZ,KAAKa,OAAO,CAACL;IAEzB,OAAOG,IAAIG,aAAa,CAACP,UAAU;QACjC,GAAIK,QAAQ,UAAUA,QAAQ,SAASF,WAAWK,UAAU,GAAGL,WAAWM,aAAa;QACvFC,UAAUT;IACZ;AACF"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ts-swc-transform",
3
- "version": "2.4.1",
3
+ "version": "2.4.2",
4
4
  "description": "Typescript transformers for swc. Supports Node >= 0.8",
5
5
  "keywords": [
6
6
  "matcher",