Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
[AssetMapper] Fixing merge from multiple PR's
  • Loading branch information
weaverryan committed Oct 29, 2023
commit 99d5cbb25b9cd7cd34d1c4cf2145339fbebd93b4
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,12 @@ private function findAssetForRelativeImport(string $importedModule, MappedAsset
return null;
}

$dependentAsset = $assetMapper->getAsset($resolvedSourcePath);
try {
$dependentAsset = $assetMapper->getAssetFromSourcePath($resolvedSourcePath);
} catch (CircularAssetsException $exception) {
$dependentAsset = $exception->getIncompleteMappedAsset();
}

if ($dependentAsset) {
return $dependentAsset;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,6 @@ public static function provideCompileTests(): iterable
];

yield 'importing_non_existent_file_without_strict_mode_is_ignored_and_no_import_added' => [
'sourceLogicalName' => 'app.js',
'input' => "import './non-existent.js';",
'expectedJavaScriptImports' => [],
];
Expand Down Expand Up @@ -277,7 +276,6 @@ public static function provideCompileTests(): iterable
];

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

public function testCompileHandlesCircularRelativeAssets()
{
$appAsset = new MappedAsset('app.js', 'anythingapp', '/assets/app.js');
$otherAsset = new MappedAsset('other.js', 'anythingother', '/assets/other.js');
$appAsset = new MappedAsset('app.js', '/project/assets/app.js', '/assets/app.js');
$otherAsset = new MappedAsset('other.js', '/project/assets/other.js', '/assets/other.js');

$importMapConfigReader = $this->createMock(ImportMapConfigReader::class);
$assetMapper = $this->createMock(AssetMapperInterface::class);
$assetMapper->expects($this->once())
->method('getAsset')
->with('other.js')
->method('getAssetFromSourcePath')
->with('/project/assets/other.js')
->willThrowException(new CircularAssetsException($otherAsset));

$compiler = new JavaScriptImportPathCompiler($importMapConfigReader);
Expand Down