@@ -195,14 +195,16 @@ class NormalModule extends Module {
195195
196196 const resourceBuffer = result . resourceBuffer ;
197197 const source = result . result [ 0 ] ;
198- const sourceMap = result . result [ 1 ] ;
198+ const sourceMap = result . result . length >= 1 ? result . result [ 1 ] : null ;
199+ const extraInfo = result . result . length >= 2 ? result . result [ 2 ] : null ;
199200
200201 if ( ! Buffer . isBuffer ( source ) && typeof source !== "string" ) {
201202 const error = new ModuleBuildError ( this , new Error ( "Final loader didn't return a Buffer or String" ) ) ;
202203 return callback ( error ) ;
203204 }
204205
205206 this . _source = this . createSource ( asString ( source ) , resourceBuffer , sourceMap ) ;
207+ this . _ast = typeof extraInfo === "object" && extraInfo !== null && extraInfo . webpackAST !== undefined ? extraInfo . webpackAST : null ;
206208 return callback ( ) ;
207209 } ) ;
208210 }
@@ -217,6 +219,7 @@ class NormalModule extends Module {
217219 this . error = error ;
218220 this . errors . push ( this . error ) ;
219221 this . _source = new RawSource ( "throw new Error(" + JSON . stringify ( this . error . message ) + ");" ) ;
222+ this . _ast = null ;
220223 }
221224
222225 applyNoParseRule ( rule , content ) {
@@ -264,6 +267,7 @@ class NormalModule extends Module {
264267 this . buildTimestamp = Date . now ( ) ;
265268 this . built = true ;
266269 this . _source = null ;
270+ this . _ast = null ;
267271 this . error = null ;
268272 this . errors . length = 0 ;
269273 this . warnings . length = 0 ;
@@ -289,7 +293,7 @@ class NormalModule extends Module {
289293 }
290294
291295 try {
292- this . parser . parse ( this . _source . source ( ) , {
296+ this . parser . parse ( this . _ast || this . _source . source ( ) , {
293297 current : this ,
294298 module : this ,
295299 compilation : compilation ,
0 commit comments