mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-11 08:33:53 +00:00
fix(vite): greater type-safety within runtime vite-node (#21849)
This commit is contained in:
parent
cc4cf68ed4
commit
d4addcf7b1
@ -1,8 +0,0 @@
|
||||
export interface ViteNodeRuntimeOptions {
|
||||
baseURL: string,
|
||||
rootDir: string,
|
||||
entryPath: string,
|
||||
base: string
|
||||
}
|
||||
|
||||
export function getViteNodeOptions (): ViteNodeRuntimeOptions
|
@ -2,6 +2,7 @@
|
||||
import { Agent as HTTPSAgent } from 'node:https'
|
||||
import { $fetch } from 'ofetch'
|
||||
|
||||
/** @type {import('../vite-node').ViteNodeServerOptions} */
|
||||
export const viteNodeOptions = JSON.parse(process.env.NUXT_VITE_NODE_OPTIONS || '{}')
|
||||
|
||||
export const viteNodeFetch = $fetch.create({
|
||||
|
@ -161,6 +161,13 @@ function createViteNodeApp (ctx: ViteBuildContext, invalidates: Set<string> = ne
|
||||
return app
|
||||
}
|
||||
|
||||
export type ViteNodeServerOptions = {
|
||||
baseURL: string
|
||||
root: string
|
||||
entryPath: string
|
||||
base: string
|
||||
}
|
||||
|
||||
export async function initViteNodeServer (ctx: ViteBuildContext) {
|
||||
// Serialize and pass vite-node runtime options
|
||||
const viteNodeServerOptions = {
|
||||
@ -168,7 +175,7 @@ export async function initViteNodeServer (ctx: ViteBuildContext) {
|
||||
root: ctx.nuxt.options.srcDir,
|
||||
entryPath: ctx.entry,
|
||||
base: ctx.ssrServer!.config.base || '/_nuxt/'
|
||||
}
|
||||
} satisfies ViteNodeServerOptions
|
||||
process.env.NUXT_VITE_NODE_OPTIONS = JSON.stringify(viteNodeServerOptions)
|
||||
|
||||
const serverResolvedPath = resolve(distDir, 'runtime/vite-node.mjs')
|
||||
|
Loading…
Reference in New Issue
Block a user