-
Notifications
You must be signed in to change notification settings - Fork 33
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
improve compatibility with webpack@5 #52
Comments
Hi @evilebottnawi ! 👋 I've started a branch on this at https://github.com/FormidableLabs/webpack-stats-plugin/tree/feature/webpack5 and I've got my test harness in place for all of webpacks 1 - 5 now (using beta 25) and everything works as-is. For migrating to the new format do you have any examples? I was able to access the |
@ryan-roemer Hello, you can't add asset to /cc @sokra |
So right now in curCompiler.assets[filename] = {
source() {
return statsStr;
},
size() {
return statsStr.length;
}
}; where Do you or @sokra have an example of using the Thanks! |
@ryan-roemer You can use I can send a PR late with example, do we really need webpack@3 supporting? Because it was deprecated and unsupported? |
Ok I see multiple use cases for this plugin:
And I see 2 way the plugin could work: A. It adds the stats.json as asset to the compilation, it's displayed in the final stats output and emitted by the Compiler. When the output filesystem is changed (e. g. by the webpack-dev-server) the stats.json is written to this filesystem. For the webpack-dev-server this means the stats.json is not written to disk but instead served by the server directly. The asset is written to B. It writes the stats.json to the intermediateFileSystem when the compilation has finished ( I think for use case 1 and 2 you want way B, for use case 3 you want way A. Instead of |
Thanks for the in-depth comment @sokra ! @evilebottnawi -- I've got test fixtures mostly up and running, but I'm currently blocked by entry: {
main: "../../src/main.js"
}, but with Once |
@ryan-roemer Thanks, new release will be soon (today/tomorrow) |
Hi @sokra -- Now that I'd ideally like just one place that emits stats and emits them as completely as possible (I don't mind if say later plugins then emit assets that get missed). So, if I want to do the Thanks! |
@sokra @evilebottnawi -- I've now got a WIP PR/branch up at: #54 I'm going for this for the modern webpack5 hook: // Modern: `processAssets` is one of the last hooks before frozen assets.
compilation.hooks.processAssets.tapPromise(
{
name: "stats-writer-plugin",
stage: compilation.PROCESS_ASSETS_STAGE_DERIVED
},
() => this.emitStats(compilation)
); but I'm not totally sure ... and this is how I'm emitting if the compiler has if (curCompiler.emitAsset) {
// Modern method.
curCompiler.emitAsset(filename, source);
} else {
// Fallback to deprecated method.
curCompiler.assets[filename] = source;
} |
Drop old versions of webpack and use Yes, you need to use |
- Use non-deprecated hooks / methods of adding assets. Fixes #52 - Update tests for webpack5 expected failures
Released in |
@ryan-roemer Thanks for the update! Unfortunately, this results in |
@ryan-roemer https://github.com/FormidableLabs/webpack-stats-plugin/blob/main/lib/stats-writer-plugin.js#L75 compiler.hooks.thisCompilation.tap("stats-writer-plugin", (compilation) => {
// Logic
}); Otherwise you will be work on each child compilation, you don't need it |
@evilebottnawi -- Thanks I'll try that out! Other question if you're around -- is there a better explanation of the @kelunik -- I'll get a brach up soon for you to try with @evilebottnawi's sugggestion |
@kelunik @koconnorIXL -- I have a branch up at Thanks! |
I think this is good https://github.com/webpack/webpack/blob/master/lib/Compilation.js#L3463 |
Fixes released in |
@ryan-roemer - All of my problems seem resolved after your changes |
I'm still on webpack 4, and on upgrading from webpack-stats-plugin 0.3.2 have started seeing "WARNING in Conflict: Multiple assets emit different content to the same filename stats.json". I'm using these webpack packages:
|
@jdelStrother -- Can you create a minimal repository with install and build steps to produce the issue? Thanks! |
Sure, see #59 |
in webpack@5 adding assets on emit hook is deprecated, so it should be improve, we talked with @sokra about migration and compatibility.
So, we need do migration on
done
hook and usecompilation.intermediateFileSystem
Thanks for plugin.
P.S. I would also like to say that it is very popular and we would to get it in
webpack-contrib
as official plugin, if you interested in this, just say me it and we will start to do it.The text was updated successfully, but these errors were encountered: