privatenumber / esbuild-loader

šŸ’  Speed up your Webpack with esbuild āš”ļø
MIT License
3.56k stars 108 forks source link

Significant perf regression in version 2.21.0 with Webpack v4 #313

Closed Chevelleboyer closed 1 year ago

Chevelleboyer commented 1 year ago

Bug description

A few weeks ago a colleague of mine opened issue #298 regarding the explicit dependency on webpack-sources@1.4.3 for Webpack v4. It was resolved in esbuild-loader v2.21.0, thank you so much!

After upgrading to esbuild-loader v2.21.0, however, we noticed a significant slow down in Webpack build times. Our build times have almost doubled :( When downgrading to version 2.20.0 we see the build times improve again.

Do the fixes in v2.21.0 necessitate this performance regression when using Webpack v4, or is there a way to fix this?

Reproduction

n/a

Node.js package manager

npm

Environment

npmPackages:
  webpack: 4.x
  esbuild-loader: 2.21.0

Can you contribute a fix?

privatenumber commented 1 year ago

I can't help you with how little information you've provided.

Can you provide a minimal reproduction so I can debug?

Chevelleboyer commented 1 year ago

You mean n/a wasn't enough? šŸ˜‚

While trying to reproduce with a trivial project, I found that we actually had a patch for esbuild-loader 2.20.0

Our patch was disabling the calls to asset.source.map() and asset.source.sourceAndMap() unless it was a sourcemap build. (We generate sourcemaps in a separate build)

Removing our patch makes v2.20.0 and v2.21.0 perform the same šŸ˜ƒ

Closing this now, sorry for any troubles!!

privatenumber commented 1 year ago

Are you saying disabling those calls makes large performance improvements even with devtools: false in the Webpack config?

If so, I'm very open to bringing those changes into the project. Would you be willing to open a PR?

Chevelleboyer commented 1 year ago

Yes that's correct, even with devtools: false it seems like asset.source.sourceAndMap() is still being called. Our patch just calls asset.source.source() instead of asset.source.sourceAndMap() if sourcemaps aren't enabled.

And yes I'm happy to open a PR!šŸ˜„