You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
refactor!: make unstable_fsRouter API to be independent from fs internally (#1603)
Alternative of #1599. This simplifies
`unstable_fsRouter` API so that fs crawling are expected to be handled
outside. For managed mode, it uses `import.meta.glob` to set this up
automatically.
New API accepts a mapping of a file to a module such as
```tsx
unstalbe_fsRouter(
{
"index.tsx": () => ({ default: Index }),
"bar/index.tsx": () => ({ default: Bar }),
},
{ apiDir: 'api' },
);
function Index() {
return <div>Index</div>
}
function Bar() {
return <div>Bar</div>
}
```
which can be ergonomically generated by Vite's `import.meta.glob`.
```tsx
unstalbe_fsRouter(
import.meta.glob("/src/pages/**/*.tsx", { base: "/src/pages" })
{ apiDir: 'api' },
);
```
---------
Co-authored-by: Daishi Kato <dai-shi@users.noreply.github.com>
0 commit comments