svelte-package watch mode leaves the compiled .js of a deleted .ts file in the output
Maintainers usually reply within 1 day
@svelte-triage-bot is already working on this.
Since Oct 22, 2026.
- #17519 by @svelte-triage-bot — open
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 84/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Active
- Tech stack
- javascript
- Domain
- build-system, tooling
Research direction
Start in packages/package/src/index.js at the watcher's unlink branch, then read the existing "watches for changes" test mentioned in the issue. Reproduce by deleting src/lib/b.ts during watch mode and check whether package/b.js is removed. Done means the compiled output is removed for deleted or renamed TypeScript files and the regression test passes.
Written by the indexing model from the issue text.
Description
Describe the bug
In watch mode (svelte-package -w), deleting or renaming a .ts module in src/lib removes its .d.ts from the output directory, but the compiled .js stays there. The watcher still logs Removed foo.js.
The unlink branch in packages/package/src/index.js deletes path.join(output, file.name). That is the source path (foo.ts), which never exists in the output. It never deletes file.dest (foo.js). The same applies to Svelte files with a custom extension from config.extensions (for example .svx), whose output is .svelte.
The stale file stays until the next build without --preserve-output. Meanwhile it can still be imported, and it gets published if someone runs npm publish on a watched output directory.
Reproduction
- Take any library packaged with
@sveltejs/package(for example, one created bysv createwith the library template). npx svelte-package -w- Create
src/lib/foo.tswithexport const foo = 1;.dist/foo.jsanddist/foo.d.tsare created. - Delete
src/lib/foo.ts. The watcher logsRemoved foo.js. ls dist:foo.d.tsis gone, butfoo.jsis still there.
Logs
Processing foo.ts
Removed foo.js
(dist/foo.js still exists afterwards.)
System Info
System:
OS: macOS 27.0.1 (arm64)
Binaries:
Node: 26.8.2
npmPackages:
@sveltejs/package: 3.0.1 (also 3.0.0 and main)
Severity
annoyance
Additional Information
A likely fix is to delete file.dest instead of file.name in that branch. For .js and .svelte files the two are the same, so their behaviour wouldn't change. With that change, a test in the existing "watches for changes" test that deletes src/lib/b.ts and checks that package/b.js is gone passes; without it, the test fails.
- 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 3 days ago. Openpkg:adapter-cloudflare
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
Maintainers usually reply within 1 day
-
types / typescript
Difficulty 2/5 1-3 hours Newbie friendliness 85/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 30 days ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
Maintainers usually reply within 1 day
Similar issues
-
self-driving
Difficulty 1/5 1-3 hours Newbie friendliness 86/100
Maintainers usually reply within 1 day
-
kind:bug needs-triage
Difficulty 2/5 1-3 hours Newbie friendliness 66/100
Maintainers usually reply within 1 day
-
status: needs triage
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
mastra-ai/mastra#28500 · 1 comment ·
Maintainers usually reply within 1 day
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
fossasia/scrum_helper#949 ·
Maintainers usually reply within 2 days
-
Difficulty 1/5 Under an hour Newbie friendliness 88/100
Foundryborne/daggerheart#2531 ·
Maintainers usually reply within 1 day