From d1a0460554e8c46caa105a6fb64cfa316ed42b58 Mon Sep 17 00:00:00 2001 From: Dylan Piercey Date: Mon, 8 May 2023 15:18:51 -0700 Subject: [PATCH] feat: automatically disable linked mode for vitest (#61) --- .changeset/short-penguins-prove.md | 5 +++++ src/index.ts | 7 ++++++- 2 files changed, 11 insertions(+), 1 deletion(-) create mode 100644 .changeset/short-penguins-prove.md diff --git a/.changeset/short-penguins-prove.md b/.changeset/short-penguins-prove.md new file mode 100644 index 0000000..0e64497 --- /dev/null +++ b/.changeset/short-penguins-prove.md @@ -0,0 +1,5 @@ +--- +"@marko/vite": patch +--- + +Disable linked mode automatically for vitest diff --git a/src/index.ts b/src/index.ts index 6560b30..a6b24f5 100644 --- a/src/index.ts +++ b/src/index.ts @@ -99,7 +99,8 @@ const thisFile = export default function markoPlugin(opts: Options = {}): vite.Plugin[] { let compiler: typeof Compiler; - const { runtimeId, basePathVar, linked = true } = opts; + let { linked = true } = opts; + const { runtimeId, basePathVar } = opts; const baseConfig: Compiler.Config = { cache, runtimeId, @@ -194,6 +195,10 @@ export default function markoPlugin(opts: Options = {}): vite.Plugin[] { `marko-vite-${crypto.createHash("SHA1").update(root).digest("hex")}` ); + if (isTest) { + linked = false; + } + if (linked && !registeredTag) { // Here we inject either the watchMode vite tag, or the build one. const transformer = path.resolve(