Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[fix] rebuild manifest when client hooks or param matcher file is added/removed #7915

Merged
merged 2 commits into from Dec 2, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/wet-trainers-perform.md
@@ -0,0 +1,5 @@
---
'@sveltejs/kit': patch
---

[fix] rebuild manifest when client hooks or param matcher file is added/removed
2 changes: 1 addition & 1 deletion packages/kit/src/core/sync/write_types/index.js
Expand Up @@ -150,7 +150,7 @@ export async function write_types(config, manifest_data, file) {
const id = '/' + posixify(path.relative(config.kit.files.routes, path.dirname(file)));

const route = manifest_data.routes.find((route) => route.id === id);
if (!route) return; // this shouldn't ever happen
if (!route) return;
if (!route.leaf && !route.layout && !route.endpoint) return; // nothing to do

update_types(config, create_routes_map(manifest_data), route);
Expand Down
8 changes: 7 additions & 1 deletion packages/kit/src/exports/vite/dev/index.js
Expand Up @@ -202,7 +202,13 @@ export async function dev(vite, vite_config, svelte_config) {
*/
const watch = (event, cb) => {
vite.watcher.on(event, (file) => {
if (file.startsWith(svelte_config.kit.files.routes + path.sep)) {
if (
file.startsWith(svelte_config.kit.files.routes + path.sep) ||
file.startsWith(svelte_config.kit.files.params + path.sep) ||
// in contrast to server hooks, client hooks are written to the client manifest
// and therefore need rebuilding when they are added/removed
file.startsWith(svelte_config.kit.files.hooks.client)
) {
cb(file);
}
});
Expand Down