-
Notifications
You must be signed in to change notification settings - Fork 309
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
Large bundle size with webpack #257
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? |
Thanks for the helpful tip, I didn't think about that because I was trying to use tree shaking. Do you think it would make sense to publish with For anyone else having this issue with webpack, here's the workaround I'm using now: plugins: [
new webpack.IgnorePlugin({
resourceRegExp: /^puppeteer$/,
})
] |
@nickmccurdy unfortunately, I am not familiar with |
Yes. It tells webpack that an entire package's code is pure, so that modules can be tree shaked without losing side effects. However, Rollup can tree shake ES modules.
In theory, yes, though that should only be used if the entire package is side effect free. If that's not the case, you can use Source: webpack Tree Shaking |
I gave it a try but it looks it does not work: if I import anything from the replay lib, Webpack decides to import Puppeteer too although Puppeteer is only a dynamic import in the generated ESM code? |
Do you have an example webpack config? |
@nickmccurdy I used the one you posted in the gist: https://gist.github.com/nickmccurdy/ad7d2641f9b7b8c6012d031edab790c4 |
Sorry, got distracted working on other things for the extension. Adding Does anyone have ideas on how to tree shake away Puppeteer without having to install or configure it? |
Actual 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
npm install
Specifications
The text was updated successfully, but these errors were encountered: