From 9303f0a5b9674260e6789654cd851ffaca296dc4 Mon Sep 17 00:00:00 2001 From: Thomas Gerbet Date: Thu, 18 Mar 2021 11:01:31 +0100 Subject: [PATCH] Fix Webpack 5 deprecation warning: Chunk.files is now a Set This contribution solves the deprecation warning caused by the transformation into a Set of Chunk.files in Webpack 5 [0]. The warning should not been visible anymore ``` [DEP_WEBPACK_DEPRECATION_ARRAY_TO_SET_PUSH] DeprecationWarning: chunk.files was changed from Array to Set (using Array method 'push' is deprecated) ``` [0] https://webpack.js.org/blog/2020-10-10-webpack-5-release/#arrays-to-sets --- index.js | 6 +++++- index.node6-compatible.js | 7 ++++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/index.js b/index.js index 0d30b0d..3cf773b 100755 --- a/index.js +++ b/index.js @@ -134,7 +134,11 @@ class MergeIntoFile { const chunk = compilation.addChunk(fileId); chunk.id = fileId; chunk.ids = [chunk.id]; - chunk.files.push(newFileNameHashed); + if (chunk.files instanceof Set) { + chunk.files.add(newFileNameHashed); + } else { + chunk.files.push(newFileNameHashed); + } } } generatedFiles[newFileName] = newFileNameHashed; diff --git a/index.node6-compatible.js b/index.node6-compatible.js index efddee7..026b021 100644 --- a/index.node6-compatible.js +++ b/index.node6-compatible.js @@ -267,7 +267,12 @@ var MergeIntoFile = /*#__PURE__*/function () { var chunk = compilation.addChunk(fileId); chunk.id = fileId; chunk.ids = [chunk.id]; - chunk.files.push(newFileNameHashed); + + if (chunk.files instanceof Set) { + chunk.files.add(newFileNameHashed); + } else { + chunk.files.push(newFileNameHashed); + } } }