Closed Levdbas closed 3 years ago
I'm stretched a little thin at the moment so would appreciate a PR to resolve this.
Okey, since I have little to no knowledge of the inner workings of this plugin/webpack I am kind of hesitant with making a PR.
That being said, I dived into the code and found out the error occurs right here:
if (webpack.version.startsWith("4")) {
compiler.hooks.emit.tap(hookOptions, emit);
} else {
compiler.hooks.afterCompile.tap(hookOptions, (compilation) => {
compilation.hooks.processAssets.tap(hookOptions, () =>
emit(compilation)
);
});
}
When removing the if/else alltogether and change it just to
compiler.hooks.emit.tap(hookOptions, emit);
at least my test repo works again and the file does get added to the manifest.
I think you have a good reason for adding that if/else statement in the first place but it seems that emit hook is getting called too early or something. Hopefully this will point you in the right direction.
Thanks for the extra info. I won't be working on this one but hopefully it helps someone in the community to contribute a fix.
@Levdbas Perhaps try the following in the else section. I think the inner emit might have lost its scope, depending on your js environment.
compiler.hooks.afterCompile.tap(hookOptions, compilation.hooks.processAssets.tap(hookOptions, emit.bind(this, compilation)) .bind(this, compilation));
Hi NovaLagnus see the comments on #246 . The updated hook for webpack 5 in version 3.0 is right but other plugins are still using the deprecated compiler.hooks.emit.tap hook. Those other plugins are generating assets after the manifest was generated.
Hey folks. This issue hasn't received any traction for 60 days, so we're going to close this for housekeeping. If this is still an ongoing issue, please do consider contributing a Pull Request to resolve it. Further discussion is always welcome even with the issue closed. If anything actionable is posted in the comments, we'll consider reopening it. ⓘ
Expected Behavior
when running npm run dev index.asset.json, generated by @wordpress/dependency-extraction-webpack-plugin, is also added to the manifest file.
Actual Behavior
index.asset.json is missing from manifest file.
Additional Information
I've the same issue with other webpack plugins that emit files as well, but I have limited this repo to only one example. Nice detail: when setting webpack to 4.46 and webpack-manifest-plugin to 2.2.0 and retry to run npm run dev index.asset.json does get added to the manifest file.
So it seems like the files like this outside the entry files are not being added to the manifest. Any idea?