ts-swc-transform 1.1.1 → 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/extensions.js +24 -0
- package/dist/cjs/extensions.js.map +1 -0
- package/dist/cjs/index.js +22 -0
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/lib/toPath.js +63 -0
- package/dist/cjs/lib/toPath.js.map +1 -0
- package/dist/cjs/resolveFileSync.js +50 -0
- package/dist/cjs/resolveFileSync.js.map +1 -0
- package/dist/cjs/transformSync.js +4 -4
- package/dist/cjs/transformSync.js.map +1 -1
- package/dist/cjs/types.js +5 -0
- package/dist/cjs/types.js.map +1 -0
- package/dist/esm/extensions.mjs +13 -0
- package/dist/esm/extensions.mjs.map +1 -0
- package/dist/esm/index.mjs +3 -0
- package/dist/esm/index.mjs.map +1 -1
- package/dist/esm/lib/toPath.mjs +48 -0
- package/dist/esm/lib/toPath.mjs.map +1 -0
- package/dist/esm/resolveFileSync.mjs +28 -0
- package/dist/esm/resolveFileSync.mjs.map +1 -0
- package/dist/esm/transformSync.mjs +2 -2
- package/dist/esm/transformSync.mjs.map +1 -1
- package/dist/esm/types.mjs +1 -0
- package/dist/esm/types.mjs.map +1 -0
- package/dist/types/extensions.d.ts +2 -0
- package/dist/types/index.d.ts +3 -0
- package/dist/types/lib/toPath.d.ts +2 -0
- package/dist/types/resolveFileSync.d.ts +2 -0
- package/dist/types/types.d.ts +4 -0
- package/package.json +7 -5
- /package/dist/cjs/{lazy.js → lib/lazy.js} +0 -0
- /package/dist/cjs/{lazy.js.map → lib/lazy.js.map} +0 -0
- /package/dist/cjs/{process.js → lib/process.js} +0 -0
- /package/dist/cjs/{process.js.map → lib/process.js.map} +0 -0
- /package/dist/esm/{lazy.cjs → lib/lazy.cjs} +0 -0
- /package/dist/esm/{lazy.cjs.map → lib/lazy.cjs.map} +0 -0
- /package/dist/esm/{process.cjs → lib/process.cjs} +0 -0
- /package/dist/esm/{process.cjs.map → lib/process.cjs.map} +0 -0
- /package/dist/types/{lazy.d.cts → lib/lazy.d.cts} +0 -0
- /package/dist/types/{process.d.cts → lib/process.d.cts} +0 -0
|
@@ -0,0 +1,24 @@
|
|
|
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 _default;
|
|
9
|
+
}
|
|
10
|
+
});
|
|
11
|
+
var _default = [
|
|
12
|
+
'.js',
|
|
13
|
+
'.jsx',
|
|
14
|
+
'.cjs',
|
|
15
|
+
'.mjs',
|
|
16
|
+
'.ts',
|
|
17
|
+
'.tsx',
|
|
18
|
+
'.cts',
|
|
19
|
+
'.mts',
|
|
20
|
+
'.json',
|
|
21
|
+
'.es6',
|
|
22
|
+
'.es'
|
|
23
|
+
];
|
|
24
|
+
/* 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":["extensions.ts"],"sourcesContent":["export default ['.js', '.jsx', '.cjs', '.mjs', '.ts', '.tsx', '.cts', '.mts', '.json', '.es6', '.es'];\n"],"names":[],"mappings":";;;;+BAAA;;;eAAA;;;IAAA,WAAe;IAAC;IAAO;IAAQ;IAAQ;IAAQ;IAAO;IAAQ;IAAQ;IAAQ;IAAS;IAAQ;CAAM"}
|
package/dist/cjs/index.js
CHANGED
|
@@ -12,6 +12,12 @@ _export(exports, {
|
|
|
12
12
|
createMatcher: function() {
|
|
13
13
|
return _createMatcher.default;
|
|
14
14
|
},
|
|
15
|
+
extensions: function() {
|
|
16
|
+
return _extensions.default;
|
|
17
|
+
},
|
|
18
|
+
resolveFileSync: function() {
|
|
19
|
+
return _resolveFileSync.default;
|
|
20
|
+
},
|
|
15
21
|
transformDirectory: function() {
|
|
16
22
|
return _transformDirectory.default;
|
|
17
23
|
},
|
|
@@ -22,10 +28,26 @@ _export(exports, {
|
|
|
22
28
|
return _transformSync.default;
|
|
23
29
|
}
|
|
24
30
|
});
|
|
31
|
+
_export_star(require("./types.js"), exports);
|
|
25
32
|
var _createMatcher = /*#__PURE__*/ _interop_require_default(require("./createMatcher.js"));
|
|
33
|
+
var _extensions = /*#__PURE__*/ _interop_require_default(require("./extensions.js"));
|
|
34
|
+
var _resolveFileSync = /*#__PURE__*/ _interop_require_default(require("./resolveFileSync.js"));
|
|
26
35
|
var _transformFile = /*#__PURE__*/ _interop_require_default(require("./transformFile.js"));
|
|
27
36
|
var _transformDirectory = /*#__PURE__*/ _interop_require_default(require("./transformDirectory.js"));
|
|
28
37
|
var _transformSync = /*#__PURE__*/ _interop_require_default(require("./transformSync.js"));
|
|
38
|
+
function _export_star(from, to) {
|
|
39
|
+
Object.keys(from).forEach(function(k) {
|
|
40
|
+
if (k !== "default" && !Object.prototype.hasOwnProperty.call(to, k)) {
|
|
41
|
+
Object.defineProperty(to, k, {
|
|
42
|
+
enumerable: true,
|
|
43
|
+
get: function() {
|
|
44
|
+
return from[k];
|
|
45
|
+
}
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
return from;
|
|
50
|
+
}
|
|
29
51
|
function _interop_require_default(obj) {
|
|
30
52
|
return obj && obj.__esModule ? obj : {
|
|
31
53
|
default: obj
|
package/dist/cjs/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["index.ts"],"sourcesContent":["export { default as createMatcher } from './createMatcher.js';\nexport { default as transformFile } from './transformFile.js';\nexport { default as transformDirectory } from './transformDirectory.js';\nexport { default as transformSync } from './transformSync.js';\n"],"names":["createMatcher","transformDirectory","transformFile","transformSync"],"mappings":";;;;;;;;;;;
|
|
1
|
+
{"version":3,"sources":["index.ts"],"sourcesContent":["export * from './types.js';\nexport { default as createMatcher } from './createMatcher.js';\nexport { default as extensions } from './extensions.js';\nexport { default as resolveFileSync } from './resolveFileSync.js';\nexport { default as transformFile } from './transformFile.js';\nexport { default as transformDirectory } from './transformDirectory.js';\nexport { default as transformSync } from './transformSync.js';\n"],"names":["createMatcher","extensions","resolveFileSync","transformDirectory","transformFile","transformSync"],"mappings":";;;;;;;;;;;IACoBA,aAAa;eAAbA,sBAAa;;IACbC,UAAU;eAAVA,mBAAU;;IACVC,eAAe;eAAfA,wBAAe;;IAEfC,kBAAkB;eAAlBA,2BAAkB;;IADlBC,aAAa;eAAbA,sBAAa;;IAEbC,aAAa;eAAbA,sBAAa;;;qBANnB;oEAC2B;iEACH;sEACK;oEACF;yEACK;oEACL"}
|
|
@@ -0,0 +1,63 @@
|
|
|
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 toPath;
|
|
9
|
+
}
|
|
10
|
+
});
|
|
11
|
+
var _fs = /*#__PURE__*/ _interop_require_default(require("fs"));
|
|
12
|
+
var _path = /*#__PURE__*/ _interop_require_default(require("path"));
|
|
13
|
+
var _url = /*#__PURE__*/ _interop_require_default(require("url"));
|
|
14
|
+
var _isabsolute = /*#__PURE__*/ _interop_require_default(require("is-absolute"));
|
|
15
|
+
var _resolve = /*#__PURE__*/ _interop_require_default(require("resolve"));
|
|
16
|
+
var _processcjs = /*#__PURE__*/ _interop_require_default(require("./process.js"));
|
|
17
|
+
function _interop_require_default(obj) {
|
|
18
|
+
return obj && obj.__esModule ? obj : {
|
|
19
|
+
default: obj
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
var moduleRegEx = /^[^.\/]|^\.[^.\/]|^\.\.[^\/]/;
|
|
23
|
+
function getParentPath(context) {
|
|
24
|
+
if (context.parentPath) return _path.default.dirname(context.parentPath);
|
|
25
|
+
return context.parentURL ? _path.default.dirname(toPath(context.parentURL)) : _processcjs.default.cwd();
|
|
26
|
+
}
|
|
27
|
+
function toPath(specifier, context) {
|
|
28
|
+
if (specifier.startsWith('file:')) return _url.default.parse(specifier).pathname;
|
|
29
|
+
if ((0, _isabsolute.default)(specifier)) return specifier;
|
|
30
|
+
if (specifier[0] === '.') {
|
|
31
|
+
var parentPath = context ? getParentPath(context) : _processcjs.default.cwd();
|
|
32
|
+
return _path.default.resolve(parentPath, specifier);
|
|
33
|
+
}
|
|
34
|
+
if (moduleRegEx.test(specifier)) {
|
|
35
|
+
var parentPath1 = context ? getParentPath(context) : _processcjs.default.cwd();
|
|
36
|
+
var pkg = null;
|
|
37
|
+
var main = _resolve.default.sync(specifier, {
|
|
38
|
+
basedir: parentPath1,
|
|
39
|
+
extensions: [
|
|
40
|
+
'.js',
|
|
41
|
+
'.json',
|
|
42
|
+
'.node',
|
|
43
|
+
'.mjs'
|
|
44
|
+
],
|
|
45
|
+
packageFilter: function packageFilter(json, dir) {
|
|
46
|
+
pkg = {
|
|
47
|
+
json: json,
|
|
48
|
+
dir: dir
|
|
49
|
+
};
|
|
50
|
+
return json;
|
|
51
|
+
}
|
|
52
|
+
});
|
|
53
|
+
if (!pkg || !pkg.json.module) return main; // no modules, use main
|
|
54
|
+
if (pkg.json.name === specifier) return _path.default.resolve(pkg.dir, pkg.json.module); // the module
|
|
55
|
+
// a relative path. Only accept if it doesn't break the relative naming and it exists
|
|
56
|
+
var modulePath = _path.default.resolve(pkg.dir, pkg.json.module);
|
|
57
|
+
var mainPath = _path.default.resolve(pkg.dir, pkg.json.main);
|
|
58
|
+
var moduleResolved = _path.default.resolve(modulePath, _path.default.relative(mainPath, main));
|
|
59
|
+
return moduleResolved.indexOf(specifier.replace(pkg.json.name, '')) < 0 || !_fs.default.existsSync(moduleResolved) ? main : moduleResolved;
|
|
60
|
+
}
|
|
61
|
+
return specifier;
|
|
62
|
+
}
|
|
63
|
+
/* 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":["toPath.ts"],"sourcesContent":["import fs from 'fs';\nimport path from 'path';\nimport url from 'url';\nimport isAbsolute from 'is-absolute';\nimport resolve from 'resolve';\nimport type { Context } from '../types';\n// @ts-ignore\nimport process from './process.cjs';\n\nconst moduleRegEx = /^[^.\\/]|^\\.[^.\\/]|^\\.\\.[^\\/]/;\n\nfunction getParentPath(context: Context) {\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) {\n if (specifier.startsWith('file:')) return url.parse(specifier).pathname;\n if (isAbsolute(specifier)) return specifier;\n if (specifier[0] === '.') {\n const parentPath = context ? getParentPath(context) : process.cwd();\n return path.resolve(parentPath, specifier);\n }\n if (moduleRegEx.test(specifier)) {\n const parentPath = context ? getParentPath(context) : process.cwd();\n\n let pkg = null;\n const main = resolve.sync(specifier, {\n basedir: parentPath,\n extensions: ['.js', '.json', '.node', '.mjs'],\n packageFilter(json, dir) {\n pkg = { json, dir };\n return json;\n },\n });\n if (!pkg || !pkg.json.module) return main; // no modules, use main\n if (pkg.json.name === specifier) return path.resolve(pkg.dir, pkg.json.module); // the module\n\n // a relative path. Only accept if it doesn't break the relative naming and it exists\n const modulePath = path.resolve(pkg.dir, pkg.json.module);\n const mainPath = path.resolve(pkg.dir, pkg.json.main);\n const moduleResolved = path.resolve(modulePath, path.relative(mainPath, main));\n return moduleResolved.indexOf(specifier.replace(pkg.json.name, '')) < 0 || !fs.existsSync(moduleResolved) ? main : moduleResolved;\n }\n\n return specifier;\n}\n"],"names":["toPath","moduleRegEx","getParentPath","context","parentPath","path","dirname","parentURL","process","cwd","specifier","startsWith","url","parse","pathname","isAbsolute","resolve","test","pkg","main","sync","basedir","extensions","packageFilter","json","dir","module","name","modulePath","mainPath","moduleResolved","relative","indexOf","replace","fs","existsSync"],"mappings":";;;;+BAgBA;;;eAAwBA;;;yDAhBT;2DACE;0DACD;iEACO;8DACH;iEAGA;;;;;;AAEpB,IAAMC,cAAc;AAEpB,SAASC,cAAcC,OAAgB;IACrC,IAAIA,QAAQC,UAAU,EAAE,OAAOC,aAAI,CAACC,OAAO,CAACH,QAAQC,UAAU;IAC9D,OAAOD,QAAQI,SAAS,GAAGF,aAAI,CAACC,OAAO,CAACN,OAAOG,QAAQI,SAAS,KAAKC,mBAAO,CAACC,GAAG;AAClF;AAEe,SAAST,OAAOU,SAAiB,EAAEP,OAAiB;IACjE,IAAIO,UAAUC,UAAU,CAAC,UAAU,OAAOC,YAAG,CAACC,KAAK,CAACH,WAAWI,QAAQ;IACvE,IAAIC,IAAAA,mBAAU,EAACL,YAAY,OAAOA;IAClC,IAAIA,SAAS,CAAC,EAAE,KAAK,KAAK;QACxB,IAAMN,aAAaD,UAAUD,cAAcC,WAAWK,mBAAO,CAACC,GAAG;QACjE,OAAOJ,aAAI,CAACW,OAAO,CAACZ,YAAYM;IAClC;IACA,IAAIT,YAAYgB,IAAI,CAACP,YAAY;QAC/B,IAAMN,cAAaD,UAAUD,cAAcC,WAAWK,mBAAO,CAACC,GAAG;QAEjE,IAAIS,MAAM;QACV,IAAMC,OAAOH,gBAAO,CAACI,IAAI,CAACV,WAAW;YACnCW,SAASjB;YACTkB,YAAY;gBAAC;gBAAO;gBAAS;gBAAS;aAAO;YAC7CC,eAAAA,SAAAA,cAAcC,IAAI,EAAEC,GAAG;gBACrBP,MAAM;oBAAEM,MAAAA;oBAAMC,KAAAA;gBAAI;gBAClB,OAAOD;YACT;QACF;QACA,IAAI,CAACN,OAAO,CAACA,IAAIM,IAAI,CAACE,MAAM,EAAE,OAAOP,MAAM,uBAAuB;QAClE,IAAID,IAAIM,IAAI,CAACG,IAAI,KAAKjB,WAAW,OAAOL,aAAI,CAACW,OAAO,CAACE,IAAIO,GAAG,EAAEP,IAAIM,IAAI,CAACE,MAAM,GAAG,aAAa;QAE7F,qFAAqF;QACrF,IAAME,aAAavB,aAAI,CAACW,OAAO,CAACE,IAAIO,GAAG,EAAEP,IAAIM,IAAI,CAACE,MAAM;QACxD,IAAMG,WAAWxB,aAAI,CAACW,OAAO,CAACE,IAAIO,GAAG,EAAEP,IAAIM,IAAI,CAACL,IAAI;QACpD,IAAMW,iBAAiBzB,aAAI,CAACW,OAAO,CAACY,YAAYvB,aAAI,CAAC0B,QAAQ,CAACF,UAAUV;QACxE,OAAOW,eAAeE,OAAO,CAACtB,UAAUuB,OAAO,CAACf,IAAIM,IAAI,CAACG,IAAI,EAAE,OAAO,KAAK,CAACO,WAAE,CAACC,UAAU,CAACL,kBAAkBX,OAAOW;IACrH;IAEA,OAAOpB;AACT"}
|
|
@@ -0,0 +1,50 @@
|
|
|
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 resolveFileSync;
|
|
9
|
+
}
|
|
10
|
+
});
|
|
11
|
+
var _fs = /*#__PURE__*/ _interop_require_default(require("fs"));
|
|
12
|
+
var _path = /*#__PURE__*/ _interop_require_default(require("path"));
|
|
13
|
+
var _extensions = /*#__PURE__*/ _interop_require_default(require("./extensions.js"));
|
|
14
|
+
var _toPath = /*#__PURE__*/ _interop_require_default(require("./lib/toPath.js"));
|
|
15
|
+
function _interop_require_default(obj) {
|
|
16
|
+
return obj && obj.__esModule ? obj : {
|
|
17
|
+
default: obj
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
var moduleRegEx = /^[^.\/]|^\.[^.\/]|^\.\.[^\/]/;
|
|
21
|
+
var typeFileRegEx = /^[^.]+\.d\.[cm]?ts$/;
|
|
22
|
+
var indexExtensions = _extensions.default.map(function(x) {
|
|
23
|
+
return "index".concat(x);
|
|
24
|
+
});
|
|
25
|
+
function resolveFileSync(specifier, context) {
|
|
26
|
+
var filePath = (0, _toPath.default)(specifier, context);
|
|
27
|
+
var ext = _path.default.extname(filePath);
|
|
28
|
+
var stats;
|
|
29
|
+
try {
|
|
30
|
+
stats = _fs.default.statSync(filePath);
|
|
31
|
+
} catch (_err) {}
|
|
32
|
+
// biome-ignore lint/complexity/useOptionalChain: <explanation>
|
|
33
|
+
if (stats && stats.isDirectory() || specifier.endsWith('/')) {
|
|
34
|
+
var items = _fs.default.readdirSync(filePath);
|
|
35
|
+
var item = items.find(function(x) {
|
|
36
|
+
return indexExtensions.indexOf(x) >= 0;
|
|
37
|
+
});
|
|
38
|
+
if (item) return _path.default.join(filePath, item);
|
|
39
|
+
} else if (!stats || !ext && !moduleRegEx.test(specifier)) {
|
|
40
|
+
var fileName = _path.default.basename(filePath).replace(/(\.[^/.]+)+$/, '');
|
|
41
|
+
var items1 = _fs.default.readdirSync(_path.default.dirname(filePath));
|
|
42
|
+
var item1 = items1.find(function(x) {
|
|
43
|
+
return x.startsWith(fileName) && !typeFileRegEx.test(x) && _extensions.default.indexOf(_path.default.extname(x)) >= 0;
|
|
44
|
+
});
|
|
45
|
+
if (item1) return _path.default.join(_path.default.dirname(filePath), item1);
|
|
46
|
+
}
|
|
47
|
+
// return what was found
|
|
48
|
+
return stats ? filePath : null;
|
|
49
|
+
}
|
|
50
|
+
/* 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":["resolveFileSync.ts"],"sourcesContent":["import fs from 'fs';\nimport path from 'path';\nimport extensions from './extensions.js';\nimport toPath from './lib/toPath.js';\n\nimport type { Context } from './types';\n\nconst moduleRegEx = /^[^.\\/]|^\\.[^.\\/]|^\\.\\.[^\\/]/;\nconst typeFileRegEx = /^[^.]+\\.d\\.[cm]?ts$/;\nconst indexExtensions = extensions.map((x) => `index${x}`);\n\nexport default function resolveFileSync(specifier: string, context?: Context) {\n const filePath = toPath(specifier, context);\n const ext = path.extname(filePath);\n\n let stats: fs.Stats | undefined;\n try {\n stats = fs.statSync(filePath);\n } catch (_err) {}\n\n // biome-ignore lint/complexity/useOptionalChain: <explanation>\n if ((stats && stats.isDirectory()) || specifier.endsWith('/')) {\n const items = fs.readdirSync(filePath);\n const item = items.find((x) => indexExtensions.indexOf(x) >= 0);\n if (item) return path.join(filePath, item);\n }\n\n // look up the extension\n else if (!stats || (!ext && !moduleRegEx.test(specifier))) {\n const fileName = path.basename(filePath).replace(/(\\.[^/.]+)+$/, '');\n const items = fs.readdirSync(path.dirname(filePath));\n const item = items.find((x) => x.startsWith(fileName) && !typeFileRegEx.test(x) && extensions.indexOf(path.extname(x)) >= 0);\n if (item) return path.join(path.dirname(filePath), item);\n }\n\n // return what was found\n return stats ? filePath : null;\n}\n"],"names":["resolveFileSync","moduleRegEx","typeFileRegEx","indexExtensions","extensions","map","x","specifier","context","filePath","toPath","ext","path","extname","stats","fs","statSync","_err","isDirectory","endsWith","items","readdirSync","item","find","indexOf","join","test","fileName","basename","replace","dirname","startsWith"],"mappings":";;;;+BAWA;;;eAAwBA;;;yDAXT;2DACE;iEACM;6DACJ;;;;;;AAInB,IAAMC,cAAc;AACpB,IAAMC,gBAAgB;AACtB,IAAMC,kBAAkBC,mBAAU,CAACC,GAAG,CAAC,SAACC;WAAM,AAAC,QAAS,OAAFA;;AAEvC,SAASN,gBAAgBO,SAAiB,EAAEC,OAAiB;IAC1E,IAAMC,WAAWC,IAAAA,eAAM,EAACH,WAAWC;IACnC,IAAMG,MAAMC,aAAI,CAACC,OAAO,CAACJ;IAEzB,IAAIK;IACJ,IAAI;QACFA,QAAQC,WAAE,CAACC,QAAQ,CAACP;IACtB,EAAE,OAAOQ,MAAM,CAAC;IAEhB,+DAA+D;IAC/D,IAAI,AAACH,SAASA,MAAMI,WAAW,MAAOX,UAAUY,QAAQ,CAAC,MAAM;QAC7D,IAAMC,QAAQL,WAAE,CAACM,WAAW,CAACZ;QAC7B,IAAMa,OAAOF,MAAMG,IAAI,CAAC,SAACjB;mBAAMH,gBAAgBqB,OAAO,CAAClB,MAAM;;QAC7D,IAAIgB,MAAM,OAAOV,aAAI,CAACa,IAAI,CAAChB,UAAUa;IACvC,OAGK,IAAI,CAACR,SAAU,CAACH,OAAO,CAACV,YAAYyB,IAAI,CAACnB,YAAa;QACzD,IAAMoB,WAAWf,aAAI,CAACgB,QAAQ,CAACnB,UAAUoB,OAAO,CAAC,gBAAgB;QACjE,IAAMT,SAAQL,WAAE,CAACM,WAAW,CAACT,aAAI,CAACkB,OAAO,CAACrB;QAC1C,IAAMa,QAAOF,OAAMG,IAAI,CAAC,SAACjB;mBAAMA,EAAEyB,UAAU,CAACJ,aAAa,CAACzB,cAAcwB,IAAI,CAACpB,MAAMF,mBAAU,CAACoB,OAAO,CAACZ,aAAI,CAACC,OAAO,CAACP,OAAO;;QAC1H,IAAIgB,OAAM,OAAOV,aAAI,CAACa,IAAI,CAACb,aAAI,CAACkB,OAAO,CAACrB,WAAWa;IACrD;IAEA,wBAAwB;IACxB,OAAOR,QAAQL,WAAW;AAC5B"}
|
|
@@ -14,18 +14,18 @@ Object.defineProperty(exports, /**
|
|
|
14
14
|
});
|
|
15
15
|
var _path = /*#__PURE__*/ _interop_require_default(require("path"));
|
|
16
16
|
var _url = /*#__PURE__*/ _interop_require_default(require("url"));
|
|
17
|
-
var
|
|
18
|
-
var
|
|
17
|
+
var _lazycjs = /*#__PURE__*/ _interop_require_default(require("./lib/lazy.js"));
|
|
18
|
+
var _processcjs = /*#__PURE__*/ _interop_require_default(require("./lib/process.js"));
|
|
19
19
|
function _interop_require_default(obj) {
|
|
20
20
|
return obj && obj.__esModule ? obj : {
|
|
21
21
|
default: obj
|
|
22
22
|
};
|
|
23
23
|
}
|
|
24
|
-
var major = +
|
|
24
|
+
var major = +_processcjs.default.versions.node.split('.')[0];
|
|
25
25
|
var version = major >= 14 ? 'local' : 'lts';
|
|
26
26
|
var filename = typeof __filename !== 'undefined' ? __filename : _url.default.fileURLToPath(require("url").pathToFileURL(__filename).toString());
|
|
27
27
|
var worker = _path.default.resolve(_path.default.dirname(filename), 'workers', "transformSync".concat(_path.default.extname(filename) === '.mjs' ? '.cjs' : '.js'));
|
|
28
|
-
var call = (0,
|
|
28
|
+
var call = (0, _lazycjs.default)('node-version-call');
|
|
29
29
|
function transformSync(contents, fileName, config) {
|
|
30
30
|
return call()(version, worker, contents, fileName, config);
|
|
31
31
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["transformSync.ts"],"sourcesContent":["import path from 'path';\nimport url from 'url';\n// @ts-ignore\nimport lazy from './lazy.
|
|
1
|
+
{"version":3,"sources":["transformSync.ts"],"sourcesContent":["import path from 'path';\nimport url from 'url';\n// @ts-ignore\nimport lazy from './lib/lazy.cjs';\n// @ts-ignore\nimport process from './lib/process.cjs';\n\nconst major = +process.versions.node.split('.')[0];\nconst version = major >= 14 ? 'local' : 'lts';\nconst filename = typeof __filename !== 'undefined' ? __filename : url.fileURLToPath(import.meta.url);\nconst worker = path.resolve(path.dirname(filename), 'workers', `transformSync${path.extname(filename) === '.mjs' ? '.cjs' : '.js'}`);\nconst call = lazy('node-version-call');\n\n/**\n * @param {string} contents The file contents.\n * @param {string} fileName The filename.\n * @returns {{ code: string, map?: string }} Returns object with the transformed code and source map if option sourceMaps was provided.\n */\nexport default function transformSync(contents, fileName, config) {\n return call()(version, worker, contents, fileName, config);\n}\n"],"names":["transformSync","major","process","versions","node","split","version","filename","__filename","url","fileURLToPath","worker","path","resolve","dirname","extname","call","lazy","contents","fileName","config"],"mappings":";;;;+BAaA;;;;CAIC,GACD;;;eAAwBA;;;2DAlBP;0DACD;8DAEC;iEAEG;;;;;;AAEpB,IAAMC,QAAQ,CAACC,mBAAO,CAACC,QAAQ,CAACC,IAAI,CAACC,KAAK,CAAC,IAAI,CAAC,EAAE;AAClD,IAAMC,UAAUL,SAAS,KAAK,UAAU;AACxC,IAAMM,WAAW,OAAOC,eAAe,cAAcA,aAAaC,YAAG,CAACC,aAAa,CAAC;AACpF,IAAMC,SAASC,aAAI,CAACC,OAAO,CAACD,aAAI,CAACE,OAAO,CAACP,WAAW,WAAW,AAAC,gBAAkE,OAAnDK,aAAI,CAACG,OAAO,CAACR,cAAc,SAAS,SAAS;AAC5H,IAAMS,OAAOC,IAAAA,gBAAI,EAAC;AAOH,SAASjB,cAAckB,QAAQ,EAAEC,QAAQ,EAAEC,MAAM;IAC9D,OAAOJ,OAAOV,SAASK,QAAQO,UAAUC,UAAUC;AACrD"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
/* 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":[],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["extensions.ts"],"sourcesContent":["export default ['.js', '.jsx', '.cjs', '.mjs', '.ts', '.tsx', '.cts', '.mts', '.json', '.es6', '.es'];\n"],"names":[],"mappings":"AAAA,eAAe;IAAC;IAAO;IAAQ;IAAQ;IAAQ;IAAO;IAAQ;IAAQ;IAAQ;IAAS;IAAQ;CAAM,CAAC"}
|
package/dist/esm/index.mjs
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
|
+
export * from './types.mjs';
|
|
1
2
|
export { default as createMatcher } from './createMatcher.mjs';
|
|
3
|
+
export { default as extensions } from './extensions.mjs';
|
|
4
|
+
export { default as resolveFileSync } from './resolveFileSync.mjs';
|
|
2
5
|
export { default as transformFile } from './transformFile.mjs';
|
|
3
6
|
export { default as transformDirectory } from './transformDirectory.mjs';
|
|
4
7
|
export { default as transformSync } from './transformSync.mjs';
|
package/dist/esm/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["index.ts"],"sourcesContent":["export { default as createMatcher } from './createMatcher.js';\nexport { default as transformFile } from './transformFile.js';\nexport { default as transformDirectory } from './transformDirectory.js';\nexport { default as transformSync } from './transformSync.js';\n"],"names":["default","createMatcher","transformFile","transformDirectory","transformSync"],"mappings":"AAAA,SAASA,WAAWC,aAAa,QAAQ,qBAAqB;AAC9D,SAASD,WAAWE,aAAa,QAAQ,qBAAqB;AAC9D,
|
|
1
|
+
{"version":3,"sources":["index.ts"],"sourcesContent":["export * from './types.js';\nexport { default as createMatcher } from './createMatcher.js';\nexport { default as extensions } from './extensions.js';\nexport { default as resolveFileSync } from './resolveFileSync.js';\nexport { default as transformFile } from './transformFile.js';\nexport { default as transformDirectory } from './transformDirectory.js';\nexport { default as transformSync } from './transformSync.js';\n"],"names":["default","createMatcher","extensions","resolveFileSync","transformFile","transformDirectory","transformSync"],"mappings":"AAAA,cAAc,aAAa;AAC3B,SAASA,WAAWC,aAAa,QAAQ,qBAAqB;AAC9D,SAASD,WAAWE,UAAU,QAAQ,kBAAkB;AACxD,SAASF,WAAWG,eAAe,QAAQ,uBAAuB;AAClE,SAASH,WAAWI,aAAa,QAAQ,qBAAqB;AAC9D,SAASJ,WAAWK,kBAAkB,QAAQ,0BAA0B;AACxE,SAASL,WAAWM,aAAa,QAAQ,qBAAqB"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import fs from 'fs';
|
|
2
|
+
import path from 'path';
|
|
3
|
+
import url from 'url';
|
|
4
|
+
import isAbsolute from 'is-absolute';
|
|
5
|
+
import resolve from 'resolve';
|
|
6
|
+
// @ts-ignore
|
|
7
|
+
import process from './process.cjs';
|
|
8
|
+
const moduleRegEx = /^[^.\/]|^\.[^.\/]|^\.\.[^\/]/;
|
|
9
|
+
function getParentPath(context) {
|
|
10
|
+
if (context.parentPath) return path.dirname(context.parentPath);
|
|
11
|
+
return context.parentURL ? path.dirname(toPath(context.parentURL)) : process.cwd();
|
|
12
|
+
}
|
|
13
|
+
export default function toPath(specifier, context) {
|
|
14
|
+
if (specifier.startsWith('file:')) return url.parse(specifier).pathname;
|
|
15
|
+
if (isAbsolute(specifier)) return specifier;
|
|
16
|
+
if (specifier[0] === '.') {
|
|
17
|
+
const parentPath = context ? getParentPath(context) : process.cwd();
|
|
18
|
+
return path.resolve(parentPath, specifier);
|
|
19
|
+
}
|
|
20
|
+
if (moduleRegEx.test(specifier)) {
|
|
21
|
+
const parentPath = context ? getParentPath(context) : process.cwd();
|
|
22
|
+
let pkg = null;
|
|
23
|
+
const main = resolve.sync(specifier, {
|
|
24
|
+
basedir: parentPath,
|
|
25
|
+
extensions: [
|
|
26
|
+
'.js',
|
|
27
|
+
'.json',
|
|
28
|
+
'.node',
|
|
29
|
+
'.mjs'
|
|
30
|
+
],
|
|
31
|
+
packageFilter (json, dir) {
|
|
32
|
+
pkg = {
|
|
33
|
+
json,
|
|
34
|
+
dir
|
|
35
|
+
};
|
|
36
|
+
return json;
|
|
37
|
+
}
|
|
38
|
+
});
|
|
39
|
+
if (!pkg || !pkg.json.module) return main; // no modules, use main
|
|
40
|
+
if (pkg.json.name === specifier) return path.resolve(pkg.dir, pkg.json.module); // the module
|
|
41
|
+
// a relative path. Only accept if it doesn't break the relative naming and it exists
|
|
42
|
+
const modulePath = path.resolve(pkg.dir, pkg.json.module);
|
|
43
|
+
const mainPath = path.resolve(pkg.dir, pkg.json.main);
|
|
44
|
+
const moduleResolved = path.resolve(modulePath, path.relative(mainPath, main));
|
|
45
|
+
return moduleResolved.indexOf(specifier.replace(pkg.json.name, '')) < 0 || !fs.existsSync(moduleResolved) ? main : moduleResolved;
|
|
46
|
+
}
|
|
47
|
+
return specifier;
|
|
48
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["toPath.ts"],"sourcesContent":["import fs from 'fs';\nimport path from 'path';\nimport url from 'url';\nimport isAbsolute from 'is-absolute';\nimport resolve from 'resolve';\nimport type { Context } from '../types';\n// @ts-ignore\nimport process from './process.cjs';\n\nconst moduleRegEx = /^[^.\\/]|^\\.[^.\\/]|^\\.\\.[^\\/]/;\n\nfunction getParentPath(context: Context) {\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) {\n if (specifier.startsWith('file:')) return url.parse(specifier).pathname;\n if (isAbsolute(specifier)) return specifier;\n if (specifier[0] === '.') {\n const parentPath = context ? getParentPath(context) : process.cwd();\n return path.resolve(parentPath, specifier);\n }\n if (moduleRegEx.test(specifier)) {\n const parentPath = context ? getParentPath(context) : process.cwd();\n\n let pkg = null;\n const main = resolve.sync(specifier, {\n basedir: parentPath,\n extensions: ['.js', '.json', '.node', '.mjs'],\n packageFilter(json, dir) {\n pkg = { json, dir };\n return json;\n },\n });\n if (!pkg || !pkg.json.module) return main; // no modules, use main\n if (pkg.json.name === specifier) return path.resolve(pkg.dir, pkg.json.module); // the module\n\n // a relative path. Only accept if it doesn't break the relative naming and it exists\n const modulePath = path.resolve(pkg.dir, pkg.json.module);\n const mainPath = path.resolve(pkg.dir, pkg.json.main);\n const moduleResolved = path.resolve(modulePath, path.relative(mainPath, main));\n return moduleResolved.indexOf(specifier.replace(pkg.json.name, '')) < 0 || !fs.existsSync(moduleResolved) ? main : moduleResolved;\n }\n\n return specifier;\n}\n"],"names":["fs","path","url","isAbsolute","resolve","process","moduleRegEx","getParentPath","context","parentPath","dirname","parentURL","toPath","cwd","specifier","startsWith","parse","pathname","test","pkg","main","sync","basedir","extensions","packageFilter","json","dir","module","name","modulePath","mainPath","moduleResolved","relative","indexOf","replace","existsSync"],"mappings":"AAAA,OAAOA,QAAQ,KAAK;AACpB,OAAOC,UAAU,OAAO;AACxB,OAAOC,SAAS,MAAM;AACtB,OAAOC,gBAAgB,cAAc;AACrC,OAAOC,aAAa,UAAU;AAE9B,aAAa;AACb,OAAOC,aAAa,gBAAgB;AAEpC,MAAMC,cAAc;AAEpB,SAASC,cAAcC,OAAgB;IACrC,IAAIA,QAAQC,UAAU,EAAE,OAAOR,KAAKS,OAAO,CAACF,QAAQC,UAAU;IAC9D,OAAOD,QAAQG,SAAS,GAAGV,KAAKS,OAAO,CAACE,OAAOJ,QAAQG,SAAS,KAAKN,QAAQQ,GAAG;AAClF;AAEA,eAAe,SAASD,OAAOE,SAAiB,EAAEN,OAAiB;IACjE,IAAIM,UAAUC,UAAU,CAAC,UAAU,OAAOb,IAAIc,KAAK,CAACF,WAAWG,QAAQ;IACvE,IAAId,WAAWW,YAAY,OAAOA;IAClC,IAAIA,SAAS,CAAC,EAAE,KAAK,KAAK;QACxB,MAAML,aAAaD,UAAUD,cAAcC,WAAWH,QAAQQ,GAAG;QACjE,OAAOZ,KAAKG,OAAO,CAACK,YAAYK;IAClC;IACA,IAAIR,YAAYY,IAAI,CAACJ,YAAY;QAC/B,MAAML,aAAaD,UAAUD,cAAcC,WAAWH,QAAQQ,GAAG;QAEjE,IAAIM,MAAM;QACV,MAAMC,OAAOhB,QAAQiB,IAAI,CAACP,WAAW;YACnCQ,SAASb;YACTc,YAAY;gBAAC;gBAAO;gBAAS;gBAAS;aAAO;YAC7CC,eAAcC,IAAI,EAAEC,GAAG;gBACrBP,MAAM;oBAAEM;oBAAMC;gBAAI;gBAClB,OAAOD;YACT;QACF;QACA,IAAI,CAACN,OAAO,CAACA,IAAIM,IAAI,CAACE,MAAM,EAAE,OAAOP,MAAM,uBAAuB;QAClE,IAAID,IAAIM,IAAI,CAACG,IAAI,KAAKd,WAAW,OAAOb,KAAKG,OAAO,CAACe,IAAIO,GAAG,EAAEP,IAAIM,IAAI,CAACE,MAAM,GAAG,aAAa;QAE7F,qFAAqF;QACrF,MAAME,aAAa5B,KAAKG,OAAO,CAACe,IAAIO,GAAG,EAAEP,IAAIM,IAAI,CAACE,MAAM;QACxD,MAAMG,WAAW7B,KAAKG,OAAO,CAACe,IAAIO,GAAG,EAAEP,IAAIM,IAAI,CAACL,IAAI;QACpD,MAAMW,iBAAiB9B,KAAKG,OAAO,CAACyB,YAAY5B,KAAK+B,QAAQ,CAACF,UAAUV;QACxE,OAAOW,eAAeE,OAAO,CAACnB,UAAUoB,OAAO,CAACf,IAAIM,IAAI,CAACG,IAAI,EAAE,OAAO,KAAK,CAAC5B,GAAGmC,UAAU,CAACJ,kBAAkBX,OAAOW;IACrH;IAEA,OAAOjB;AACT"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import fs from 'fs';
|
|
2
|
+
import path from 'path';
|
|
3
|
+
import extensions from './extensions.mjs';
|
|
4
|
+
import toPath from './lib/toPath.mjs';
|
|
5
|
+
const moduleRegEx = /^[^.\/]|^\.[^.\/]|^\.\.[^\/]/;
|
|
6
|
+
const typeFileRegEx = /^[^.]+\.d\.[cm]?ts$/;
|
|
7
|
+
const indexExtensions = extensions.map((x)=>`index${x}`);
|
|
8
|
+
export default function resolveFileSync(specifier, context) {
|
|
9
|
+
const filePath = toPath(specifier, context);
|
|
10
|
+
const ext = path.extname(filePath);
|
|
11
|
+
let stats;
|
|
12
|
+
try {
|
|
13
|
+
stats = fs.statSync(filePath);
|
|
14
|
+
} catch (_err) {}
|
|
15
|
+
// biome-ignore lint/complexity/useOptionalChain: <explanation>
|
|
16
|
+
if (stats && stats.isDirectory() || specifier.endsWith('/')) {
|
|
17
|
+
const items = fs.readdirSync(filePath);
|
|
18
|
+
const item = items.find((x)=>indexExtensions.indexOf(x) >= 0);
|
|
19
|
+
if (item) return path.join(filePath, item);
|
|
20
|
+
} else if (!stats || !ext && !moduleRegEx.test(specifier)) {
|
|
21
|
+
const fileName = path.basename(filePath).replace(/(\.[^/.]+)+$/, '');
|
|
22
|
+
const items = fs.readdirSync(path.dirname(filePath));
|
|
23
|
+
const item = items.find((x)=>x.startsWith(fileName) && !typeFileRegEx.test(x) && extensions.indexOf(path.extname(x)) >= 0);
|
|
24
|
+
if (item) return path.join(path.dirname(filePath), item);
|
|
25
|
+
}
|
|
26
|
+
// return what was found
|
|
27
|
+
return stats ? filePath : null;
|
|
28
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["resolveFileSync.ts"],"sourcesContent":["import fs from 'fs';\nimport path from 'path';\nimport extensions from './extensions.js';\nimport toPath from './lib/toPath.js';\n\nimport type { Context } from './types';\n\nconst moduleRegEx = /^[^.\\/]|^\\.[^.\\/]|^\\.\\.[^\\/]/;\nconst typeFileRegEx = /^[^.]+\\.d\\.[cm]?ts$/;\nconst indexExtensions = extensions.map((x) => `index${x}`);\n\nexport default function resolveFileSync(specifier: string, context?: Context) {\n const filePath = toPath(specifier, context);\n const ext = path.extname(filePath);\n\n let stats: fs.Stats | undefined;\n try {\n stats = fs.statSync(filePath);\n } catch (_err) {}\n\n // biome-ignore lint/complexity/useOptionalChain: <explanation>\n if ((stats && stats.isDirectory()) || specifier.endsWith('/')) {\n const items = fs.readdirSync(filePath);\n const item = items.find((x) => indexExtensions.indexOf(x) >= 0);\n if (item) return path.join(filePath, item);\n }\n\n // look up the extension\n else if (!stats || (!ext && !moduleRegEx.test(specifier))) {\n const fileName = path.basename(filePath).replace(/(\\.[^/.]+)+$/, '');\n const items = fs.readdirSync(path.dirname(filePath));\n const item = items.find((x) => x.startsWith(fileName) && !typeFileRegEx.test(x) && extensions.indexOf(path.extname(x)) >= 0);\n if (item) return path.join(path.dirname(filePath), item);\n }\n\n // return what was found\n return stats ? filePath : null;\n}\n"],"names":["fs","path","extensions","toPath","moduleRegEx","typeFileRegEx","indexExtensions","map","x","resolveFileSync","specifier","context","filePath","ext","extname","stats","statSync","_err","isDirectory","endsWith","items","readdirSync","item","find","indexOf","join","test","fileName","basename","replace","dirname","startsWith"],"mappings":"AAAA,OAAOA,QAAQ,KAAK;AACpB,OAAOC,UAAU,OAAO;AACxB,OAAOC,gBAAgB,kBAAkB;AACzC,OAAOC,YAAY,kBAAkB;AAIrC,MAAMC,cAAc;AACpB,MAAMC,gBAAgB;AACtB,MAAMC,kBAAkBJ,WAAWK,GAAG,CAAC,CAACC,IAAM,CAAC,KAAK,EAAEA,GAAG;AAEzD,eAAe,SAASC,gBAAgBC,SAAiB,EAAEC,OAAiB;IAC1E,MAAMC,WAAWT,OAAOO,WAAWC;IACnC,MAAME,MAAMZ,KAAKa,OAAO,CAACF;IAEzB,IAAIG;IACJ,IAAI;QACFA,QAAQf,GAAGgB,QAAQ,CAACJ;IACtB,EAAE,OAAOK,MAAM,CAAC;IAEhB,+DAA+D;IAC/D,IAAI,AAACF,SAASA,MAAMG,WAAW,MAAOR,UAAUS,QAAQ,CAAC,MAAM;QAC7D,MAAMC,QAAQpB,GAAGqB,WAAW,CAACT;QAC7B,MAAMU,OAAOF,MAAMG,IAAI,CAAC,CAACf,IAAMF,gBAAgBkB,OAAO,CAAChB,MAAM;QAC7D,IAAIc,MAAM,OAAOrB,KAAKwB,IAAI,CAACb,UAAUU;IACvC,OAGK,IAAI,CAACP,SAAU,CAACF,OAAO,CAACT,YAAYsB,IAAI,CAAChB,YAAa;QACzD,MAAMiB,WAAW1B,KAAK2B,QAAQ,CAAChB,UAAUiB,OAAO,CAAC,gBAAgB;QACjE,MAAMT,QAAQpB,GAAGqB,WAAW,CAACpB,KAAK6B,OAAO,CAAClB;QAC1C,MAAMU,OAAOF,MAAMG,IAAI,CAAC,CAACf,IAAMA,EAAEuB,UAAU,CAACJ,aAAa,CAACtB,cAAcqB,IAAI,CAAClB,MAAMN,WAAWsB,OAAO,CAACvB,KAAKa,OAAO,CAACN,OAAO;QAC1H,IAAIc,MAAM,OAAOrB,KAAKwB,IAAI,CAACxB,KAAK6B,OAAO,CAAClB,WAAWU;IACrD;IAEA,wBAAwB;IACxB,OAAOP,QAAQH,WAAW;AAC5B"}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import path from 'path';
|
|
2
2
|
import url from 'url';
|
|
3
3
|
// @ts-ignore
|
|
4
|
-
import lazy from './lazy.cjs';
|
|
4
|
+
import lazy from './lib/lazy.cjs';
|
|
5
5
|
// @ts-ignore
|
|
6
|
-
import process from './process.cjs';
|
|
6
|
+
import process from './lib/process.cjs';
|
|
7
7
|
const major = +process.versions.node.split('.')[0];
|
|
8
8
|
const version = major >= 14 ? 'local' : 'lts';
|
|
9
9
|
const filename = typeof __filename !== 'undefined' ? __filename : url.fileURLToPath(import.meta.url);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["transformSync.ts"],"sourcesContent":["import path from 'path';\nimport url from 'url';\n// @ts-ignore\nimport lazy from './lazy.
|
|
1
|
+
{"version":3,"sources":["transformSync.ts"],"sourcesContent":["import path from 'path';\nimport url from 'url';\n// @ts-ignore\nimport lazy from './lib/lazy.cjs';\n// @ts-ignore\nimport process from './lib/process.cjs';\n\nconst major = +process.versions.node.split('.')[0];\nconst version = major >= 14 ? 'local' : 'lts';\nconst filename = typeof __filename !== 'undefined' ? __filename : url.fileURLToPath(import.meta.url);\nconst worker = path.resolve(path.dirname(filename), 'workers', `transformSync${path.extname(filename) === '.mjs' ? '.cjs' : '.js'}`);\nconst call = lazy('node-version-call');\n\n/**\n * @param {string} contents The file contents.\n * @param {string} fileName The filename.\n * @returns {{ code: string, map?: string }} Returns object with the transformed code and source map if option sourceMaps was provided.\n */\nexport default function transformSync(contents, fileName, config) {\n return call()(version, worker, contents, fileName, config);\n}\n"],"names":["path","url","lazy","process","major","versions","node","split","version","filename","__filename","fileURLToPath","worker","resolve","dirname","extname","call","transformSync","contents","fileName","config"],"mappings":"AAAA,OAAOA,UAAU,OAAO;AACxB,OAAOC,SAAS,MAAM;AACtB,aAAa;AACb,OAAOC,UAAU,iBAAiB;AAClC,aAAa;AACb,OAAOC,aAAa,oBAAoB;AAExC,MAAMC,QAAQ,CAACD,QAAQE,QAAQ,CAACC,IAAI,CAACC,KAAK,CAAC,IAAI,CAAC,EAAE;AAClD,MAAMC,UAAUJ,SAAS,KAAK,UAAU;AACxC,MAAMK,WAAW,OAAOC,eAAe,cAAcA,aAAaT,IAAIU,aAAa,CAAC,YAAYV,GAAG;AACnG,MAAMW,SAASZ,KAAKa,OAAO,CAACb,KAAKc,OAAO,CAACL,WAAW,WAAW,CAAC,aAAa,EAAET,KAAKe,OAAO,CAACN,cAAc,SAAS,SAAS,OAAO;AACnI,MAAMO,OAAOd,KAAK;AAElB;;;;CAIC,GACD,eAAe,SAASe,cAAcC,QAAQ,EAAEC,QAAQ,EAAEC,MAAM;IAC9D,OAAOJ,OAAOR,SAASI,QAAQM,UAAUC,UAAUC;AACrD"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["types.ts"],"sourcesContent":["export interface Context {\n parentURL?: string;\n parentPath?: string;\n}\n"],"names":[],"mappings":"AAAA,WAGC"}
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
|
+
export * from './types.js';
|
|
1
2
|
export { default as createMatcher } from './createMatcher.js';
|
|
3
|
+
export { default as extensions } from './extensions.js';
|
|
4
|
+
export { default as resolveFileSync } from './resolveFileSync.js';
|
|
2
5
|
export { default as transformFile } from './transformFile.js';
|
|
3
6
|
export { default as transformDirectory } from './transformDirectory.js';
|
|
4
7
|
export { default as transformSync } from './transformSync.js';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ts-swc-transform",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.2.0",
|
|
4
4
|
"description": "Typescript transformers for swc. Supports Node >= 0.8",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"matcher",
|
|
@@ -43,7 +43,7 @@
|
|
|
43
43
|
"depcheck": "depcheck",
|
|
44
44
|
"deploy": "tsds deploy",
|
|
45
45
|
"format": "biome check --write --unsafe src/ test/",
|
|
46
|
-
"test": "tsds test:node --
|
|
46
|
+
"test": "tsds test:node --no-timeouts",
|
|
47
47
|
"test:engines": "nvu engines npm test",
|
|
48
48
|
"version": "tsds version"
|
|
49
49
|
},
|
|
@@ -54,13 +54,15 @@
|
|
|
54
54
|
"exit": "^0.1.2",
|
|
55
55
|
"fs-access-sync-compat": "^1.0.2",
|
|
56
56
|
"fs-iterator": "^5.1.1",
|
|
57
|
-
"get-tsconfig-compat": "^1.1.
|
|
57
|
+
"get-tsconfig-compat": "^1.1.1",
|
|
58
|
+
"is-absolute": "^1.0.0",
|
|
58
59
|
"lazy-cache": "^2.0.2",
|
|
59
60
|
"minimatch": "^3.1.2",
|
|
60
61
|
"mkdirp": "^0.5.6",
|
|
61
62
|
"node-version-call": "^1.1.1",
|
|
62
63
|
"path-posix": "^1.0.0",
|
|
63
|
-
"queue-cb": "^1.4.
|
|
64
|
+
"queue-cb": "^1.4.3",
|
|
65
|
+
"resolve": "^1.22.9",
|
|
64
66
|
"temp-suffix": "^0.1.1",
|
|
65
67
|
"ts-node": "*",
|
|
66
68
|
"typescript": "*",
|
|
@@ -75,7 +77,7 @@
|
|
|
75
77
|
"cr": "^0.1.0",
|
|
76
78
|
"react": "^19.0.0",
|
|
77
79
|
"rimraf2": "^2.8.2",
|
|
78
|
-
"ts-dev-stack": "^1.2.
|
|
80
|
+
"ts-dev-stack": "^1.2.2",
|
|
79
81
|
"ts-node": "^10.8.2",
|
|
80
82
|
"typescript": "^5.7.2"
|
|
81
83
|
},
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|