@hirarijs/loader-ts 1.0.14 → 1.0.16
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 +29 -3
- package/dist/index.js +29 -3
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -213426,8 +213426,30 @@ function createTsResolveForConfig(tsconfigPath, debug = false) {
|
|
|
213426
213426
|
};
|
|
213427
213427
|
const resolver = (specifier, importer) => {
|
|
213428
213428
|
const result = import_typescript.default.resolveModuleName(specifier, importer, options, host);
|
|
213429
|
-
|
|
213430
|
-
if (resolved &&
|
|
213429
|
+
let resolved = result.resolvedModule?.resolvedFileName;
|
|
213430
|
+
if (resolved && resolved.endsWith(".d.ts")) {
|
|
213431
|
+
const candidates = [
|
|
213432
|
+
resolved.replace(/\.d\.ts$/, ".ts"),
|
|
213433
|
+
resolved.replace(/\.d\.ts$/, ".tsx"),
|
|
213434
|
+
resolved.replace(/\.d\.ts$/, ".js"),
|
|
213435
|
+
resolved.replace(/\.d\.ts$/, ".mjs"),
|
|
213436
|
+
resolved.replace(/\.d\.ts$/, ".cts"),
|
|
213437
|
+
resolved.replace(/\.d\.ts$/, ".cjs")
|
|
213438
|
+
];
|
|
213439
|
+
if (resolved.includes(`${import_path.default.sep}dist${import_path.default.sep}`)) {
|
|
213440
|
+
const srcBase = resolved.replace(`${import_path.default.sep}dist${import_path.default.sep}`, `${import_path.default.sep}src${import_path.default.sep}`);
|
|
213441
|
+
candidates.unshift(
|
|
213442
|
+
srcBase.replace(/\.d\.ts$/, ".ts"),
|
|
213443
|
+
srcBase.replace(/\.d\.ts$/, ".tsx"),
|
|
213444
|
+
srcBase.replace(/\.d\.ts$/, ".js"),
|
|
213445
|
+
srcBase.replace(/\.d\.ts$/, ".mjs"),
|
|
213446
|
+
srcBase.replace(/\.d\.ts$/, ".cts"),
|
|
213447
|
+
srcBase.replace(/\.d\.ts$/, ".cjs")
|
|
213448
|
+
);
|
|
213449
|
+
}
|
|
213450
|
+
resolved = candidates.find((f) => import_typescript.default.sys.fileExists(f)) || resolved;
|
|
213451
|
+
}
|
|
213452
|
+
if (resolved) {
|
|
213431
213453
|
if (debug) {
|
|
213432
213454
|
console.log(`[loader-ts] resolved ${specifier} -> ${resolved}`);
|
|
213433
213455
|
}
|
|
@@ -213464,8 +213486,12 @@ function rewriteImports(code, filename, resolve, debug = false) {
|
|
|
213464
213486
|
return full.replace(spec, normalized);
|
|
213465
213487
|
});
|
|
213466
213488
|
}
|
|
213467
|
-
var extensions = [".ts", ".mts", ".cts"
|
|
213489
|
+
var extensions = [".ts", ".mts", ".cts"];
|
|
213468
213490
|
function runTransform(code, filename, ctx) {
|
|
213491
|
+
const ext = import_path.default.extname(filename);
|
|
213492
|
+
if (!extensions.includes(ext)) {
|
|
213493
|
+
return { code, continue: true };
|
|
213494
|
+
}
|
|
213469
213495
|
const opts = ctx.loaderConfig.pluginOptions?.["@hirarijs/loader-ts"] || {};
|
|
213470
213496
|
const ignoreNm = opts.ignoreNodeModules !== false && opts.allowNodeModules !== true;
|
|
213471
213497
|
if (ignoreNm && filename.includes("node_modules")) {
|
package/dist/index.js
CHANGED
|
@@ -213423,8 +213423,30 @@ function createTsResolveForConfig(tsconfigPath, debug = false) {
|
|
|
213423
213423
|
};
|
|
213424
213424
|
const resolver = (specifier, importer) => {
|
|
213425
213425
|
const result = import_typescript.default.resolveModuleName(specifier, importer, options, host);
|
|
213426
|
-
|
|
213427
|
-
if (resolved &&
|
|
213426
|
+
let resolved = result.resolvedModule?.resolvedFileName;
|
|
213427
|
+
if (resolved && resolved.endsWith(".d.ts")) {
|
|
213428
|
+
const candidates = [
|
|
213429
|
+
resolved.replace(/\.d\.ts$/, ".ts"),
|
|
213430
|
+
resolved.replace(/\.d\.ts$/, ".tsx"),
|
|
213431
|
+
resolved.replace(/\.d\.ts$/, ".js"),
|
|
213432
|
+
resolved.replace(/\.d\.ts$/, ".mjs"),
|
|
213433
|
+
resolved.replace(/\.d\.ts$/, ".cts"),
|
|
213434
|
+
resolved.replace(/\.d\.ts$/, ".cjs")
|
|
213435
|
+
];
|
|
213436
|
+
if (resolved.includes(`${path.sep}dist${path.sep}`)) {
|
|
213437
|
+
const srcBase = resolved.replace(`${path.sep}dist${path.sep}`, `${path.sep}src${path.sep}`);
|
|
213438
|
+
candidates.unshift(
|
|
213439
|
+
srcBase.replace(/\.d\.ts$/, ".ts"),
|
|
213440
|
+
srcBase.replace(/\.d\.ts$/, ".tsx"),
|
|
213441
|
+
srcBase.replace(/\.d\.ts$/, ".js"),
|
|
213442
|
+
srcBase.replace(/\.d\.ts$/, ".mjs"),
|
|
213443
|
+
srcBase.replace(/\.d\.ts$/, ".cts"),
|
|
213444
|
+
srcBase.replace(/\.d\.ts$/, ".cjs")
|
|
213445
|
+
);
|
|
213446
|
+
}
|
|
213447
|
+
resolved = candidates.find((f) => import_typescript.default.sys.fileExists(f)) || resolved;
|
|
213448
|
+
}
|
|
213449
|
+
if (resolved) {
|
|
213428
213450
|
if (debug) {
|
|
213429
213451
|
console.log(`[loader-ts] resolved ${specifier} -> ${resolved}`);
|
|
213430
213452
|
}
|
|
@@ -213461,8 +213483,12 @@ function rewriteImports(code, filename, resolve, debug = false) {
|
|
|
213461
213483
|
return full.replace(spec, normalized);
|
|
213462
213484
|
});
|
|
213463
213485
|
}
|
|
213464
|
-
var extensions = [".ts", ".mts", ".cts"
|
|
213486
|
+
var extensions = [".ts", ".mts", ".cts"];
|
|
213465
213487
|
function runTransform(code, filename, ctx) {
|
|
213488
|
+
const ext = path.extname(filename);
|
|
213489
|
+
if (!extensions.includes(ext)) {
|
|
213490
|
+
return { code, continue: true };
|
|
213491
|
+
}
|
|
213466
213492
|
const opts = ctx.loaderConfig.pluginOptions?.["@hirarijs/loader-ts"] || {};
|
|
213467
213493
|
const ignoreNm = opts.ignoreNodeModules !== false && opts.allowNodeModules !== true;
|
|
213468
213494
|
if (ignoreNm && filename.includes("node_modules")) {
|