Not reduce bundle size as expected
See original GitHub issueThere is a project that has been written in Typescript.
bundle size with babel/preset-env
is 101.29KB minified & gzipped also bundle size with babel/preset-modules
is 100.27 KB minified & gzipped.
here is a repository that you can check:
sample-react-redux-typescript
I removed polyfills for a better comparison of bundle size.
you can run yarn analysis
for viewing bundle size.
node version: v12.12.0
Issue Analytics
- State:
- Created 4 years ago
- Comments:5 (1 by maintainers)
Top Results From Across the Web
5 Methods to Reduce JavaScript Bundle Size - Bits and Pieces
In this article, I will discuss 5 techniques to reduce the JavaScript bundle size to avoid any performance bottlenecks.
Read more >Slimming down your bundle size - LogRocket Blog
Here are some potential next steps you can take to decrease your bundle size and load time and increase performance. Consider rewriting ......
Read more >Possible ways to reduce your webpack bundle size - Medium
Here are some cool ways you can reduce your webpack bundle size: ... It can also tell some packages not include debug code....
Read more >How to easily reduce your NextJS bundle size by 30%?
0. Creating a Baseline · 1. Improve lodash Imports · 2. Use Dynamic Imports · 3. Analyze the Bundle · 4. Do Not...
Read more >Small Bundles, Fast Pages: What To Do With Too Much ...
This post will explain why bundle size matters and recommend tools and ... visualise, and most importantly, shrink your JS bundles.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@alireza-mh Code imported from node_modules is ES5, regardless of whether it uses ES Modules. This is a common misconception - libraries like
react-router-dom
andredux
don’t actually provide ES2015, they just publish ES5 in a few different module formats. As such, they are entirely unaffected by this preset (whether you run them through Babel or not).Regarding your repo, I can clarify something: the code isn’t using
async/await
or Tagged Templates, which are the two syntax features that benefit most from this preset. The code is essentially written in ES2015 (classes, arrow functions), whereas this preset seeks to enable ES2017. It’s likely the only output changes between preset-modules and preset-env for you are arrow functions being used more consistently and slightly worse JSX output (#4 will address).In general we don’t “modernize” code written in older syntax**, which means optimizations like
preset-modules
have no effect on that code. In order to see size gains from preset-modules, code needs to be written in ~ES2017 - the more the better.** I have actually been looking into this space and am working on something.
@alireza-mh the problem is that what you’re bundling is, probably, already compiled. For example,
react
andreact-dom
are already transpiled. Almost everything that’s already in yournode_modules
is, in fact, already transpiled. That’s why you’re able to ignore them in your webpack.config.js.So, your improvement of 1KB is from your codebase. Which, is not bad at all, in terms that your app is noticeable small.