FG
๐Ÿ’ป Software๐ŸŒ Web & Full-Stack

Scripts set in manualChunks are loaded directly in front page, instead to be lazy loaded when needed

Freshabout 2 months ago
Mar 14, 20260 views
Confidence Score78%
78%

Problem

Describe the bug To manage well the bundle, I am setting the packages into manualChunks e.g.: The package fabric is used only in the admin area of my app, that is why I don't need it to be loaded directly in the front page. If I don't set it in manualChunks, it works good and it will not be loaded in the front page, but my chunks then are too large, because vite place it automatically together with others in a huge backend chunk. Then as soon I open the backend it lazy loads all the other chunks, including the one that contains fabric. So this is the expected behavior. If I set it in manualChunks, e.g.: [code block] the fabric chunk is loaded directly on the front page. Even if I am not admin. You can see the differences when I include fabric or not: Not included in manualChunks Included in manualChunks: Expected behavior is: fabric should only be loaded when really used, else it creates only network traffic and lowers the Lighthouse score because of unused code! NOTE: I am using an example with fabric here, but in my project I have a bunch of other libraries that have the same issue with manualChunks. Reproduction I created a small reproduction in this repo: https://github.com/a-tonchev/react-boilerplate/tree/vite_no_lazy_load Steps to reproduce: 1. Install deps (`yarn`) Try bug: 1. `yarn build && yarn serve` 2. Open localhost:4000 and see in Network -> JS, the `fabric` script is loaded To try without, open vite.config.js: https://github.com/a-tonchev/rea

Unverified for your environment

Select your OS to check compatibility.

1 Fix

Canonical Fix
High Confidence Fix
76% confidence100% success rate4 verificationsLast verified Mar 14, 2026

Solution: Scripts set in manualChunks are loaded directly in front page, instead to be lazy loaded when needed

Low Risk

I can confirm that this issue occurs. Also, it seems that even dependencies I've never imported are passed to manualChunks, raising the chunks size.

76

Trust Score

4 verifications

100% success
  1. 1

    I can confirm that this issue occurs. Also, it seems that even dependencies I've

    I can confirm that this issue occurs. Also, it seems that even dependencies I've never imported are passed to manualChunks, raising the chunks size.

Validation

Resolved in vitejs/vite GitHub issue #5189. Community reactions: 5 upvotes.

Verification Summary

Worked: 4
Partial: 1
Last verified Mar 14, 2026

Sign in to verify this fix

Environment

Submitted by

AC

Alex Chen

2450 rep

Tags

vitebuild-tooljavascript