Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

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

Aperta Adatta ai principianti
#17,518 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

@svelte-triage-bot ci sta già lavorando.

Dal 22/10/2026.

  • #17519 di @svelte-triage-bot — aperta

Valutazione

Difficoltà
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
84/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
javascript

Direzione di ricerca

Inizia in packages/package/src/index.js, nel ramo unlink del watcher, poi leggi il test esistente «watches for changes» menzionato nell’issue. Riproduci il problema eliminando src/lib/b.ts durante la modalità watch e controlla se package/b.js viene rimosso. Il lavoro è completato quando l’output compilato viene rimosso per i file TypeScript eliminati o rinominati e il test di regressione passa.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

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.

Lingua principale
JavaScript
Stelle
20.9k
Fork
2.4k
Merge medio
1g 20h
PR unite (30g)
83

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di sveltejs/kit

Tutte le issue di sveltejs/kit

Issue simili

Altre issue su JavaScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.