Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: load translator with require when checking tags API #181

Merged
merged 1 commit into from
Dec 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/five-schools-complain.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@marko/vite": patch
---

Fix loading of translator when checking if tags API is being used"
5 changes: 3 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import anyMatch from "anymatch";
import crypto from "crypto";
import glob from "fast-glob";
import fs from "fs";
import { createRequire } from "module";
import path from "path";
import { pathToFileURL } from "url";
import type * as vite from "vite";
Expand Down Expand Up @@ -661,8 +662,8 @@ export default function markoPlugin(opts: Options = {}): vite.Plugin[] {
tagsAPI = false;
} else {
try {
tagsAPI =
(await import(translatorPackage)).preferAPI !== "class";
const require = createRequire(import.meta.url);
tagsAPI = require(translatorPackage).preferAPI !== "class";
} catch {
tagsAPI = true;
}
Expand Down
Loading