@@ -574,6 +574,34 @@ public function testCompileHandlesCircularBareImportAssets()
574
574
$ this ->assertSame ($ popperAsset ->logicalPath , $ bootstrapAsset ->getJavaScriptImports ()[0 ]->assetLogicalPath );
575
575
}
576
576
577
+ public function testCompileIgnoresSelfReferencingBareImportAssets ()
578
+ {
579
+ $ bootstrapAsset = new MappedAsset ('foo.js ' , 'foo.js ' , 'foo.js ' );
580
+
581
+ $ importMapConfigReader = $ this ->createMock (ImportMapConfigReader::class);
582
+ $ importMapConfigReader ->expects ($ this ->once ())
583
+ ->method ('findRootImportMapEntry ' )
584
+ ->with ('foobar ' )
585
+ ->willReturn (ImportMapEntry::createRemote ('foobar ' , ImportMapType::JS , 'foo.js ' , '1.2.3 ' , 'foobar ' , false ));
586
+ $ importMapConfigReader ->expects ($ this ->any ())
587
+ ->method ('convertPathToFilesystemPath ' )
588
+ ->with ('foo.js ' )
589
+ ->willReturn ('foo.js ' );
590
+
591
+ $ assetMapper = $ this ->createMock (AssetMapperInterface::class);
592
+ $ assetMapper ->expects ($ this ->once ())
593
+ ->method ('getAssetFromSourcePath ' )
594
+ ->with ('foo.js ' )
595
+ ->willReturn ($ bootstrapAsset );
596
+
597
+ $ compiler = new JavaScriptImportPathCompiler ($ importMapConfigReader );
598
+ $ input = 'import { foo } from "foobar"; ' ;
599
+ $ compiler ->compile ($ input , $ bootstrapAsset , $ assetMapper );
600
+ $ this ->assertCount (0 , $ bootstrapAsset ->getDependencies ());
601
+ $ this ->assertCount (0 , $ bootstrapAsset ->getFileDependencies ());
602
+ $ this ->assertCount (0 , $ bootstrapAsset ->getJavaScriptImports ());
603
+ }
604
+
577
605
/**
578
606
* @dataProvider provideMissingImportModeTests
579
607
*/
0 commit comments