Skip to content
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

fix: DeprecationWarning Compilation.assets #677

Closed
wants to merge 1 commit into from

Conversation

duterte
Copy link

@duterte duterte commented Dec 21, 2020

Summary

This is to fix Webpack 5 deprecation warning :

(node:4312) [DEP_WEBPACK_COMPILATION_ASSETS] DeprecationWarning: Compilation.assets will be frozen in future, all modifications are deprecated.
BREAKING CHANGE: No more changes should happen to Compilation.assets after sealing the Compilation.
        Do changes to assets earlier, e. g. in Compilation.hooks.processAssets.
        Make sure to select an appropriate stage from Compilation.PROCESS_ASSETS_STAGE_*.

This warning was trace to line 32 of packages/webpack-plugin/src/index.js. This warning will fired when plugin emit loadable-stats.json

Test plan

This version of code is compatible with Webpack version 4 and 5. I've already used in my own project. Original version uses compilation.assets to emit loadable-stats.json . This version will produce similar output by not using compilation hook. This should work even compilation.getStats().toJson() produces huge bytes of strings.

Copy link
Collaborator

@theKashey theKashey left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's focus on a solution from #676

this.opts.filename,
)
const file = fs.createWriteStream(outputPath)
file.write(result)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is definitely not a correct way to handle this moment. You should not write file in order to handle deprecation warning, especially if that functionality already exists via writeAssetsFile.

Ask yourself why there were two ways of doing this?

Let's proceed with, which addresses the same problem without removing breaking the contract between loadable and webpack.
https://github.com/gregberge/loadable-components/pull/676/files#diff-ca9a5ec2c1a865ca7d717cfaed22c11c91459fefce687dccc92ca910c1409c5eL32

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@theKashey
Copy link
Collaborator

Closing as #676 got merged

@theKashey theKashey closed this Jan 24, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants