Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

svelte-package watch mode leaves the compiled .js of a deleted .ts file in the output

Open Beginner friendly
#17,518 0 comments 0 reactions 0 assignees View on GitHub

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

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
  1. Take any library packaged with @sveltejs/package (for example, one created by sv create with the library template).
  2. npx svelte-package -w
  3. Create src/lib/foo.ts with export const foo = 1;. dist/foo.js and dist/foo.d.ts are created.
  4. Delete src/lib/foo.ts. The watcher logs Removed foo.js.
  5. ls dist: foo.d.ts is gone, but foo.js is 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

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from sveltejs/kit

All issues in sveltejs/kit

Similar issues

More JavaScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.