-
Notifications
You must be signed in to change notification settings - Fork 26.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unzipping is 50x times slower in NextJS compared to Gatsby or other platform #22372
Comments
And the problem occurs only for cjs modules. It works fine when I use the same library imported by |
Had a look into this issue through profiling and debugging. As it turns out this has nothing to do with commonjs or even Next.js execution and it's certainly not "every library": The particular library that you're using
Webpack 4 automatically polyfilled browser modules to match the Node.js environment, this includes Webpack 5 disables all automatic polyfilling behavior, in Next.js we still provide backwards compat for cases like crypto/process to make sure you can use webpack 5 in a backwards compatible way. In case of There are multiple open PRs on
Because of So TLDR: Next.js is not slow, the particular library is incorrectly being polyfilled in the case where you're building the library using Gatsby and the |
This issue has been automatically locked due to no recent activity. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you. |
What version of Next.js are you using?
10.0.5
What version of Node.js are you using?
12.0.0
What browser are you using?
Safari, Chrome
What operating system are you using?
macOS, Windows
How are you deploying your application?
next start
Describe the Bug
Unzipping a zip file using JSZip is 50x slower in NextJS than in Gatsby.
I made a sample app that unzips a zip file on both NextJS and Gatsby. It took for 162647.844ms for NextJS while it only took for 3091.979ms in Gatsby.
I believe it's not only unzipping but execution of javascript (especially cjs modules) is generally slow in NextJS. The whole reason I've done it in the first place was because my js library was significantly slow only when it was used on NextJS app. Unzipping is just the most extreme case that I've observed. My library, which is primarily WebGL, becomes about 2~10x slower (depending on the kind of job) in NextJS compared to Gatsby or other platforms.
Expected Behavior
I expect no runtime performance difference to Gatsby.
To Reproduce
Here's the sample app
https://github.com/ingun37/nextjs-bug-reproduce-sample
NextJS
/nextjs
yarn run dev
oryarn run build && yarn run start
Unzip and measure the time
button and check the console.Gatsby
/gatsby
npm i && npm run develop
Unzip and measure the time
button and check the console.The text was updated successfully, but these errors were encountered: