kit: Blocked migration to SvelteKit 2 - Out of memory & explosion in compilation time

Describe the bug

We have decided to try migrating our relatively large app to SvelteKit 2 (dashboard with tons of components and [internal] dependencies).

Unfortunately, we have to give up upgrading.

The amount of memory required for the build process has doubled. We now need a server with 12GB of RAM at least to compile. Worse, the compilation time has exploded now (about 30x longer on Apple M1 Pro). This is extremely expensive.

The reasons are not SvelteKit per se, we think. But rather Vite: vitejs/vite#2433

It might be that Vite 5 has more memory leaks.

For now, we are continuing with SvelteKit 1 (and its Vite 4 dep), which has been great to us!

Reproduction

We cannot share our code base. It happens for large and complex apps.

Logs

[12305:0x138008000]     8389 ms: Mark-Compact 8138.7 (8239.1) -> 8138.5 (8239.1) MB, 79.67 / 0.00 ms  (average mu = 0.511, current mu = 0.018) allocation failure; scavenge might not succeed
[12305:0x138008000]     8467 ms: Mark-Compact 8140.8 (8241.2) -> 8140.6 (8241.2) MB, 77.38 / 0.00 ms  (average mu = 0.330, current mu = 0.011) allocation failure; scavenge might not succeed


<--- JS stacktrace --->

FATAL ERROR: Reached heap limit Allocation failed - JavaScript heap out of memory

System Info

System:
    OS: macOS 14.3
    CPU: (10) arm64 Apple M1 Pro
    Memory: 7.89 GB / 16.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 20.11.0 - /opt/homebrew/bin/node
    npm: 10.2.4 - /opt/homebrew/bin/npm
  Browsers:
    Chrome: 121.0.6167.139
    Safari: 17.3
  npmPackages:
    @sveltejs/adapter-cloudflare: ^4.1.0 => 4.1.0
    @sveltejs/kit: ^2.5.0 => 2.5.0
    @sveltejs/vite-plugin-svelte: ^3.0.2 => 3.0.2
    svelte: ^4.2.10 => 4.2.10
    vite: ^5.0.12 => 5.0.12

Severity

blocking an upgrade

Additional Information

No response

About this issue

  • Original URL
  • State: open
  • Created 5 months ago
  • Comments: 16 (9 by maintainers)

Most upvoted comments

For https://github.com/huntabyte/shadcn-svelte, the PR that upgraded the project to SK 2 + Vite 5 also included the addition of @sveltejs/enhanced-img. Removing the plugin resulted in the build times returning back to normal (and is seemingly faster than SK 1 + Vite 4).

I’m unsure of what normal build times are expected when using this plugin, however I don’t think we’re experiencing the problems presented in this particular issue. Sorry for the confusion!

@dummdidumm exactly what I mean.

Interestingly, I’ve spent the last few days migrating the app to Astro 4.4 (just front-end, in dev mode), and I’ve just hit exactly the same issues at build time.

Astro 4 also uses Vite 5.

Pretty sure at this point that the issue is Vite 5 not being scalable at all…

Sadly I’m forced to use the JS hell-system 😭