Change how stats file assets are build using emit hook#132
Merged
Conversation
c77b83b to
2da54ab
Compare
rvlb
commented
Oct 30, 2025
| compiler.hooks.compile.tap(this.name, this._handleCompile.bind(this, compiler)); | ||
| compiler.hooks.done.tap(this.name, this._handleDone.bind(this, compiler)); | ||
| compiler.hooks.compile.tap(this.name, this._handleCompile.bind(this)); | ||
| compiler.hooks.emit.tap(this.name, this._handleEmit.bind(this)); |
Contributor
Author
There was a problem hiding this comment.
The emit hook was the only place where we could always access the full list of compiled assets and could access their in-memory contents.
Other hooks tried:
done: we could not access the in-memory content of the filescompilation.processAssets: we do not have to all compiled assets, broke tests where we compressed themassetEmitted: we have access to all files + their in-memory content, however it's not always called without changing the plugin settings, so ended up causing the stats file to have missing files when not used in a dev server environment.
Contributor
Author
|
This update was also tested using the examples from django-webpack-loader, with and without setting |
rvlb
commented
Oct 31, 2025
| ); | ||
| }); | ||
|
|
||
| it('It should generate the stats file when the plugin runs twice and the output assets already exist', done => { |
Contributor
Author
There was a problem hiding this comment.
This test ensures that even if an asset didn't change between builds, the stats file will always contain its correct info.
fjsj
reviewed
Nov 4, 2025
lib/index.js
Outdated
| this.options = options; | ||
| /** @type {Contents} */ | ||
| this.contents = { | ||
| this.output = { |
Member
There was a problem hiding this comment.
can we keep the this.contents name to avoid changing the API?
fjsj
requested changes
Nov 4, 2025
Member
fjsj
left a comment
There was a problem hiding this comment.
Overall LGTM, but please check comment.
fjsj
approved these changes
Nov 4, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.