Skip to content

Commit

Permalink
fix: issue where linked mode enabled in tests (#186)
Browse files Browse the repository at this point in the history
  • Loading branch information
DylanPiercey authored Jan 7, 2025
1 parent 9c2f2e2 commit 85ccd2f
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
5 changes: 5 additions & 0 deletions .changeset/blue-humans-boil.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@marko/vite": patch
---

Fix issue where link mode was incorrectly left enabled in test environments.
9 changes: 6 additions & 3 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,12 @@ export default function markoPlugin(opts: Options = {}): vite.Plugin[] {
enforce: "pre", // Must be pre to allow us to resolve assets before vite.
async config(config, env) {
let optimize = env.mode === "production";
isTest = env.mode === "test";
isBuild = env.command === "build";

if (isTest) {
linked = false;
}

if ("MARKO_DEBUG" in process.env) {
optimize =
Expand Down Expand Up @@ -239,8 +245,6 @@ export default function markoPlugin(opts: Options = {}): vite.Plugin[] {
compiler.configure(baseConfig);
devEntryFile = path.join(root, "index.html");
devEntryFilePosix = normalizePath(devEntryFile);
isTest = env.mode === "test";
isBuild = env.command === "build";
isSSRBuild = isBuild && linked && Boolean(config.build!.ssr);
renderAssetsRuntimeCode = getRenderAssetsRuntime({
isBuild,
Expand All @@ -249,7 +253,6 @@ export default function markoPlugin(opts: Options = {}): vite.Plugin[] {
});

if (isTest) {
linked = false;
const { test } = config as any;

if ((test.environment as string | undefined)?.includes("dom")) {
Expand Down

0 comments on commit 85ccd2f

Please sign in to comment.