Skip to content

Commit

Permalink
fix: manifest inject in dynamic import entries
Browse files Browse the repository at this point in the history
  • Loading branch information
DylanPiercey committed Apr 18, 2024
1 parent 58aec9f commit bb30d94
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
5 changes: 5 additions & 0 deletions .changeset/happy-ducks-rule.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@marko/vite": patch
---

Fix issue when a Marko server entry is loaded inside of another chunk which caused the assets injection runtime to be in a different chunk than the server entry (since it will codesplit the runtime). This change now ensures the asset manifest is only ever injected into chunks that reference the assets runtime injector.
11 changes: 4 additions & 7 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -748,13 +748,10 @@ export default function markoPlugin(opts: Options = {}): vite.Plugin[] {
const chunk = bundle[fileName];

if (chunk.type === "chunk") {
for (const id in chunk.modules) {
if (id.endsWith(serverEntryQuery)) {
serverManifest!.chunksNeedingAssets.push(
path.resolve(dir, fileName),
);
break;
}
if (chunk.moduleIds.includes(renderAssetsRuntimeId)) {
serverManifest!.chunksNeedingAssets.push(
path.resolve(dir, fileName),
);
}
}
}
Expand Down

0 comments on commit bb30d94

Please sign in to comment.