Repository navigation
fix: ensure vite build watch mode works - #16632
Conversation
|
Install the latest version of pnpm add https://pkg.svelte.dev/@sveltejs/kit/c/f9ed999acc114297c97c2011543e02475a6fefc2Open in |
🦋 Changeset detectedLatest commit: f9ed999 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
vite build --watch49a9699 to
96fe7e0
Compare
|
What if the replacement happened in generateBundle instead, mutating chunk.code before write? That would make rebuilds correct by construction and remove normalise_build entirely. As it stands the chunk threading also still crashes; the second argument is evaluated before the watcher's first build, so it's permanently undefined (repro'd with the pkg build from 49a9699 on vite 8.0.12 and 8.2.0, same "chunks is not iterable" as #16624; the ERROR path has the same issue). |
e99e640 to
849b73d
Compare
|
The real issue is that all our logic in the |
|
Tested 849b73d. The crash is gone and the full pipeline runs, adapter output included. An error during the first build still hits the original TypeError though, because |
|
Thought I could just make it rely on a single watcher and re-run everything based on that (this is how we used to do it). Turns out, Rolldown's watchers are smarter now with Vite environments, so if you only changed files related to the service worker entrypoint, only those files would rebuild. Going to sleep on this and try to divide up the build steps logically tomorrow (though it's a bit of a waterfall right now). Some notes I jotted down roughly: EDIT: see PR description |
|
/autofix |
This PR was opened by the [Changesets release](https://github.com/changesets/action) GitHub action. When you're ready to do a release, you can merge this and the packages will be published to npm automatically. If you're not ready to do a release yet, that's fine, whenever you add more changesets to version-3, this PR will be updated.⚠️ ⚠️ ⚠️ ⚠️ ⚠️ ⚠️ `version-3` is currently in **pre mode** so this branch has prereleases rather than normal releases. If you want to exit prereleases, run `changeset pre exit` on `version-3`.⚠️ ⚠️ ⚠️ ⚠️ ⚠️ ⚠️ # Releases ## @sveltejs/[email protected] ### Major Changes - breaking: move remote function types to `$app/server` ([#16740](#16740)) - breaking: remove `#lib` definition from `paths`; requires explicit module extensions as a result ([#16736](#16736)) - breaking: move hooks-related types to `@sveltejs/kit/hooks` ([#16737](#16737)) - breaking: move env-related types to `@sveltejs/kit/env` ([#16739](#16739)) ### Minor Changes - feat: better response logging ([#16744](#16744)) ### Patch Changes - chore: bump `mrmime` to 2.0.1 ([#16745](#16745)) - chore: bump `@sveltejs/acorn-typescript` to 1.0.12 ([#16745](#16745)) - chore: bump `magic-string` to 1.1.0 ([#16745](#16745)) - chore: bump `devalue` to 5.9.0 ([#16745](#16745)) - chore: bump `cookie` to 2.0.1 ([#16745](#16745)) - chore: bump `acorn` to 8.18.0 ([#16745](#16745)) - fix: avoid infinite loop when building with `--watch` flag ([#16632](#16632)) ## @sveltejs/[email protected] ### Patch Changes - chore: bump `@cloudflare/worker-types` to 5.20260809.1 ([#16745](#16745)) - Updated dependencies [[`1742811`](1742811), [`1611c61`](1611c61), [`b361b81`](b361b81), [`b361b81`](b361b81), [`b361b81`](b361b81), [`b361b81`](b361b81), [`13e7b18`](13e7b18), [`529346d`](529346d), [`b361b81`](b361b81), [`81d6319`](81d6319), [`b361b81`](b361b81), [`69a5bdf`](69a5bdf)]: - @sveltejs/[email protected] ## @sveltejs/[email protected] ### Patch Changes - chore: bump `rolldown` to 1.2.3 ([#16745](#16745)) - Updated dependencies [[`1742811`](1742811), [`1611c61`](1611c61), [`b361b81`](b361b81), [`b361b81`](b361b81), [`b361b81`](b361b81), [`b361b81`](b361b81), [`13e7b18`](13e7b18), [`529346d`](529346d), [`b361b81`](b361b81), [`81d6319`](81d6319), [`b361b81`](b361b81), [`69a5bdf`](69a5bdf)]: - @sveltejs/[email protected] ## @sveltejs/[email protected] ### Patch Changes - chore: bump `rolldown` to 1.2.3 ([#16745](#16745)) - Updated dependencies [[`1742811`](1742811), [`1611c61`](1611c61), [`b361b81`](b361b81), [`b361b81`](b361b81), [`b361b81`](b361b81), [`b361b81`](b361b81), [`13e7b18`](13e7b18), [`529346d`](529346d), [`b361b81`](b361b81), [`81d6319`](81d6319), [`b361b81`](b361b81), [`69a5bdf`](69a5bdf)]: - @sveltejs/[email protected] ## @sveltejs/[email protected] ### Patch Changes - chore: bump `magic-string` to 1.1.0 ([#16745](#16745)) - chore: bump `zimmerframe` to 1.1.4 ([#16745](#16745)) ## @sveltejs/[email protected] ### Patch Changes - chore: bump `svelte2tsx` to 0.7.59 ([#16745](#16745)) Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Fixes #17609 Every server-side transform of a remote module appends a record, even when its filename-derived hash is already known. HMR therefore retains an additional record on every edit. The lazy dev manifest hides the duplicates by overwriting object entries, but still traverses the growing collection on every access. Store the registry in a Map keyed by the normalized remote hash. Each transform replaces the current record, making duplicate retention impossible without scanning existing records. The dev manifest consumes the live map's values; the compile plugin materializes an array once at the production boundary, preserving the existing analysis, treeshaking, and adapter contracts. The shared discovery mechanism survived the [remote plugin extraction](#16868) and [compile plugin separation](#16885). It still needs to remain live because modules are discovered after the [dev manifest is initialized](#16965). Preserve the [watch-mode reset](#16632), dedicated entry emission, original-module lookup, self-import protection, and dev source decoration. Registration continues using the query-normalized identity from [#17604](#17604). A linear push guard would prevent retention but scan all known remotes on each transform; deduplicating only the manifest would leave the memory growth intact. The regression instead inspects the underlying registry through a real Vite server, covering lazy discovery and repeated transforms that page-content assertions cannot distinguish. - [Ported minimal reproduction](https://www.sveltelab.dev/#code=N4IgzgTgxiBcoBMCWECmUAuB7CBPOoAhgA7EB0AFhgLYA2BIAZkrag1FgHYardhwgAPAEIEWTLmKoABFToA%2BADqdBc2tNqFOAcwC8ikLwNLOijKtSEEJs2cHVUGQtKgVCEMI-0gArhkYAtAAcBtIA9DYYdg5O0pyEDt4AbkioAO7EOFEgLlw83N5pSAgYFLoIqClQqAFFJRQANNJInEgYSIS0AWBQnai6AIyhEcq25jHO8YkGPAAeGN29rKEc3LwY3j19w5FmAKRgSai0PADWbZSWCHuj5mEUV5GCAEZYCLjSCIRO3UcnqOcFsQ0LQsFYAl8nN4KF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Q9wFi8ROYpD7WynFoAkbQQ1AADEfE4TB5ssgkMAm6cprGBViCfCAAHkB37iv-3T2UzXWTo294sBcF7wfh8dE2zHZNMAF1lAPstzc%2BofvrsnVCoNdsjT4ARXZHfifLRWVsywLBTh473QPdVyFRYBA1YCHNAb8eAQE-t-JcJcMCgisMmHwEBaBNFfPMJooZ5gZjgWYKMVo0BgGzvGOIYYMBIJQWgo02CyxjCQIwEKyDaBkBomAAA6m0CgyY3RB1QGEMun0wgd3siWHB9czCEOzg2Pk0AZAJgAMpD18smSRJxpHIOqElNAuJCDVG4R3MAZBiA%2BF0ioziRZSxuiaAAAwMUYkxXCO6lmUFGLArAyCgm0GYriAoPG8G0KUTB6RpDyMcN4oshilTEBUZmAslAdIUDTElOaAAvSazQEClmsc40wUQMB7zyWgDAyCpyqIwLQ-JJ8GckVnZEAA) <!-- svelte-triage-bot:feedback-baseline:4ce7989bbcc4cd6195f371674a76f4280c937f3b --> --------- Co-authored-by: svelte-triage-bot <[email protected]> Co-authored-by: Nic Polumeyv <[email protected]>
fixes #16624
Few changes were required:
builder.buildwhich can return a watcher instead of the build chunks. Added a normaliser to handle that. Unfortunately, the bundle has to be taken from thegenerateBundlehook.buildApphook doesn't re-run on watchThis only fixes the regression. There were additional existing bugs I've listed in #16708 but I don't think it's a high priority to fix them now when Vite's build watch mode support itself wasn't fully thought out
Questions:
build --watchprocess and end it if the assertions pass? with a timeout so it doesn't go on indefinitely?