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
- this.pagesDir = path4.resolve(baseDir, config.pagesDir || "pages");
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 files = scanDirectory(this.pagesDir, extensions);
162
- this.routes = files.map((filePath) => {
163
- const pattern = filePathToPattern(filePath, this.pagesDir);
164
- const { regex, params } = patternToRegex(pattern);
165
- const layouts = config.layouts !== false ? resolveLayoutChain(filePath, this.pagesDir) : [];
166
- return {
167
- pattern,
168
- regex,
169
- params,
170
- filePath,
171
- isDynamic: params.length > 0,
172
- layout: layouts.length > 0 ? layouts[layouts.length - 1] : undefined
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
@@ -8,7 +8,7 @@ import {
8
8
  startWatchMode,
9
9
  stxPlugin,
10
10
  watchAndBuild
11
- } from "./chunk-qrdapdgw.js";
11
+ } from "./chunk-b4s904jx.js";
12
12
  import"./chunk-2mx7fq49.js";
13
13
  export {
14
14
  watchAndBuild,
package/dist/preload.js CHANGED
@@ -1,7 +1,7 @@
1
1
  // @bun
2
2
  import {
3
3
  src_default
4
- } from "./chunk-qrdapdgw.js";
4
+ } from "./chunk-b4s904jx.js";
5
5
  import"./chunk-2mx7fq49.js";
6
6
 
7
7
  // src/preload.ts
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-nyzhqegd.js");
8960
- const pagesDir = patterns[0]?.replace(/\/$/, "") || "pages";
8961
- const router = new Router(process19.cwd(), { pagesDir });
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.42",
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.42"
75
+ "@stacksjs/stx": "0.2.47"
76
76
  }
77
77
  }