diff --git a/.changeset/five-schools-complain.md b/.changeset/five-schools-complain.md new file mode 100644 index 0000000..0593d71 --- /dev/null +++ b/.changeset/five-schools-complain.md @@ -0,0 +1,5 @@ +--- +"@marko/vite": patch +--- + +Fix loading of translator when checking if tags API is being used" diff --git a/src/index.ts b/src/index.ts index 67f01bd..05b7600 100644 --- a/src/index.ts +++ b/src/index.ts @@ -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"; @@ -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; }