8000 bug #50356 [AssetMapper] Fix bug where dependencies were preloaded ev… · symfony/symfony@54a3b84 · GitHub
[go: up one dir, main page]

Skip to content

Commit 54a3b84

Browse files
bug #50356 [AssetMapper] Fix bug where dependencies were preloaded even if the parent was not (weaverryan)
This PR was squashed before being merged into the 6.3 branch. Discussion ---------- [AssetMapper] Fix bug where dependencies were preloaded even if the parent was not | Q | A | ------------- | --- | Branch? | 6.3 | Bug fix? | yes | New feature? | no | Deprecations? | no | Tickets | None | License | MIT | Doc PR | Still TODO In `importmap.php`, if you have `preload => false` for an assets... but that asset imports another assets, we would always list that imported asset as "preload => true". Basically, when looking at a dependency to determine if it should be preloaded, we need to first look at the parent to see if IT was preloaded. Cheers! Commits ------- feb680b [AssetMapper] Fix bug where dependencies were preloaded even if the parent was not
2 parents 398036b + feb680b commit 54a3b84

File tree

4 files changed

+7
-3
lines changed

4 files changed

+7
-3
lines changed

src/Symfony/Component/AssetMapper/ImportMap/ImportMapManager.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -417,11 +417,11 @@ private function convertEntriesToImports(array $entries): array
417417
$this->modulesToPreload[] = $path;
418418
}
419419

420-
$dependencyImportMapEntries = array_map(function (AssetDependency $dependency) {
420+
$dependencyImportMapEntries = array_map(function (AssetDependency $dependency) use ($entryOptions) {
421421
return new ImportMapEntry(
422422
$dependency->asset->getPublicPathWithoutDigest(),
423423
$dependency->asset->getLogicalPath(),
424-
preload: !$dependency->isLazy,
424+
preload: $entryOptions->preload && !$dependency->isLazy,
425425
);
426426
}, $dependencies);
427427
$imports = array_merge($imports, $this->convertEntriesToImports($dependencyImportMapEntries));

src/Symfony/Component/AssetMapper/Tests/ImportMap/ImportMapManagerTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,8 @@ public function testGetImportMapJson()
7777
'/assets/pizza/index.js' => '/assets/pizza/index-b3fb5ee31adaf5e1b32d28edf1ab8e7a.js',
7878
'/assets/popcorn.js' => '/assets/popcorn-c0778b84ef9893592385aebc95a2896e.js',
7979
'/assets/imported_async.js' => '/assets/imported_async-8f0cd418bfeb0cf63826e09a4474a81c.js',
80-
'other_app' => '/assets/namespaced_assets2/app2-344d0d513d424647e7d8a394ffe5e4b5.js',
80+
'other_app' => '/assets/namespaced_assets2/app2-d5bf10c20bf9a0b77e67d78fcac301c5.js',
81+
'/assets/namespaced_assets2/imported.js' => '/assets/namespaced_assets2/imported-9ab37dabcfe317fba77123a4e573d53b.js',
8182
]], json_decode($manager->getImportMapJson(), true));
8283
}
8384

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
1+
import './imported.js';
2+
13
console.log('app2');
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
console.log('imported.js');

0 commit comments

Comments
 (0)
0