Skip to content

Commit

Permalink
Merge pull request #1 from marko-js/fix-issue-with-multiple-flags
Browse files Browse the repository at this point in the history
fix: issue with multiple flags
  • Loading branch information
DylanPiercey authored Nov 10, 2023
2 parents aa809ee + e295c47 commit dcdb794
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .changeset/yellow-bobcats-scream.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"arc-vite": patch
---

Fix issue when there are multiple flags.
4 changes: 4 additions & 0 deletions src/plugins/build-ssr.ts
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ function partsToString(parts, base, injectAttrs) {

let code = "";
let matchCode = "";
let matchCodeSep = "";
let i = 0;

for (const { flags, value } of adaptiveMatches.alternates) {
Expand All @@ -145,9 +146,12 @@ function partsToString(parts, base, injectAttrs) {
)};\n`;

matchCode +=
matchCodeSep +
flags.map((flag) => `f.${flag}`).join("&&") +
"?" +
adaptedImportId;

matchCodeSep = ":";
}

const defaultId = `_${indexToId(i)}`;
Expand Down
4 changes: 4 additions & 0 deletions src/plugins/build-web.ts
Original file line number Diff line number Diff line change
Expand Up @@ -424,12 +424,16 @@ export function pluginBuildWeb({
const defaultFlaggedAssets = flaggedAssetsForEntry
.sort(compareFlaggedObject)
.pop()!;
let matchCodeSep = "";

manifestCode += `case ${JSON.stringify(entryName)}:return `;
for (const { flags, manifest } of flaggedAssetsForEntry) {
manifestCode +=
matchCodeSep +
flags.map((flag) => `f.${flag}`).join("&&") +
"?" +
JSON.stringify(manifest);
matchCodeSep = ":";
}

manifestCode += `:${JSON.stringify(defaultFlaggedAssets.manifest)}`;
Expand Down

0 comments on commit dcdb794

Please sign in to comment.