webpack-clean-obsolete-chunks icon indicating copy to clipboard operation
webpack-clean-obsolete-chunks copied to clipboard

webpack 5 chunks array depreciation

Open aniketfuryrocks opened this issue 3 years ago • 7 comments

Webpack 5 deprecated chunks array in favour of object.

*/51 > /*
let chunks = compilation.chunks.map(chunk => {
     const copy = Object.assign({}, chunk)
     copy.uniqueId = `${compilationName}--${copy.id}`
     return copy
})

.map needs to be replaced with something related to Object.keys

Errror:

(node:36954) [DEP_WEBPACK_DEPRECATION_ARRAY_TO_SET] DeprecationWarning: Compilation.chunks was changed from Array to Set (using Array method 'map' is deprecated)
    at Set.set.<computed> [as map] (/media/dedsec/Projects/FireJSX/node_modules/webpack/lib/util/deprecation.js:85:4)
    at /media/dedsec/Projects/FireJSX/node_modules/webpack-clean-obsolete-chunks/index.js:51:37
    at Array.reduce (<anonymous>)
    at CleanObsoleteChunks._retrieveAllChunks (/media/dedsec/Projects/FireJSX/node_modules/webpack-clean-obsolete-chunks/index.js:49:23)
    at CleanObsoleteChunks._getObsoleteFiles (/media/dedsec/Projects/FireJSX/node_modules/webpack-clean-obsolete-chunks/index.js:41:23)
    at CleanObsoleteChunks._removeObsoleteFiles (/media/dedsec/Projects/FireJSX/node_modules/webpack-clean-obsolete-chunks/index.js:28:28)
    at Hook.eval [as callAsync] (eval at create (/media/dedsec/Projects/FireJSX/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:7:1)
    at Hook.CALL_ASYNC_DELEGATE [as _callAsync] (/media/dedsec/Projects/FireJSX/node_modules/tapable/lib/Hook.js:18:14)
    at /media/dedsec/Projects/FireJSX/node_modules/webpack/lib/Compiler.js:730:27
    at /media/dedsec/Projects/FireJSX/node_modules/neo-async/async.js:2818:7

Platform : Linux Webpack : 5.1.3 webpack-clean-obsolete-chunks : 0.4.0

aniketfuryrocks avatar Oct 18 '20 07:10 aniketfuryrocks

I'm getting the same warning. It seems like you know enough to send a PR?

Philipp91 avatar Jan 03 '21 22:01 Philipp91

I am busy with other work, I'll work on it, as soon as possible.

aniketfuryrocks avatar Jan 12 '21 13:01 aniketfuryrocks

Seems like webpack's native output.clean actually handles what this plugin does. Wonder if this plugin can be deprecated? https://webpack.js.org/configuration/output/#outputclean

JohnnyFun avatar Mar 12 '21 17:03 JohnnyFun

@JohnnyFun I don't see the option you mentioned in the docs... I see the mention of the clean-webpack-plugin only here

GProst avatar Mar 12 '21 17:03 GProst

hmm, that link takes me to something that looks like this: image

JohnnyFun avatar Mar 12 '21 17:03 JohnnyFun

@JohnnyFun yeah, now I see it, lol

GProst avatar Mar 12 '21 17:03 GProst

Yes, it seems like Webpack 5.20.0 deprecates this plugin. I'm gonna add a note about it when I have time 👍 Thanks for pointing that out @JohnnyFun

GProst avatar Mar 12 '21 18:03 GProst