-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Tree shaking is hindered by dependencies #78
Comments
Tagging #55 as a link. |
The issue isn't immediately critical, I guess, but it'd be nice if we can figure it out. Related to this, I've been trying to conditionally import |
So I went through these module concat errors one-by-one. Here is what I found:
|
Potentially useful: https://github.com/TrySound/rollup-plugin-size-snapshot |
I just experimented with this a little bit, and I stumbled at I guess there are still use-cases for the module (electron apps?), but including it by default takes up waaaay too much space IMHO. @markerikson what do you think - would removing that and using the extension-provided global variable instead be an option? |
That doesn't sound right. Bundlephobia says it's like 600 bytes: https://bundlephobia.com/result?p=redux-devtools-extension@2.13.8 Ditto for the index file: https://unpkg.com/browse/redux-devtools-extension@2.13.8/index.js How are you seeing 6.7K? And here's the Bundlephobia report for RSK 1.0.1: https://bundlephobia.com/result?p=redux-starter-kit@1.0.1 11.5K Immer, 6.65K Redux, 5K self. |
In building the project posted by @denisw above twice, once with Here are the results: (second build based on this branch: https://github.com/phryneas/redux-starter-kit/tree/tree-shaking ) |
Huh. That seems... odd. We'll have to dig into this further. |
Okay, a little experimentation later: |
Ah, interesting. Now, realistically, I'd expect this to be a moot point because most apps would be using Still, it'd be interesting to figure out what things could and should be tree-shaken, both from RSK and our deps. |
Yup, but it also depends on how much redux could be tree-shaken again. Another point here is immer - it's being included 100% even if it isn't called at all (when just using createAction). Not sure why though. |
Just filed immerjs/immer#500 to see if they can maybe improve Immer's behavior by adding |
Michel Weststrate is doing some work on improving Immer's tree-shaking, and just tweeted that the Rollup |
And he also dropped this neat-looking tool: |
This will be resolved once 1.3 comes out, so closing. |
I just checked why tree shaking is not working correctly as mentioned by @markerikson in his tweet. I tested using the following small example project.
package.json
webpack.config.js
src/index.js
When building, all of redux-starter-kit ends up in the output. Looking more at the Webpack tree-shaking optimization, I eventually found the Debugging Optimization Bailouts section, which suggests running Webpack with
--display-optimization-bailout
to find out when optimizations don't get applied. This is what I got:As ModuleConcatenationPlugin is needed for tree-shaking, this suggests that some of the dependencies using
require()
prevent tree-shaking from happening.The text was updated successfully, but these errors were encountered: