Huge bundle size increase using Webpack 4 #2026
Unanswered
dios-david
asked this question in
Q&A
Replies: 1 comment
-
Ha! looks like we'll have to obscure this for Webpack 😄 Thanks for the report! |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I found a weird thing (and a fix 🎉 ) so I thought I should share it with the community.
I'm using Webpack 4 and I updated some urql packages in my project:
Then I realised my vendor bundle increased by 7-8 kb (gzipped), which I did not really expect from these changes.
I checked bundlephobia (I know that's not 100% accurate) and I noticed that there was a slight jump at 2.3.0 but that was only ~0.7 kb (gzipped).
So I started to look into the old and the new vendor bundles using the coverage report in devtools and I realised there is a huge Buffer shim included in the new bundle. After a quick search I found out that Webpack 4 includes this Buffer shim automatically when
Buffer
is used in the code, as browsers usually don't implementBuffer
. (afaik Webpack 5 doesn't do this anymore)I found out that in 2.3.0 urql introduced support for
@defer
and@stream
which included some new usages ofBuffer
, which then made Webpack 4 bundling theBuffer
shim in my new vendor bundle.I'm not using
@defer
/@stream
currently so I think it's safe to remove the shim to save some kbs in my vendor bundle. I could achieve this by adding this to the webpack config (docs here):I hope this is useful for other Webpack 4 users here :)
Beta Was this translation helpful? Give feedback.
All reactions