Skip to content

Commit

Permalink
fix bug manualChunks are not preloaded
Browse files Browse the repository at this point in the history
  • Loading branch information
lhapaipai committed Jul 11, 2023
1 parent 36a9595 commit f407591
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/Asset/EntrypointRenderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -110,14 +110,22 @@ public function renderLinks(string $entryName, array $options = [], $buildName =
], $options['attr'] ?? []), $buildName);
}

if ($this->entrypointsLookup->isProd($buildName) && isset($options['preloadDynamicImports']) && true === $options['preloadDynamicImports']) {
if ($this->entrypointsLookup->isProd($buildName)) {
foreach ($this->entrypointsLookup->getJavascriptDependencies($entryName, $buildName) as $fileWithHash) {
$content[] = $this->tagRenderer->renderLinkPreload($fileWithHash['path'], [
'integrity' => $fileWithHash['hash'],
], $buildName);
}
}

if ($this->entrypointsLookup->isProd($buildName) && isset($options['preloadDynamicImports']) && true === $options['preloadDynamicImports']) {
foreach ($this->entrypointsLookup->getJavascriptDynamicDependencies($entryName, $buildName) as $fileWithHash) {
$content[] = $this->tagRenderer->renderLinkPreload($fileWithHash['path'], [
'integrity' => $fileWithHash['hash'],
], $buildName);
}
}

return implode(PHP_EOL, $content);
}

Expand Down
7 changes: 7 additions & 0 deletions src/Asset/EntrypointsLookup.php
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,13 @@ public function getJavascriptDependencies($entryName, $buildName = null): array
return $this->getInfos($buildName)['entryPoints'][$entryName]['preload'] ?? [];
}

public function getJavascriptDynamicDependencies($entryName, $buildName = null): array
{
$this->throwIfEntryIsMissing($entryName, $buildName);

return $this->getInfos($buildName)['entryPoints'][$entryName]['dynamic'] ?? [];
}

public function hasLegacy($entryName, $buildName = null): bool
{
$this->throwIfEntryIsMissing($entryName, $buildName);
Expand Down

0 comments on commit f407591

Please sign in to comment.