Skip to content

Commit

Permalink
no duplicate modulepreload for javascriptDependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
lhapaipai committed Oct 6, 2023
1 parent faaa9cb commit 1a7c800
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/Asset/EntrypointRenderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

namespace Pentatrion\ViteBundle\Asset;

use function in_array;

class EntrypointRenderer
{
private $entrypointsLookup;
Expand Down Expand Up @@ -115,15 +113,17 @@ public function renderLinks(string $entryName, array $options = [], $buildName =

if ($this->entrypointsLookup->isProd($buildName)) {
foreach ($this->entrypointsLookup->getJavascriptDependencies($entryName, $buildName) as $fileWithHash) {
$content[] = $this->tagRenderer->renderLinkPreload($fileWithHash['path'], [
'integrity' => $fileWithHash['hash'],
], $buildName);
if (false === \in_array($fileWithHash['path'], $this->returnedPreloadedScripts, true)) {
$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) {
if (in_array($fileWithHash['path'], $this->returnedPreloadedScripts, true) === false) {
if (false === \in_array($fileWithHash['path'], $this->returnedPreloadedScripts, true)) {
$content[] = $this->tagRenderer->renderLinkPreload($fileWithHash['path'], [
'integrity' => $fileWithHash['hash'],
], $buildName);
Expand Down

0 comments on commit 1a7c800

Please sign in to comment.