[Vite 3] Pre-bundling not discovering all dependencies
See original GitHub issueDescribe the bug
Vite 3’s pre-bundling phase doesn’t seem to discover all dependencies leading to a full page reload.
Reproduction
https://github.com/brillout/vite3-prebundler-bug
System Info
System:
OS: Linux 5.10 Debian GNU/Linux 10 (buster) 10 (buster)
CPU: (2) x64 Intel(R) Celeron(R) N4020 CPU @ 1.10GHz
Memory: 333.75 MB / 2.71 GB
Container: Yes
Shell: 5.0.3 - /bin/bash
Binaries:
Node: 18.0.0 - ~/.config/nvm/versions/node/v18.0.0/bin/node
Yarn: 1.22.17 - /usr/local/bin/yarn
npm: 8.6.0 - ~/.config/nvm/versions/node/v18.0.0/bin/npm
Browsers:
Firefox: 97.0.1
npmPackages:
@vitejs/plugin-react: ^1.3.2 => 1.3.2
vite: 3.0.0-beta.10 => 3.0.0-beta.10
Used Package Manager
pnpm
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. For example, if it’s a Vue SFC related bug, it should likely be reported to vuejs/core instead.
- 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.
Issue Analytics
- State:
- Created a year ago
- Comments:7 (7 by maintainers)
Top Results From Across the Web
Dependency Pre-Bundling - Vite
If an existing cache is not found, Vite will crawl your source code and automatically discover dependency imports (i.e. "bare imports" that expect...
Read more >Vite 3.0 vs. Create React App: Comparison and migration guide
During the pre-bundling process, Vite converts dependencies that are shipped as CommonJS or UMD into ESM. This conversion occurs because Vite ...
Read more >Vite creating its own node_modules in workspace instead of ...
My understanding is that the point of using npm workspaces is to avoid having multiple node_modules/ in each sub-project, instead having all ......
Read more >4 Reasons Why You Should Prefer Vite Over Create-React ...
Dependencies are plain JavaScript that do not change often during development (large component libraries like mui). Vite pre-bundles these ...
Read more >How JavaScript works: A deep dive into Vite - SessionStack Blog
How Vite Works · Vite pre-bundles the app's dependencies — that does not change often, by using esbuild. esbuild is built with Golang...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
This is a tradeoff with the scanner, and one of the reasons we wanted to remove it. It would probably depend on the user app. For small apps, it is a good default, for larger apps, the best would be to only scan the most common routes, and accept that there will be a reload when visiting some other routes for the first time.
We found that esbuild is quite slow when called with a lot of entries, so a possible optimization could be to aggregate all the entries and import them from a dynamically generated single file (for example for your .jsx routes, I think it will be possible) and feed that as the only entry to the scanner.
I tried to reproduce it, without luck. Let’s hope it was a glitch, somehow.