PrismarineJS / prismarine-web-client

Minecraft web client running in your browser
https://prismarinejs.github.io/prismarine-web-client/
MIT License
444 stars 142 forks source link

Make Webpack faster #210

Open AwesomestCode opened 3 years ago

AwesomestCode commented 3 years ago

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 commented 2 years ago

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 commented 2 years ago

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 commented 2 years ago

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

Saiv46 commented 2 years ago

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 commented 2 years ago

227 was reverted so we're back at square 1

rom1504 commented 2 years ago

yep, I reverted because it broke npm start

zardoy commented 1 year ago

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

rom1504 commented 9 months ago

switching to esbuild seems good

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

zardoy commented 1 month ago

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

Now, one year later I have investigated new ways to improve build times once again and have completely moved to Rsbuild! After a month of usage, I got feedback from different devs and everyone is really happy as it is performing well on any platform and by almost 2x faster than Vite. Unlike esbuild it supports HMR, code splitting, Webpack plugins, and fast incremental builds.

So in my case compared to esbuild it was:

I bet Rsbuild will stay the fastest bundler for a few more years. Can't think anymore of something better...