Repository navigation
Commit f36e7bd
fix(pages): include .dev and .prod pages only in their environment (#595)
Fixes #558.
Pages stripped `.dev` and `.prod` from the URL but kept the page in
every environment. So `debug.dev.tsx` shipped to production, and a
`home.dev.tsx` + `home.prod.tsx` pair failed as a duplicate route. Pages
now follow the same rule as `routes/`.
| Page file(s) | `vp dev` | build / deploy / preview | URL |
|---|---|---|---|
| `home.tsx` | ✓ | ✓ | `/home` |
| `debug.dev.tsx` | ✓ | — | `/debug` |
| `stats.prod.tsx` | — | ✓ | `/stats` |
| `home.dev.tsx` + `home.prod.tsx` | dev file | prod file | `/home` |
| `home.tsx` + `home.dev.tsx` | error (two pages for `/home`) |
`home.tsx` | `/home` |
| `home.tsx` + `home.prod.tsx` | `home.tsx` | error | `/home` |
```
environment when pages kept
dev vp dev plain + .dev
prod build, deploy, vite preview plain + .prod
(none) void prepare (types only) all; clash check runs once as dev, once as prod
```
Rules:
- The suffix goes before `.island`: `chart.dev.island.tsx`.
- A companion repeats it: `home.dev.tsx` pairs with
`home.dev.server.ts`. A dropped page's companion is never read.
- Layouts take no suffix.
- The page id keeps the suffix (`home.dev`, `home.prod`), so the two
pages of a pair never share an id.
## Every way a `.dev` page could reach production, and what closes it
```
core route table, prerender, ISR, deploy, types → scanPages(environment), passed from the app analysis
adapter renderer + client entry (React/Vue/Svelte/Solid)
→ pages plugin rescans with the current environment
adapter island list and island client → islands plugin scans with the current environment
islands client entry, dev island rescan → hasIslandPages scans 'prod'; the dev watcher scans 'dev'
inferred bindings (D1, KV, R2, AI…) → page files and companions filtered like routes/
@void/md pages list and md client scripts → same filter; the listed path drops the suffix
```
Framework apps that own `pages/` (Nuxt and others) are unchanged.
## Generated types
- For a `.dev` + `.prod` pair, `void prepare` writes one `PageActionMap`
entry per URL as a union, `{ dev shape } | { prod shape }`. So each
page's form body type-checks even when the two bodies differ.
- `ResolveActionBody` and `ActionUrl` in `void/routes` (and their
generated copies) now read each half of that union on its own. So
`useForm` accepts each page's URLs and body, even when one page has
`action` and the other has `actions`, or the two have different named
actions. A page with only named actions no longer loosens the other
page's bare-URL body. For a single page the result is the same as
before.
## Tests
- `pages-scan.test.ts`: `.dev` page; `.dev` + `.prod` pair; plain +
`.dev` and plain + `.prod` clashes, per environment and unfiltered;
shadow warnings per environment; `.dev.island`; a broken companion of a
dropped page is never parsed; `index.dev`; layouts; a
`pageFileEnvironment` table checked against the scanner.
- `scan.test.ts`, `route-types.test.ts`, `plugin-routing.test.ts`,
`pages-islands-rescan.test.ts`, `plugin-inference.test.ts` (including a
Nuxt app, whose bindings are not filtered).
- React, Vue, Svelte and Solid: pages and islands in build and in serve,
including `pages/` created after the dev server starts.
- `@void/md`: serve lists `debug.dev.md` as `/debug`; a build leaves it
and its script out.
- Integration:
- `tsx-server.test.ts` runs a real `vp dev` and `vp build`. `/debug`
gives 200 in dev and 404 in prod, `/greeting` shows each environment's
page, and the production types and module graphs have no `.dev` page.
- `page-action-types-typecheck.test.ts` runs `tsc` on generated pair
types through the same `U extends ActionUrl` constraint the adapters'
`useForm` uses.
- Mutation checks: each guarded line was broken in turn (the scanner
filter, the per-environment clash loop, every adapter's environment
value and the `isDev` move, the islands helpers, the type join,
`ResolveActionBody`, the inference filter, the md filter). Each break
made a test fail.
- `vp fmt`, `vp lint`, the void/react/vue/svelte/solid/md typechecks,
`vp run test` and one full `vp test run` pass.
A separate review built real apps and found no trace of `.dev` files in
any production output: bundles, manifests, prerender output, `_headers`,
wrangler bindings or types. It also checked `vp preview`, adding and
removing pages while `vp dev` runs, and `void prepare`.
## Choices to check
- **Types follow the running environment.** The dev server and builds
write `.void/routes.d.ts` for their own environment, as `routes/`
already does, and `void prepare` writes both. So while `vp dev` runs, a
`.prod` page that uses `useForm` shows a type error in the editor (and
the other way round after `vp build`). Fixing that would need a second
page scan just for types, which would have to parse dev-only files
during a production build. The docs say this plainly.
- **`home.tsx` + `home.prod.tsx` errors only at build or `void
prepare`**, not on the dev server, because only one page runs in dev.
The same goes for `routes/`.
- **Helper files shared by `.dev` pages** (`pages/_db.ts`, `src/db.ts`)
still add their bindings to production. Binding inference reads each
file on its own and doesn't follow imports, as with `routes/`.
- **Wrong suffix order** (`chart.island.dev.tsx`) gets no new error. It
is a dev-only regular page at `/chart.island`. The docs say the suffix
goes first, as in `chat.dev.ws.ts` for WebSocket routes.
- An app whose only island page or only md page with a `<script>` is
`.dev` gets an empty client chunk in production. No page code ships.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
---------
Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>1 parent a71da90 commit f36e7bd
41 files changed
Lines changed: 1451 additions & 88 deletions
File tree
- docs
- guide
- pages-routing
- reference
- packages
- md
- src
- test/unit
- react
- src
- test/unit
- solid
- src
- test/unit
- svelte
- src
- test/unit
- void
- src
- codegen
- pages
- router
- test
- integration
- unit
- vue
- src
- test/unit
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
241 | 241 | | |
242 | 242 | | |
243 | 243 | | |
| 244 | + | |
| 245 | + | |
244 | 246 | | |
245 | 247 | | |
246 | 248 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
109 | 109 | | |
110 | 110 | | |
111 | 111 | | |
112 | | - | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
113 | 135 | | |
114 | 136 | | |
115 | 137 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
29 | 29 | | |
30 | 30 | | |
31 | 31 | | |
32 | | - | |
| 32 | + | |
33 | 33 | | |
34 | 34 | | |
35 | 35 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
85 | 85 | | |
86 | 86 | | |
87 | 87 | | |
| 88 | + | |
88 | 89 | | |
89 | 90 | | |
90 | 91 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
6 | | - | |
| 6 | + | |
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
| |||
44 | 44 | | |
45 | 45 | | |
46 | 46 | | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
47 | 60 | | |
48 | 61 | | |
49 | 62 | | |
| |||
79 | 92 | | |
80 | 93 | | |
81 | 94 | | |
| 95 | + | |
| 96 | + | |
82 | 97 | | |
83 | 98 | | |
84 | 99 | | |
| |||
100 | 115 | | |
101 | 116 | | |
102 | 117 | | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
103 | 123 | | |
104 | | - | |
| 124 | + | |
105 | 125 | | |
106 | 126 | | |
107 | 127 | | |
108 | 128 | | |
109 | | - | |
110 | | - | |
| 129 | + | |
| 130 | + | |
111 | 131 | | |
112 | 132 | | |
113 | 133 | | |
114 | 134 | | |
115 | 135 | | |
116 | 136 | | |
117 | | - | |
| 137 | + | |
118 | 138 | | |
119 | 139 | | |
120 | 140 | | |
| |||
137 | 157 | | |
138 | 158 | | |
139 | 159 | | |
| 160 | + | |
140 | 161 | | |
141 | 162 | | |
142 | 163 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
65 | 65 | | |
66 | 66 | | |
67 | 67 | | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
68 | 124 | | |
69 | 125 | | |
70 | 126 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
73 | 73 | | |
74 | 74 | | |
75 | 75 | | |
76 | | - | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
77 | 80 | | |
78 | 81 | | |
79 | 82 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
74 | 74 | | |
75 | 75 | | |
76 | 76 | | |
77 | | - | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
78 | 80 | | |
79 | 81 | | |
80 | 82 | | |
| |||
174 | 176 | | |
175 | 177 | | |
176 | 178 | | |
| 179 | + | |
| 180 | + | |
177 | 181 | | |
178 | 182 | | |
179 | 183 | | |
| |||
182 | 186 | | |
183 | 187 | | |
184 | 188 | | |
185 | | - | |
186 | | - | |
| 189 | + | |
187 | 190 | | |
188 | 191 | | |
189 | 192 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
12 | | - | |
| 12 | + | |
13 | 13 | | |
14 | 14 | | |
15 | 15 | | |
| |||
25 | 25 | | |
26 | 26 | | |
27 | 27 | | |
28 | | - | |
| 28 | + | |
29 | 29 | | |
30 | 30 | | |
31 | 31 | | |
32 | | - | |
| 32 | + | |
| 33 | + | |
33 | 34 | | |
34 | 35 | | |
35 | 36 | | |
| |||
178 | 179 | | |
179 | 180 | | |
180 | 181 | | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
203 | 203 | | |
204 | 204 | | |
205 | 205 | | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
0 commit comments