mirror of
https://github.com/nuxt/nuxt.git
synced 2025-01-18 17:35:57 +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 { Agent as HTTPSAgent } from 'node:https'
|
||||||
import { $fetch } from 'ofetch'
|
import { $fetch } from 'ofetch'
|
||||||
|
|
||||||
|
/** @type {import('../vite-node').ViteNodeServerOptions} */
|
||||||
export const viteNodeOptions = JSON.parse(process.env.NUXT_VITE_NODE_OPTIONS || '{}')
|
export const viteNodeOptions = JSON.parse(process.env.NUXT_VITE_NODE_OPTIONS || '{}')
|
||||||
|
|
||||||
export const viteNodeFetch = $fetch.create({
|
export const viteNodeFetch = $fetch.create({
|
||||||
|
@ -161,6 +161,13 @@ function createViteNodeApp (ctx: ViteBuildContext, invalidates: Set<string> = ne
|
|||||||
return app
|
return app
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export type ViteNodeServerOptions = {
|
||||||
|
baseURL: string
|
||||||
|
root: string
|
||||||
|
entryPath: string
|
||||||
|
base: string
|
||||||
|
}
|
||||||
|
|
||||||
export async function initViteNodeServer (ctx: ViteBuildContext) {
|
export async function initViteNodeServer (ctx: ViteBuildContext) {
|
||||||
// Serialize and pass vite-node runtime options
|
// Serialize and pass vite-node runtime options
|
||||||
const viteNodeServerOptions = {
|
const viteNodeServerOptions = {
|
||||||
@ -168,7 +175,7 @@ export async function initViteNodeServer (ctx: ViteBuildContext) {
|
|||||||
root: ctx.nuxt.options.srcDir,
|
root: ctx.nuxt.options.srcDir,
|
||||||
entryPath: ctx.entry,
|
entryPath: ctx.entry,
|
||||||
base: ctx.ssrServer!.config.base || '/_nuxt/'
|
base: ctx.ssrServer!.config.base || '/_nuxt/'
|
||||||
}
|
} satisfies ViteNodeServerOptions
|
||||||
process.env.NUXT_VITE_NODE_OPTIONS = JSON.stringify(viteNodeServerOptions)
|
process.env.NUXT_VITE_NODE_OPTIONS = JSON.stringify(viteNodeServerOptions)
|
||||||
|
|
||||||
const serverResolvedPath = resolve(distDir, 'runtime/vite-node.mjs')
|
const serverResolvedPath = resolve(distDir, 'runtime/vite-node.mjs')
|
||||||
|
Loading…
Reference in New Issue
Block a user