Skip to content

Commit b1ec74b

Browse files
committed
minor #52351 [AssetMapper] Fixing merge (weaverryan)
This PR was merged into the 6.4 branch. Discussion ---------- [AssetMapper] Fixing merge | Q | A | ------------- | --- | Branch? | 6.4 | Bug fix? | yes | New feature? | no | Deprecations? | no | Issues | None | License | MIT Fixing the merge of #52323, #52331 and #52349 Also tested on a real project locally to verify the moving pieces :). Thanks! Commits ------- 99d5cbb [AssetMapper] Fixing merge from multiple PR's
2 parents d15c34b + 99d5cbb commit b1ec74b

File tree

2 files changed

+10
-7
lines changed

2 files changed

+10
-7
lines changed

src/Symfony/Component/AssetMapper/Compiler/JavaScriptImportPathCompiler.php

+6-1
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,12 @@ private function findAssetForRelativeImport(string $importedModule, MappedAsset
172172
return null;
173173
}
174174

175-
$dependentAsset = $assetMapper->getAsset($resolvedSourcePath);
175+
try {
176+
$dependentAsset = $assetMapper->getAssetFromSourcePath($resolvedSourcePath);
177+
} catch (CircularAssetsException $exception) {
178+
$dependentAsset = $exception->getIncompleteMappedAsset();
179+
}
180+
176181
if ($dependentAsset) {
177182
return $dependentAsset;
178183
}

src/Symfony/Component/AssetMapper/Tests/Compiler/JavaScriptImportPathCompilerTest.php

+4-6
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,6 @@ public static function provideCompileTests(): iterable
173173
];
174174

175175
yield 'importing_non_existent_file_without_strict_mode_is_ignored_and_no_import_added' => [
176-
'sourceLogicalName' => 'app.js',
177176
'input' => "import './non-existent.js';",
178177
'expectedJavaScriptImports' => [],
179178
];
@@ -277,7 +276,6 @@ public static function provideCompileTests(): iterable
277276
];
278277

279278
yield 'absolute_import_ignored_and_no_dependency_added' => [
280-
'sourceLogicalName' => 'app.js',
281279
'input' => 'import "https://example.com/module.js";',
282280
'expectedJavaScriptImports' => [],
283281
];
@@ -415,14 +413,14 @@ public static function providePathsCanUpdateTests(): iterable
415413

416414
public function testCompileHandlesCircularRelativeAssets()
417415
{
418-
$appAsset = new MappedAsset('app.js', 'anythingapp', '/assets/app.js');
419-
$otherAsset = new MappedAsset('other.js', 'anythingother', '/assets/other.js');
416+
$appAsset = new MappedAsset('app.js', '/project/assets/app.js', '/assets/app.js');
417+
$otherAsset = new MappedAsset('other.js', '/project/assets/other.js', '/assets/other.js');
420418

421419
$importMapConfigReader = $this->createMock(ImportMapConfigReader::class);
422420
$assetMapper = $this->createMock(AssetMapperInterface::class);
423421
$assetMapper->expects($this->once())
424-
->method('getAsset')
425-
->with('other.js')
422+
->method('getAssetFromSourcePath')
423+
->with('/project/assets/other.js')
426424
->willThrowException(new CircularAssetsException($otherAsset));
427425

428426
$compiler = new JavaScriptImportPathCompiler($importMapConfigReader);

0 commit comments

Comments
 (0)