11/**
2- * This dependency plugin is a fork of:
2+ * This dependency plugin is a fork of:
33 * chunk-manifest-webpack-plugin (https://github.com/soundcloud/chunk-manifest-webpack-plugin)
4- *
4+ *
55 * inline-chunk-manifest-html-webpack-plugin already enables inlining webpack's chunk manifest,
66 * and therefor has been extracted.
77 */
@@ -22,15 +22,15 @@ class ChunkManifestPlugin {
2222 const manifestVariable = this . manifestVariable ;
2323 let chunkFilename ;
2424
25- compiler . plugin ( "this-compilation ", compilation => {
25+ compiler . hooks . thisCompilation . tap ( "ChunkManifestPlugin ", compilation => {
2626 const mainTemplate = compilation . mainTemplate ;
27- mainTemplate . plugin ( "require-ensure ", function (
27+ mainTemplate . hooks . requireEnsure . tap ( "ChunkManifestPlugin ", (
2828 source ,
2929 chunk ,
3030 hash
3131 /*, chunkIdVariableName */
32- ) {
33- chunkFilename = this . outputOptions . chunkFilename ;
32+ ) => {
33+ chunkFilename = compilation . outputOptions . chunkFilename ;
3434
3535 if ( chunkFilename ) {
3636 const chunkManifest = [ chunk ] . reduce ( function registerChunk (
@@ -42,23 +42,29 @@ class ChunkManifestPlugin {
4242 if ( c . hasRuntime ( ) ) {
4343 manifest [ c . id ] = undefined ;
4444 } else {
45- const assetFilename = mainTemplate . applyPluginsWaterfall (
46- "asset-path" ,
45+ const assetFilename = mainTemplate . getAssetPath (
4746 chunkFilename ,
4847 {
49- hash,
48+ hash : hash ,
5049 chunk : c
5150 }
5251 ) ;
5352
5453 manifest [ c . id ] = assetFilename ;
5554 }
5655
57- return c . chunks . reduce ( registerChunk , manifest ) ;
58- } ,
59- { } ) ;
56+ const cGroups = Array . from ( c . groupsIterable ) ;
57+ const cGroupsChildren = cGroups . map ( group => group . chunks ) ;
58+ const unsortedChunks = cGroupsChildren . reduce (
59+ ( chunksArray , childrens ) => chunksArray . concat ( childrens ) ,
60+ [ ] ) ;
6061
61- this . outputOptions . chunkFilename = "__CHUNK_MANIFEST__" ;
62+ const chunks = Array . from ( new Set ( unsortedChunks ) ) ;
63+
64+ return chunks . reduce ( registerChunk , manifest ) ;
65+ } , { } ) ;
66+
67+ compilation . outputOptions . chunkFilename = "__CHUNK_MANIFEST__" ;
6268
6369 compilation . assets [ manifestFilename ] = new RawSource (
6470 JSON . stringify ( chunkManifest )
@@ -69,16 +75,16 @@ class ChunkManifestPlugin {
6975 } ) ;
7076 } ) ;
7177
72- compiler . plugin ( "compilation ", compilation => {
78+ compiler . hooks . compilation . tap ( "ChunkManifestPlugin ", compilation => {
7379 const mainTemplate = compilation . mainTemplate ;
74- mainTemplate . plugin ( "require-ensure ", function (
80+ mainTemplate . hooks . requireEnsure . tap ( "ChunkManifestPlugin ", (
7581 source ,
7682 chunk ,
7783 hash ,
7884 chunkIdVariableName
79- ) {
85+ ) => {
8086 if ( chunkFilename ) {
81- this . outputOptions . chunkFilename = chunkFilename ;
87+ compilation . outputOptions . chunkFilename = chunkFilename ;
8288 }
8389
8490 const updatedSource = source . replace (
0 commit comments