Skip to content
This repository has been archived by the owner on Oct 6, 2023. It is now read-only.

Commit

Permalink
fix: transform components (.vue) with ssr: false
Browse files Browse the repository at this point in the history
  • Loading branch information
Akryum committed Dec 8, 2021
1 parent 627867d commit 51cd0a1
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion packages/peeky-runner/src/runtime/vite.ts
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ async function rawRequest (id: string, realPath: string, callstack: string[], de
return cachedRequest(dep, callstack, deps, executionContext, root)
}

const result = await viteServer.transformRequest(id, { ssr: true })
const result = await transform(id)
if (!result) {
throw new Error(`failed to load ${id}`)
}
Expand Down Expand Up @@ -277,3 +277,17 @@ function matchModuleFilter (filters: (string | RegExp) | (string | RegExp)[], fi
}
})
}

async function transform (id: string) {
if (id.match(/\.(?:[cm]?[jt]sx?|json)$/)) {
return await viteServer.transformRequest(id, { ssr: true })
} else {
// for components like Vue, we want to use the client side plugins
// but then convert the code to be consumed by the server
const result = await viteServer.transformRequest(id)
if (!result) {
return undefined
}
return await viteServer.ssrTransform(result.code, result.map, id)
}
}

0 comments on commit 51cd0a1

Please sign in to comment.