Skip to content

Commit

Permalink
fix: ssr check for transform hook (#58)
Browse files Browse the repository at this point in the history
  • Loading branch information
DylanPiercey authored May 5, 2023
1 parent f62ae4c commit 5968d1b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .changeset/proud-hats-battle.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@marko/vite": patch
---

Fixes an issue where the ssr check was not accurate for the transform hook.
5 changes: 3 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -510,6 +510,7 @@ export default function markoPlugin(opts: Options = {}): vite.Plugin[] {
);
},
async transform(source, id, ssr) {
const isSSR = typeof ssr === "object" ? ssr.ssr : ssr;
const query = getMarkoQuery(id);

if (query && !query.startsWith(virtualFileQuery)) {
Expand All @@ -524,7 +525,7 @@ export default function markoPlugin(opts: Options = {}): vite.Plugin[] {
return null;
}

if (ssr && entrySources.has(id)) {
if (isSSR && linked && entrySources.has(id)) {
entrySources.set(id, source);

if (serverManifest) {
Expand All @@ -535,7 +536,7 @@ export default function markoPlugin(opts: Options = {}): vite.Plugin[] {
const compiled = await compiler.compile(
source,
id,
(typeof ssr === "object" ? (ssr as any).ssr : ssr)
isSSR
? ssrConfig
: query === browserEntryQuery
? hydrateConfig
Expand Down

0 comments on commit 5968d1b

Please sign in to comment.