-
Notifications
You must be signed in to change notification settings - Fork 203
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
Bundle Size for the browser version is too big #2318
Comments
I checked our code, as additional information, these are the APIs we are using:
|
Hi @moonglum we've noticed something similar on our project and I thought this PR would most likely resolve it. @axe312ger is that your view also? |
Yes my PR should solve it! :) |
Its published as v11! Can you rebundle and share your results @moonglum? It should now properly tree shake :) |
Thanks, Benedikt! Are there any breaking changes? Or do I just keep everything the same? |
@moonglum The API of the package is the same. We "just" changed the wrapping code. You might need to adjust your requires/imports, but besides of that, everything stayed the same. Changelog coming soon, preview here: #2334 (comment) |
Thank you, the hint with ESM is important 👍 I'll try it out and get back to you, @axe312ger |
@axe312ger If I update the package, and change nothing else, our build fails:
The same is raised for zlib and tty. It feels like this uses the node package, and not the browser package. Do I need to adjust the import? |
The bundle you mentioned is now exported as un-bundled code with all the dependencies. You will be able to deliver smaller files to the browser now, but likely, How to Fix the Polyfill Issue:1. Use Modern Import SyntaxTry using: import * as contentful from 'contentful'; This could help with modern module resolution and might tell axios to exclude. 2. Fix Your SetupIt looks like you might have an older or misconfigured Webpack 5 setup. Maybe your Next.js version is outdated? Also, older versions of 3. Patch Webpack FallbackIf updating your setup doesn’t work, use Webpack’s module.exports = {
resolve: {
fallback: {
os: false,
zlib: false,
tty: false,
},
},
}; This is mostly what axios does in their own webpack (4) config. If issues persist, here’s a list of shims/polyfills that might help. |
Thanks, we invested some time today in updating our Babel configuration, and now it works 👍 I can confirm that this significantly reduces the size of contentful in our bundle to the point that it turned from the biggest package in our bundle to now being barely visible. Thanks for the effort 🙇 |
@moonglum AMAZING! That was the plan. Makes me really happy when it worked out! Huge bundles s*ck! :) |
We are using Contentful on our site for a few pages like the blog. Unfortunately, the chunk size of contentful keeps increasing version by version (a few versions ago, it was 90kb). It is now at 227kb, and is now the biggest chunk in our entire bundle.
Expected Behavior
Actual Behavior
Possible Solution
Allow tree shaking instead of including the entire minified bundle. You always get the entire code, I assume that contains a lot of code for previewing etc. which we don't use:
Steps to Reproduce
Context
A bundle size like that is a burden for our customers, who need to download it.
Environment
The text was updated successfully, but these errors were encountered: