@@ -361,123 +361,4 @@ describe("emit option", () => {
361361 } ) ;
362362 } ) ;
363363 } ) ;
364-
365- it ( 'should invalidate the cache with disabled "emit" option' , async ( ) => {
366- class AssetsModifyPlugin {
367- constructor ( options = { } ) {
368- this . options = options ;
369- }
370-
371- apply ( compiler ) {
372- compiler . hooks . emit . tapAsync (
373- "AssetsModifyPlugin" ,
374- ( compilation , callback ) => {
375- fs . writeFileSync ( this . options . file , ".a{color: red;}" ) ;
376-
377- callback ( ) ;
378- } ,
379- ) ;
380- }
381- }
382-
383- const outputPath = path . resolve ( __dirname , "./js/cache-memory-3" ) ;
384- const modifyAsset = path . resolve ( __dirname , "fixtures" , "style-url.css" ) ;
385- const modifyAssetContent = fs . readFileSync ( modifyAsset ) ;
386- const webpackConfig = {
387- mode : "development" ,
388- context : path . resolve ( __dirname , "fixtures" ) ,
389- cache : {
390- type : "memory" ,
391- } ,
392- output : {
393- path : outputPath ,
394- } ,
395- entry : "./style-url.js" ,
396- module : {
397- rules : [
398- {
399- test : / \. c s s $ / ,
400- use : [
401- {
402- loader : MiniCssExtractPlugin . loader ,
403- options : {
404- emit : false ,
405- } ,
406- } ,
407- "css-loader" ,
408- ] ,
409- } ,
410- {
411- test : / \. s v g $ / ,
412- type : "asset/resource" ,
413- generator : {
414- filename : "static/[name][ext][query]" ,
415- } ,
416- } ,
417- ] ,
418- } ,
419- plugins : [
420- new MiniCssExtractPlugin ( {
421- filename : "[name].css" ,
422- } ) ,
423- new AssetsModifyPlugin ( {
424- file : modifyAsset ,
425- } ) ,
426- ] ,
427- } ;
428-
429- await del ( [ outputPath ] ) ;
430-
431- const compiler1 = webpack ( webpackConfig ) ;
432-
433- await new Promise ( ( resolve , reject ) => {
434- compiler1 . run ( ( error , stats ) => {
435- if ( error ) {
436- reject ( error ) ;
437-
438- return ;
439- }
440-
441- compiler1 . close ( ( ) => {
442- expect ( Object . keys ( stats . compilation . assets ) . sort ( ) ) . toMatchSnapshot (
443- "assets" ,
444- ) ;
445- expect ( [ ...stats . compilation . emittedAssets ] . sort ( ) ) . toMatchSnapshot (
446- "emittedAssets" ,
447- ) ;
448- expect ( getWarnings ( stats ) ) . toMatchSnapshot ( "warnings" ) ;
449- expect ( getErrors ( stats ) ) . toMatchSnapshot ( "errors" ) ;
450-
451- resolve ( ) ;
452- } ) ;
453- } ) ;
454- } ) ;
455-
456- const compiler2 = webpack ( webpackConfig ) ;
457-
458- await new Promise ( ( resolve , reject ) => {
459- compiler2 . run ( ( error , stats ) => {
460- if ( error ) {
461- reject ( error ) ;
462-
463- return ;
464- }
465-
466- compiler2 . close ( ( ) => {
467- expect ( Object . keys ( stats . compilation . assets ) . sort ( ) ) . toMatchSnapshot (
468- "assets" ,
469- ) ;
470- expect ( [ ...stats . compilation . emittedAssets ] . sort ( ) ) . toMatchSnapshot (
471- "emittedAssets" ,
472- ) ;
473- expect ( getWarnings ( stats ) ) . toMatchSnapshot ( "warnings" ) ;
474- expect ( getErrors ( stats ) ) . toMatchSnapshot ( "errors" ) ;
475-
476- resolve ( ) ;
477- } ) ;
478- } ) ;
479- } ) ;
480-
481- fs . writeFileSync ( modifyAsset , modifyAssetContent ) ;
482- } ) ;
483364} ) ;
0 commit comments