From 7a4b118982ef9b59db0bd9b6d0bfcad69ef248f9 Mon Sep 17 00:00:00 2001 From: Dylan Piercey Date: Sun, 1 Oct 2023 15:28:37 -0700 Subject: [PATCH] fix: ensure proper resolve condition set for vitest env --- .changeset/pretty-plums-perform.md | 5 +++++ src/index.ts | 10 ++++++++++ 2 files changed, 15 insertions(+) create mode 100644 .changeset/pretty-plums-perform.md diff --git a/.changeset/pretty-plums-perform.md b/.changeset/pretty-plums-perform.md new file mode 100644 index 0000000..480e5e5 --- /dev/null +++ b/.changeset/pretty-plums-perform.md @@ -0,0 +1,5 @@ +--- +"@marko/vite": patch +--- + +Fix support for using this plugin with Vitest and a browser environment. diff --git a/src/index.ts b/src/index.ts index a46b5a4..4457307 100644 --- a/src/index.ts +++ b/src/index.ts @@ -223,6 +223,16 @@ export default function markoPlugin(opts: Options = {}): vite.Plugin[] { if (isTest) { linked = false; + + if ( + ((config as any).test?.environment as string | undefined)?.includes( + "dom" + ) + ) { + config.resolve ??= {}; + config.resolve.conditions ??= []; + config.resolve.conditions.push("browser"); + } } if (linked && !registeredTag) {