sync: prune metadata entries for removed routes
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 85/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Active
- Tech stack
- javascript
- Domain
- tooling
Research direction
The change belongs in write_all_types in packages/kit/src/core/sync/write_types/index.js, which reads the existing route_meta_data.json, updates entries for current routes, and writes it back without removing entries for deleted routes. Start by reading that function, then add the pruning step so only route IDs in the current manifest are kept. Run the new test in packages/kit/src/core/sync/write_types/index.spec.js inside the 'Cleans up unused files' block; it passes when /about is removed and / keeps its original metadata.
Written by the indexing model from the issue text.
Description
Describe the problem
After a route is removed and write_all_types runs with a fresh manifest, its generated type files are deleted, but its entry remains in .svelte-kit/types/route_meta_data.json. Repeated route churn can leave obsolete cache entries behind in the file.
Describe the proposed solution
Prune metadata entries whose route IDs are no longer present in the current manifest, preserving metadata for current routes.
Alternatives considered
Keep the current behavior. Retained entries have not been shown to break type generation.
Importance
Nice to have.
Failing test
Add this test inside describe('Cleans up unused files', ...) in packages/kit/src/core/sync/write_types/index.spec.js.
test('prunes metadata entries for removed routes', () => {
const types_dir = sync();
const meta_data_file = path.join(types_dir, 'route_meta_data.json');
const original_metadata = JSON.parse(fs.readFileSync(meta_data_file, 'utf-8'));
assert.deepEqual(original_metadata['/about'], []);
fs.rmSync(path.join(root, 'src/routes/about'), { recursive: true });
sync();
const metadata = JSON.parse(fs.readFileSync(meta_data_file, 'utf-8'));
assert.ok(!Object.hasOwn(metadata, '/about'));
assert.deepEqual(metadata['/'], original_metadata['/']);
});
Relevant implementation: write_all_types reads the existing metadata, updates generated routes, and writes it back without pruning removed-route entries.
- Dominant language
- JavaScript
- Stars
- 20.9k
- Forks
- 2.4k
- Avg merge
- 1d 20h
- Merged PRs (30d)
- 83
Getting set up
- No Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from sveltejs/kit
-
awaiting submitter
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
Maintainers usually reply within 1 day
-
adapter-cloudflare: `cloudflare:workers` keeps using the old platform proxy after the Wrangler config reloads in devPossibly taken @svelte-triage-bot claimed this 4 days ago. Openpkg:adapter-cloudflare
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
Maintainers usually reply within 1 day
-
svelte-package watch mode leaves the compiled .js of a deleted .ts file in the outputPossibly taken @svelte-triage-bot claimed this 5 days ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
Maintainers usually reply within 1 day
-
Prerendering no longer shows progressMay be free again A pull request for this issue was closed without being merged. Open
Difficulty 2/5 1-3 hours Newbie friendliness 64/100
sveltejs/kit#17163 · 4 comments ·
Maintainers usually reply within 1 day
-
sync: concurrent runs can read a truncated route_meta_data.json (JSON.parse error)Possibly taken @Nic-Polumeyv claimed this 31 days ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
Maintainers usually reply within 1 day
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
evi0s/WMPFDebugger#303 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
HakanSeven12/OpenCADStudio#2257 · 1 comment ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 64/100
-
bug good first issue
Difficulty 2/5 1-3 hours Newbie friendliness 85/100
-
bug code-annotation
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
quarto-dev/quarto-cli#15215 ·
Maintainers usually reply within 1 day