`SSR`: ssrLoadModule issue
See original GitHub issueDescribe the bug
description
I’m using antd
in ssr
mode, everytime startup vite devServer, it took about 40s to start.
I’ve debug vite
source code in local, and I found that the reason is: https://github.com/vitejs/vite/blob/main/packages/vite/src/node/server/transformRequest.ts#L234
I tested three conditions:
- use antd and vite no ssr => fast
- use only vite ssr, no UI lib => fast
- use antd and vite ssr => slow
BTW, I think this is not related to #8850.
Reproduction
https://github.com/hemengke1997/vps-antd-repo
System Info
System:
OS: Windows 10 10.0.22000
CPU: (16) x64 Intel(R) Core(TM) i7-10700F CPU @ 2.90GHz
Memory: 5.39 GB / 23.78 GB
Binaries:
Node: 16.14.2 - C:\Program Files\nodejs\node.EXE
Yarn: 1.22.18 - ~\AppData\Roaming\npm\yarn.CMD
npm: 8.5.0 - C:\Program Files\nodejs\npm.CMD
Browsers:
Chrome: 63.0.3239.132
Edge: Spartan (44.22000.120.0), Chromium (103.0.1264.37)
Internet Explorer: 11.0.22000.120
npmPackages:
@vitejs/plugin-react: ^2.0.0 => 2.0.0
vite: ^3.0.4 => 3.0.4
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:13 (11 by maintainers)
Top Results From Across the Web
Server-Side Rendering - Vite
Produce a client build as normal;; Produce an SSR build, which can be directly loaded via require() so that we don't have to...
Read more >Has anyone run into issues with a vite SSR import error?
I'm trying to install the svelte-fullcalendar package in my app, but when I run it, I get the following cryptic error: 3:10:42 p.m....
Read more >vite-plugin-ssr
With vite-plugin-ssr you integrate tools manually; while it means more work, it gives you a fundamentally simpler & more stable foundation to build...
Read more >Problems with SSR and Firebase in the latest SvelteKit release
I had a similar problem, and my solution was to remove the old node modules and lock files using rm -rf node_modules package-lock.json...
Read more >What About Vite SSR? - JavaScript in Plain English
Related issue: https://github.com/vitejs/vite/issues/5424. The module loaded by Vite's module loader (vite.ssrLoadModule), once the CommonJS module is ...
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 Free
Top 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
hookNodeResolve
is removed in https://github.com/vitejs/vite/pull/11101. You can try the Vite 4 beta to test it out now.Nice!!! There is no problem now I checkout vite@4.0.0-beta.1, then I add the heavy deps to
ssr.optimizeDeps
and found that works well!!Thank you very much! ❤️ @bluwy