Skip to content

Commit 99d5cbb

Browse files
committed
[AssetMapper] Fixing merge from multiple PR's
1 parent e400626 commit 99d5cbb

File tree

2 files changed

+10
-7
lines changed

2 files changed

+10
-7
lines changed

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

Lines changed: 6 additions & 1 deletion
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

Lines changed: 4 additions & 6 deletions
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)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy