-
-
Notifications
You must be signed in to change notification settings - Fork 27k
Consider using DllPlugin #48
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
Comments
@mxstbr Would be great if you could take a look at it. I saw |
(No pressure though! I’m sure somebody will help us after open sourcing if you don’t have time. Thanks a lot for your help so far.) |
Would not recommend, adds a lot of complexity. The sole benefit is that in dev mode, your builds are slightly faster if you have a lot of dependencies. (in our case it knocked off a few seconds of build time) In production, we simply use the |
Oh, okay, not a big deal then. |
@mxstbr @gaearon I thought the big benefit of DLL was rebuild times. Having a faster hot-reload/rebuild when you make a change is very useful. I did some quick and rough testing on react-boilerplate taking the commits before and after DLL was added. Both tested in same order doing and in two different folders, right after one another.
I feel those rebuild times are pretty significant. Its a difference between feeling instant and 'waiting' for the reload. Larger project should have even more benefit. As this project is, in part about a great dev experience, it would make sense to me that that fast rebuilds is worth adding if it can be done in a not-so-complicated manner (would be a great example for others to follow as well) |
If you can submit a PR significantly improving rebuild times in any way I will be happy to get it in. |
@gaearon On my own project it took our rebuild times from ~4000ms to ~1000ms. However in the CRA which basically just has React in the DLL the difference is alot smaller. Stats
Added complexityCreating DLL package list Weird webpack stuff Reliability Worth adding?I don't have much of an answer if it's worth adding. The 'feeling' between the two rather minimal as is. However if CRA is used for something containin 10+ node_modules, the difference might be much larger. Large CRA exampleExample with larger CRA (imports: redux, react-redux, lodash, react-bootstrap, immutable, redux-saga, reselect, babel-polyfill, react-router. No other changes)
|
IMO it'd be nice to have, even though the gains on the minimal examples are small. It's such a pain to set up if you're unfamiliar with it, so having something working out of the box is really nice. |
Shameless plug, you can look how tarec uses DLLS:
So it's not perfect yet:
But I concur with @ro-savage, in my experience it yields very impressive improvements even on medium size apps with a dozen dependencies. |
I implemented it pretty quickly in a work project with similar performance gains as @ro-savage:
|
Would you like to submit a proof of concept PR? |
@gaearon Sorry this sat here for nearly a week. I guess now I know you were talking to me? ;) |
Haha. If you’d like 😄 |
Closing for lack of interest. If somebody wants to do this, please go ahead and submit a PR! |
I am so excited about this! After seeing @ro-savage's Stats, I had to try it for myself. So, I decided to make a PR. I wanted to Add the DllPlugin to CRA without introducing new files, The main challenges was that:
Those constraints led to many iterations over this PR, You just add it to webpack.config.dev.js as usual, tell it which modules you want to move to the DLL and that's it. Now, when you run webpack for the first time, It creates a separate compiler that builds the DLLs, stores them in a cache directory, and load them into the memory so webpack's dev server can consume them later. Then, it connects with the HTMLPlugin to injects the DLL bundles before the main one. The next time you run webpack, it will read the DLLs from the cache, to skip unnecessary build, unless node_modules changed or if the plugin's settings are different from the last build. The more I worked on the Plugin, the more I realized that there's nothing specific to CRA about it, and that this plugin can serve many other webpacks configurations, so I extracted the code into a separate repository and called it AutoDllPlugin. This PR is now included only 2 changes: The way to use it is by adding the dll entries in the packge.json, like so: {
"name": "closed-cra-dll-test",
"version": "1.0.0",
"private": true,
"dependencies": {
"react": "^15.6.1",
"react-dom": "^15.6.1"
},
"devDependencies": {
"react-scripts": "1.0.7"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test --env=jsdom",
"eject": "react-scripts eject"
},
"dll": {
"entry": {
"vendor": [
"react",
"react-dom"
]
}
}
} Only ./polyfills are included by default. That's it. |
Can you do the same thing with CommonChunks plugin please? |
Hi @JustFly1984, |
Thank you) |
@asfktz nice job |
nice job |
http://engineering.invisionapp.com/post/optimizing-webpack/
https://robertknight.github.io/posts/webpack-dll-plugins/
I don’t quite understand how to integrate it, and community help would be most welcome.
It would be ideal if we could make both dev and prod builds faster.
The idea is that we’d only use it for
react
andreact-dom
.The text was updated successfully, but these errors were encountered: