@@ -201,7 +201,7 @@ class Compiler extends Tapable {
201201 } ) ;
202202 } ) ;
203203 } ,
204- apply : function ( ) {
204+ apply : ( ) => {
205205 const args = arguments ;
206206 if ( ! deprecationReported ) {
207207 console . warn ( "webpack: Using compiler.parser is deprecated.\n" +
@@ -214,7 +214,7 @@ class Compiler extends Tapable {
214214 parser . apply . apply ( parser , args ) ;
215215 } ) ;
216216 } ) ;
217- } . bind ( this )
217+ }
218218 } ;
219219
220220 this . options = { } ;
@@ -313,13 +313,7 @@ class Compiler extends Tapable {
313313 emitAssets ( compilation , callback ) {
314314 let outputPath ;
315315
316- this . applyPluginsAsync ( "emit" , compilation , err => {
317- if ( err ) return callback ( err ) ;
318- outputPath = compilation . getPath ( this . outputPath ) ;
319- this . outputFileSystem . mkdirp ( outputPath , emitFiles . bind ( this ) ) ;
320- } ) ;
321-
322- function emitFiles ( err ) {
316+ const emitFiles = ( err ) => {
323317 if ( err ) return callback ( err ) ;
324318
325319 require ( "async" ) . forEach ( Object . keys ( compilation . assets ) , ( file , callback ) => {
@@ -330,12 +324,7 @@ class Compiler extends Tapable {
330324 targetFile = targetFile . substr ( 0 , queryStringIdx ) ;
331325 }
332326
333- if ( targetFile . match ( / \/ | \\ / ) ) {
334- const dir = path . dirname ( targetFile ) ;
335- this . outputFileSystem . mkdirp ( this . outputFileSystem . join ( outputPath , dir ) , writeOut . bind ( this ) ) ;
336- } else writeOut . call ( this ) ;
337-
338- function writeOut ( err ) {
327+ const writeOut = ( err ) => {
339328 if ( err ) return callback ( err ) ;
340329 const targetPath = this . outputFileSystem . join ( outputPath , targetFile ) ;
341330 const source = compilation . assets [ file ] ;
@@ -352,14 +341,25 @@ class Compiler extends Tapable {
352341 source . existsAt = targetPath ;
353342 source . emitted = true ;
354343 this . outputFileSystem . writeFile ( targetPath , content , callback ) ;
355- }
344+ } ;
345+
346+ if ( targetFile . match ( / \/ | \\ / ) ) {
347+ const dir = path . dirname ( targetFile ) ;
348+ this . outputFileSystem . mkdirp ( this . outputFileSystem . join ( outputPath , dir ) , writeOut ) ;
349+ } else writeOut ( ) ;
356350
357351 } , err => {
358352 if ( err ) return callback ( err ) ;
359353
360354 afterEmit . call ( this ) ;
361355 } ) ;
362- }
356+ } ;
357+
358+ this . applyPluginsAsync ( "emit" , compilation , err => {
359+ if ( err ) return callback ( err ) ;
360+ outputPath = compilation . getPath ( this . outputPath ) ;
361+ this . outputFileSystem . mkdirp ( outputPath , emitFiles ) ;
362+ } ) ;
363363
364364 function afterEmit ( ) {
365365 this . applyPluginsAsyncSeries1 ( "after-emit" , compilation , err => {
0 commit comments