From 1c103fbf3299f08bce9f48eb053cc20f64b07652 Mon Sep 17 00:00:00 2001 From: Claude Date: Fri, 26 Jun 2026 23:40:59 +0000 Subject: [PATCH 1/3] chore: make fsRoutes dir and adapter required The experimental `fsRoutes` plugin option previously defaulted `dir` to `"./src/pages"` and `adapter` to the built-in `nextRoutes()` convention. Require both fields so users are explicit about the routes directory and the file-name convention rather than relying on opinionated defaults. - Make `dir` and `adapter` required in `FsRoutesConfig` - Drop the default resolution in the plugin and always wire the adapter import into the synthesized entries module - Add explicit `adapter` modules to the example and e2e fixture - Update API and File-System Routing docs Co-Authored-By: Claude Opus 4.8 Claude-Session: https://claude.ai/code/session_019KZaV9B4HmtACBqoPdL8qK --- .../docs/src/pages/api/FunstackStatic.mdx | 9 ++--- .../src/pages/learn/FileSystemRouting.mdx | 14 ++++++-- packages/example-fs-routing/src/adapter.ts | 5 +++ packages/example-fs-routing/vite.config.ts | 1 + .../e2e/fixture-fs-routing/src/adapter.ts | 3 ++ .../e2e/fixture-fs-routing/vite.config.ts | 1 + packages/static/src/plugin/index.ts | 33 +++++++++---------- 7 files changed, 42 insertions(+), 24 deletions(-) create mode 100644 packages/example-fs-routing/src/adapter.ts create mode 100644 packages/static/e2e/fixture-fs-routing/src/adapter.ts diff --git a/packages/docs/src/pages/api/FunstackStatic.mdx b/packages/docs/src/pages/api/FunstackStatic.mdx index 8c5aeac..653cf9a 100644 --- a/packages/docs/src/pages/api/FunstackStatic.mdx +++ b/packages/docs/src/pages/api/FunstackStatic.mdx @@ -72,6 +72,7 @@ export default defineConfig({ fsRoutes: { dir: "./src/pages", root: "./src/root.tsx", + adapter: "./src/adapter.ts", }, }), react(), @@ -203,16 +204,16 @@ funstackStatic({ fsRoutes: { dir: "./src/pages", root: "./src/root.tsx", - adapter: "./src/my-adapter.ts", // optional + adapter: "./src/adapter.ts", }, }); ``` -`FsRoutesConfig` fields: +`FsRoutesConfig` fields (all required — you must be explicit about each): -- **`dir`** (optional, default `"./src/pages"`) — directory scanned for route files, relative to the Vite root. +- **`dir`** (required) — directory scanned for route files, relative to the Vite root. Commonly `"./src/pages"`. - **`root`** (required) — path to the root (HTML shell) component module. -- **`adapter`** (optional) — path to a module that `export default`s an `FsRoutesAdapter`. Defaults to the built-in Next.js-like adapter (`nextRoutes()` from `@funstack/static/fs-routes`). +- **`adapter`** (required) — path to a module that `export default`s an `FsRoutesAdapter`. To use the built-in Next.js-like convention, point this at a module that re-exports `nextRoutes()` from `@funstack/static/fs-routes`. Enable [`ssr`](#ssr-optional) alongside `fsRoutes` — it is required for the dev server to render pages and recommended in general. diff --git a/packages/docs/src/pages/learn/FileSystemRouting.mdx b/packages/docs/src/pages/learn/FileSystemRouting.mdx index 4736151..e2112af 100644 --- a/packages/docs/src/pages/learn/FileSystemRouting.mdx +++ b/packages/docs/src/pages/learn/FileSystemRouting.mdx @@ -31,6 +31,7 @@ export default defineConfig({ fsRoutes: { dir: "./src/pages", root: "./src/root.tsx", + adapter: "./src/adapter.ts", }, }), react(), @@ -38,9 +39,18 @@ export default defineConfig({ }); ``` -- `dir` — the directory scanned for route files (default `./src/pages`). +All `fsRoutes` fields are required, so each choice is explicit in your config: + +- `dir` — the directory scanned for route files (commonly `./src/pages`). - `root` — the HTML shell component (`…{children}`). -- `adapter` — optional path to a custom adapter module (defaults to the built-in Next.js-like adapter). +- `adapter` — path to a module that `export default`s the adapter defining the directory / file-name convention. To use the built-in Next.js-like convention, re-export `nextRoutes()`: + +```tsx +// src/adapter.ts +import { nextRoutes } from "@funstack/static/fs-routes"; + +export default nextRoutes(); +``` `fsRoutes` is mutually exclusive with the `root` + `app` (single-entry) and `entries` (multiple entries) modes. diff --git a/packages/example-fs-routing/src/adapter.ts b/packages/example-fs-routing/src/adapter.ts new file mode 100644 index 0000000..59515a0 --- /dev/null +++ b/packages/example-fs-routing/src/adapter.ts @@ -0,0 +1,5 @@ +import { nextRoutes } from "@funstack/static/fs-routes"; + +// The built-in Next.js-like convention: `page.tsx` / `layout.tsx` files mapped +// to routes. Pass it explicitly so the convention is visible in the config. +export default nextRoutes(); diff --git a/packages/example-fs-routing/vite.config.ts b/packages/example-fs-routing/vite.config.ts index 998bd97..b58a9c5 100644 --- a/packages/example-fs-routing/vite.config.ts +++ b/packages/example-fs-routing/vite.config.ts @@ -14,6 +14,7 @@ export default defineConfig({ fsRoutes: { dir: "./src/pages", root: "./src/root.tsx", + adapter: "./src/adapter.ts", }, }), react(), diff --git a/packages/static/e2e/fixture-fs-routing/src/adapter.ts b/packages/static/e2e/fixture-fs-routing/src/adapter.ts new file mode 100644 index 0000000..7b665c4 --- /dev/null +++ b/packages/static/e2e/fixture-fs-routing/src/adapter.ts @@ -0,0 +1,3 @@ +import { nextRoutes } from "@funstack/static/fs-routes"; + +export default nextRoutes(); diff --git a/packages/static/e2e/fixture-fs-routing/vite.config.ts b/packages/static/e2e/fixture-fs-routing/vite.config.ts index 9c027db..e1d3dde 100644 --- a/packages/static/e2e/fixture-fs-routing/vite.config.ts +++ b/packages/static/e2e/fixture-fs-routing/vite.config.ts @@ -10,6 +10,7 @@ export default defineConfig({ fsRoutes: { dir: "./src/pages", root: "./src/root.tsx", + adapter: "./src/adapter.ts", }, }), react(), diff --git a/packages/static/src/plugin/index.ts b/packages/static/src/plugin/index.ts index 9e3fc7d..a625884 100644 --- a/packages/static/src/plugin/index.ts +++ b/packages/static/src/plugin/index.ts @@ -96,9 +96,9 @@ export interface FsRoutesConfig { /** * Directory containing route files, relative to the Vite root. * - * @default "./src/pages" + * Commonly `"./src/pages"`. */ - dir?: string; + dir: string; /** * Path to the root (HTML shell) component module. * The file should `export default` a React component that renders the whole @@ -109,10 +109,10 @@ export interface FsRoutesConfig { * Path to a module that `export default`s an `FsRoutesAdapter`, which defines * the directory / file-name convention. * - * Defaults to the built-in Next.js-like adapter (`nextRoutes()` from - * `@funstack/static/fs-routes`). + * To use the built-in Next.js-like convention, point this at a module that + * `export default`s `nextRoutes()` from `@funstack/static/fs-routes`. */ - adapter?: string; + adapter: string; } interface FsRoutesOptions { @@ -159,7 +159,7 @@ export default function funstackStatic( let resolvedBuildEntry: string | undefined; // Resolved configuration for file-system routing (fsRoutes mode). let resolvedFsRoutes: - | { root: string; adapter: string | undefined; globBase: string } + | { root: string; adapter: string; globBase: string } | undefined; // Determine which entry mode the user selected. @@ -198,20 +198,21 @@ export default function funstackStatic( configResolved(config) { if (isFsRoutes) { const fsRoutes = options.fsRoutes; - const dir = fsRoutes.dir ?? "./src/pages"; const resolvedRoot = normalizePath( path.resolve(config.root, fsRoutes.root), ); - const resolvedDir = normalizePath(path.resolve(config.root, dir)); + const resolvedDir = normalizePath( + path.resolve(config.root, fsRoutes.dir), + ); // Glob patterns in generated virtual modules must be root-relative // (a virtual module has no real path to resolve "./" against). const relativeDir = normalizePath( path.relative(config.root, resolvedDir), ); const globBase = `/${relativeDir.replace(/^\.?\/?/, "").replace(/\/$/, "")}`; - const adapter = fsRoutes.adapter - ? normalizePath(path.resolve(config.root, fsRoutes.adapter)) - : undefined; + const adapter = normalizePath( + path.resolve(config.root, fsRoutes.adapter), + ); resolvedFsRoutes = { root: resolvedRoot, adapter, globBase }; } else if (isMultiEntry) { resolvedEntriesModule = normalizePath( @@ -294,19 +295,15 @@ export default function funstackStatic( const globPattern = `${globBase}/**/*.{tsx,jsx}`; const lines = [ `import Root from "${root}";`, + `import adapter from "${adapter}";`, `import { createFsRoutesEntries } from "@funstack/static/fs-routes";`, - ]; - if (adapter) { - lines.push(`import adapter from "${adapter}";`); - } - lines.push( `const modules = import.meta.glob(${JSON.stringify(globPattern)}, { eager: true });`, `export default createFsRoutesEntries({`, ` modules,`, ` root: Root,`, - ...(adapter ? [` adapter,`] : []), + ` adapter,`, `});`, - ); + ]; return lines.join("\n"); } if (isMultiEntry) { From 2eaf780932ba47bb3f196a3e666913f19238ce04 Mon Sep 17 00:00:00 2001 From: Claude Date: Fri, 26 Jun 2026 23:48:38 +0000 Subject: [PATCH 2/3] feat: add @funstack/static/fs-routes/next convenience adapter module Now that `fsRoutes.adapter` is required, provide a bundled module that `export default`s `nextRoutes()` so users can opt into the built-in Next.js-like convention without writing their own re-export file: fsRoutes: { adapter: "@funstack/static/fs-routes/next", ... } - Add the `src/fs-routes/next.ts` entry and `./fs-routes/next` package export - Let `fsRoutes.adapter` accept a bare module specifier (a package import), not just a path resolved against the Vite root - Use the convenience module in the example and e2e fixture - Update API and File-System Routing docs Co-Authored-By: Claude Opus 4.8 Claude-Session: https://claude.ai/code/session_019KZaV9B4HmtACBqoPdL8qK --- .../docs/src/pages/api/FunstackStatic.mdx | 6 ++-- .../src/pages/learn/FileSystemRouting.mdx | 13 ++------ packages/example-fs-routing/src/adapter.ts | 5 --- packages/example-fs-routing/vite.config.ts | 2 +- .../e2e/fixture-fs-routing/src/adapter.ts | 3 -- .../e2e/fixture-fs-routing/vite.config.ts | 2 +- packages/static/package.json | 4 +++ packages/static/src/fs-routes/next.ts | 31 +++++++++++++++++++ packages/static/src/plugin/index.ts | 29 ++++++++++++----- packages/static/tsdown.config.ts | 1 + 10 files changed, 66 insertions(+), 30 deletions(-) delete mode 100644 packages/example-fs-routing/src/adapter.ts delete mode 100644 packages/static/e2e/fixture-fs-routing/src/adapter.ts create mode 100644 packages/static/src/fs-routes/next.ts diff --git a/packages/docs/src/pages/api/FunstackStatic.mdx b/packages/docs/src/pages/api/FunstackStatic.mdx index 653cf9a..79e0c45 100644 --- a/packages/docs/src/pages/api/FunstackStatic.mdx +++ b/packages/docs/src/pages/api/FunstackStatic.mdx @@ -72,7 +72,7 @@ export default defineConfig({ fsRoutes: { dir: "./src/pages", root: "./src/root.tsx", - adapter: "./src/adapter.ts", + adapter: "@funstack/static/fs-routes/next", }, }), react(), @@ -204,7 +204,7 @@ funstackStatic({ fsRoutes: { dir: "./src/pages", root: "./src/root.tsx", - adapter: "./src/adapter.ts", + adapter: "@funstack/static/fs-routes/next", }, }); ``` @@ -213,7 +213,7 @@ funstackStatic({ - **`dir`** (required) — directory scanned for route files, relative to the Vite root. Commonly `"./src/pages"`. - **`root`** (required) — path to the root (HTML shell) component module. -- **`adapter`** (required) — path to a module that `export default`s an `FsRoutesAdapter`. To use the built-in Next.js-like convention, point this at a module that re-exports `nextRoutes()` from `@funstack/static/fs-routes`. +- **`adapter`** (required) — a module that `export default`s an `FsRoutesAdapter`, given as a bare module specifier or a path relative to the Vite root. Use the bundled `@funstack/static/fs-routes/next` for the built-in Next.js-like convention, or point it at your own module for a custom one. Enable [`ssr`](#ssr-optional) alongside `fsRoutes` — it is required for the dev server to render pages and recommended in general. diff --git a/packages/docs/src/pages/learn/FileSystemRouting.mdx b/packages/docs/src/pages/learn/FileSystemRouting.mdx index e2112af..7da0f1f 100644 --- a/packages/docs/src/pages/learn/FileSystemRouting.mdx +++ b/packages/docs/src/pages/learn/FileSystemRouting.mdx @@ -31,7 +31,7 @@ export default defineConfig({ fsRoutes: { dir: "./src/pages", root: "./src/root.tsx", - adapter: "./src/adapter.ts", + adapter: "@funstack/static/fs-routes/next", }, }), react(), @@ -43,14 +43,7 @@ All `fsRoutes` fields are required, so each choice is explicit in your config: - `dir` — the directory scanned for route files (commonly `./src/pages`). - `root` — the HTML shell component (`…{children}`). -- `adapter` — path to a module that `export default`s the adapter defining the directory / file-name convention. To use the built-in Next.js-like convention, re-export `nextRoutes()`: - -```tsx -// src/adapter.ts -import { nextRoutes } from "@funstack/static/fs-routes"; - -export default nextRoutes(); -``` +- `adapter` — a module that `export default`s the adapter defining the directory / file-name convention. The bundled `@funstack/static/fs-routes/next` provides the built-in Next.js-like convention with default options; see [Custom Conventions](#custom-conventions-adapters) to configure it or write your own. `fsRoutes` is mutually exclusive with the `root` + `app` (single-entry) and `entries` (multiple entries) modes. @@ -118,7 +111,7 @@ A dynamic route without `generateStaticParams` is **not** pre-rendered (a warnin ## Custom Conventions (Adapters) -The convention is defined by an **adapter** implementing `FsRoutesAdapter`. Point `adapter` at a module that `export default`s an adapter to use a different convention: +The convention is defined by an **adapter** implementing `FsRoutesAdapter`. The built-in `@funstack/static/fs-routes/next` is the Next.js-like adapter with default options; to use a different convention, point `adapter` at your own module that `export default`s an adapter: ```typescript // vite.config.ts diff --git a/packages/example-fs-routing/src/adapter.ts b/packages/example-fs-routing/src/adapter.ts deleted file mode 100644 index 59515a0..0000000 --- a/packages/example-fs-routing/src/adapter.ts +++ /dev/null @@ -1,5 +0,0 @@ -import { nextRoutes } from "@funstack/static/fs-routes"; - -// The built-in Next.js-like convention: `page.tsx` / `layout.tsx` files mapped -// to routes. Pass it explicitly so the convention is visible in the config. -export default nextRoutes(); diff --git a/packages/example-fs-routing/vite.config.ts b/packages/example-fs-routing/vite.config.ts index b58a9c5..7547eb8 100644 --- a/packages/example-fs-routing/vite.config.ts +++ b/packages/example-fs-routing/vite.config.ts @@ -14,7 +14,7 @@ export default defineConfig({ fsRoutes: { dir: "./src/pages", root: "./src/root.tsx", - adapter: "./src/adapter.ts", + adapter: "@funstack/static/fs-routes/next", }, }), react(), diff --git a/packages/static/e2e/fixture-fs-routing/src/adapter.ts b/packages/static/e2e/fixture-fs-routing/src/adapter.ts deleted file mode 100644 index 7b665c4..0000000 --- a/packages/static/e2e/fixture-fs-routing/src/adapter.ts +++ /dev/null @@ -1,3 +0,0 @@ -import { nextRoutes } from "@funstack/static/fs-routes"; - -export default nextRoutes(); diff --git a/packages/static/e2e/fixture-fs-routing/vite.config.ts b/packages/static/e2e/fixture-fs-routing/vite.config.ts index e1d3dde..71b7046 100644 --- a/packages/static/e2e/fixture-fs-routing/vite.config.ts +++ b/packages/static/e2e/fixture-fs-routing/vite.config.ts @@ -10,7 +10,7 @@ export default defineConfig({ fsRoutes: { dir: "./src/pages", root: "./src/root.tsx", - adapter: "./src/adapter.ts", + adapter: "@funstack/static/fs-routes/next", }, }), react(), diff --git a/packages/static/package.json b/packages/static/package.json index 374f323..92581f9 100644 --- a/packages/static/package.json +++ b/packages/static/package.json @@ -35,6 +35,10 @@ "types": "./dist/fs-routes/index.d.mts", "import": "./dist/fs-routes/index.mjs" }, + "./fs-routes/next": { + "types": "./dist/fs-routes/next.d.mts", + "import": "./dist/fs-routes/next.mjs" + }, "./entries/*": "./dist/entries/*.mjs" }, "imports": { diff --git a/packages/static/src/fs-routes/next.ts b/packages/static/src/fs-routes/next.ts new file mode 100644 index 0000000..6bb3d82 --- /dev/null +++ b/packages/static/src/fs-routes/next.ts @@ -0,0 +1,31 @@ +/** + * Convenience adapter module for the built-in Next.js-like file-system routing + * convention, configured with default options. + * + * Point the `fsRoutes.adapter` plugin option at this module to use it without + * writing your own adapter file: + * + * ```ts + * funstackStatic({ + * fsRoutes: { + * dir: "./src/pages", + * root: "./src/root.tsx", + * adapter: "@funstack/static/fs-routes/next", + * }, + * }); + * ``` + * + * To customize the convention, call `nextRoutes(options)` from + * `@funstack/static/fs-routes` in your own adapter module instead. + * + * @experimental File-system routing is experimental and not yet subject to + * semantic versioning. + * + * @packageDocumentation + */ +import { nextRoutes } from "./nextAdapter"; +import type { FsRoutesAdapter } from "./types"; + +const adapter: FsRoutesAdapter = nextRoutes(); + +export default adapter; diff --git a/packages/static/src/plugin/index.ts b/packages/static/src/plugin/index.ts index a625884..e4a6005 100644 --- a/packages/static/src/plugin/index.ts +++ b/packages/static/src/plugin/index.ts @@ -106,11 +106,14 @@ export interface FsRoutesConfig { */ root: string; /** - * Path to a module that `export default`s an `FsRoutesAdapter`, which defines - * the directory / file-name convention. + * Module that `export default`s an `FsRoutesAdapter`, which defines the + * directory / file-name convention. Either a bare module specifier (a package + * import) or a path to a local module, relative to the Vite root. * - * To use the built-in Next.js-like convention, point this at a module that - * `export default`s `nextRoutes()` from `@funstack/static/fs-routes`. + * To use the built-in Next.js-like convention with default options, point + * this at the bundled convenience module `@funstack/static/fs-routes/next`. + * For custom options, `export default nextRoutes(options)` (from + * `@funstack/static/fs-routes`) in your own module and point this at it. */ adapter: string; } @@ -131,6 +134,15 @@ interface FsRoutesOptions { export type FunstackStaticOptions = FunstackStaticBaseOptions & (SingleEntryOptions | MultipleEntriesOptions | FsRoutesOptions); +/** + * Whether `id` is a bare module specifier (a package import) rather than a + * relative or absolute file path. Bare specifiers are passed through to the + * generated import as-is; paths are resolved against the Vite root. + */ +function isBareSpecifier(id: string): boolean { + return !id.startsWith(".") && !path.isAbsolute(id); +} + export default function funstackStatic( options: FunstackStaticOptions, ): (Plugin | Plugin[])[] { @@ -210,9 +222,12 @@ export default function funstackStatic( path.relative(config.root, resolvedDir), ); const globBase = `/${relativeDir.replace(/^\.?\/?/, "").replace(/\/$/, "")}`; - const adapter = normalizePath( - path.resolve(config.root, fsRoutes.adapter), - ); + // The adapter may be a bare module specifier (e.g. the built-in + // `@funstack/static/fs-routes/next`) or a path to a local module. + // Resolve only the latter against the Vite root. + const adapter = isBareSpecifier(fsRoutes.adapter) + ? fsRoutes.adapter + : normalizePath(path.resolve(config.root, fsRoutes.adapter)); resolvedFsRoutes = { root: resolvedRoot, adapter, globBase }; } else if (isMultiEntry) { resolvedEntriesModule = normalizePath( diff --git a/packages/static/tsdown.config.ts b/packages/static/tsdown.config.ts index 7a6a140..c29bfdd 100644 --- a/packages/static/tsdown.config.ts +++ b/packages/static/tsdown.config.ts @@ -7,6 +7,7 @@ export default defineConfig({ "src/entries/*.ts", "src/bin/*.ts", "src/fs-routes/index.ts", + "src/fs-routes/next.ts", ], // Vite virtual modules & subpath imports external: [/^virtual:/, /^#/], From 7f760570b7ca25b0161178a09abffc7381b41930 Mon Sep 17 00:00:00 2001 From: Claude Date: Fri, 26 Jun 2026 23:57:08 +0000 Subject: [PATCH 3/3] refactor: rename convenience module to @funstack/static/fs-routes/next-adapter Rename the bundled adapter module from `@funstack/static/fs-routes/next` to `@funstack/static/fs-routes/next-adapter` for a clearer name. - Rename src/fs-routes/next.ts -> next-adapter.ts and the package export - Update the example, e2e fixture, and docs to the new specifier Co-Authored-By: Claude Opus 4.8 Claude-Session: https://claude.ai/code/session_019KZaV9B4HmtACBqoPdL8qK --- packages/docs/src/pages/api/FunstackStatic.mdx | 6 +++--- packages/docs/src/pages/learn/FileSystemRouting.mdx | 6 +++--- packages/example-fs-routing/vite.config.ts | 2 +- packages/static/e2e/fixture-fs-routing/vite.config.ts | 2 +- packages/static/package.json | 6 +++--- packages/static/src/fs-routes/{next.ts => next-adapter.ts} | 2 +- packages/static/src/plugin/index.ts | 4 ++-- packages/static/tsdown.config.ts | 2 +- 8 files changed, 15 insertions(+), 15 deletions(-) rename packages/static/src/fs-routes/{next.ts => next-adapter.ts} (93%) diff --git a/packages/docs/src/pages/api/FunstackStatic.mdx b/packages/docs/src/pages/api/FunstackStatic.mdx index 79e0c45..87f6194 100644 --- a/packages/docs/src/pages/api/FunstackStatic.mdx +++ b/packages/docs/src/pages/api/FunstackStatic.mdx @@ -72,7 +72,7 @@ export default defineConfig({ fsRoutes: { dir: "./src/pages", root: "./src/root.tsx", - adapter: "@funstack/static/fs-routes/next", + adapter: "@funstack/static/fs-routes/next-adapter", }, }), react(), @@ -204,7 +204,7 @@ funstackStatic({ fsRoutes: { dir: "./src/pages", root: "./src/root.tsx", - adapter: "@funstack/static/fs-routes/next", + adapter: "@funstack/static/fs-routes/next-adapter", }, }); ``` @@ -213,7 +213,7 @@ funstackStatic({ - **`dir`** (required) — directory scanned for route files, relative to the Vite root. Commonly `"./src/pages"`. - **`root`** (required) — path to the root (HTML shell) component module. -- **`adapter`** (required) — a module that `export default`s an `FsRoutesAdapter`, given as a bare module specifier or a path relative to the Vite root. Use the bundled `@funstack/static/fs-routes/next` for the built-in Next.js-like convention, or point it at your own module for a custom one. +- **`adapter`** (required) — a module that `export default`s an `FsRoutesAdapter`, given as a bare module specifier or a path relative to the Vite root. Use the bundled `@funstack/static/fs-routes/next-adapter` for the built-in Next.js-like convention, or point it at your own module for a custom one. Enable [`ssr`](#ssr-optional) alongside `fsRoutes` — it is required for the dev server to render pages and recommended in general. diff --git a/packages/docs/src/pages/learn/FileSystemRouting.mdx b/packages/docs/src/pages/learn/FileSystemRouting.mdx index 7da0f1f..eed6df6 100644 --- a/packages/docs/src/pages/learn/FileSystemRouting.mdx +++ b/packages/docs/src/pages/learn/FileSystemRouting.mdx @@ -31,7 +31,7 @@ export default defineConfig({ fsRoutes: { dir: "./src/pages", root: "./src/root.tsx", - adapter: "@funstack/static/fs-routes/next", + adapter: "@funstack/static/fs-routes/next-adapter", }, }), react(), @@ -43,7 +43,7 @@ All `fsRoutes` fields are required, so each choice is explicit in your config: - `dir` — the directory scanned for route files (commonly `./src/pages`). - `root` — the HTML shell component (`…{children}`). -- `adapter` — a module that `export default`s the adapter defining the directory / file-name convention. The bundled `@funstack/static/fs-routes/next` provides the built-in Next.js-like convention with default options; see [Custom Conventions](#custom-conventions-adapters) to configure it or write your own. +- `adapter` — a module that `export default`s the adapter defining the directory / file-name convention. The bundled `@funstack/static/fs-routes/next-adapter` provides the built-in Next.js-like convention with default options; see [Custom Conventions](#custom-conventions-adapters) to configure it or write your own. `fsRoutes` is mutually exclusive with the `root` + `app` (single-entry) and `entries` (multiple entries) modes. @@ -111,7 +111,7 @@ A dynamic route without `generateStaticParams` is **not** pre-rendered (a warnin ## Custom Conventions (Adapters) -The convention is defined by an **adapter** implementing `FsRoutesAdapter`. The built-in `@funstack/static/fs-routes/next` is the Next.js-like adapter with default options; to use a different convention, point `adapter` at your own module that `export default`s an adapter: +The convention is defined by an **adapter** implementing `FsRoutesAdapter`. The built-in `@funstack/static/fs-routes/next-adapter` is the Next.js-like adapter with default options; to use a different convention, point `adapter` at your own module that `export default`s an adapter: ```typescript // vite.config.ts diff --git a/packages/example-fs-routing/vite.config.ts b/packages/example-fs-routing/vite.config.ts index 7547eb8..fba687e 100644 --- a/packages/example-fs-routing/vite.config.ts +++ b/packages/example-fs-routing/vite.config.ts @@ -14,7 +14,7 @@ export default defineConfig({ fsRoutes: { dir: "./src/pages", root: "./src/root.tsx", - adapter: "@funstack/static/fs-routes/next", + adapter: "@funstack/static/fs-routes/next-adapter", }, }), react(), diff --git a/packages/static/e2e/fixture-fs-routing/vite.config.ts b/packages/static/e2e/fixture-fs-routing/vite.config.ts index 71b7046..400fef3 100644 --- a/packages/static/e2e/fixture-fs-routing/vite.config.ts +++ b/packages/static/e2e/fixture-fs-routing/vite.config.ts @@ -10,7 +10,7 @@ export default defineConfig({ fsRoutes: { dir: "./src/pages", root: "./src/root.tsx", - adapter: "@funstack/static/fs-routes/next", + adapter: "@funstack/static/fs-routes/next-adapter", }, }), react(), diff --git a/packages/static/package.json b/packages/static/package.json index 92581f9..5da0f52 100644 --- a/packages/static/package.json +++ b/packages/static/package.json @@ -35,9 +35,9 @@ "types": "./dist/fs-routes/index.d.mts", "import": "./dist/fs-routes/index.mjs" }, - "./fs-routes/next": { - "types": "./dist/fs-routes/next.d.mts", - "import": "./dist/fs-routes/next.mjs" + "./fs-routes/next-adapter": { + "types": "./dist/fs-routes/next-adapter.d.mts", + "import": "./dist/fs-routes/next-adapter.mjs" }, "./entries/*": "./dist/entries/*.mjs" }, diff --git a/packages/static/src/fs-routes/next.ts b/packages/static/src/fs-routes/next-adapter.ts similarity index 93% rename from packages/static/src/fs-routes/next.ts rename to packages/static/src/fs-routes/next-adapter.ts index 6bb3d82..ae58a7f 100644 --- a/packages/static/src/fs-routes/next.ts +++ b/packages/static/src/fs-routes/next-adapter.ts @@ -10,7 +10,7 @@ * fsRoutes: { * dir: "./src/pages", * root: "./src/root.tsx", - * adapter: "@funstack/static/fs-routes/next", + * adapter: "@funstack/static/fs-routes/next-adapter", * }, * }); * ``` diff --git a/packages/static/src/plugin/index.ts b/packages/static/src/plugin/index.ts index e4a6005..3e9bc55 100644 --- a/packages/static/src/plugin/index.ts +++ b/packages/static/src/plugin/index.ts @@ -111,7 +111,7 @@ export interface FsRoutesConfig { * import) or a path to a local module, relative to the Vite root. * * To use the built-in Next.js-like convention with default options, point - * this at the bundled convenience module `@funstack/static/fs-routes/next`. + * this at the bundled module `@funstack/static/fs-routes/next-adapter`. * For custom options, `export default nextRoutes(options)` (from * `@funstack/static/fs-routes`) in your own module and point this at it. */ @@ -223,7 +223,7 @@ export default function funstackStatic( ); const globBase = `/${relativeDir.replace(/^\.?\/?/, "").replace(/\/$/, "")}`; // The adapter may be a bare module specifier (e.g. the built-in - // `@funstack/static/fs-routes/next`) or a path to a local module. + // `@funstack/static/fs-routes/next-adapter`) or a path to a local module. // Resolve only the latter against the Vite root. const adapter = isBareSpecifier(fsRoutes.adapter) ? fsRoutes.adapter diff --git a/packages/static/tsdown.config.ts b/packages/static/tsdown.config.ts index c29bfdd..6e3b80c 100644 --- a/packages/static/tsdown.config.ts +++ b/packages/static/tsdown.config.ts @@ -7,7 +7,7 @@ export default defineConfig({ "src/entries/*.ts", "src/bin/*.ts", "src/fs-routes/index.ts", - "src/fs-routes/next.ts", + "src/fs-routes/next-adapter.ts", ], // Vite virtual modules & subpath imports external: [/^virtual:/, /^#/],