perf(vite): don't write stub manifest for legacy bundler (#27957)

This commit is contained in:
Daniel Roe 2024-07-02 19:27:38 +01:00 committed by GitHub
parent ebe6c7122c
commit e717937c03
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 5 additions and 25 deletions

View File

@ -5,7 +5,6 @@ import { relative, resolve } from 'pathe'
import { withTrailingSlash, withoutLeadingSlash } from 'ufo'
import escapeRE from 'escape-string-regexp'
import { normalizeViteManifest } from 'vue-bundle-renderer'
import type { Manifest } from 'vue-bundle-renderer'
import type { ViteBuildContext } from './vite'
export async function writeManifest (ctx: ViteBuildContext) {
@ -13,26 +12,8 @@ export async function writeManifest (ctx: ViteBuildContext) {
const clientDist = resolve(ctx.nuxt.options.buildDir, 'dist/client')
const serverDist = resolve(ctx.nuxt.options.buildDir, 'dist/server')
const devClientManifest: Manifest = {
'@vite/client': {
isEntry: true,
file: '@vite/client',
css: [],
module: true,
resourceType: 'script',
},
[ctx.entry]: {
isEntry: true,
file: ctx.entry,
module: true,
resourceType: 'script',
},
}
const manifestFile = resolve(clientDist, 'manifest.json')
const clientManifest = ctx.nuxt.options.dev
? devClientManifest
: JSON.parse(readFileSync(manifestFile, 'utf-8'))
const clientManifest = JSON.parse(readFileSync(manifestFile, 'utf-8'))
const buildAssetsDir = withTrailingSlash(withoutLeadingSlash(ctx.nuxt.options.app.buildAssetsDir))
const BASE_RE = new RegExp(`^${escapeRE(buildAssetsDir)}`)

View File

@ -146,9 +146,6 @@ export async function buildServer (ctx: ViteBuildContext) {
return
}
// Write dev client manifest
await writeManifest(ctx)
if (!ctx.nuxt.options.ssr) {
await onBuild()
return

View File

@ -1,8 +1,8 @@
import { writeFile } from 'node:fs/promises'
import { mkdir, writeFile } from 'node:fs/promises'
import { pathToFileURL } from 'node:url'
import { createApp, createError, defineEventHandler, defineLazyEventHandler, eventHandler, toNodeListener } from 'h3'
import { ViteNodeServer } from 'vite-node/server'
import { isAbsolute, normalize, resolve } from 'pathe'
import { isAbsolute, join, normalize, resolve } from 'pathe'
import { addDevServerHandler } from '@nuxt/kit'
import { isFileServingAllowed } from 'vite'
import type { ModuleNode, Plugin as VitePlugin } from 'vite'
@ -192,6 +192,8 @@ export async function initViteNodeServer (ctx: ViteBuildContext) {
const serverResolvedPath = resolve(distDir, 'runtime/vite-node.mjs')
const manifestResolvedPath = resolve(distDir, 'runtime/client.manifest.mjs')
await mkdir(join(ctx.nuxt.options.buildDir, 'dist/server'), { recursive: true })
await writeFile(
resolve(ctx.nuxt.options.buildDir, 'dist/server/server.mjs'),
`export { default } from ${JSON.stringify(pathToFileURL(serverResolvedPath).href)}`,