@hirarijs/loader-ts 1.0.15 → 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 +20 -3
- package/dist/index.js +20 -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,8 +213489,14 @@ 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) {
|
|
213496
|
+
const ext = import_path.default.extname(filename);
|
|
213497
|
+
if (!extensions.includes(ext)) {
|
|
213498
|
+
return { code, continue: true };
|
|
213499
|
+
}
|
|
213491
213500
|
const opts = ctx.loaderConfig.pluginOptions?.["@hirarijs/loader-ts"] || {};
|
|
213492
213501
|
const ignoreNm = opts.ignoreNodeModules !== false && opts.allowNodeModules !== true;
|
|
213493
213502
|
if (ignoreNm && filename.includes("node_modules")) {
|
|
@@ -213495,6 +213504,14 @@ function runTransform(code, filename, ctx) {
|
|
|
213495
213504
|
}
|
|
213496
213505
|
const pathResolver = createTsResolve(filename, ctx.loaderConfig.debug);
|
|
213497
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
|
+
}
|
|
213498
213515
|
if (ctx.loaderConfig.debug) {
|
|
213499
213516
|
console.log(`[loader-ts] transforming ${filename}`);
|
|
213500
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,8 +213486,14 @@ 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) {
|
|
213493
|
+
const ext = path.extname(filename);
|
|
213494
|
+
if (!extensions.includes(ext)) {
|
|
213495
|
+
return { code, continue: true };
|
|
213496
|
+
}
|
|
213488
213497
|
const opts = ctx.loaderConfig.pluginOptions?.["@hirarijs/loader-ts"] || {};
|
|
213489
213498
|
const ignoreNm = opts.ignoreNodeModules !== false && opts.allowNodeModules !== true;
|
|
213490
213499
|
if (ignoreNm && filename.includes("node_modules")) {
|
|
@@ -213492,6 +213501,14 @@ function runTransform(code, filename, ctx) {
|
|
|
213492
213501
|
}
|
|
213493
213502
|
const pathResolver = createTsResolve(filename, ctx.loaderConfig.debug);
|
|
213494
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
|
+
}
|
|
213495
213512
|
if (ctx.loaderConfig.debug) {
|
|
213496
213513
|
console.log(`[loader-ts] transforming ${filename}`);
|
|
213497
213514
|
if (!pathResolver) {
|