@@ -33,16 +33,14 @@ ManifestPlugin.prototype.apply = function(compiler) {
33
33
var seed = this . opts . seed || { } ;
34
34
var moduleAssets = { } ;
35
35
36
- compiler . plugin ( "compilation" , function ( compilation ) {
37
- compilation . plugin ( 'module-asset' , function ( module , file ) {
38
- moduleAssets [ file ] = path . join (
39
- path . dirname ( file ) ,
40
- path . basename ( module . userRequest )
41
- ) ;
42
- } ) ;
43
- } ) ;
44
-
45
- compiler . plugin ( 'emit' , function ( compilation , compileCallback ) {
36
+ var moduleAsset = function ( module , file ) {
37
+ moduleAssets [ file ] = path . join (
38
+ path . dirname ( file ) ,
39
+ path . basename ( module . userRequest )
40
+ ) ;
41
+ } ;
42
+
43
+ var emit = function ( compilation , compileCallback ) {
46
44
var publicPath = compilation . options . output . publicPath ;
47
45
var stats = compilation . getStats ( ) . toJson ( ) ;
48
46
@@ -61,7 +59,7 @@ ManifestPlugin.prototype.apply = function(compiler) {
61
59
path : path ,
62
60
chunk : chunk ,
63
61
name : name ,
64
- isInitial : chunk . isInitial ? chunk . isInitial ( ) : chunk . initial ,
62
+ isInitial : chunk . isInitial ? chunk . isInitial ( ) : chunk . isOnlyInitial ( ) ,
65
63
isChunk : true ,
66
64
isAsset : false ,
67
65
isModuleAsset : false
@@ -172,14 +170,32 @@ ManifestPlugin.prototype.apply = function(compiler) {
172
170
173
171
// NOTE: make sure webpack is not writing multiple manifests simultaneously
174
172
lock ( function ( release ) {
175
- compiler . plugin ( 'after-emit' , function ( compilation , cb ) {
176
- release ( ) ;
177
- cb ( ) ;
178
- } ) ;
173
+ if ( compiler . hooks ) {
174
+ compiler . hooks . afterEmit . tap ( 'ManifestPlugin' , function ( compilation ) {
175
+ release ( ) ;
176
+ } ) ;
177
+ } else {
178
+ compiler . plugin ( 'after-emit' , function ( compilation , cb ) {
179
+ release ( ) ;
180
+ cb ( ) ;
181
+ } ) ;
182
+
183
+ compilation . applyPluginsAsync ( 'webpack-manifest-plugin-after-emit' , manifest , compileCallback ) ;
184
+ }
185
+ } ) ;
186
+ } . bind ( this ) ;
179
187
180
- compilation . applyPluginsAsync ( 'webpack-manifest-plugin-after-emit' , manifest , compileCallback ) ;
188
+ if ( compiler . hooks ) {
189
+ compiler . hooks . compilation . tap ( 'ManifestPlugin' , function ( compilation ) {
190
+ compilation . hooks . moduleAsset . tap ( 'ManifestPlugin' , moduleAsset ) ;
181
191
} ) ;
182
- } . bind ( this ) ) ;
192
+ compiler . hooks . emit . tap ( 'ManifestPlugin' , emit ) ;
193
+ } else {
194
+ compiler . plugin ( 'compilation' , function ( compilation ) {
195
+ compilation . plugin ( 'module-asset' , moduleAsset ) ;
196
+ } ) ;
197
+ compiler . plugin ( 'emit' , emit ) ;
198
+ }
183
199
} ;
184
200
185
- module . exports = ManifestPlugin ;
201
+ module . exports = ManifestPlugin ;
0 commit comments