filesystem-routing 0.2.1 → 0.3.0
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/analyze.js +33 -1
- package/dist/vite/constants.js +1 -1
- package/package.json +6 -1
package/dist/analyze.js
CHANGED
|
@@ -1,5 +1,21 @@
|
|
|
1
1
|
import fs from "node:fs";
|
|
2
|
+
import { createRequire } from "node:module";
|
|
2
3
|
import { parseSync } from "oxc-parser";
|
|
4
|
+
let tsrxParseSync;
|
|
5
|
+
function loadTsrxParser(src) {
|
|
6
|
+
if (!tsrxParseSync) {
|
|
7
|
+
try {
|
|
8
|
+
const facade = createRequire(import.meta.url)("@tsrx/oxc/parser");
|
|
9
|
+
tsrxParseSync = facade.parseSync;
|
|
10
|
+
}
|
|
11
|
+
catch (cause) {
|
|
12
|
+
throw new Error(`Cannot analyze the TSRX route module ${src}: analyzing .tsrx exports requires ` +
|
|
13
|
+
`the optional peer dependency @tsrx/oxc. Install it (npm i -D @tsrx/oxc) ` +
|
|
14
|
+
`or keep route modules in .ts/.tsx.`, { cause });
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
return tsrxParseSync;
|
|
18
|
+
}
|
|
3
19
|
/**
|
|
4
20
|
* Analyze a route module's static exports.
|
|
5
21
|
*
|
|
@@ -8,7 +24,23 @@ import { parseSync } from "oxc-parser";
|
|
|
8
24
|
* a compiler that already performs export analysis can provide it instead.
|
|
9
25
|
*/
|
|
10
26
|
export function analyzeModule(src) {
|
|
11
|
-
const
|
|
27
|
+
const source = fs.readFileSync(src, "utf-8");
|
|
28
|
+
let result;
|
|
29
|
+
if (src.endsWith(".tsrx")) {
|
|
30
|
+
const parse = loadTsrxParser(src);
|
|
31
|
+
// The TSRX facade reports most syntax errors through `result.errors` but
|
|
32
|
+
// throws on some malformed sources; normalize both into the same shape.
|
|
33
|
+
try {
|
|
34
|
+
result = parse(src, source, { lang: "tsrx" });
|
|
35
|
+
}
|
|
36
|
+
catch (cause) {
|
|
37
|
+
const message = cause instanceof Error ? cause.message : String(cause);
|
|
38
|
+
throw new SyntaxError(`Failed to parse ${src}:\n${message}`, { cause });
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
else {
|
|
42
|
+
result = parseSync(src, source, { lang: "tsx" });
|
|
43
|
+
}
|
|
12
44
|
const error = result.errors[0];
|
|
13
45
|
if (error)
|
|
14
46
|
throw new SyntaxError(`Failed to parse ${src}:\n${error.codeframe || error.message}`);
|
package/dist/vite/constants.js
CHANGED
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "filesystem-routing",
|
|
3
3
|
"description": "Router-neutral file-system routing: scans a route directory into a neutral route manifest with pluggable conventions and delivery adapters",
|
|
4
4
|
"license": "MIT",
|
|
5
|
-
"version": "0.
|
|
5
|
+
"version": "0.3.0",
|
|
6
6
|
"author": "Ryan Carniato",
|
|
7
7
|
"homepage": "https://github.com/solidjs/filesystem-routing#readme",
|
|
8
8
|
"repository": {
|
|
@@ -63,15 +63,20 @@
|
|
|
63
63
|
"radix3": "^1.1.2"
|
|
64
64
|
},
|
|
65
65
|
"peerDependencies": {
|
|
66
|
+
"@tsrx/oxc": ">=0.9.0",
|
|
66
67
|
"vite": "^6.0.0 || ^7.0.0 || ^8.0.0"
|
|
67
68
|
},
|
|
68
69
|
"peerDependenciesMeta": {
|
|
70
|
+
"@tsrx/oxc": {
|
|
71
|
+
"optional": true
|
|
72
|
+
},
|
|
69
73
|
"vite": {
|
|
70
74
|
"optional": true
|
|
71
75
|
}
|
|
72
76
|
},
|
|
73
77
|
"devDependencies": {
|
|
74
78
|
"@changesets/cli": "^2.31.1",
|
|
79
|
+
"@tsrx/oxc": "^0.9.0",
|
|
75
80
|
"@types/node": "^22.10.0",
|
|
76
81
|
"prettier": "^3.4.1",
|
|
77
82
|
"typescript": "^5.7.2",
|