@@ -51,8 +51,9 @@ const emitHook = function emit(
5151
5252 emitCountMap . set ( manifestFileName , emitCount ) ;
5353
54+ const auxiliaryFiles = { } ;
5455 let files = Array . from ( compilation . chunks ) . reduce (
55- ( prev , chunk ) => reduceChunk ( prev , chunk , options ) ,
56+ ( prev , chunk ) => reduceChunk ( prev , chunk , options , auxiliaryFiles ) ,
5657 [ ]
5758 ) ;
5859
@@ -66,6 +67,17 @@ const emitHook = function emit(
6667 typeof emitCountMap . get ( join ( compiler . options . output . path , name ) ) === 'undefined'
6768 ) ;
6869
70+ // auxiliary files are "extra" files that are probably already included
71+ // in other ways. Loop over files and remove any from auxiliaryFiles
72+ files . forEach ( ( file ) => {
73+ delete auxiliaryFiles [ file . path ] ;
74+ } ) ;
75+ // if there are any auxiliaryFiles left, add them to the files
76+ // this handles, specifically, sourcemaps
77+ Object . keys ( auxiliaryFiles ) . forEach ( ( auxiliaryFile ) => {
78+ files = files . concat ( auxiliaryFiles [ auxiliaryFile ] ) ;
79+ } ) ;
80+
6981 files = files . map ( ( file ) => {
7082 const changes = {
7183 // Append optional basepath onto all references. This allows output path to be reflected in the manifest.
@@ -119,16 +131,16 @@ const normalModuleLoaderHook = ({ moduleAssets, assetTypeModuleAssets }, loaderC
119131 // the "emitFile" callback is never called on asset modules
120132 // so, we create a different map that can be used later in the "emit" hook
121133 if ( [ 'asset' , 'asset/inline' , 'asset/resource' , 'asset/source' ] . includes ( module . type ) ) {
122- // This takes the userRequest (which is an absolute path) and turns it into
123- // a relative path to the root context. This is done so that the string
124- // will match asset.info.sourceFilename in the emit hook.
125- let sourceFilename = relative ( loaderContext . rootContext , module . userRequest ) ;
126- // at this point, Windows paths use \ in their paths
127- // but in the emit hook, asset.info.sourceFilename fill have UNIX slashes
128- sourceFilename = sourceFilename . replace ( / \\ / g, '/' ) ;
129- Object . assign ( assetTypeModuleAssets , {
130- [ sourceFilename ] : basename ( module . userRequest ) ,
131- } ) ;
134+ // This takes the userRequest (which is an absolute path) and turns it into
135+ // a relative path to the root context. This is done so that the string
136+ // will match asset.info.sourceFilename in the emit hook.
137+ let sourceFilename = relative ( loaderContext . rootContext , module . userRequest ) ;
138+ // at this point, Windows paths use \ in their paths
139+ // but in the emit hook, asset.info.sourceFilename fill have UNIX slashes
140+ sourceFilename = sourceFilename . replace ( / \\ / g, '/' ) ;
141+ Object . assign ( assetTypeModuleAssets , {
142+ [ sourceFilename ] : basename ( module . userRequest )
143+ } ) ;
132144 }
133145
134146 // eslint-disable-next-line no-param-reassign
0 commit comments