Skip to content
Source
Sign inSign up
TanStack/router

fix(start-plugin-core): release the start compiler when a build bundle closes #8662

Openscil(GitHub profile, opens in a new tab)wants to merge 2 commits intomain fromrefs/pull/8662/headopened

Showing 3 changed files with 92 additions and 0 deletions.

x
0 of 3 viewed, 3 left
5 additions and 0 deletions.changeset/start-compiler-release-after-build.mdAdded
View file
@@ -0,0 +1,5 @@
+---
+'@tanstack/start-plugin-core': patch
+---
+​
+Release each environment's Start compiler when its build bundle closes. `vite build` builds the client, SSR and server environments once each in one process, so the compiler kept from an earlier environment, and the finished module graph its load/resolve closures held, stayed in memory for the rest of the build and could push large apps past the heap limit.
10 additions and 0 deletionspackages/start-plugin-core/src/vite/start-compiler-plugin/plugin.tsModified
View file
@@ -409,6 +409,16 @@
compilers.delete(this.environment.name)
+ closeBundle() {
+ if (this.environment.mode === 'build') {
+ // `vite build` bundles each environment once, in one process, so the
+ // reset in buildStart never runs again for this environment. Drop the
+ // compiler now: its load/resolve closures hold this hook context and,
+ // through it, the finished module graph, which would otherwise stay
+ // alive while the remaining environments build.
+ compilers.delete(this.environment.name)
+ }
+ },
async watchChange(id) {
if (bundledDev && this.environment.mode === 'dev') {
if (environment.type === 'server') {