Skip to content

Commit

Permalink
fix: use vue esm bundler while running SSR
Browse files Browse the repository at this point in the history
  • Loading branch information
linzhe141 committed Feb 21, 2024
1 parent 7b5c7a1 commit 4b2fd64
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/import-map.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,16 @@ export function useVueImportMap(
`https://cdn.jsdelivr.net/npm/@vue/server-renderer@${
vueVersion.value || currentVersion
}/dist/server-renderer.esm-browser.js`

const vueEsm = `https://cdn.jsdelivr.net/npm/@vue/runtime-dom@${
vueVersion.value || currentVersion
}/dist/runtime-dom.esm-bundler.js/+esm`

return {
imports: {
vue,
'vue/server-renderer': serverRenderer,
'vue-esm': vueEsm,
},
}
})
Expand Down
6 changes: 6 additions & 0 deletions src/transform.ts
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,12 @@ async function doCompileScript(
2,
)} */`
}
if (ssr) {
compiledScript.content = compiledScript.content.replaceAll(
/'vue'/g,
"'vue-esm'",
)
}
code +=
`\n` +
store.compiler.rewriteDefault(
Expand Down

0 comments on commit 4b2fd64

Please sign in to comment.