Skip to content

Commit 85ccd2f

Browse files
authored
fix: issue where linked mode enabled in tests (#186)
1 parent 9c2f2e2 commit 85ccd2f

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

.changeset/blue-humans-boil.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@marko/vite": patch
3+
---
4+
5+
Fix issue where link mode was incorrectly left enabled in test environments.

src/index.ts

+6-3
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,12 @@ export default function markoPlugin(opts: Options = {}): vite.Plugin[] {
167167
enforce: "pre", // Must be pre to allow us to resolve assets before vite.
168168
async config(config, env) {
169169
let optimize = env.mode === "production";
170+
isTest = env.mode === "test";
171+
isBuild = env.command === "build";
172+
173+
if (isTest) {
174+
linked = false;
175+
}
170176

171177
if ("MARKO_DEBUG" in process.env) {
172178
optimize =
@@ -239,8 +245,6 @@ export default function markoPlugin(opts: Options = {}): vite.Plugin[] {
239245
compiler.configure(baseConfig);
240246
devEntryFile = path.join(root, "index.html");
241247
devEntryFilePosix = normalizePath(devEntryFile);
242-
isTest = env.mode === "test";
243-
isBuild = env.command === "build";
244248
isSSRBuild = isBuild && linked && Boolean(config.build!.ssr);
245249
renderAssetsRuntimeCode = getRenderAssetsRuntime({
246250
isBuild,
@@ -249,7 +253,6 @@ export default function markoPlugin(opts: Options = {}): vite.Plugin[] {
249253
});
250254

251255
if (isTest) {
252-
linked = false;
253256
const { test } = config as any;
254257

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

0 commit comments

Comments
 (0)