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
{{ message }}
Repository navigation
Commit e3fb803
Browse filesBrowse the repository at this point in the historyBrowse files
fix(config): stop pointing users at the legacy void.json (#716)
Projects configure Void through `void.config.ts`, but several messages
still name `void.json`, a file those projects don't have. For example,
with `sourceDir: 'src'` and `routes/` in both the project root and
`src/`, `vp dev` stops with:
```
Error: sourceDir: void.json sets "sourceDir": "src", but convention path(s) also exist at the project root: routes. Move them under "src" or remove the root copy.
```
The same file name appears in:
- `sourceDir` errors from `readProjectPaths()`, which framework adapters
and many CLI commands use. `readConfig()` already named the right file.
- The `[cause]` line printed under every `void.config.ts` validation
error, because `validateConfig()` kept the error from before it replaced
the file name:
```
Error: config: "routing.isr" in void.config.ts must be a boolean.
[cause]: Error: config: "routing.isr" in void.json must be a boolean.
```
- `VoidAssetRewriteError`.
- `origin` labels in the dev `X-Void-Routing` header and routing lint
warnings. `docs/guide/edge/rewrites.md` already documents them as
`void.config.ts#routing.rewrites`.
- The file tree on the App Types docs page.
`VoidAssetRewriteError` also links to `void.dev`, which answers any path
with a page that redirects to `/lander`. The docs are on `void.cloud`.
## Fix
- The `sourceDir` and conflict errors name the project's actual config
file, so projects that still use `void.json` keep seeing `void.json`.
- `validateConfig()` no longer attaches the original error as `cause`.
Its message only differs by the placeholder file name.
- `VoidAssetRewriteError` names `void.config.ts` and links to
`void.cloud`.
- `origin` labels read `void.config.ts#routing.*`.
- The App Types file tree lists `void.config.ts`. The other docs already
use it, so they do not change.
## Not changed here
- `VoidAssetRewriteError` and the `origin` labels aren't given the file
name, so projects that still use `void.json` see `void.config.ts` there.
`void init` and `void deploy` migrate those projects.
- `playground/kitchen-sink/pages/auth.vue` still says `void.json`.
## Tests
- `packages/void/test/unit/project-paths.test.ts`: the `sourceDir` and
conflict errors with `void.config.ts`, with `void.json` and with no
config file.
- `packages/void/test/unit/config.test.ts`: what an invalid
`void.config.ts` prints, through `util.inspect`, which is what adds the
`[cause]` line.
- `packages/void/test/unit/compile.test.ts`: the file name and link in
`VoidAssetRewriteError`.
- `origin` expectations in five unit test files move to the new label.
These cases fail without this fix, except the `void.json` ones, which
already passed.
## Verification
- `vp test run`: 774 files pass, 1 skipped (15,966 tests pass, 29
skipped).
- `vp run check`: 33/33 pass.
- By hand with `vp dev` on a copy of `playground/ssr`:
- `/docs/x` through a `routing.rewrites` rule answers `X-Void-Routing:
rewrite[/docs/*] -> /api/hello (void.config.ts#routing.rewrites)`.
- `/old` through a `routing.redirects` rule answers `X-Void-Routing:
redirect[/old] -> /api/hello 302 (void.config.ts#routing.redirects)`.
- `c.rewrite('/hero.png')` in middleware answers 500 and logs
`VoidAssetRewriteError`, which names `void.config.ts` and links to
`void.cloud`.
- A bad `sourceDir`, a bad `routing.isr` and a root conflict stop the
server. With `void.config.ts`, the output has no `void.json` and no
`[cause]` line. With `void.json`, the errors name `void.json`.
- By hand with `void prepare` and a bad `routing.isr` in
`void.config.ts`: the error names `void.config.ts`, and the output has
no `void.json`.
- `vp run --filter ./docs build`: the App Types page lists
`void.config.ts`, and `void.json` is gone from it.
- Not run by hand: a `routing.fallbacks` rule. The app's SSR entry
answered first, and the unit tests check that label.
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
@@ -142,6 +142,6 @@ export function assertNoRootSourceConventionConflicts(paths: ProjectPaths): void
142
142
return;
143
143
}
144
144
thrownewError(
145
-
`sourceDir: void.json sets "sourceDir": "${paths.sourceDir}", but convention path(s) also exist at the project root: ${conflicts.join(', ')}. Move them under "${paths.sourceDir}" or remove the root copy.`,
145
+
`sourceDir: ${getConfigFileName(paths.root)} sets "sourceDir": "${paths.sourceDir}", but convention path(s) also exist at the project root: ${conflicts.join(', ')}. Move them under "${paths.sourceDir}" or remove the root copy.`,
Copy file name to clipboardExpand all lines: packages/void/src/runtime/handler.ts
+1-1Lines changed: 1 addition & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -22,7 +22,7 @@ export class VoidAssetRewriteError extends Error {
22
22
overridename='VoidAssetRewriteError';
23
23
constructor(destination: string){
24
24
super(
25
-
`c.rewrite() cannot re-dispatch to a static asset path (${JSON.stringify(destination)}). Runtime rewrites only reach routes and SSR entries inside the worker — static asset handlers run in front of the worker. To rewrite into an asset, use a static \`routing.rewrites\` rule in void.json or a \`200!\` entry in _redirects. See https://void.dev/guide/edge/rewrites#runtime-rewrites-cannot-reach-static-assets`,
25
+
`c.rewrite() cannot re-dispatch to a static asset path (${JSON.stringify(destination)}). Runtime rewrites only reach routes and SSR entries inside the worker — static asset handlers run in front of the worker. To rewrite into an asset, use a static \`routing.rewrites\` rule in void.config.ts or a \`200!\` entry in _redirects. See https://void.cloud/guide/edge/rewrites#runtime-rewrites-cannot-reach-static-assets`,
0 commit comments