mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-25 15:15:19 +00:00
fix(vite): only mark nitro deps as externals when building (#22812)
This commit is contained in:
parent
9bee320c7a
commit
b319087c9f
@ -15,7 +15,6 @@ import { transpile } from './utils/transpile'
|
|||||||
export async function buildServer (ctx: ViteBuildContext) {
|
export async function buildServer (ctx: ViteBuildContext) {
|
||||||
const helper = ctx.nuxt.options.nitro.imports !== false ? '' : 'globalThis.'
|
const helper = ctx.nuxt.options.nitro.imports !== false ? '' : 'globalThis.'
|
||||||
const entry = ctx.nuxt.options.ssr ? ctx.entry : await resolvePath(resolve(ctx.nuxt.options.appDir, 'entry-spa'))
|
const entry = ctx.nuxt.options.ssr ? ctx.entry : await resolvePath(resolve(ctx.nuxt.options.appDir, 'entry-spa'))
|
||||||
const nitroDependencies = await tryResolveModule('nitropack/package.json', ctx.nuxt.options.modulesDir).then(r => import(r!)).then(r => Object.keys(r.dependencies || {})).catch(() => [])
|
|
||||||
const serverConfig: ViteConfig = vite.mergeConfig(ctx.config, vite.mergeConfig({
|
const serverConfig: ViteConfig = vite.mergeConfig(ctx.config, vite.mergeConfig({
|
||||||
configFile: false,
|
configFile: false,
|
||||||
base: ctx.nuxt.options.dev
|
base: ctx.nuxt.options.dev
|
||||||
@ -62,11 +61,7 @@ export async function buildServer (ctx: ViteBuildContext) {
|
|||||||
},
|
},
|
||||||
ssr: {
|
ssr: {
|
||||||
external: [
|
external: [
|
||||||
'#internal/nitro', '#internal/nitro/utils',
|
'#internal/nitro', '#internal/nitro/utils'
|
||||||
// explicit dependencies we use in our ssr renderer - these can be inlined (if necessary) in the nitro build
|
|
||||||
'unhead', '@unhead/ssr', '@unhead/vue', 'unctx', 'h3', 'devalue', '@nuxt/devalue', 'radix3', 'unstorage', 'hookable',
|
|
||||||
// dependencies we might share with nitro - these can be inlined (if necessary) in the nitro build
|
|
||||||
...nitroDependencies
|
|
||||||
],
|
],
|
||||||
noExternal: [
|
noExternal: [
|
||||||
...transpile({ isServer: true, isDev: ctx.nuxt.options.dev }),
|
...transpile({ isServer: true, isDev: ctx.nuxt.options.dev }),
|
||||||
@ -112,6 +107,17 @@ export async function buildServer (ctx: ViteBuildContext) {
|
|||||||
]
|
]
|
||||||
} satisfies vite.InlineConfig, ctx.nuxt.options.vite.$server || {}))
|
} satisfies vite.InlineConfig, ctx.nuxt.options.vite.$server || {}))
|
||||||
|
|
||||||
|
if (!ctx.nuxt.options.dev) {
|
||||||
|
const nitroDependencies = await tryResolveModule('nitropack/package.json', ctx.nuxt.options.modulesDir)
|
||||||
|
.then(r => import(r!)).then(r => Object.keys(r.dependencies || {})).catch(() => [])
|
||||||
|
serverConfig.ssr!.external!.push(
|
||||||
|
// explicit dependencies we use in our ssr renderer - these can be inlined (if necessary) in the nitro build
|
||||||
|
'unhead', '@unhead/ssr', 'unctx', 'h3', 'devalue', '@nuxt/devalue', 'radix3', 'unstorage', 'hookable',
|
||||||
|
// dependencies we might share with nitro - these can be inlined (if necessary) in the nitro build
|
||||||
|
...nitroDependencies
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
serverConfig.customLogger = createViteLogger(serverConfig)
|
serverConfig.customLogger = createViteLogger(serverConfig)
|
||||||
|
|
||||||
await ctx.nuxt.callHook('vite:extendConfig', serverConfig, { isClient: false, isServer: true })
|
await ctx.nuxt.callHook('vite:extendConfig', serverConfig, { isClient: false, isServer: true })
|
||||||
|
Loading…
Reference in New Issue
Block a user