feat: move file-system routing from SolidStart into router-neutral packages#572
Draft
brenelz wants to merge 2 commits into
Draft
feat: move file-system routing from SolidStart into router-neutral packages#572brenelz wants to merge 2 commits into
brenelz wants to merge 2 commits into
Conversation
…ckages Implements the architecture from discussion solidjs#571 (shared analysis, per-consumer emission), building on the workspace layout from solidjs#570: - @solidjs/file-routes: router-neutral core — bundler-agnostic scanning (BaseFileSystemRouter), the SolidStart-proven filename convention as a pluggable default (PageFileSystemRouter), route-module export analysis behind its own seam (oxc-parser), and a neutral route manifest as the emission seam. Server conventions (GET/POST exports) stay in Start. - @solidjs/file-routes/vite: the Vite delivery adapter — serves the manifest as the solid:file-routes virtual module (lazy $-refs become code-split dynamic imports, eager $$-refs become static imports, tree-shaken per export via ?pick), with watcher-driven HMR and per-Vite-environment routers so Start can compose it. - @solidjs/router/fs: Solid Router's emission adapter — createFileRoutes nests the flat manifest, strips (group) segments and merges route configs into lazy RouteDefinitions, and ships <FileRoutes />. - examples/file-routes: a plain Vite + Solid Router SPA exercising the whole path (nested layout, params, preload, catch-all); wired into the workspace so the root build doubles as an end-to-end check. Fixes found while porting: single-extension globs were treated as literal brace patterns, and the watcher invalidated the virtual module during the initial scan (routes are now pre-built before the reloader attaches). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
🦋 Changeset detectedLatest commit: d1f2a86 The changes in this PR will be included in the next version bump. This PR includes changesets to release 3 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Implements the architecture refined by @ryansolid in #571 — shapes vs machinery, shared analysis / per-consumer emission — building on the pnpm workspace layout from #570 (this branch includes that PR's commit; the new work is the top commit).
What's in here
@solidjs/file-routes(new, router-neutral)The machinery, ported from SolidStart's
config/fs-routes:BaseFileSystemRouterscans a directory into a flat, neutral route manifest (paths in a neutral pattern language, module refs with export picks). No Vite imports in the core.PageFileSystemRouteris exactly the convention Start has proven ([id],[[opt]],[...rest],(group),index,routeexport, md/mdx), overridable viatoPath/toRouteor a custom router.analyze.ts, oxc-parser) — the compiler-shaped slice, kept separable so a compiler that already reports exports can provide it instead.GET/POSTexport handling stays in Start, which can extendPageFileSystemRouter.@solidjs/file-routes/vite(delivery adapter)solid:file-routesvirtual module:$-prefixed refs become code-split dynamic imports,$$-prefixed refs become static imports, each tree-shaken to the picked exports (?pick).routers: { client, ssr, ... }option keyed by Vite environment, so Start can compose it with different conventions per environment.@solidjs/router/fs(emission adapter, new subpath export)createFileRoutes(manifest)— nests the flat manifest by path prefix, strips(group)segments, mergesrouteconfigs, emits lazyRouteDefinitions taggedinfo.filesystem.<FileRoutes />— the runtime component for<Router>children.@solidjs/routerdoes not depend on@solidjs/file-routes; the adapter only consumes the virtual module, so Start's bring-your-own-router story is preserved.examples/file-routesA plain Vite + Solid Router SPA (no Start) exercising the whole path — nested layout, index routes, params with typed
routeconfig +preload+createAsync, catch-all 404. Wired into the workspace so the root build doubles as an end-to-end check.Notes for reviewers
*.{tsx}); the watcher used to invalidate the virtual module during the initial scan — routes are now pre-built before the reloader attaches.solid({ extensions: [".jsx", ".tsx"] })is required because vite-plugin-solid's dev filter tests the raw id, which the?pickquery defeats — same reason Start passesextensions. Could be fixed upstream in vite-plugin-solid.solid:file-routes(Start currently usessolid-start:routes);<FileRoutes>here is the SPA/client variant — Start keeps its per-request SSR variant and composes the rest.fs-routes/internals and rebaseSolidStartServerFileRouter+ config wiring onto@solidjs/file-routes.Verification
@solidjs/file-routestests (incl. ported solid-start specs for export analysis + tree-shaking) and 264 router tests (incl. new emission-adapter unit tests and a mounted<Router><FileRoutes/></Router>rendering test) — all passing.arethetypeswronggreen (esm-only profile) for both packages including the new subpaths.🤖 Generated with Claude Code