Comments (15)
Hi, @faceyspacey!
Really interesting idea you have here.
Sure, if this little change can help AutoDLL better cooperate with your plugin I'll gladly add it.
I have a few critical things on my list first, but I will get to it.
You are more than welcome to send a PR if you like (;
from autodll-webpack-plugin.
By the way it seems you cant add to stats
. I tried but it wouldn't work, and then I come across something that says it's on the Webpack roadmap.
It's unfortunate, but unless I'm missing something, there's nothing we can do.
from autodll-webpack-plugin.
Yeah, I'm thinking quite a lot about it lately.
I believe that the reason the stats don't know anything about the DLL is that the plugin creates a separate compiler for the DLL and call it before the main compiler.
What if I give you access to the DLL compiler?
I can expose a plugin hook
compiler.plugin('dll-compiler-created', dllCompiler => {
dllCompiler.plugin('emit', (compilation, callback) => {
...
});
});
The catch is that I only compile it when needed, otherwise I read the DLL from the cache (file system) so the stats won't be available in that case.
I thought that the stats are not serializable, but then I read in your docs about a plugin called
stats-webpack-plugin maybe I can add this to the DLL compiler config.
What do think?
from autodll-webpack-plugin.
Regarding the hook, it would need to be 100% reliable. Also currently I'm not passed the compiler, just the stats.
As for the stats, editing the file created by the stats-webpack-plugin
would work, but then you would be coupled to that plugin, and users would have to write the stats file even in development, etc. The case of using in-memory-stats wouldn't be solved. So I don't think that route is solid enough either unfortunately.
I think we have no choice, but to wait until Webpack has an API to write to stats.
from autodll-webpack-plugin.
Is there an issue for that or does the webpack team have plans on doing so?
from autodll-webpack-plugin.
Hi @faceyspacey!
I added a hook for the DLL stats.
You can use it like this:
compiler.plugin('autodll-stats-retrieved', (stats, source) => {
console.log(stats) // stats object
console.log(source) // build / memory / fs
}
from autodll-webpack-plugin.
Sweet!
from autodll-webpack-plugin.
Let me know if it works for you 😄
from autodll-webpack-plugin.
Hi @asfktz, I've also encountered a problem of vendor files missing in stats object. I wanted to analyze some issues with size of files it produces but unfortunately it relies on the stats being generated by autodllplugin. Is there any way that could be achieved at the moment? Do you have any suggestions on how to use the hook you mentioned in order to append stats from this plugin to the rest of the plugins?
from autodll-webpack-plugin.
HI @PeterKottas!
How about something like this:
class MyPlugin {
apply(compiler) {
let dllStats;
// 'autodll-stats-retrieved' will always be called
// before the main compiler is done
compiler.plugin('autodll-stats-retrieved', (_dllStats, source) => {
// store the dll stats somehow
dllStats = _dllStats
})
compiler.plugin('done', (stats) => {
// now you have access to both
console.log(stats, dllStats)
});
}
}
from autodll-webpack-plugin.
Cool, that looks simple enough. I assume this will only output stats specific for the vendors bundle. Or is it actually combining it with the rest of the stats?
from autodll-webpack-plugin.
You're right. It's the stats as is.
To be precise, what you get is stats.toJson()
,
So if you want to merge them, you might what to do the same for the main compilers stats too:
compiler.plugin('done', (stats) => {
// now both are serialized
console.log(stats.json(), dllStats);
});
from autodll-webpack-plugin.
Nice one! Would it maybe be worth doing that inside autodll-webpack-plugin? Or in fact, if 'done' is called by webpack only after everything is done, I see how that could be a problem. Maybe you could add some prebuild functionality for this? Although it's hard to say how many people are actually interested in this.
from autodll-webpack-plugin.
Hmm.. I can see why you want that, other plugin authors might benefit from abstracting away the fact that there's is actually two different stats, but I feel that I'm not familiar enough with the stats to make the merge inside the plugin.
What I can think of is adding another hook right after done
that will expose both of the stats, serialized.
compiler.plugin('autodll-done', (stats, dllStats) => {
// now you have access to both
console.log(stats, dllStats)
});
from autodll-webpack-plugin.
I see your point. I would look at it myself but I don't have time for it now (might have some around Christmas). I really believe it would be the best if this could be abstracted away so that we have a switch in options "outputStats": boolean which would just spit out the final merged stats. It's true though that merging stats can be tricky. But maybe not, it might surprise us. If you're fine with it, we can open a new issue or reopen this one and hope to find somebody to help, or at least to keep track.
One thing I struggle with is to understand how many people are actually looking at stats. (Everybody should imho :D, but I doubt that's the case). I normally just check the output for sanity, saves quite a lot of size of js files as there's always some bs forgotten here and there
from autodll-webpack-plugin.
Related Issues (20)
- 'Is valid cache' is aways false
- How to DevExpress to DLL? HOT 3
- got error when use dynamic import
- Only updating package produces wrong broken dll-links when using chunkhashes
- AutoDLL not working in NextJS HOT 1
- webpack4中每次修改app.js时dll会重新打包 HOT 1
- I use this plugin for react-app,it wiil not inject to the html HOT 1
- TypeError: Cannot read property 'properties' of undefined HOT 1
- multiple dll packages are generated, it will cause duplicate references HOT 2
- Is it support css dll?
- ModuleNotFoundError with Webpack 4
- stats.json are too big HOT 1
- How do I set entryOnly to true to enable treeshaking?
- Plugins are not run when cache is valid
- Autodll-webpack-plugin specifying node_modules in different projects
- what is the right context for a monorepo setup?
- inject the DLL bundles into the html fail HOT 5
- add path parameter html script src can add /
- Cannot add property autodllStatsRetrieved, object is not extensible HOT 3
- how to use this plugin with create-react-app & craco ? HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from autodll-webpack-plugin.