optimisation warning conflicts with large React library barrels
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 54/100
- Issue type
- Bug
- Clarity
- Mostly clear
- Activity status
- Active
- Tech stack
- react, typescript, vite
Research direction
Start with the plugin-rsc use-client optimization warning and reproduce it using the linked vite-rsc-bundling example: run npm install and npm run dev, then open the app. Compare the warning and browser requests for the lucide-react barrel import with the subpath import workaround described in the issue. Done means finding a way to avoid the warning without requesting the full icon module graph during development.
Written by the indexing model from the issue text.
Description
Related plugins
Describe the bug
When a React library has a large barrel entry, @vitejs/plugin-rsc warns that the dependency is inconsistently optimised:
16:30:30 [vite] (rsc) warning: client component dependency is inconsistently optimized. It's recommended to add the dependency to 'optimizeDeps.exclude'.
Plugin: rsc:use-client
File: /Users/karl.stoney/git/vite-rsc-bundling/node_modules/lucide-react/dist/esm/Icon.mjs?v=233653df
16:30:31 [vite] (rsc) warning: client component dependency is inconsistently optimized. It's recommended to add the dependency to 'optimizeDeps.exclude'.
Plugin: rsc:use-client
File: /Users/karl.stoney/git/vite-rsc-bundling/node_modules/lucide-react/dist/esm/context.mjs?v=233653df
For lucide-react, following that recommendation removes the warning but causes the browser to request the entire icon module graph (2000+ icons individually) during development, even when only one icon is used.
There is a workaround in my repro (not using the barrel import, and importing from subpaths directly) but it seems odd to need to do this.
Reproduction
https://github.com/Stono/vite-rsc-bundling
Steps to reproduce
npm install then npm run dev, then open it. More info in the README
System Info
System:
OS: macOS 26.6.1
CPU: (14) arm64 Apple M4 Max
Memory: 928.25 MB / 36.00 GB
Shell: 5.9 - /bin/zsh
Binaries:
Node: 24.22.2 - /Users/karl.stoney/.local/state/fnm_multishells/79801_1794241455736/bin/node
npm: 11.19.1 - /Users/karl.stoney/.local/state/fnm_multishells/79801_1794241455736/bin/npm
Browsers:
Safari: 27.0
npmPackages:
@vitejs/plugin-rsc: 0.5.39 => 0.5.39
vite: 8.3.7 => 8.3.7
Used Package Manager
npm
Logs
No response
Validations
- Follow our Code of Conduct
- Read the Contributing Guidelines.
- Read the docs.
- Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
- Make sure this is a Vite issue and not a framework-specific issue.
- Check that this is a concrete bug. For Q&A open a GitHub Discussion or join our Discord Chat Server.
- The provided reproduction is a minimal reproducible example of the bug.
- Dominant language
- TypeScript
- Stars
- 1.2k
- Forks
- 287
- Avg merge
- 1d 17h
- Merged PRs (30d)
- 19
Getting set up
- No Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from vitejs/vite-plugin-react
-
plugin-rsc: a client reference's CSS is linked before the CSS of the chunks it imports (build)Possibly taken @wozhenbang2004 claimed this 6 days ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
vitejs/vite-plugin-react#1570 ·
Maintainers usually reply within 1 day
-
pending triage
Difficulty 4/5 3-5 days Newbie friendliness 35/100
vitejs/vite-plugin-react#1581 ·
Maintainers usually reply within 1 day
-
[plugin-rsc] Build exits 0, but the app fails at runtime: a server action imported only by browser code is missing from the RSC buildPossibly taken @NeilPant claimed this 3 days ago. Open
Difficulty 4/5 3-5 days Newbie friendliness 48/100
vitejs/vite-plugin-react#1578 ·
Maintainers usually reply within 1 day
-
Difficulty 4/5 3-5 days Newbie friendliness 42/100
vitejs/vite-plugin-react#1577 ·
Maintainers usually reply within 1 day
-
[plugin-rsc] inline "use server" function declarations lose hoisting and throw TDZ ReferenceErrorPossibly taken @draarivpatel-ui claimed this 2 days ago. Open
Difficulty 3/5 1-2 days Newbie friendliness 55/100
vitejs/vite-plugin-react#1566 · 1 comment ·
Maintainers usually reply within 1 day
All issues in vitejs/vite-plugin-react
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
earendil-works/pi#12615 ·
Maintainers usually reply within 1 day
-
My Caps shows "Shared" on private Caps that were never sharedPossibly taken @AksharP5 claimed this today. Open
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
CapSoftware/Cap#4569 · 1 comment ·
Maintainers usually reply within 1 day
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
OHDSI/Data2Evidence#3749 ·
Maintainers usually reply within 4 days
-
Difficulty 2/5 1-3 hours Newbie friendliness 63/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
Flagsmith/flagsmith-nodejs-client#332 ·
Maintainers usually reply within 2 days