Open aheissenberger opened 1 day ago
Hi! Thanks for the detailed report! Static route parameter definitions should now work with the latest version as described in the documentation, so please upgrade.
The previous version only supported the path object format ({ path }
) which was described in the docs at https://react-server.dev/router/static#override-static-paths. With this change, the file-system based router is trying to apply route parameters defined in the static file to the route path with a fallback to the original path object format.
This works:
export default [{ id: 1 }, { id: 2 }, { id: 3 }];
but this still throws an error (with and without async
):
import { products } from '../../data/products'
export default () => products.map(p => ({ id: p.id}))
react-server/0.0.0-experimental-61cbefd-20241204-b7fff15a building static for production
Error: path property is not defined for 4 paths
at file:/shop/node_modules/.pnpm/@lazarv+react-server@0.0.0-experimental-61cbefd-20241204-b7fff15a_@types+node@22.10.1_rollup@_4vfvp67tg5juqdb6xcq6lyosle/node_modules/@lazarv/react-server/lib/build/static.mjs:113:15
at async file:/shop/node_modules/.pnpm/@lazarv+react-server@0.0.0-experimental-61cbefd-20241204-b7fff15a_@types+node@22.10.1_rollup@_4vfvp67tg5juqdb6xcq6lyosle/node_modules/@lazarv/react-server/server/runtime.mjs:29:9
Describe the bug
I run
react-server build
and expect static output for all pages with anxxx.static.ts
file:react-server.config.json
1) Error: TypeError: configRoot.export is not iterable @lazarv/react-server/lib/build/static.mjs:110:28
I think
: [...configRoot.export, ...paths];
should be changed to: [...(configRoot?.export??[]), ...paths];
2) Dynamic static routes
product/[id].static.ts
I first tried based on your documentation with this:
export default [{ id: 1 }, { id: 2 }, { id: 3 }];
which broke herestatic.mjs:129
as there was nopath
property andreplace
did not check if the propertypath
exists.What worked was this:
export default [{ path: "/product/1" }, { path: "/product/2" }, { path: "/product/3" }];
3) Page without props
about/page.static.ts
content:
export default true;
No static page is created - see output
building static for production
section 2) I got a static page, if added the path/about
to react-server.config.jsonReproduction
https://github.com/aheissenberger/bug-rs-static-reder-demo
Steps to reproduce
pnpm build
System Info
Used Package Manager
pnpm
Logs
No response
Validations