bun-plugin-stx 0.2.42 → 0.2.47
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.
|
@@ -310,6 +310,8 @@ function stxPlugin(userOptions) {
|
|
|
310
310
|
build.onResolve({ filter: /^\// }, (args) => {
|
|
311
311
|
if (args.path.startsWith("//"))
|
|
312
312
|
return null;
|
|
313
|
+
if (!args.importer)
|
|
314
|
+
return null;
|
|
313
315
|
return { external: true, path: args.path };
|
|
314
316
|
});
|
|
315
317
|
build.onLoad({ filter: /\.md$/ }, async (args) => {
|
|
@@ -153,25 +153,35 @@ function scanDirectory(dir, extensions) {
|
|
|
153
153
|
class Router {
|
|
154
154
|
routes;
|
|
155
155
|
pagesDir;
|
|
156
|
+
pagesDirs;
|
|
156
157
|
config;
|
|
157
158
|
constructor(baseDir, config = {}) {
|
|
158
159
|
this.config = config;
|
|
159
|
-
|
|
160
|
+
const rawDirs = config.pagesDirs && config.pagesDirs.length > 0 ? config.pagesDirs : [config.pagesDir || "pages"];
|
|
161
|
+
this.pagesDirs = rawDirs.map((d) => path4.resolve(baseDir, d));
|
|
162
|
+
this.pagesDir = this.pagesDirs[0];
|
|
160
163
|
const extensions = config.extensions || [".stx"];
|
|
161
|
-
const
|
|
162
|
-
this.routes =
|
|
163
|
-
|
|
164
|
-
const
|
|
165
|
-
const
|
|
166
|
-
|
|
167
|
-
pattern
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
164
|
+
const seenPatterns = new Set;
|
|
165
|
+
this.routes = [];
|
|
166
|
+
for (const dir of this.pagesDirs) {
|
|
167
|
+
const files = scanDirectory(dir, extensions);
|
|
168
|
+
for (const filePath of files) {
|
|
169
|
+
const pattern = filePathToPattern(filePath, dir);
|
|
170
|
+
if (seenPatterns.has(pattern))
|
|
171
|
+
continue;
|
|
172
|
+
seenPatterns.add(pattern);
|
|
173
|
+
const { regex, params } = patternToRegex(pattern);
|
|
174
|
+
const layouts = config.layouts !== false ? resolveLayoutChain(filePath, dir) : [];
|
|
175
|
+
this.routes.push({
|
|
176
|
+
pattern,
|
|
177
|
+
regex,
|
|
178
|
+
params,
|
|
179
|
+
filePath,
|
|
180
|
+
isDynamic: params.length > 0,
|
|
181
|
+
layout: layouts.length > 0 ? layouts[layouts.length - 1] : undefined
|
|
182
|
+
});
|
|
183
|
+
}
|
|
184
|
+
}
|
|
175
185
|
this.routes.sort((a, b) => {
|
|
176
186
|
if (!a.isDynamic && b.isDynamic)
|
|
177
187
|
return -1;
|
package/dist/index.js
CHANGED
package/dist/preload.js
CHANGED
package/dist/serve.js
CHANGED
|
@@ -8956,9 +8956,9 @@ After installing: bun add bun-plugin-stx`);
|
|
|
8956
8956
|
pageMiddlewarePatterns.length = 0;
|
|
8957
8957
|
await Promise.all(files.map((f) => detectPageMiddleware(f)));
|
|
8958
8958
|
try {
|
|
8959
|
-
const { Router } = await import("./chunk-
|
|
8960
|
-
const
|
|
8961
|
-
const router = new Router(process19.cwd(), {
|
|
8959
|
+
const { Router } = await import("./chunk-mf3agv0w.js");
|
|
8960
|
+
const pagesDirs = patterns.map((p) => p.replace(/\/$/, "")).filter(Boolean);
|
|
8961
|
+
const router = new Router(process19.cwd(), { pagesDirs });
|
|
8962
8962
|
console.log(`[stx] Generated ${router.routes.length} routes \u2192 .stx/routes.ts`);
|
|
8963
8963
|
} catch (e) {}
|
|
8964
8964
|
return files;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "bun-plugin-stx",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.2.
|
|
4
|
+
"version": "0.2.47",
|
|
5
5
|
"description": "A Bun plugin that allows for using Laravel Blade-like syntax.",
|
|
6
6
|
"author": "Chris Breuer <chris@stacksjs.org>",
|
|
7
7
|
"license": "MIT",
|
|
@@ -72,6 +72,6 @@
|
|
|
72
72
|
"typecheck": "bun tsc --noEmit"
|
|
73
73
|
},
|
|
74
74
|
"dependencies": {
|
|
75
|
-
"@stacksjs/stx": "0.2.
|
|
75
|
+
"@stacksjs/stx": "0.2.47"
|
|
76
76
|
}
|
|
77
77
|
}
|