File tree Expand file tree Collapse file tree 3 files changed +41
-0
lines changed Expand file tree Collapse file tree 3 files changed +41
-0
lines changed Original file line number Diff line number Diff line change @@ -146,6 +146,7 @@ class MiniCssExtractPlugin {
146146 ) } `
147147 ) ;
148148 }
149+
149150 const identifierCountMap = new Map ( ) ;
150151 for ( const line of content ) {
151152 const count = identifierCountMap . get ( line . identifier ) || 0 ;
Original file line number Diff line number Diff line change @@ -59,6 +59,7 @@ export function pitch(request) {
5959 compilation . hooks . normalModuleLoader . tap (
6060 `${ pluginName } loader` ,
6161 ( loaderContext , module ) => {
62+ loaderContext . emitFile = this . emitFile ;
6263 loaderContext [ MODULE_TYPE ] = false ; // eslint-disable-line no-param-reassign
6364 if ( module . request === request ) {
6465 // eslint-disable-next-line no-param-reassign
Original file line number Diff line number Diff line change 1+ import path from 'path' ;
2+
3+ import MemoryFS from 'memory-fs' ;
4+ import webpack from 'webpack' ;
5+
6+ const assetsNames = ( json ) => json . assets . map ( ( asset ) => asset . name ) ;
7+
8+ describe ( 'TestMemoryFS' , ( ) => {
9+ it ( 'should preserve asset even if not emitted' , ( done ) => {
10+ const casesDirectory = path . resolve ( __dirname , 'cases' ) ;
11+ const directoryForCase = path . resolve ( casesDirectory , 'simple-publicpath' ) ;
12+ const webpackConfig = require ( path . resolve (
13+ directoryForCase ,
14+ 'webpack.config.js'
15+ ) ) ;
16+ const compiler = webpack ( {
17+ ...webpackConfig ,
18+ mode : 'development' ,
19+ context : directoryForCase ,
20+ } ) ;
21+ compiler . outputFileSystem = new MemoryFS ( ) ;
22+ compiler . run ( ( err1 , stats1 ) => {
23+ if ( err1 ) {
24+ done ( err1 ) ;
25+ return ;
26+ }
27+ compiler . run ( ( err2 , stats2 ) => {
28+ if ( err2 ) {
29+ done ( err2 ) ;
30+ return ;
31+ }
32+ expect ( assetsNames ( stats1 . toJson ( ) ) ) . toEqual (
33+ assetsNames ( stats2 . toJson ( ) )
34+ ) ;
35+ done ( ) ;
36+ } ) ;
37+ } ) ;
38+ } ) ;
39+ } ) ;
You can’t perform that action at this time.
0 commit comments