Skip to content
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

Make Webpack faster #210

Open
AwesomestCode opened this issue Aug 22, 2021 · 8 comments · Fixed by #227 · May be fixed by #353
Open

Make Webpack faster #210

AwesomestCode opened this issue Aug 22, 2021 · 8 comments · Fixed by #227 · May be fixed by #353

Comments

@AwesomestCode
Copy link
Member

We're at this point again. Somehow, webpack is again being extremely slow. This is hampering development; I can't iterate quickly/test stuff if I need to wait a minute every time I make a change, no matter how small.

@Saiv46
Copy link
Contributor

Saiv46 commented Oct 12, 2021

What speed-measure-webpack-plugin gives to me

 SMP  ⏱  
General output time took 3 mins, 18.8 secs   

 SMP  ⏱  Plugins
CopyPlugin took 1 min, 7.67 secs
GenerateSW took 9.23 secs
NormalModuleReplacementPlugin took 0.898 secs
HtmlWebpackPlugin took 0.067 secs
ProvidePlugin took 0.001 secs

 SMP  ⏱  Loaders
modules with no loaders took 25.062 secs     
  module count = 1061
html-webpack-plugin took 0.13 secs
  module count = 1

Looks like much time are wasted on I/O, copying files every time.

@Karang
Copy link
Contributor

Karang commented Oct 12, 2021

Indeed, it looks likes it's copying a bunch of useless stuff too. https://github.com/PrismarineJS/prismarine-web-client/blob/master/webpack.common.js#L72 also copy sub-directories while we are only interested in the .png at the root (and maybe some entities and gui textures, but we clearly don't need the many many individual files of the blocks).

@AwesomestCode
Copy link
Member Author

Does it copy the files for dev builds though? I thought those were incremental

@Saiv46
Copy link
Contributor

Saiv46 commented Oct 19, 2021

So, I wrote a little plugin for symlinking directories, now dev builds are faster

 SMP  ⏱
General output time took 57.3 secs

 SMP  ⏱  Plugins
GenerateSW took 14.13 secs
NormalModuleReplacementPlugin took 0.388 secs
HtmlWebpackPlugin took 0.097 secs
SymlinkPlugin took 0.088 secs
CopyPlugin took 0.078 secs
ProvidePlugin took 0.001 secs

 SMP  ⏱  Loaders
modules with no loaders took 15.38 secs
  module count = 703
html-webpack-plugin took 0.043 secs
  module count = 1

@AwesomestCode
Copy link
Member Author

#227 was reverted so we're back at square 1

@AwesomestCode AwesomestCode reopened this Nov 28, 2021
@rom1504
Copy link
Member

rom1504 commented Nov 28, 2021

yep, I reverted because it broke npm start

@zardoy
Copy link
Contributor

zardoy commented Aug 29, 2023

Hi all! I investigated new ways to improve build times. Here's what I found:

  • CopyPlugin is indeed quite inefficient when copying a large number of files. It can also lead to EMFILE issues on Windows. So I just moved this step to standalone script which skips copying when possible (overall was ~17s on my end).

  • Then, by switching minimizer to EsbuildPlugin I could get prod build in 15s.

  • After I while I encountered some webpack misconfiguration issues, instead of resolving them I decided to switch to using only esbuild build pipeline. This resulted in a bundle time of 3s (13s with Workbox). I know that esbuild isn't commonly used as a webpack replacement (it doesnt have HMR, incremental build, and chunks support), but I really enjoy fast & stable rebuilds now. I added logging to the browser console to see how fast it takes for full page reload (in my case it takes 3-5s, which is still faster than webpack watch mode). Also, it works well with pnpm. Will look at how it is possible to optimize assets copying...

@zardoy zardoy linked a pull request Sep 19, 2023 that will close this issue
5 tasks
@rom1504
Copy link
Member

rom1504 commented Dec 31, 2023

switching to esbuild seems good

I think it'd be pretty helpful to first switch to that here

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
5 participants