DeprecationWarning: Compilation.assets will be frozen in future, all modifications are deprecated
Asked Answered
F

3

33

I am working on a react project and when I updated webpack 4.44.2 to 5.4.0 I am getting the following message:

[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_*.
(Use `node --trace-deprecation ...` to show where the warning was created)

I searched a lot but did not get an exact answer. So how can I solve ?

Fincher answered 13/11, 2020 at 6:4 Comment(0)
P
34

Update 2021, Feb 25

Html-webpack-plugin v5 is released, just run

npm i -D html-webpack-plugin@latest

or

npm uninstall html-webpack-plugin

npm i -D html-webpack-plugin

Original answer

This is mostly related to html-webpack-plugin, and while its new version 5 (integrated with webpack v5) is still in beta, you should update it manually:

npm show html-webpack-plugin version 
4.5.1

npm show html-webpack-plugin@next version
5.0.0-beta.5

npm i -D html-webpack-plugin@next
Precentor answered 16/1, 2021 at 15:5 Comment(4)
Should be the accepted answer ! Thank youVentriloquism
I found this too, but it didn't fix it for me.Vomiturition
this issue can happen not only for html-webpack-plugin, for me it was for brotli-webpack-pluginChristabella
As per comment by Oleh, this can happen due to other plugins, For me it was the copy-webpack-plugin.Colo
R
11

Are you running command like npx webpack? If so, you can use:

$ node --trace-deprecation ./node_modules/.bin/webpack

It should show you all those webpack plugins producing those warnings.

Ross answered 13/11, 2020 at 12:13 Comment(1)
In my case I had to use tracing this way node --trace-deprecation ./node_modules/webpack-cli/bin/cli.js (Im running webpack using package.json scripts via npn run build)Vharat
P
3

These depraction warnings are negligible. The root case are plugins which violate the quite new Webpack 5 specs. Someday they will swing together (for a while).

You can get arround of [DEP_WEBPACK_COMPILATION_ASSETS] by updating npm packages. Check the latest versions with:

npm outdated

That worked for me, but now I get [DEP_WEBPACK_COMPILATION_OPTIMIZE_CHUNK_ASSETS]. Just wait and see.

Pacheco answered 8/2, 2021 at 15:32 Comment(1)
Works fine, just run npm update (or npm update --force if you must) afterwardAfroasian

© 2022 - 2024 — McMap. All rights reserved.