Skip to content

Commit

Permalink
fix: issue with tags api detection (#179)
Browse files Browse the repository at this point in the history
  • Loading branch information
DylanPiercey authored Dec 13, 2024
1 parent 68b28b7 commit 8a584b3
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 5 deletions.
5 changes: 5 additions & 0 deletions .changeset/healthy-bees-burn.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@marko/vite": patch
---

Fix tags api detection
27 changes: 22 additions & 5 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -151,11 +151,7 @@ export default function markoPlugin(opts: Options = {}): vite.Plugin[] {
let serverManifest: ServerManifest | undefined;
let basePath = "/";
let getMarkoAssetFns: undefined | API.getMarkoAssetCodeForEntry[];
const tagsAPI = !/^@marko\/translator-(?:default|interop-class-tags)$/.test(
opts.translator ||
compiler.globalConfig?.translator ||
"@marko/translator-default",
);
let tagsAPI: undefined | boolean;
const entryIds = new Set<string>();
const cachedSources = new Map<string, string>();
const transformWatchFiles = new Map<string, string[]>();
Expand Down Expand Up @@ -652,6 +648,27 @@ export default function markoPlugin(opts: Options = {}): vite.Plugin[] {
}
}

if (tagsAPI === undefined) {
const translatorPackage =
opts.translator ||
compiler.globalConfig?.translator ||
"marko/translator";
if (
/^@marko\/translator-(?:default|interop-class-tags)$/.test(
translatorPackage,
)
) {
tagsAPI = false;
} else {
try {
tagsAPI =
(await import(translatorPackage)).preferAPI !== "class";
} catch {
tagsAPI = true;
}
}
}

source = await getServerEntryTemplate({
fileName,
entryData,
Expand Down

0 comments on commit 8a584b3

Please sign in to comment.