Large bundle size with webpack
See original GitHub issueActual Behavior
I’m making a Chrome recorder extension, and I’ve noticed the production library bundle was 437KB in my project, which I would consider to be relatively large for a bundle that doesn’t need to ship GUI assets. I’m guessing this is due to a combination of Node.js dependencies and Puppeteer not being originally designed for browser usage (since the DOM and Selenium APIs already support browser automation). This issue may also apply to Puppeteer’s build, but I wanted to open it here because it’s related to the recorder use case.
Steps to Reproduce the Problem
- Clone https://gist.github.com/ad7d2641f9b7b8c6012d031edab790c4
npm install
- Note the sizes outputted by webpack or on disk
Specifications
- Version: 0.6.1
- Platform: macOS
Issue Analytics
- State:
- Created a year ago
- Comments:8 (4 by maintainers)
Top Results From Across the Web
How to Reduce Your Webpack Bundle Size for Web App ...
So I'm gonna try to give you some tips used by teams working on large apps to reduce the size of their main...
Read more >Webpack final bundle size is too big - node.js - Stack Overflow
I know I am missing something here. Should be somewhere near to or more than webpack recommendations but 1010 KB is too much....
Read more >3 ways to reduce webpack bundle size - Jakob Lind
3 ways to reduce webpack bundle size · Easy: Run webpack in production mode · Medium: use an analyzer tool such as webpack-bundle-analyzer...
Read more >5 Methods to Reduce JavaScript Bundle Size - Bits and Pieces
5 Methods to Reduce JavaScript Bundle Size · 1. Code Splitting with Webpack · 2. Using Webpack Plugins for Tree Shaking · 3....
Read more >Minimizing Webpack bundle size - Anvil
Learn how to minimize your Webpack bundle size by following these best practices, ensuring an optimal user experience.
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
Hey @nickmccurdy I suspect that you don’t require Puppeteer for the extension as we currently only support export extensions? In that case, you can safely exclude Puppeteer (which is an optional peer dependency needed for the replay part) from the bundle. Please see this rollup config https://github.com/cypress-io/cypress-chrome-recorder-extension/blob/main/rollup.config.js#L10 as an example in rollup. I believe a similar configuration should be possible for Webpack. Would that work for your extension?
Sorry, got distracted working on other things for the extension.
Adding
"sideEffects": false
tonode_modules/@puppeteer/replay/package.json
seems to work, as it results in themain.js
bundle being empty. This is closer to what we want, because we told webpack it has no side effects and we aren’t using any imports from it. However, this unfortunately still requires installingpuppeteer
and getting webpack to build it with the fairly largeresolve.fallback
config.Does anyone have ideas on how to tree shake away Puppeteer without having to install or configure it?