vitejs / vitejs/vite-plugin-react

false-positive of `optimizeDeps.exclude` suggestion

Open
#759 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

plugin: rsc
Dominant language
TypeScript
Stars
1.2k
Forks
269
Avg merge
1d 3h
Merged PRs (30d)
19

Description

Related

I thought It's pretty accurate now but technically it causes a false positive when users are optimizing aggressively with optimizeDeps.entries, which picks up server libraries. Even though browser will only load "non optimized" version of modules, "optimized" version of modules can end up in .vite/deps, which triggers a warning.

For example, Waku uses all server routes as optimizeDeps.enties and waku-jotai/router is imported in one of a page https://github.com/wakujs/waku/blob/e100dab9915946f64c436e01917a88aac675d13b/e2e/fixtures/waku-jotai/src/pages/index.tsx#L3. Then browser optimizer will pick up and optimize waku-jotai/router, which end up bundling waku-jotai/dist/router/client.js while what browser actually loads is only non-optimized waku-jotai/dist/router/client.js.

To avoid this, we might need to detect .vite/deps files are actually requested via transform hook.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by tracing the plugin's transform hook and how files under .vite/deps are handled when optimizeDeps.entries includes server routes. Reproduce the Waku example, then verify that the suggestion is emitted only for .vite/deps files actually requested by the browser.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
build-system, tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.