@hirarijs/loader-ts 1.0.5 → 1.0.7

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 CHANGED
@@ -213381,6 +213381,13 @@ var import_path = __toESM(require("path"), 1);
213381
213381
  var import_typescript = __toESM(require_typescript(), 1);
213382
213382
  var resolverCache = /* @__PURE__ */ new Map();
213383
213383
  var nearestConfigCache = /* @__PURE__ */ new Map();
213384
+ var rootConfigPath = null;
213385
+ function findRootTsconfig() {
213386
+ if (rootConfigPath !== null) return rootConfigPath;
213387
+ const candidate = import_path.default.join(process.cwd(), "tsconfig.json");
213388
+ rootConfigPath = import_typescript.default.sys.fileExists(candidate) ? candidate : null;
213389
+ return rootConfigPath;
213390
+ }
213384
213391
  function findNearestTsconfig(start) {
213385
213392
  if (nearestConfigCache.has(start)) return nearestConfigCache.get(start);
213386
213393
  let dir = start;
@@ -213435,7 +213442,8 @@ function createTsResolveForConfig(tsconfigPath, debug = false) {
213435
213442
  return resolver;
213436
213443
  }
213437
213444
  function createTsResolve(importer, debug = false) {
213438
- const tsconfigPath = findNearestTsconfig(import_path.default.dirname(importer));
213445
+ const root = findRootTsconfig();
213446
+ const tsconfigPath = root ?? findNearestTsconfig(import_path.default.dirname(importer));
213439
213447
  if (!tsconfigPath) return null;
213440
213448
  return createTsResolveForConfig(tsconfigPath, debug);
213441
213449
  }
@@ -213456,7 +213464,7 @@ function rewriteImports(code, filename, resolve, debug = false) {
213456
213464
  return full.replace(spec, normalized);
213457
213465
  });
213458
213466
  }
213459
- var extensions = [".ts", ".mts", ".cts"];
213467
+ var extensions = [".ts", ".mts", ".cts", ".js", ".mjs", ".cjs"];
213460
213468
  function runTransform(code, filename, ctx) {
213461
213469
  const pathResolver = createTsResolve(filename, ctx.loaderConfig.debug);
213462
213470
  const rewrittenCode = pathResolver && !filename.includes("node_modules") ? rewriteImports(code, filename, pathResolver, ctx.loaderConfig.debug) : code;
@@ -213486,7 +213494,11 @@ function runTransform(code, filename, ctx) {
213486
213494
  var plugin = {
213487
213495
  name: "@hirarijs/loader-ts",
213488
213496
  extensions,
213489
- match: (filename) => extensions.some((ext) => filename.endsWith(ext)),
213497
+ match: (filename) => {
213498
+ const ext = import_path.default.extname(filename);
213499
+ if (!ext) return true;
213500
+ return extensions.includes(ext);
213501
+ },
213490
213502
  transform: runTransform
213491
213503
  };
213492
213504
  var index_default = plugin;
package/dist/index.js CHANGED
@@ -213378,6 +213378,13 @@ import {
213378
213378
  import path from "path";
213379
213379
  var resolverCache = /* @__PURE__ */ new Map();
213380
213380
  var nearestConfigCache = /* @__PURE__ */ new Map();
213381
+ var rootConfigPath = null;
213382
+ function findRootTsconfig() {
213383
+ if (rootConfigPath !== null) return rootConfigPath;
213384
+ const candidate = path.join(process.cwd(), "tsconfig.json");
213385
+ rootConfigPath = import_typescript.default.sys.fileExists(candidate) ? candidate : null;
213386
+ return rootConfigPath;
213387
+ }
213381
213388
  function findNearestTsconfig(start) {
213382
213389
  if (nearestConfigCache.has(start)) return nearestConfigCache.get(start);
213383
213390
  let dir = start;
@@ -213432,7 +213439,8 @@ function createTsResolveForConfig(tsconfigPath, debug = false) {
213432
213439
  return resolver;
213433
213440
  }
213434
213441
  function createTsResolve(importer, debug = false) {
213435
- const tsconfigPath = findNearestTsconfig(path.dirname(importer));
213442
+ const root = findRootTsconfig();
213443
+ const tsconfigPath = root ?? findNearestTsconfig(path.dirname(importer));
213436
213444
  if (!tsconfigPath) return null;
213437
213445
  return createTsResolveForConfig(tsconfigPath, debug);
213438
213446
  }
@@ -213453,7 +213461,7 @@ function rewriteImports(code, filename, resolve, debug = false) {
213453
213461
  return full.replace(spec, normalized);
213454
213462
  });
213455
213463
  }
213456
- var extensions = [".ts", ".mts", ".cts"];
213464
+ var extensions = [".ts", ".mts", ".cts", ".js", ".mjs", ".cjs"];
213457
213465
  function runTransform(code, filename, ctx) {
213458
213466
  const pathResolver = createTsResolve(filename, ctx.loaderConfig.debug);
213459
213467
  const rewrittenCode = pathResolver && !filename.includes("node_modules") ? rewriteImports(code, filename, pathResolver, ctx.loaderConfig.debug) : code;
@@ -213483,7 +213491,11 @@ function runTransform(code, filename, ctx) {
213483
213491
  var plugin = {
213484
213492
  name: "@hirarijs/loader-ts",
213485
213493
  extensions,
213486
- match: (filename) => extensions.some((ext) => filename.endsWith(ext)),
213494
+ match: (filename) => {
213495
+ const ext = path.extname(filename);
213496
+ if (!ext) return true;
213497
+ return extensions.includes(ext);
213498
+ },
213487
213499
  transform: runTransform
213488
213500
  };
213489
213501
  var index_default = plugin;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hirarijs/loader-ts",
3
- "version": "1.0.5",
3
+ "version": "1.0.7",
4
4
  "description": "TypeScript loader plugin for HirariJS loader",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",
@@ -28,6 +28,7 @@
28
28
  },
29
29
  "devDependencies": {
30
30
  "@hirarijs/loader": "workspace:*",
31
+ "@types/node": "^25.0.3",
31
32
  "tsup": "^8.0.1",
32
33
  "typescript": "^5.3.3"
33
34
  }