Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions guide/api-environment-frameworks.md
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ Vite は、`dispatchFetch` メソッドの入力と出力を検証します。
// Vite の API を使用するコード
import { createServer } from 'vite'

const server = createServer({
const server = await createServer({
plugins: [
// `virtual:entrypoint` を処理するプラグイン
{
Expand All @@ -189,7 +189,7 @@ const server = createServer({
},
],
})
const ssrEnvironment = server.environment.ssr
const ssrEnvironment = server.environments.ssr
const input = {}

// コードを実行する各環境ファクトリーによって公開されている関数を使用します
Expand Down Expand Up @@ -252,7 +252,7 @@ function vitePluginVirtualIndexHtml(): Plugin {
// Vite の API を使用するコード
import { createServer } from 'vite'

const server = createServer({
const server = await createServer({
plugins: [
// `virtual:entrypoint` を処理するプラグイン
{
Expand All @@ -261,13 +261,13 @@ const server = createServer({
},
],
})
const ssrEnvironment = server.environment.ssr
const ssrEnvironment = server.environments.ssr
const input = {}

// コードを実行する各環境ファクトリーによって公開されている関数を使用します
// 各環境ファクトリーについて、それらが提供するものをチェックします
if (ssrEnvironment instanceof RunnableDevEnvironment) {
ssrEnvironment.runner.import('virtual:entrypoint')
await ssrEnvironment.runner.import('virtual:entrypoint')
} else if (ssrEnvironment instanceof CustomDevEnvironment) {
ssrEnvironment.runEntrypoint('virtual:entrypoint')
} else {
Expand All @@ -277,9 +277,9 @@ if (ssrEnvironment instanceof RunnableDevEnvironment) {
const req = new Request('http://example.com/')

const uniqueId = 'a-unique-id'
ssrEnvironment.send('request', serialize({ req, uniqueId }))
ssrEnvironment.hot.send('request', serialize({ req, uniqueId }))
const response = await new Promise((resolve) => {
ssrEnvironment.on('response', (data) => {
ssrEnvironment.hot.on('response', (data) => {
data = deserialize(data)
if (data.uniqueId === uniqueId) {
resolve(data.res)
Expand Down
Loading