question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

`SSR`: ssrLoadModule issue

See original GitHub issue

Describe 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:

  1. use antd and vite no ssr => fast
  2. use only vite ssr, no UI lib => fast
  3. 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

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:13 (11 by maintainers)

github_iconTop GitHub Comments

3reactions
bluwycommented, Dec 7, 2022

hookNodeResolve is removed in https://github.com/vitejs/vite/pull/11101. You can try the Vite 4 beta to test it out now.

1reaction
hemengke1997commented, Dec 7, 2022

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!!

ssr: {
  optimizeDeps: {
    include: ['antd', '...other heavy deps'],
    disabled: 'build'
  }
}

Thank you very much! ❤️ @bluwy

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found