Skip to content

Commit

Permalink
fix: avoid use new URL during SSR
Browse files Browse the repository at this point in the history
  • Loading branch information
ygj6 committed Oct 16, 2021
1 parent 13a7ebf commit d223f99
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion packages/playground/ssr-vue/src/entry-server.js
@@ -1,5 +1,7 @@
import { createApp } from './main'
import { renderToString } from 'vue/server-renderer'
import { fileURLToPath } from 'url'
import path from 'path'

export async function render(url, manifest) {
const { app, router } = createApp()
Expand All @@ -20,7 +22,8 @@ export async function render(url, manifest) {
process.versions.node.split('.')[0] >= '14'
? await import('fs/promises')
: (await import('fs')).promises
const msg = await fs.readFile(new URL('./message', import.meta.url), 'utf-8')
const __dirname = path.dirname(fileURLToPath(import.meta.url))
const msg = await fs.readFile(path.resolve(__dirname, './message'), 'utf-8')
html += `<p class="file-message">msg read via deep import built-in module: ${msg}</p>`

// the SSR manifest generated by Vite contains module -> chunk/asset mapping
Expand Down

0 comments on commit d223f99

Please sign in to comment.