@@ -436,6 +436,90 @@ export function setupVueTests({ version, dir }) {
436
436
. file ( `test/fixtures/app/dist/js/app.js` )
437
437
. contains ( [ 'false ? 0 : _vue_shared__' ] ) ;
438
438
} ) ;
439
+
440
+ test . serial (
441
+ 'File loader has esModule disabled for Vue 2 and is not broken by custom loader rules' ,
442
+ async t => {
443
+ const { assert, mix, webpack } = context ( t ) ;
444
+
445
+ if ( version === 3 ) {
446
+ t . pass . skip ( 'Skipping for vue 3' ) ;
447
+
448
+ return ;
449
+ }
450
+
451
+ // Using an extension so it modifies the rules before Vue processes them
452
+ mix . extend ( 'foo' , {
453
+ webpackRules ( ) {
454
+ return [
455
+ {
456
+ test : / \. s o m e t h i n g 1 $ / ,
457
+ loader : 'css-loader'
458
+ } ,
459
+ {
460
+ test : / \. s o m e t h i n g 2 $ / ,
461
+ use : 'css-loader'
462
+ } ,
463
+ {
464
+ test : / \. s o m e t h i n g 3 $ / ,
465
+ use : [ 'css-loader' ]
466
+ } ,
467
+ {
468
+ test : / \. s o m e t h i n g 3 $ / ,
469
+ use : [ { ident : 'foobar' } ]
470
+ }
471
+ ] ;
472
+ }
473
+ } ) ;
474
+
475
+ // @ts -ignore
476
+ mix . foo ( ) ;
477
+
478
+ mix . options ( { assetModules : false } ) ;
479
+ mix . vue ( ) ;
480
+ mix . js ( `test/fixtures/app/src/${ dir } /app-with-vue-and-css.js` , 'js/app.js' ) ;
481
+
482
+ const config = await webpack . buildConfig ( ) ;
483
+ const spy = sinon . spy ( ) ;
484
+
485
+ // TODO: This is basically a copy of the module code in the Vue.js file
486
+ // That's not so great…
487
+ for ( const rule of ( config . module && config . module . rules ) || [ ] ) {
488
+ if ( typeof rule !== 'object' ) {
489
+ continue ;
490
+ }
491
+
492
+ let loaders = ( rule && rule . use ) || [ ] ;
493
+
494
+ if ( ! Array . isArray ( loaders ) ) {
495
+ continue ;
496
+ }
497
+
498
+ for ( const loader of loaders ) {
499
+ if ( typeof loader !== 'object' ) {
500
+ continue ;
501
+ }
502
+
503
+ // TODO: This isn't the best check
504
+ // We should check that the loader itself is correct
505
+ // Not that file-loader is anywhere in it's absolute path
506
+ // As this can produce false positives
507
+ if (
508
+ loader . loader &&
509
+ loader . loader . includes ( 'file-loader' ) &&
510
+ loader . options
511
+ ) {
512
+ spy ( ) ;
513
+
514
+ // @ts -ignore
515
+ t . falsy ( loader . options . esModule ) ;
516
+ }
517
+ }
518
+ }
519
+
520
+ t . true ( spy . called ) ;
521
+ }
522
+ ) ;
439
523
}
440
524
441
525
async function compilerSpy ( Mix ) {
0 commit comments