@hirarijs/loader-ts 1.0.19 → 1.0.21
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 +17 -1
- package/dist/index.d.cts +0 -0
- package/dist/index.d.ts +0 -0
- package/dist/index.js +17 -1
- package/package.json +35 -35
package/dist/index.cjs
CHANGED
|
@@ -213378,6 +213378,7 @@ module.exports = __toCommonJS(index_exports);
|
|
|
213378
213378
|
var import_esbuild = require("esbuild");
|
|
213379
213379
|
var import_loader = require("@hirarijs/loader");
|
|
213380
213380
|
var import_path = __toESM(require("path"), 1);
|
|
213381
|
+
var import_url = require("url");
|
|
213381
213382
|
var import_typescript = __toESM(require_typescript(), 1);
|
|
213382
213383
|
var resolverCache = /* @__PURE__ */ new Map();
|
|
213383
213384
|
var nearestConfigCache = /* @__PURE__ */ new Map();
|
|
@@ -213475,6 +213476,11 @@ function createTsResolve(importer, debug = false) {
|
|
|
213475
213476
|
if (!tsconfigPath) return null;
|
|
213476
213477
|
return createTsResolveForConfig(tsconfigPath, debug);
|
|
213477
213478
|
}
|
|
213479
|
+
function hasTsconfigFor(importer) {
|
|
213480
|
+
const root = findRootTsconfig();
|
|
213481
|
+
if (root) return true;
|
|
213482
|
+
return Boolean(findNearestTsconfig(import_path.default.dirname(importer)));
|
|
213483
|
+
}
|
|
213478
213484
|
function rewriteImports(code, filename, resolve, debug = false) {
|
|
213479
213485
|
const importLike = /(import\s+[^'";]+?from\s+['"]([^'"]+)['"])|(import\s+['"]([^'"]+)['"])|(export\s+[^'";]+?from\s+['"]([^'"]+)['"])/g;
|
|
213480
213486
|
return code.replace(importLike, (full, _a, from1, _b, from2, _c, from3) => {
|
|
@@ -213536,7 +213542,17 @@ var plugin = {
|
|
|
213536
213542
|
extensions,
|
|
213537
213543
|
match: (filename) => {
|
|
213538
213544
|
const ext = import_path.default.extname(filename);
|
|
213539
|
-
return extensions.includes(ext);
|
|
213545
|
+
return extensions.includes(ext) && hasTsconfigFor(filename);
|
|
213546
|
+
},
|
|
213547
|
+
resolve: (specifier, importer, ctx) => {
|
|
213548
|
+
if (!importer) return null;
|
|
213549
|
+
if (specifier.startsWith("node:")) return null;
|
|
213550
|
+
const resolver = createTsResolve(importer, ctx.loaderConfig.debug);
|
|
213551
|
+
if (!resolver) return null;
|
|
213552
|
+
const resolved = resolver(specifier, importer);
|
|
213553
|
+
if (!resolved) return null;
|
|
213554
|
+
if (resolved.includes("node_modules")) return null;
|
|
213555
|
+
return { url: (0, import_url.pathToFileURL)(resolved).href, shortCircuit: true };
|
|
213540
213556
|
},
|
|
213541
213557
|
transform: runTransform
|
|
213542
213558
|
};
|
package/dist/index.d.cts
CHANGED
|
File without changes
|
package/dist/index.d.ts
CHANGED
|
File without changes
|
package/dist/index.js
CHANGED
|
@@ -213376,6 +213376,7 @@ import {
|
|
|
213376
213376
|
IMPORT_META_URL_VARIABLE
|
|
213377
213377
|
} from "@hirarijs/loader";
|
|
213378
213378
|
import path from "path";
|
|
213379
|
+
import { pathToFileURL } from "url";
|
|
213379
213380
|
var resolverCache = /* @__PURE__ */ new Map();
|
|
213380
213381
|
var nearestConfigCache = /* @__PURE__ */ new Map();
|
|
213381
213382
|
var rootConfigPath = null;
|
|
@@ -213472,6 +213473,11 @@ function createTsResolve(importer, debug = false) {
|
|
|
213472
213473
|
if (!tsconfigPath) return null;
|
|
213473
213474
|
return createTsResolveForConfig(tsconfigPath, debug);
|
|
213474
213475
|
}
|
|
213476
|
+
function hasTsconfigFor(importer) {
|
|
213477
|
+
const root = findRootTsconfig();
|
|
213478
|
+
if (root) return true;
|
|
213479
|
+
return Boolean(findNearestTsconfig(path.dirname(importer)));
|
|
213480
|
+
}
|
|
213475
213481
|
function rewriteImports(code, filename, resolve, debug = false) {
|
|
213476
213482
|
const importLike = /(import\s+[^'";]+?from\s+['"]([^'"]+)['"])|(import\s+['"]([^'"]+)['"])|(export\s+[^'";]+?from\s+['"]([^'"]+)['"])/g;
|
|
213477
213483
|
return code.replace(importLike, (full, _a, from1, _b, from2, _c, from3) => {
|
|
@@ -213533,7 +213539,17 @@ var plugin = {
|
|
|
213533
213539
|
extensions,
|
|
213534
213540
|
match: (filename) => {
|
|
213535
213541
|
const ext = path.extname(filename);
|
|
213536
|
-
return extensions.includes(ext);
|
|
213542
|
+
return extensions.includes(ext) && hasTsconfigFor(filename);
|
|
213543
|
+
},
|
|
213544
|
+
resolve: (specifier, importer, ctx) => {
|
|
213545
|
+
if (!importer) return null;
|
|
213546
|
+
if (specifier.startsWith("node:")) return null;
|
|
213547
|
+
const resolver = createTsResolve(importer, ctx.loaderConfig.debug);
|
|
213548
|
+
if (!resolver) return null;
|
|
213549
|
+
const resolved = resolver(specifier, importer);
|
|
213550
|
+
if (!resolved) return null;
|
|
213551
|
+
if (resolved.includes("node_modules")) return null;
|
|
213552
|
+
return { url: pathToFileURL(resolved).href, shortCircuit: true };
|
|
213537
213553
|
},
|
|
213538
213554
|
transform: runTransform
|
|
213539
213555
|
};
|
package/package.json
CHANGED
|
@@ -1,35 +1,35 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@hirarijs/loader-ts",
|
|
3
|
-
"version": "1.0.
|
|
4
|
-
"description": "TypeScript loader plugin for HirariJS loader",
|
|
5
|
-
"type": "module",
|
|
6
|
-
"main": "./dist/index.cjs",
|
|
7
|
-
"module": "./dist/index.js",
|
|
8
|
-
"types": "./dist/index.d.ts",
|
|
9
|
-
"exports": {
|
|
10
|
-
".": {
|
|
11
|
-
"import": "./dist/index.js",
|
|
12
|
-
"require": "./dist/index.cjs",
|
|
13
|
-
"types": "./dist/index.d.ts"
|
|
14
|
-
}
|
|
15
|
-
},
|
|
16
|
-
"files": [
|
|
17
|
-
"dist"
|
|
18
|
-
],
|
|
19
|
-
"scripts": {
|
|
20
|
-
"build": "tsup src/index.ts --format esm,cjs --dts",
|
|
21
|
-
"test": "node --test"
|
|
22
|
-
},
|
|
23
|
-
"peerDependencies": {
|
|
24
|
-
"@hirarijs/loader": "*"
|
|
25
|
-
},
|
|
26
|
-
"dependencies": {
|
|
27
|
-
"esbuild": "^0.21.5"
|
|
28
|
-
},
|
|
29
|
-
"devDependencies": {
|
|
30
|
-
"@hirarijs/loader": "workspace:*",
|
|
31
|
-
"@types/node": "^25.0.3",
|
|
32
|
-
"tsup": "^8.0.1",
|
|
33
|
-
"typescript": "^5.3.3"
|
|
34
|
-
}
|
|
35
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "@hirarijs/loader-ts",
|
|
3
|
+
"version": "1.0.21",
|
|
4
|
+
"description": "TypeScript loader plugin for HirariJS loader",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "./dist/index.cjs",
|
|
7
|
+
"module": "./dist/index.js",
|
|
8
|
+
"types": "./dist/index.d.ts",
|
|
9
|
+
"exports": {
|
|
10
|
+
".": {
|
|
11
|
+
"import": "./dist/index.js",
|
|
12
|
+
"require": "./dist/index.cjs",
|
|
13
|
+
"types": "./dist/index.d.ts"
|
|
14
|
+
}
|
|
15
|
+
},
|
|
16
|
+
"files": [
|
|
17
|
+
"dist"
|
|
18
|
+
],
|
|
19
|
+
"scripts": {
|
|
20
|
+
"build": "tsup src/index.ts --format esm,cjs --dts",
|
|
21
|
+
"test": "node --test"
|
|
22
|
+
},
|
|
23
|
+
"peerDependencies": {
|
|
24
|
+
"@hirarijs/loader": "*"
|
|
25
|
+
},
|
|
26
|
+
"dependencies": {
|
|
27
|
+
"esbuild": "^0.21.5"
|
|
28
|
+
},
|
|
29
|
+
"devDependencies": {
|
|
30
|
+
"@hirarijs/loader": "workspace:*",
|
|
31
|
+
"@types/node": "^25.0.3",
|
|
32
|
+
"tsup": "^8.0.1",
|
|
33
|
+
"typescript": "^5.3.3"
|
|
34
|
+
}
|
|
35
|
+
}
|