ts-swc-transform 2.6.0 → 2.6.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/createMatcher.d.cts +2 -0
- package/dist/cjs/createMatcher.d.ts +2 -0
- package/dist/cjs/createMatcher.js +25 -0
- package/dist/cjs/createMatcher.js.map +1 -0
- package/dist/cjs/index.d.cts +1 -0
- package/dist/cjs/index.d.ts +1 -0
- package/dist/cjs/index.js +4 -0
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/resolveFileSync.js +4 -1
- package/dist/cjs/resolveFileSync.js.map +1 -1
- package/dist/cjs/toPath.js +4 -1
- package/dist/cjs/toPath.js.map +1 -1
- package/dist/cjs/workers/transformDirectory.js +2 -6
- package/dist/cjs/workers/transformDirectory.js.map +1 -1
- package/dist/cjs/workers/transformTypes.js +2 -7
- package/dist/cjs/workers/transformTypes.js.map +1 -1
- package/dist/esm/createMatcher.d.ts +2 -0
- package/dist/esm/createMatcher.js +9 -0
- package/dist/esm/createMatcher.js.map +1 -0
- package/dist/esm/index.d.ts +1 -0
- package/dist/esm/index.js +1 -0
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/resolveFileSync.js +2 -1
- package/dist/esm/resolveFileSync.js.map +1 -1
- package/dist/esm/toPath.js +2 -1
- package/dist/esm/toPath.js.map +1 -1
- package/dist/esm/workers/transformDirectory.js +2 -6
- package/dist/esm/workers/transformDirectory.js.map +1 -1
- package/dist/esm/workers/transformTypes.js +2 -7
- package/dist/esm/workers/transformTypes.js.map +1 -1
- package/package.json +2 -2
|
@@ -0,0 +1,25 @@
|
|
|
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 _path = /*#__PURE__*/ _interop_require_default(require("path"));
|
|
12
|
+
var _testmatch = /*#__PURE__*/ _interop_require_default(require("test-match"));
|
|
13
|
+
function _interop_require_default(obj) {
|
|
14
|
+
return obj && obj.__esModule ? obj : {
|
|
15
|
+
default: obj
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
function createMatcher(tsconfig) {
|
|
19
|
+
return (0, _testmatch.default)({
|
|
20
|
+
cwd: _path.default.dirname(tsconfig.path),
|
|
21
|
+
include: tsconfig.config.include,
|
|
22
|
+
exclude: tsconfig.config.exclude
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
/* CJS INTEROP */ if (exports.__esModule && exports.default) { try { Object.defineProperty(exports.default, '__esModule', { value: true }); for (var key in exports) { exports.default[key] = exports[key]; } } catch (_) {}; module.exports = exports.default; }
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/typescript/ts-swc-transform/src/createMatcher.ts"],"sourcesContent":["import path from 'path';\nimport match from 'test-match';\nimport type { Matcher, TSConfig } from './types.ts';\n\nexport default function createMatcher(tsconfig: TSConfig): Matcher {\n return match({ cwd: path.dirname(tsconfig.path), include: tsconfig.config.include as string[], exclude: tsconfig.config.exclude as string[] });\n}\n"],"names":["createMatcher","tsconfig","match","cwd","path","dirname","include","config","exclude"],"mappings":";;;;+BAIA;;;eAAwBA;;;2DAJP;gEACC;;;;;;AAGH,SAASA,cAAcC,QAAkB;IACtD,OAAOC,IAAAA,kBAAK,EAAC;QAAEC,KAAKC,aAAI,CAACC,OAAO,CAACJ,SAASG,IAAI;QAAGE,SAASL,SAASM,MAAM,CAACD,OAAO;QAAcE,SAASP,SAASM,MAAM,CAACC,OAAO;IAAa;AAC9I"}
|
package/dist/cjs/index.d.cts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export * as constants from './constants.ts';
|
|
2
|
+
export { default as createMatcher } from './createMatcher.ts';
|
|
2
3
|
export { default as resolveFileSync } from './resolveFileSync.ts';
|
|
3
4
|
export { default as toPath } from './toPath.ts';
|
|
4
5
|
export { default as transformDirectory } from './transformDirectory.ts';
|
package/dist/cjs/index.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export * as constants from './constants.ts';
|
|
2
|
+
export { default as createMatcher } from './createMatcher.ts';
|
|
2
3
|
export { default as resolveFileSync } from './resolveFileSync.ts';
|
|
3
4
|
export { default as toPath } from './toPath.ts';
|
|
4
5
|
export { default as transformDirectory } from './transformDirectory.ts';
|
package/dist/cjs/index.js
CHANGED
|
@@ -12,6 +12,9 @@ _export(exports, {
|
|
|
12
12
|
get constants () {
|
|
13
13
|
return _constantsts;
|
|
14
14
|
},
|
|
15
|
+
get createMatcher () {
|
|
16
|
+
return _createMatcherts.default;
|
|
17
|
+
},
|
|
15
18
|
get resolveFileSync () {
|
|
16
19
|
return _resolveFileSyncts.default;
|
|
17
20
|
},
|
|
@@ -29,6 +32,7 @@ _export(exports, {
|
|
|
29
32
|
}
|
|
30
33
|
});
|
|
31
34
|
var _constantsts = /*#__PURE__*/ _interop_require_wildcard(require("./constants.js"));
|
|
35
|
+
var _createMatcherts = /*#__PURE__*/ _interop_require_default(require("./createMatcher.js"));
|
|
32
36
|
var _resolveFileSyncts = /*#__PURE__*/ _interop_require_default(require("./resolveFileSync.js"));
|
|
33
37
|
var _toPathts = /*#__PURE__*/ _interop_require_default(require("./toPath.js"));
|
|
34
38
|
var _transformDirectoryts = /*#__PURE__*/ _interop_require_default(require("./transformDirectory.js"));
|
package/dist/cjs/index.js.map
CHANGED
|
@@ -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 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;;;
|
|
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"}
|
|
@@ -21,6 +21,9 @@ function _interop_require_default(obj) {
|
|
|
21
21
|
var indexExtensions = _constantsts.extensions.map(function(x) {
|
|
22
22
|
return "index".concat(x);
|
|
23
23
|
});
|
|
24
|
+
var endsWith = function(string, check) {
|
|
25
|
+
return string.indexOf(check, string.length - check.length) !== -1;
|
|
26
|
+
};
|
|
24
27
|
function resolveFileSync(specifier, context) {
|
|
25
28
|
var filePath = (0, _toPathts.default)(specifier, context);
|
|
26
29
|
var stat;
|
|
@@ -31,7 +34,7 @@ function resolveFileSync(specifier, context) {
|
|
|
31
34
|
if (stat && stat.isDirectory() || specifier[specifier.length - 1] === '/') {
|
|
32
35
|
var items = _fs.default.readdirSync(filePath);
|
|
33
36
|
var item = (0, _lodashfind.default)(items, function(x) {
|
|
34
|
-
return indexExtensions
|
|
37
|
+
return endsWith(indexExtensions, x);
|
|
35
38
|
});
|
|
36
39
|
if (item) return _path.default.join(filePath, item);
|
|
37
40
|
} else if (!stat && !_constantsts.moduleRegEx.test(specifier)) {
|
|
@@ -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[specifier.length - 1] === '/') {\n const items = fs.readdirSync(filePath);\n const item = find(items, (x) => indexExtensions
|
|
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}`);\nconst endsWith = (string, check) => string.indexOf(check, string.length - check.length) !== -1;\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) => endsWith(indexExtensions, x));\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","endsWith","string","check","indexOf","length","specifier","context","filePath","toPath","stat","fs","statSync","_err","isDirectory","items","readdirSync","item","find","path","join","moduleRegEx","test","ext","extname","basename","slice","dirname","typeFileRegEx","extTest","basenameTest"],"mappings":";;;;+BAUA;;;eAAwBA;;;yDAVT;iEACE;2DACA;2BACsC;+DACpC;;;;;;AAGnB,IAAMC,kBAAkBC,uBAAU,CAACC,GAAG,CAAC,SAACC;WAAM,AAAC,QAAS,OAAFA;;AACtD,IAAMC,WAAW,SAACC,QAAQC;WAAUD,OAAOE,OAAO,CAACD,OAAOD,OAAOG,MAAM,GAAGF,MAAME,MAAM,MAAM,CAAC;;AAE9E,SAAST,gBAAgBU,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,SAAS,CAACA,UAAUD,MAAM,GAAG,EAAE,KAAK,KAAK;YAC3E,IAAMU,QAAQJ,WAAE,CAACK,WAAW,CAACR;YAC7B,IAAMS,OAAOC,IAAAA,mBAAI,EAACH,OAAO,SAACf;uBAAMC,SAASJ,iBAAiBG;;YAC1D,IAAIiB,MAAM,OAAOE,aAAI,CAACC,IAAI,CAACZ,UAAUS;QACvC,OAAO,IAAI,CAACP,QAAQ,CAACW,wBAAW,CAACC,IAAI,CAAChB,YAAY;YAChD,IAAMiB,MAAMJ,aAAI,CAACK,OAAO,CAAChB;YACzB,IAAMiB,WAAWF,MAAMJ,aAAI,CAACM,QAAQ,CAACjB,UAAUkB,KAAK,CAAC,GAAG,CAACH,IAAIlB,MAAM,IAAIc,aAAI,CAACM,QAAQ,CAACjB;YACrF,IAAMO,SAAQJ,WAAE,CAACK,WAAW,CAACG,aAAI,CAACQ,OAAO,CAACnB;YAC1C,IAAMS,QAAOC,IAAAA,mBAAI,EAACH,QAAO,SAACf;gBACxB,IAAI4B,0BAAa,CAACN,IAAI,CAACtB,IAAI,OAAO;gBAClC,IAAM6B,UAAUV,aAAI,CAACK,OAAO,CAACxB;gBAC7B,IAAM8B,eAAeD,UAAUV,aAAI,CAACM,QAAQ,CAACzB,GAAG0B,KAAK,CAAC,GAAG,CAACG,QAAQxB,MAAM,IAAIc,aAAI,CAACM,QAAQ,CAACzB;gBAC1F,OAAOyB,aAAaK;YACtB;YACA,IAAIb,OAAM,OAAOE,aAAI,CAACC,IAAI,CAACD,aAAI,CAACQ,OAAO,CAACnB,WAAWS;QACrD;QACA,wBAAwB;QACxB,OAAOP,OAAOF,WAAW;IAC3B,EAAE,OAAOK,MAAM;QACb,OAAO;IACT;AACF"}
|
package/dist/cjs/toPath.js
CHANGED
|
@@ -65,12 +65,15 @@ function _interop_require_wildcard(obj, nodeInterop) {
|
|
|
65
65
|
var useCJS = !_module.default.createRequire;
|
|
66
66
|
var fileURLToPath = _url.default.fileURLToPath || _urlFileUrlts.fileURLToPath;
|
|
67
67
|
var pathToFileURL = _url.default.pathToFileURL || _urlFileUrlts.pathToFileURL;
|
|
68
|
+
var startsWith = function(string, check) {
|
|
69
|
+
return string.lastIndexOf(check, 0) === 0;
|
|
70
|
+
};
|
|
68
71
|
function getParentPath(context) {
|
|
69
72
|
if (context.parentPath) return _path.default.dirname(context.parentPath);
|
|
70
73
|
return context.parentURL ? _path.default.dirname(toPath(context.parentURL)) : process.cwd();
|
|
71
74
|
}
|
|
72
75
|
function toPath(specifier, context) {
|
|
73
|
-
if (specifier
|
|
76
|
+
if (startsWith(specifier, 'file:')) return fileURLToPath(specifier);
|
|
74
77
|
if ((0, _isabsolute.default)(specifier)) return specifier;
|
|
75
78
|
if (specifier[0] === '.') {
|
|
76
79
|
var parentPath = context ? getParentPath(context) : process.cwd();
|
package/dist/cjs/toPath.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/typescript/ts-swc-transform/src/toPath.ts"],"sourcesContent":["import isAbsolute from 'is-absolute';\nimport module from 'module';\nimport path from 'path';\nimport resolveCJS from 'resolve';\nimport url from 'url';\nimport { moduleRegEx } from './constants.ts';\nimport importMetaResolve from './lib/import-meta-resolve.ts';\nimport * as urlPolyfills from './lib/urlFileUrl.ts';\nimport type { Context } from './types.ts';\n\nconst useCJS = !module.createRequire;\nconst fileURLToPath = url.fileURLToPath || urlPolyfills.fileURLToPath;\nconst pathToFileURL = url.pathToFileURL || urlPolyfills.pathToFileURL;\n\nfunction getParentPath(context: Context): string {\n if (context.parentPath) return path.dirname(context.parentPath);\n return context.parentURL ? path.dirname(toPath(context.parentURL)) : process.cwd();\n}\n\nexport default function toPath(specifier: string, context?: Context): string {\n if (specifier
|
|
1
|
+
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/typescript/ts-swc-transform/src/toPath.ts"],"sourcesContent":["import isAbsolute from 'is-absolute';\nimport module from 'module';\nimport path from 'path';\nimport resolveCJS from 'resolve';\nimport url from 'url';\nimport { moduleRegEx } from './constants.ts';\nimport importMetaResolve from './lib/import-meta-resolve.ts';\nimport * as urlPolyfills from './lib/urlFileUrl.ts';\nimport type { Context } from './types.ts';\n\nconst useCJS = !module.createRequire;\nconst fileURLToPath = url.fileURLToPath || urlPolyfills.fileURLToPath;\nconst pathToFileURL = url.pathToFileURL || urlPolyfills.pathToFileURL;\nconst startsWith = (string, check) => string.lastIndexOf(check, 0) === 0;\n\nfunction getParentPath(context: Context): string {\n if (context.parentPath) return path.dirname(context.parentPath);\n return context.parentURL ? path.dirname(toPath(context.parentURL)) : process.cwd();\n}\n\nexport default function toPath(specifier: string, context?: Context): string {\n if (startsWith(specifier, 'file:')) return fileURLToPath(specifier);\n if (isAbsolute(specifier)) return specifier;\n if (specifier[0] === '.') {\n const parentPath = context ? getParentPath(context) : process.cwd();\n return path.join(parentPath, specifier);\n }\n if (moduleRegEx.test(specifier)) {\n const parentPath = context ? getParentPath(context) : process.cwd();\n if (!useCJS) {\n try {\n const entryURL = importMetaResolve(specifier, pathToFileURL(parentPath));\n if (entryURL) return fileURLToPath(entryURL);\n } catch (_) {\n /* it may fail due to commonjs edge cases */\n }\n }\n const entryPath = resolveCJS.sync(specifier, {\n basedir: parentPath,\n extensions: ['.js', '.json', '.node', '.mjs'],\n });\n if (entryPath) return entryPath;\n }\n\n return specifier;\n}\n"],"names":["toPath","useCJS","module","createRequire","fileURLToPath","url","urlPolyfills","pathToFileURL","startsWith","string","check","lastIndexOf","getParentPath","context","parentPath","path","dirname","parentURL","process","cwd","specifier","isAbsolute","join","moduleRegEx","test","entryURL","importMetaResolve","_","entryPath","resolveCJS","sync","basedir","extensions"],"mappings":";;;;+BAoBA;;;eAAwBA;;;iEApBD;6DACJ;2DACF;8DACM;0DACP;2BACY;0EACE;oEACA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAG9B,IAAMC,SAAS,CAACC,eAAM,CAACC,aAAa;AACpC,IAAMC,gBAAgBC,YAAG,CAACD,aAAa,IAAIE,cAAaF,aAAa;AACrE,IAAMG,gBAAgBF,YAAG,CAACE,aAAa,IAAID,cAAaC,aAAa;AACrE,IAAMC,aAAa,SAACC,QAAQC;WAAUD,OAAOE,WAAW,CAACD,OAAO,OAAO;;AAEvE,SAASE,cAAcC,OAAgB;IACrC,IAAIA,QAAQC,UAAU,EAAE,OAAOC,aAAI,CAACC,OAAO,CAACH,QAAQC,UAAU;IAC9D,OAAOD,QAAQI,SAAS,GAAGF,aAAI,CAACC,OAAO,CAAChB,OAAOa,QAAQI,SAAS,KAAKC,QAAQC,GAAG;AAClF;AAEe,SAASnB,OAAOoB,SAAiB,EAAEP,OAAiB;IACjE,IAAIL,WAAWY,WAAW,UAAU,OAAOhB,cAAcgB;IACzD,IAAIC,IAAAA,mBAAU,EAACD,YAAY,OAAOA;IAClC,IAAIA,SAAS,CAAC,EAAE,KAAK,KAAK;QACxB,IAAMN,aAAaD,UAAUD,cAAcC,WAAWK,QAAQC,GAAG;QACjE,OAAOJ,aAAI,CAACO,IAAI,CAACR,YAAYM;IAC/B;IACA,IAAIG,wBAAW,CAACC,IAAI,CAACJ,YAAY;QAC/B,IAAMN,cAAaD,UAAUD,cAAcC,WAAWK,QAAQC,GAAG;QACjE,IAAI,CAAClB,QAAQ;YACX,IAAI;gBACF,IAAMwB,WAAWC,IAAAA,4BAAiB,EAACN,WAAWb,cAAcO;gBAC5D,IAAIW,UAAU,OAAOrB,cAAcqB;YACrC,EAAE,OAAOE,GAAG;YACV,0CAA0C,GAC5C;QACF;QACA,IAAMC,YAAYC,gBAAU,CAACC,IAAI,CAACV,WAAW;YAC3CW,SAASjB;YACTkB,YAAY;gBAAC;gBAAO;gBAAS;gBAAS;aAAO;QAC/C;QACA,IAAIJ,WAAW,OAAOA;IACxB;IAEA,OAAOR;AACT"}
|
|
@@ -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"));
|
|
15
14
|
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,11 +73,7 @@ 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,
|
|
77
|
-
cwd: _path.default.dirname(tsconfig.path),
|
|
78
|
-
include: tsconfig.config.include,
|
|
79
|
-
exclude: tsconfig.config.exclude
|
|
80
|
-
});
|
|
76
|
+
var matcher = (0, _createMatcherts.default)(tsconfig);
|
|
81
77
|
var entries = [];
|
|
82
78
|
var iterator = new _fsiterator.default(src);
|
|
83
79
|
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';\nimport
|
|
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"}
|
|
@@ -10,9 +10,8 @@ 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"));
|
|
15
13
|
var _constantsts = require("../constants.js");
|
|
14
|
+
var _createMatcherts = /*#__PURE__*/ _interop_require_default(require("../createMatcher.js"));
|
|
16
15
|
function _define_property(obj, key, value) {
|
|
17
16
|
if (key in obj) {
|
|
18
17
|
Object.defineProperty(obj, key, {
|
|
@@ -73,11 +72,7 @@ function _object_spread_props(target, source) {
|
|
|
73
72
|
var _require = typeof require === 'undefined' ? _module.default.createRequire(require("url").pathToFileURL(__filename).toString()) : require;
|
|
74
73
|
function transformTypesWorker(src, dest, options, callback) {
|
|
75
74
|
var tsconfig = options.tsconfig;
|
|
76
|
-
var matcher = (0,
|
|
77
|
-
cwd: _path.default.dirname(tsconfig.path),
|
|
78
|
-
include: tsconfig.config.include,
|
|
79
|
-
exclude: tsconfig.config.exclude
|
|
80
|
-
});
|
|
75
|
+
var matcher = (0, _createMatcherts.default)(tsconfig);
|
|
81
76
|
var ts = _require('typescript');
|
|
82
77
|
var entries = [];
|
|
83
78
|
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';\nimport Module from 'module';\
|
|
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"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/typescript/ts-swc-transform/src/createMatcher.ts"],"sourcesContent":["import path from 'path';\nimport match from 'test-match';\nimport type { Matcher, TSConfig } from './types.ts';\n\nexport default function createMatcher(tsconfig: TSConfig): Matcher {\n return match({ cwd: path.dirname(tsconfig.path), include: tsconfig.config.include as string[], exclude: tsconfig.config.exclude as string[] });\n}\n"],"names":["path","match","createMatcher","tsconfig","cwd","dirname","include","config","exclude"],"mappings":"AAAA,OAAOA,UAAU,OAAO;AACxB,OAAOC,WAAW,aAAa;AAG/B,eAAe,SAASC,cAAcC,QAAkB;IACtD,OAAOF,MAAM;QAAEG,KAAKJ,KAAKK,OAAO,CAACF,SAASH,IAAI;QAAGM,SAASH,SAASI,MAAM,CAACD,OAAO;QAAcE,SAASL,SAASI,MAAM,CAACC,OAAO;IAAa;AAC9I"}
|
package/dist/esm/index.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export * as constants from './constants.ts';
|
|
2
|
+
export { default as createMatcher } from './createMatcher.ts';
|
|
2
3
|
export { default as resolveFileSync } from './resolveFileSync.ts';
|
|
3
4
|
export { default as toPath } from './toPath.ts';
|
|
4
5
|
export { default as transformDirectory } from './transformDirectory.ts';
|
package/dist/esm/index.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import * as _constants from './constants.js';
|
|
2
2
|
export { _constants as constants };
|
|
3
|
+
export { default as createMatcher } from './createMatcher.js';
|
|
3
4
|
export { default as resolveFileSync } from './resolveFileSync.js';
|
|
4
5
|
export { default as toPath } from './toPath.js';
|
|
5
6
|
export { default as transformDirectory } from './transformDirectory.js';
|
package/dist/esm/index.js.map
CHANGED
|
@@ -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 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,
|
|
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"}
|
|
@@ -4,6 +4,7 @@ import path from 'path';
|
|
|
4
4
|
import { extensions, moduleRegEx, typeFileRegEx } from './constants.js';
|
|
5
5
|
import toPath from './toPath.js';
|
|
6
6
|
const indexExtensions = extensions.map((x)=>`index${x}`);
|
|
7
|
+
const endsWith = (string, check)=>string.indexOf(check, string.length - check.length) !== -1;
|
|
7
8
|
export default function resolveFileSync(specifier, context) {
|
|
8
9
|
const filePath = toPath(specifier, context);
|
|
9
10
|
let stat;
|
|
@@ -13,7 +14,7 @@ export default function resolveFileSync(specifier, context) {
|
|
|
13
14
|
try {
|
|
14
15
|
if (stat && stat.isDirectory() || specifier[specifier.length - 1] === '/') {
|
|
15
16
|
const items = fs.readdirSync(filePath);
|
|
16
|
-
const item = find(items, (x)=>indexExtensions
|
|
17
|
+
const item = find(items, (x)=>endsWith(indexExtensions, x));
|
|
17
18
|
if (item) return path.join(filePath, item);
|
|
18
19
|
} else if (!stat && !moduleRegEx.test(specifier)) {
|
|
19
20
|
const ext = path.extname(filePath);
|
|
@@ -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[specifier.length - 1] === '/') {\n const items = fs.readdirSync(filePath);\n const item = find(items, (x) => indexExtensions
|
|
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}`);\nconst endsWith = (string, check) => string.indexOf(check, string.length - check.length) !== -1;\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) => endsWith(indexExtensions, x));\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","endsWith","string","check","indexOf","length","resolveFileSync","specifier","context","filePath","stat","statSync","_err","isDirectory","items","readdirSync","item","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;AACzD,MAAMC,WAAW,CAACC,QAAQC,QAAUD,OAAOE,OAAO,CAACD,OAAOD,OAAOG,MAAM,GAAGF,MAAME,MAAM,MAAM,CAAC;AAE7F,eAAe,SAASC,gBAAgBC,SAAiB,EAAEC,OAAiB;IAC1E,MAAMC,WAAWZ,OAAOU,WAAWC;IACnC,IAAIE;IACJ,IAAI;QACFA,OAAOnB,GAAGoB,QAAQ,CAACF;IACrB,EAAE,OAAOG,MAAM,CAAC;IAChB,IAAI;QACF,IAAI,AAACF,QAAQA,KAAKG,WAAW,MAAON,SAAS,CAACA,UAAUF,MAAM,GAAG,EAAE,KAAK,KAAK;YAC3E,MAAMS,QAAQvB,GAAGwB,WAAW,CAACN;YAC7B,MAAMO,OAAOxB,KAAKsB,OAAO,CAACd,IAAMC,SAASH,iBAAiBE;YAC1D,IAAIgB,MAAM,OAAOvB,KAAKwB,IAAI,CAACR,UAAUO;QACvC,OAAO,IAAI,CAACN,QAAQ,CAACf,YAAYuB,IAAI,CAACX,YAAY;YAChD,MAAMY,MAAM1B,KAAK2B,OAAO,CAACX;YACzB,MAAMY,WAAWF,MAAM1B,KAAK4B,QAAQ,CAACZ,UAAUa,KAAK,CAAC,GAAG,CAACH,IAAId,MAAM,IAAIZ,KAAK4B,QAAQ,CAACZ;YACrF,MAAMK,QAAQvB,GAAGwB,WAAW,CAACtB,KAAK8B,OAAO,CAACd;YAC1C,MAAMO,OAAOxB,KAAKsB,OAAO,CAACd;gBACxB,IAAIJ,cAAcsB,IAAI,CAAClB,IAAI,OAAO;gBAClC,MAAMwB,UAAU/B,KAAK2B,OAAO,CAACpB;gBAC7B,MAAMyB,eAAeD,UAAU/B,KAAK4B,QAAQ,CAACrB,GAAGsB,KAAK,CAAC,GAAG,CAACE,QAAQnB,MAAM,IAAIZ,KAAK4B,QAAQ,CAACrB;gBAC1F,OAAOqB,aAAaI;YACtB;YACA,IAAIT,MAAM,OAAOvB,KAAKwB,IAAI,CAACxB,KAAK8B,OAAO,CAACd,WAAWO;QACrD;QACA,wBAAwB;QACxB,OAAON,OAAOD,WAAW;IAC3B,EAAE,OAAOG,MAAM;QACb,OAAO;IACT;AACF"}
|
package/dist/esm/toPath.js
CHANGED
|
@@ -9,12 +9,13 @@ import * as urlPolyfills from './lib/urlFileUrl.js';
|
|
|
9
9
|
const useCJS = !module.createRequire;
|
|
10
10
|
const fileURLToPath = url.fileURLToPath || urlPolyfills.fileURLToPath;
|
|
11
11
|
const pathToFileURL = url.pathToFileURL || urlPolyfills.pathToFileURL;
|
|
12
|
+
const startsWith = (string, check)=>string.lastIndexOf(check, 0) === 0;
|
|
12
13
|
function getParentPath(context) {
|
|
13
14
|
if (context.parentPath) return path.dirname(context.parentPath);
|
|
14
15
|
return context.parentURL ? path.dirname(toPath(context.parentURL)) : process.cwd();
|
|
15
16
|
}
|
|
16
17
|
export default function toPath(specifier, context) {
|
|
17
|
-
if (specifier
|
|
18
|
+
if (startsWith(specifier, 'file:')) return fileURLToPath(specifier);
|
|
18
19
|
if (isAbsolute(specifier)) return specifier;
|
|
19
20
|
if (specifier[0] === '.') {
|
|
20
21
|
const parentPath = context ? getParentPath(context) : process.cwd();
|
package/dist/esm/toPath.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/typescript/ts-swc-transform/src/toPath.ts"],"sourcesContent":["import isAbsolute from 'is-absolute';\nimport module from 'module';\nimport path from 'path';\nimport resolveCJS from 'resolve';\nimport url from 'url';\nimport { moduleRegEx } from './constants.ts';\nimport importMetaResolve from './lib/import-meta-resolve.ts';\nimport * as urlPolyfills from './lib/urlFileUrl.ts';\nimport type { Context } from './types.ts';\n\nconst useCJS = !module.createRequire;\nconst fileURLToPath = url.fileURLToPath || urlPolyfills.fileURLToPath;\nconst pathToFileURL = url.pathToFileURL || urlPolyfills.pathToFileURL;\n\nfunction getParentPath(context: Context): string {\n if (context.parentPath) return path.dirname(context.parentPath);\n return context.parentURL ? path.dirname(toPath(context.parentURL)) : process.cwd();\n}\n\nexport default function toPath(specifier: string, context?: Context): string {\n if (specifier
|
|
1
|
+
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/typescript/ts-swc-transform/src/toPath.ts"],"sourcesContent":["import isAbsolute from 'is-absolute';\nimport module from 'module';\nimport path from 'path';\nimport resolveCJS from 'resolve';\nimport url from 'url';\nimport { moduleRegEx } from './constants.ts';\nimport importMetaResolve from './lib/import-meta-resolve.ts';\nimport * as urlPolyfills from './lib/urlFileUrl.ts';\nimport type { Context } from './types.ts';\n\nconst useCJS = !module.createRequire;\nconst fileURLToPath = url.fileURLToPath || urlPolyfills.fileURLToPath;\nconst pathToFileURL = url.pathToFileURL || urlPolyfills.pathToFileURL;\nconst startsWith = (string, check) => string.lastIndexOf(check, 0) === 0;\n\nfunction getParentPath(context: Context): string {\n if (context.parentPath) return path.dirname(context.parentPath);\n return context.parentURL ? path.dirname(toPath(context.parentURL)) : process.cwd();\n}\n\nexport default function toPath(specifier: string, context?: Context): string {\n if (startsWith(specifier, 'file:')) return fileURLToPath(specifier);\n if (isAbsolute(specifier)) return specifier;\n if (specifier[0] === '.') {\n const parentPath = context ? getParentPath(context) : process.cwd();\n return path.join(parentPath, specifier);\n }\n if (moduleRegEx.test(specifier)) {\n const parentPath = context ? getParentPath(context) : process.cwd();\n if (!useCJS) {\n try {\n const entryURL = importMetaResolve(specifier, pathToFileURL(parentPath));\n if (entryURL) return fileURLToPath(entryURL);\n } catch (_) {\n /* it may fail due to commonjs edge cases */\n }\n }\n const entryPath = resolveCJS.sync(specifier, {\n basedir: parentPath,\n extensions: ['.js', '.json', '.node', '.mjs'],\n });\n if (entryPath) return entryPath;\n }\n\n return specifier;\n}\n"],"names":["isAbsolute","module","path","resolveCJS","url","moduleRegEx","importMetaResolve","urlPolyfills","useCJS","createRequire","fileURLToPath","pathToFileURL","startsWith","string","check","lastIndexOf","getParentPath","context","parentPath","dirname","parentURL","toPath","process","cwd","specifier","join","test","entryURL","_","entryPath","sync","basedir","extensions"],"mappings":"AAAA,OAAOA,gBAAgB,cAAc;AACrC,OAAOC,YAAY,SAAS;AAC5B,OAAOC,UAAU,OAAO;AACxB,OAAOC,gBAAgB,UAAU;AACjC,OAAOC,SAAS,MAAM;AACtB,SAASC,WAAW,QAAQ,iBAAiB;AAC7C,OAAOC,uBAAuB,+BAA+B;AAC7D,YAAYC,kBAAkB,sBAAsB;AAGpD,MAAMC,SAAS,CAACP,OAAOQ,aAAa;AACpC,MAAMC,gBAAgBN,IAAIM,aAAa,IAAIH,aAAaG,aAAa;AACrE,MAAMC,gBAAgBP,IAAIO,aAAa,IAAIJ,aAAaI,aAAa;AACrE,MAAMC,aAAa,CAACC,QAAQC,QAAUD,OAAOE,WAAW,CAACD,OAAO,OAAO;AAEvE,SAASE,cAAcC,OAAgB;IACrC,IAAIA,QAAQC,UAAU,EAAE,OAAOhB,KAAKiB,OAAO,CAACF,QAAQC,UAAU;IAC9D,OAAOD,QAAQG,SAAS,GAAGlB,KAAKiB,OAAO,CAACE,OAAOJ,QAAQG,SAAS,KAAKE,QAAQC,GAAG;AAClF;AAEA,eAAe,SAASF,OAAOG,SAAiB,EAAEP,OAAiB;IACjE,IAAIL,WAAWY,WAAW,UAAU,OAAOd,cAAcc;IACzD,IAAIxB,WAAWwB,YAAY,OAAOA;IAClC,IAAIA,SAAS,CAAC,EAAE,KAAK,KAAK;QACxB,MAAMN,aAAaD,UAAUD,cAAcC,WAAWK,QAAQC,GAAG;QACjE,OAAOrB,KAAKuB,IAAI,CAACP,YAAYM;IAC/B;IACA,IAAInB,YAAYqB,IAAI,CAACF,YAAY;QAC/B,MAAMN,aAAaD,UAAUD,cAAcC,WAAWK,QAAQC,GAAG;QACjE,IAAI,CAACf,QAAQ;YACX,IAAI;gBACF,MAAMmB,WAAWrB,kBAAkBkB,WAAWb,cAAcO;gBAC5D,IAAIS,UAAU,OAAOjB,cAAciB;YACrC,EAAE,OAAOC,GAAG;YACV,0CAA0C,GAC5C;QACF;QACA,MAAMC,YAAY1B,WAAW2B,IAAI,CAACN,WAAW;YAC3CO,SAASb;YACTc,YAAY;gBAAC;gBAAO;gBAAS;gBAAS;aAAO;QAC/C;QACA,IAAIH,WAAW,OAAOA;IACxB;IAEA,OAAOL;AACT"}
|
|
@@ -1,16 +1,12 @@
|
|
|
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';
|
|
5
4
|
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 =
|
|
10
|
-
cwd: path.dirname(tsconfig.path),
|
|
11
|
-
include: tsconfig.config.include,
|
|
12
|
-
exclude: tsconfig.config.exclude
|
|
13
|
-
});
|
|
9
|
+
const matcher = createMatcher(tsconfig);
|
|
14
10
|
const entries = [];
|
|
15
11
|
const iterator = new Iterator(src);
|
|
16
12
|
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';\nimport
|
|
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,16 +1,11 @@
|
|
|
1
1
|
import Iterator from 'fs-iterator';
|
|
2
2
|
import Module from 'module';
|
|
3
|
-
import path from 'path';
|
|
4
|
-
import match from 'test-match';
|
|
5
3
|
const _require = typeof require === 'undefined' ? Module.createRequire(import.meta.url) : require;
|
|
6
4
|
import { typeFileRegEx } from '../constants.js';
|
|
5
|
+
import createMatcher from '../createMatcher.js';
|
|
7
6
|
export default function transformTypesWorker(src, dest, options, callback) {
|
|
8
7
|
const tsconfig = options.tsconfig;
|
|
9
|
-
const matcher =
|
|
10
|
-
cwd: path.dirname(tsconfig.path),
|
|
11
|
-
include: tsconfig.config.include,
|
|
12
|
-
exclude: tsconfig.config.exclude
|
|
13
|
-
});
|
|
8
|
+
const matcher = createMatcher(tsconfig);
|
|
14
9
|
const ts = _require('typescript');
|
|
15
10
|
const entries = [];
|
|
16
11
|
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';\nimport Module from 'module';\
|
|
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"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ts-swc-transform",
|
|
3
|
-
"version": "2.6.
|
|
3
|
+
"version": "2.6.1",
|
|
4
4
|
"description": "Typescript transformers for swc. Supports Node >= 0.8",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"matcher",
|
|
@@ -57,7 +57,7 @@
|
|
|
57
57
|
"read-tsconfig-sync": "^1.0.2",
|
|
58
58
|
"resolve": "^1.22.10",
|
|
59
59
|
"rimraf2": "^2.8.2",
|
|
60
|
-
"test-match": "^1.0.
|
|
60
|
+
"test-match": "^1.0.1",
|
|
61
61
|
"ts-node": "*",
|
|
62
62
|
"typescript": "*"
|
|
63
63
|
},
|