@hirarijs/loader-ts 1.0.16 → 1.0.17
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/index.cjs +16 -3
- package/dist/index.js +16 -3
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -213384,8 +213384,11 @@ var nearestConfigCache = /* @__PURE__ */ new Map();
|
|
|
213384
213384
|
var rootConfigPath = null;
|
|
213385
213385
|
function findRootTsconfig() {
|
|
213386
213386
|
if (rootConfigPath !== null) return rootConfigPath;
|
|
213387
|
-
const
|
|
213388
|
-
|
|
213387
|
+
const candidates = [
|
|
213388
|
+
import_path.default.join(process.cwd(), "tsconfig.json"),
|
|
213389
|
+
import_path.default.join(process.cwd(), "tsconfig.base.json")
|
|
213390
|
+
];
|
|
213391
|
+
rootConfigPath = candidates.find((c) => import_typescript.default.sys.fileExists(c)) || null;
|
|
213389
213392
|
return rootConfigPath;
|
|
213390
213393
|
}
|
|
213391
213394
|
function findNearestTsconfig(start) {
|
|
@@ -213486,7 +213489,9 @@ function rewriteImports(code, filename, resolve, debug = false) {
|
|
|
213486
213489
|
return full.replace(spec, normalized);
|
|
213487
213490
|
});
|
|
213488
213491
|
}
|
|
213489
|
-
var
|
|
213492
|
+
var TS_EXTS = [".ts", ".mts", ".cts"];
|
|
213493
|
+
var JS_EXTS = [".js", ".mjs", ".cjs"];
|
|
213494
|
+
var extensions = [...TS_EXTS, ...JS_EXTS];
|
|
213490
213495
|
function runTransform(code, filename, ctx) {
|
|
213491
213496
|
const ext = import_path.default.extname(filename);
|
|
213492
213497
|
if (!extensions.includes(ext)) {
|
|
@@ -213499,6 +213504,14 @@ function runTransform(code, filename, ctx) {
|
|
|
213499
213504
|
}
|
|
213500
213505
|
const pathResolver = createTsResolve(filename, ctx.loaderConfig.debug);
|
|
213501
213506
|
const rewrittenCode = pathResolver && !filename.includes("node_modules") ? rewriteImports(code, filename, pathResolver, ctx.loaderConfig.debug) : code;
|
|
213507
|
+
if (JS_EXTS.includes(ext)) {
|
|
213508
|
+
return {
|
|
213509
|
+
code: rewrittenCode,
|
|
213510
|
+
map: void 0,
|
|
213511
|
+
format: ctx.format,
|
|
213512
|
+
continue: opts.continue === true
|
|
213513
|
+
};
|
|
213514
|
+
}
|
|
213502
213515
|
if (ctx.loaderConfig.debug) {
|
|
213503
213516
|
console.log(`[loader-ts] transforming ${filename}`);
|
|
213504
213517
|
if (!pathResolver) {
|
package/dist/index.js
CHANGED
|
@@ -213381,8 +213381,11 @@ var nearestConfigCache = /* @__PURE__ */ new Map();
|
|
|
213381
213381
|
var rootConfigPath = null;
|
|
213382
213382
|
function findRootTsconfig() {
|
|
213383
213383
|
if (rootConfigPath !== null) return rootConfigPath;
|
|
213384
|
-
const
|
|
213385
|
-
|
|
213384
|
+
const candidates = [
|
|
213385
|
+
path.join(process.cwd(), "tsconfig.json"),
|
|
213386
|
+
path.join(process.cwd(), "tsconfig.base.json")
|
|
213387
|
+
];
|
|
213388
|
+
rootConfigPath = candidates.find((c) => import_typescript.default.sys.fileExists(c)) || null;
|
|
213386
213389
|
return rootConfigPath;
|
|
213387
213390
|
}
|
|
213388
213391
|
function findNearestTsconfig(start) {
|
|
@@ -213483,7 +213486,9 @@ function rewriteImports(code, filename, resolve, debug = false) {
|
|
|
213483
213486
|
return full.replace(spec, normalized);
|
|
213484
213487
|
});
|
|
213485
213488
|
}
|
|
213486
|
-
var
|
|
213489
|
+
var TS_EXTS = [".ts", ".mts", ".cts"];
|
|
213490
|
+
var JS_EXTS = [".js", ".mjs", ".cjs"];
|
|
213491
|
+
var extensions = [...TS_EXTS, ...JS_EXTS];
|
|
213487
213492
|
function runTransform(code, filename, ctx) {
|
|
213488
213493
|
const ext = path.extname(filename);
|
|
213489
213494
|
if (!extensions.includes(ext)) {
|
|
@@ -213496,6 +213501,14 @@ function runTransform(code, filename, ctx) {
|
|
|
213496
213501
|
}
|
|
213497
213502
|
const pathResolver = createTsResolve(filename, ctx.loaderConfig.debug);
|
|
213498
213503
|
const rewrittenCode = pathResolver && !filename.includes("node_modules") ? rewriteImports(code, filename, pathResolver, ctx.loaderConfig.debug) : code;
|
|
213504
|
+
if (JS_EXTS.includes(ext)) {
|
|
213505
|
+
return {
|
|
213506
|
+
code: rewrittenCode,
|
|
213507
|
+
map: void 0,
|
|
213508
|
+
format: ctx.format,
|
|
213509
|
+
continue: opts.continue === true
|
|
213510
|
+
};
|
|
213511
|
+
}
|
|
213499
213512
|
if (ctx.loaderConfig.debug) {
|
|
213500
213513
|
console.log(`[loader-ts] transforming ${filename}`);
|
|
213501
213514
|
if (!pathResolver) {
|