@samadhi1311/router 1.0.4 → 1.0.5
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 +16 -3
- package/dist/index.js +16 -3
- package/package.json +4 -1
package/dist/index.cjs
CHANGED
|
@@ -35,9 +35,10 @@ __export(index_exports, {
|
|
|
35
35
|
module.exports = __toCommonJS(index_exports);
|
|
36
36
|
var import_fs = __toESM(require("fs"), 1);
|
|
37
37
|
var import_path = __toESM(require("path"), 1);
|
|
38
|
+
var import_esbuild = require("esbuild");
|
|
38
39
|
function router(options = {}) {
|
|
39
40
|
let root;
|
|
40
|
-
const appDir = options.appDir || "
|
|
41
|
+
const appDir = options.appDir || "src";
|
|
41
42
|
const virtualModuleId = "virtual:router";
|
|
42
43
|
const resolvedVirtualModuleId = "\0" + virtualModuleId;
|
|
43
44
|
const resolveFile = (p) => import_path.default.posix.join(root.replace(/\\/g, "/"), appDir, p);
|
|
@@ -180,8 +181,20 @@ ${routeConfigs}];
|
|
|
180
181
|
if (id === resolvedVirtualModuleId) {
|
|
181
182
|
const routes = scanDirectory("");
|
|
182
183
|
return {
|
|
183
|
-
code: generateRouteCode(routes)
|
|
184
|
-
|
|
184
|
+
code: generateRouteCode(routes)
|
|
185
|
+
};
|
|
186
|
+
}
|
|
187
|
+
},
|
|
188
|
+
async transform(code, id) {
|
|
189
|
+
if (id === resolvedVirtualModuleId) {
|
|
190
|
+
const result = await (0, import_esbuild.transform)(code, {
|
|
191
|
+
loader: "tsx",
|
|
192
|
+
jsx: "automatic",
|
|
193
|
+
target: "esnext"
|
|
194
|
+
});
|
|
195
|
+
return {
|
|
196
|
+
code: result.code,
|
|
197
|
+
map: null
|
|
185
198
|
};
|
|
186
199
|
}
|
|
187
200
|
},
|
package/dist/index.js
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
// src/index.ts
|
|
2
2
|
import fs from "fs";
|
|
3
3
|
import path from "path";
|
|
4
|
+
import { transform } from "esbuild";
|
|
4
5
|
function router(options = {}) {
|
|
5
6
|
let root;
|
|
6
|
-
const appDir = options.appDir || "
|
|
7
|
+
const appDir = options.appDir || "src";
|
|
7
8
|
const virtualModuleId = "virtual:router";
|
|
8
9
|
const resolvedVirtualModuleId = "\0" + virtualModuleId;
|
|
9
10
|
const resolveFile = (p) => path.posix.join(root.replace(/\\/g, "/"), appDir, p);
|
|
@@ -146,8 +147,20 @@ ${routeConfigs}];
|
|
|
146
147
|
if (id === resolvedVirtualModuleId) {
|
|
147
148
|
const routes = scanDirectory("");
|
|
148
149
|
return {
|
|
149
|
-
code: generateRouteCode(routes)
|
|
150
|
-
|
|
150
|
+
code: generateRouteCode(routes)
|
|
151
|
+
};
|
|
152
|
+
}
|
|
153
|
+
},
|
|
154
|
+
async transform(code, id) {
|
|
155
|
+
if (id === resolvedVirtualModuleId) {
|
|
156
|
+
const result = await transform(code, {
|
|
157
|
+
loader: "tsx",
|
|
158
|
+
jsx: "automatic",
|
|
159
|
+
target: "esnext"
|
|
160
|
+
});
|
|
161
|
+
return {
|
|
162
|
+
code: result.code,
|
|
163
|
+
map: null
|
|
151
164
|
};
|
|
152
165
|
}
|
|
153
166
|
},
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@samadhi1311/router",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.5",
|
|
4
4
|
"description": "A simple router for Vite inspired by Next.JS App Router",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "Samadhi Gunasinghe",
|
|
@@ -51,5 +51,8 @@
|
|
|
51
51
|
"devDependencies": {
|
|
52
52
|
"tsup": "^8.5.1",
|
|
53
53
|
"typescript": "^5.9.3"
|
|
54
|
+
},
|
|
55
|
+
"dependencies": {
|
|
56
|
+
"esbuild": "^0.27.2"
|
|
54
57
|
}
|
|
55
58
|
}
|