Compare commits

...

5 Commits

Author SHA1 Message Date
Idorenyin Udoh
baa68a6491
Merge branch 'main' into patch-2 2025-02-18 19:12:35 +01:00
renovate[bot]
160efe7a7f
chore(deps): update unocss monorepo to v66 (main) (major) (#31021)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-02-18 11:13:44 +01:00
renovate[bot]
323745d0d4
chore(deps): update all non-major dependencies (main) (#30983)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-02-18 10:36:58 +01:00
Ryota Watanabe
b0729241bc
fix(nuxt): use tsx loader for jsx blocks as well (#31014) 2025-02-17 19:14:12 +01:00
Alex Liu
0f0a822208
refactor(nuxt): prefer logical assignment operators (#31004) 2025-02-16 13:31:49 +00:00
48 changed files with 851 additions and 878 deletions

View File

@ -236,7 +236,7 @@ jobs:
path: packages
- name: Run benchmarks
uses: CodSpeedHQ/action@da7c57859a7a565a3a92789ac64c41aca031ca1f # v3.3.0
uses: CodSpeedHQ/action@1015f4f828ff74b7a950909897fe581d6ba868cc # v3.3.1
with:
run: pnpm vitest bench
token: ${{ secrets.CODSPEED_TOKEN }}

View File

@ -39,10 +39,8 @@ function captureStackTrace () {
continue
}
for (const key of ['line', 'column']) {
if (parsed[key]) {
// @ts-expect-error
parsed[key] = Number(parsed[key])
}
// @ts-expect-error
parsed[key] &&= Number(parsed[key])
}
trace.push(parsed)
}

View File

@ -48,6 +48,7 @@ export default createConfigForNuxt({
rules: {
'curly': ['error', 'all'], // Including if blocks with a single statement
'dot-notation': 'error',
'logical-assignment-operators': ['error', 'always', { enforceForIfStatements: true }],
'no-console': ['warn', { allow: ['warn', 'error', 'debug'] }],
'no-lonely-if': 'error', // No single if in an "else" block
'no-useless-rename': 'error',

View File

@ -37,7 +37,7 @@
"typecheck:docs": "DOCS_TYPECHECK=true pnpm nuxi prepare && nuxt-content-twoslash verify --content-dir docs --languages html"
},
"resolutions": {
"@babel/core": "7.26.8",
"@babel/core": "7.26.9",
"@babel/helper-plugin-utils": "7.26.5",
"@nuxt/cli": "3.21.1",
"@nuxt/kit": "workspace:*",
@ -45,12 +45,12 @@
"@nuxt/schema": "workspace:*",
"@nuxt/vite-builder": "workspace:*",
"@nuxt/webpack-builder": "workspace:*",
"@types/node": "22.13.2",
"@unhead/dom": "1.11.18",
"@unhead/schema": "1.11.18",
"@unhead/shared": "1.11.18",
"@unhead/ssr": "1.11.18",
"@unhead/vue": "1.11.18",
"@types/node": "22.13.4",
"@unhead/dom": "1.11.19",
"@unhead/schema": "1.11.19",
"@unhead/shared": "1.11.19",
"@unhead/ssr": "1.11.19",
"@unhead/vue": "1.11.19",
"@vue/compiler-core": "3.5.13",
"@vue/compiler-dom": "3.5.13",
"@vue/shared": "3.5.13",
@ -62,19 +62,19 @@
"nuxt": "workspace:*",
"ohash": "1.1.4",
"postcss": "8.5.2",
"rollup": "4.34.6",
"rollup": "4.34.8",
"send": ">=1.1.0",
"typescript": "5.7.3",
"ufo": "1.5.4",
"unbuild": "3.3.1",
"unhead": "1.11.18",
"unimport": "4.1.1",
"unhead": "1.11.19",
"unimport": "4.1.2",
"vite": "6.1.0",
"vue": "3.5.13"
},
"devDependencies": {
"@arethetypeswrong/cli": "0.17.3",
"@babel/core": "7.26.8",
"@babel/core": "7.26.9",
"@babel/helper-plugin-utils": "7.26.5",
"@codspeed/vitest-plugin": "4.0.0",
"@nuxt/cli": "3.21.1",
@ -86,10 +86,10 @@
"@testing-library/vue": "8.1.0",
"@types/babel__core": "7.20.5",
"@types/babel__helper-plugin-utils": "7.10.3",
"@types/node": "22.13.2",
"@types/node": "22.13.4",
"@types/semver": "7.5.8",
"@unhead/schema": "1.11.18",
"@unhead/vue": "1.11.18",
"@unhead/schema": "1.11.19",
"@unhead/vue": "1.11.19",
"@vitest/coverage-v8": "3.0.5",
"@vue/test-utils": "2.4.6",
"acorn": "8.14.0",
@ -120,12 +120,12 @@
"pathe": "2.0.3",
"pkg-pr-new": "0.0.39",
"playwright-core": "1.50.1",
"rollup": "4.34.6",
"rollup": "4.34.8",
"semver": "7.7.1",
"sherif": "1.3.0",
"std-env": "3.8.0",
"tinyexec": "0.3.2",
"tinyglobby": "0.2.10",
"tinyglobby": "0.2.11",
"ts-blank-space": "0.6.0",
"typescript": "5.7.3",
"ufo": "1.5.4",
@ -133,9 +133,9 @@
"vitest": "3.0.5",
"vitest-environment-nuxt": "1.0.1",
"vue": "3.5.13",
"vue-tsc": "2.2.0",
"vue-tsc": "2.2.2",
"webpack": "5.98.0"
},
"packageManager": "pnpm@10.3.0",
"packageManager": "pnpm@10.4.1",
"version": ""
}

View File

@ -45,7 +45,7 @@
"std-env": "^3.8.0",
"ufo": "^1.5.4",
"unctx": "^2.4.1",
"unimport": "^4.1.1",
"unimport": "^4.1.2",
"untyped": "^1.5.2"
},
"devDependencies": {

View File

@ -34,7 +34,7 @@ export async function loadNuxtConfig (opts: LoadNuxtConfigOptions): Promise<Nuxt
delete (globalThis as any).defineNuxtConfig
// Fill config
nuxtConfig.rootDir = nuxtConfig.rootDir || cwd
nuxtConfig.rootDir ||= cwd
nuxtConfig._nuxtConfigFile = configFile
nuxtConfig._nuxtConfigFiles = [configFile]
nuxtConfig.alias ||= {}
@ -64,7 +64,7 @@ export async function loadNuxtConfig (opts: LoadNuxtConfigOptions): Promise<Nuxt
for (const layer of layers) {
// Resolve `rootDir` & `srcDir` of layers
layer.config ||= {}
layer.config.rootDir = layer.config.rootDir ?? layer.cwd!
layer.config.rootDir ??= layer.cwd!
// Only process/resolve layers once
if (processedLayers.has(layer.config.rootDir)) { continue }

View File

@ -72,9 +72,7 @@ export async function findPath (paths: string | string[], opts?: ResolvePathOpti
* Resolve path aliases respecting Nuxt alias options
*/
export function resolveAlias (path: string, alias?: Record<string, string>): string {
if (!alias) {
alias = tryUseNuxt()?.options.alias || {}
}
alias ||= tryUseNuxt()?.options.alias || {}
return _resolveAlias(path, alias)
}

View File

@ -105,9 +105,7 @@ export function normalizeTemplate<T> (template: NuxtTemplate<T> | string, buildD
}
// Resolve dst
if (!template.dst) {
template.dst = resolve(buildDir ?? useNuxt().options.buildDir, template.filename)
}
template.dst ||= resolve(buildDir ?? useNuxt().options.buildDir, template.filename)
return template as ResolvedNuxtTemplate<T>
}

View File

@ -66,15 +66,15 @@
"dependencies": {
"@nuxt/cli": "^3.21.1",
"@nuxt/devalue": "^2.0.2",
"@nuxt/devtools": "^2.0.0",
"@nuxt/devtools": "^2.1.0",
"@nuxt/kit": "workspace:*",
"@nuxt/schema": "workspace:*",
"@nuxt/telemetry": "^2.6.5",
"@nuxt/vite-builder": "workspace:*",
"@unhead/dom": "^1.11.18",
"@unhead/shared": "^1.11.18",
"@unhead/ssr": "^1.11.18",
"@unhead/vue": "^1.11.18",
"@unhead/dom": "^1.11.19",
"@unhead/shared": "^1.11.19",
"@unhead/ssr": "^1.11.19",
"@unhead/vue": "^1.11.19",
"@vue/shared": "^3.5.13",
"acorn": "8.14.0",
"c12": "^2.0.2",
@ -113,14 +113,14 @@
"semver": "^7.7.1",
"std-env": "^3.8.0",
"strip-literal": "^3.0.0",
"tinyglobby": "0.2.10",
"tinyglobby": "0.2.11",
"ufo": "^1.5.4",
"ultrahtml": "^1.5.3",
"uncrypto": "^0.1.3",
"unctx": "^2.4.1",
"unenv": "^1.10.0",
"unhead": "^1.11.18",
"unimport": "^4.1.1",
"unhead": "^1.11.19",
"unimport": "^4.1.2",
"unplugin": "^2.2.0",
"unplugin-vue-router": "^0.11.2",
"unstorage": "^1.14.4",
@ -131,7 +131,7 @@
"vue-router": "^4.5.0"
},
"devDependencies": {
"@nuxt/scripts": "0.10.1",
"@nuxt/scripts": "0.10.3",
"@parcel/watcher": "2.5.1",
"@types/estree": "1.0.6",
"@vitejs/plugin-vue": "5.2.1",

View File

@ -59,9 +59,9 @@ export function createClientOnly<T extends ComponentOptions> (component: T) {
}
return elToStaticVNode(ctx._.vnode.el, STATIC_DIV)
}
} else if (clone.template) {
} else {
// handle runtime-compiler template
clone.template = `
clone.template &&= `
<template v-if="mounted$">${component.template}</template>
<template v-else>${STATIC_DIV}</template>
`

View File

@ -197,12 +197,10 @@ export default defineComponent({
}
async function fetchComponent (force = false) {
nuxtApp[pKey] = nuxtApp[pKey] || {}
if (!nuxtApp[pKey][uid.value]) {
nuxtApp[pKey][uid.value] = _fetchComponent(force).finally(() => {
delete nuxtApp[pKey]![uid.value]
})
}
nuxtApp[pKey] ||= {}
nuxtApp[pKey][uid.value] ||= _fetchComponent(force).finally(() => {
delete nuxtApp[pKey]![uid.value]
})
try {
const res: NuxtIslandResponse = await nuxtApp[pKey][uid.value]

View File

@ -506,15 +506,13 @@ function useObserver (): { observe: ObserveFn } | undefined {
const callbacks = new Map<Element, CallbackFn>()
const observe: ObserveFn = (element, callback) => {
if (!observer) {
observer = new IntersectionObserver((entries) => {
for (const entry of entries) {
const callback = callbacks.get(entry.target)
const isVisible = entry.isIntersecting || entry.intersectionRatio > 0
if (isVisible && callback) { callback() }
}
})
}
observer ||= new IntersectionObserver((entries) => {
for (const entry of entries) {
const callback = callbacks.get(entry.target)
const isVisible = entry.isIntersecting || entry.intersectionRatio > 0
if (isVisible && callback) { callback() }
}
})
callbacks.set(element, callback)
observer.observe(element)
return () => {

View File

@ -230,14 +230,14 @@ export function useAsyncData<
const getDefaultCachedData = () => nuxtApp.isHydrating ? nuxtApp.payload.data[key] : nuxtApp.static.data[key]
// Apply defaults
options.server = options.server ?? true
options.default = options.default ?? (getDefault as () => DefaultT)
options.getCachedData = options.getCachedData ?? getDefaultCachedData
options.server ??= true
options.default ??= getDefault as () => DefaultT
options.getCachedData ??= getDefaultCachedData
options.lazy = options.lazy ?? false
options.immediate = options.immediate ?? true
options.deep = options.deep ?? asyncDataDefaults.deep
options.dedupe = options.dedupe ?? 'cancel'
options.lazy ??= false
options.immediate ??= true
options.deep ??= asyncDataDefaults.deep
options.dedupe ??= 'cancel'
// Create or use a shared asyncData entity
const initialCachedData = options.getCachedData!(key, nuxtApp)

View File

@ -31,7 +31,7 @@ export const showError = <DataT = unknown>(
nuxtApp.hooks.callHook('app:error', nuxtError)
}
error.value = error.value || nuxtError
error.value ||= nuxtError
} catch {
throw nuxtError
}

View File

@ -170,9 +170,9 @@ export function useLoadingIndicator (opts: Partial<LoadingIndicatorOpts> = {}):
const nuxtApp = useNuxtApp()
// Initialise global loading indicator if it doesn't exist already
const indicator = nuxtApp._loadingIndicator = nuxtApp._loadingIndicator || createLoadingIndicator(opts)
const indicator = nuxtApp._loadingIndicator ||= createLoadingIndicator(opts)
if (import.meta.client && getCurrentScope()) {
nuxtApp._loadingIndicatorDeps = nuxtApp._loadingIndicatorDeps || 0
nuxtApp._loadingIndicatorDeps ||= 0
nuxtApp._loadingIndicatorDeps++
onScopeDispose(() => {
nuxtApp._loadingIndicatorDeps!--

View File

@ -38,7 +38,7 @@ export async function callOnce (...args: any): Promise<void> {
}
nuxtApp._once ||= {}
nuxtApp._once[_key] = nuxtApp._once[_key] || fn() || true
nuxtApp._once[_key] ||= fn() || true
await nuxtApp._once[_key]
nuxtApp.payload.once.add(_key)
delete nuxtApp._once[_key]

View File

@ -21,7 +21,7 @@ export async function loadPayload (url: string, opts: LoadPayloadOptions = {}):
if (import.meta.server || !payloadExtraction) { return null }
const payloadURL = await _getPayloadURL(url, opts)
const nuxtApp = useNuxtApp()
const cache = nuxtApp._payloadCache = nuxtApp._payloadCache || {}
const cache = nuxtApp._payloadCache ||= {}
if (payloadURL in cache) {
return cache[payloadURL] || null
}

View File

@ -49,10 +49,10 @@ export async function preloadRouteComponents (to: RouteLocationRaw, router: Rout
const { path, matched } = router.resolve(to)
if (!matched.length) { return }
if (!router._routePreloaded) { router._routePreloaded = new Set() }
router._routePreloaded ||= new Set()
if (router._routePreloaded.has(path)) { return }
const promises = router._preloadPromises = router._preloadPromises || []
const promises = router._preloadPromises ||= []
if (promises.length > 4) {
// Defer adding new preload requests until the existing ones have resolved

View File

@ -69,12 +69,12 @@ export function useRouteAnnouncer (opts: Partial<NuxtRouteAnnouncerOpts> = {}):
const nuxtApp = useNuxtApp()
// Initialise global route announcer if it doesn't exist already
const announcer = nuxtApp._routeAnnouncer = nuxtApp._routeAnnouncer || createRouteAnnouncer(opts)
const announcer = nuxtApp._routeAnnouncer ||= createRouteAnnouncer(opts)
if (opts.politeness !== announcer.politeness.value) {
announcer.politeness.value = opts.politeness || 'polite'
}
if (import.meta.client && getCurrentScope()) {
nuxtApp._routeAnnouncerDeps = nuxtApp._routeAnnouncerDeps || 0
nuxtApp._routeAnnouncerDeps ||= 0
nuxtApp._routeAnnouncerDeps++
onScopeDispose(() => {
nuxtApp._routeAnnouncerDeps!--

View File

@ -117,9 +117,7 @@ export interface NavigateToOptions {
const URL_QUOTE_RE = /"/g
/** @since 3.0.0 */
export const navigateTo = (to: RouteLocationRaw | undefined | null, options?: NavigateToOptions): Promise<void | NavigationFailure | false> | false | void | RouteLocationRaw => {
if (!to) {
to = '/'
}
to ||= '/'
const toPath = typeof to === 'string' ? to : 'path' in to ? resolveRouteObject(to) : useRouter().resolve(to).href

View File

@ -38,7 +38,7 @@ function deepAssign (obj: any, newObj: any) {
const val = newObj[key]
if (isPojoOrArray(val)) {
const defaultVal = Array.isArray(val) ? [] : {}
obj[key] = obj[key] || defaultVal
obj[key] ||= defaultVal
deepAssign(obj[key], val)
} else {
obj[key] = val
@ -48,9 +48,7 @@ function deepAssign (obj: any, newObj: any) {
export function useAppConfig (): AppConfig {
const nuxtApp = useNuxtApp()
if (!nuxtApp._appConfig) {
nuxtApp._appConfig = (import.meta.server ? klona(__appConfig) : reactive(__appConfig)) as AppConfig
}
nuxtApp._appConfig ||= (import.meta.server ? klona(__appConfig) : reactive(__appConfig)) as AppConfig
return nuxtApp._appConfig
}

View File

@ -32,7 +32,7 @@ if (import.meta.server) {
await nuxt.hooks.callHook('app:created', vueApp)
} catch (error) {
await nuxt.hooks.callHook('app:error', error)
nuxt.payload.error = nuxt.payload.error || createError(error as any)
nuxt.payload.error ||= createError(error as any)
}
if (ssrContext?._renderResponse) { throw new Error('skipping render') }
@ -63,7 +63,7 @@ if (import.meta.client) {
async function handleVueError (error: any) {
await nuxt.callHook('app:error', error)
nuxt.payload.error = nuxt.payload.error || createError(error as any)
nuxt.payload.error ||= createError(error as any)
}
vueApp.config.errorHandler = handleVueError

View File

@ -377,7 +377,7 @@ export function createNuxtApp (options: CreateOptions) {
}
})
}
window.useNuxtApp = window.useNuxtApp || useNuxtApp
window.useNuxtApp ||= useNuxtApp
// Log errors captured when running plugins, in the `app:created` and `app:beforeMount` hooks
// as well as when mounting the app.

View File

@ -21,7 +21,7 @@ if (componentIslands) {
revivers.push(['Island', ({ key, params, result }: any) => {
const nuxtApp = useNuxtApp()
if (!nuxtApp.isHydrating) {
nuxtApp.payload.data[key] = nuxtApp.payload.data[key] || $fetch(`/__nuxt_island/${key}.json`, {
nuxtApp.payload.data[key] ||= $fetch(`/__nuxt_island/${key}.json`, {
responseType: 'json',
...params ? { params } : {},
}).then((r) => {

View File

@ -230,7 +230,7 @@ export default defineNuxtPlugin<{ route: Route, router: Router }>({
nuxtApp._route = route
// Handle middleware
nuxtApp._middleware = nuxtApp._middleware || {
nuxtApp._middleware ||= {
global: [],
named: {},
}

View File

@ -34,9 +34,9 @@ function pageToClientOnly<T extends ComponentOptions> (component: T) {
clone.render = (ctx: any, cache: any, $props: any, $setup: any, $data: any, $options: any) => ($setup.mounted$ ?? ctx.mounted$)
? h(component.render?.bind(ctx)(ctx, cache, $props, $setup, $data, $options))
: h('div')
} else if (clone.template) {
} else {
// handle runtime-compiler template
clone.template = `
clone.template &&= `
<template v-if="mounted$">${component.template}</template>
<template v-else><div></div></template>
`

View File

@ -136,29 +136,21 @@ async function compileTemplate<T> (template: NuxtTemplate<T>, ctx: { nuxt: Nuxt,
export async function resolveApp (nuxt: Nuxt, app: NuxtApp) {
// Resolve main (app.vue)
if (!app.mainComponent) {
app.mainComponent = await findPath(
nuxt.options._layers.flatMap(layer => [
join(layer.config.srcDir, 'App'),
join(layer.config.srcDir, 'app'),
]),
)
}
if (!app.mainComponent) {
app.mainComponent = resolve(nuxt.options.appDir, 'components/welcome.vue')
}
app.mainComponent ||= await findPath(
nuxt.options._layers.flatMap(layer => [
join(layer.config.srcDir, 'App'),
join(layer.config.srcDir, 'app'),
]),
)
app.mainComponent ||= resolve(nuxt.options.appDir, 'components/welcome.vue')
// Resolve root component
if (!app.rootComponent) {
app.rootComponent = await findPath(['~/app.root', resolve(nuxt.options.appDir, 'components/nuxt-root.vue')])
}
app.rootComponent ||= await findPath(['~/app.root', resolve(nuxt.options.appDir, 'components/nuxt-root.vue')])
// Resolve error component
if (!app.errorComponent) {
app.errorComponent = (await findPath(
nuxt.options._layers.map(layer => join(layer.config.srcDir, 'error')),
)) ?? resolve(nuxt.options.appDir, 'components/nuxt-error-page.vue')
}
app.errorComponent ||= (await findPath(
nuxt.options._layers.map(layer => join(layer.config.srcDir, 'error')),
)) ?? resolve(nuxt.options.appDir, 'components/nuxt-error-page.vue')
// Resolve layouts/ from all config layers
const layerConfigs = nuxt.options._layers.map(layer => layer.config)
@ -174,7 +166,7 @@ export async function resolveApp (nuxt: Nuxt, app: NuxtApp) {
logger.warn(`No layout name could be resolved for \`~/${relative(nuxt.options.srcDir, file)}\`. Bear in mind that \`index\` is ignored for the purpose of creating a layout name.`)
continue
}
app.layouts[name] = app.layouts[name] || { name, file }
app.layouts[name] ||= { name, file }
}
}

View File

@ -942,7 +942,7 @@ function createPortalProperties (sourceValue: any, options: NuxtOptions, paths:
while (segments.length) {
const key = segments.shift()!
parent = parent[key] || (parent[key] = {})
parent = parent[key] ||= {}
}
delete parent[key]

View File

@ -70,7 +70,7 @@ export async function extractMetadata (code: string, loader = 'ts' as 'ts' | 'ts
meta = defu(extractMetaFromObject(plugin.properties), meta)
}
meta.order = meta.order || orderMap[meta.enforce || 'default'] || orderMap.default
meta.order ||= orderMap[meta.enforce || 'default'] || orderMap.default
delete meta.enforce
})
metaCache[code] = meta

View File

@ -11,9 +11,7 @@ export function useAppConfig (event?: H3Event) {
if (!event) {
return _sharedAppConfig
}
if (!event.context.nuxt) {
event.context.nuxt = {}
}
event.context.nuxt ||= {}
// Reuse cached app config from event context
if (event.context.nuxt.appConfig) {
return event.context.nuxt.appConfig

View File

@ -167,7 +167,7 @@ const getSPARenderer = lazyCachedFunction(async () => {
const renderToString = (ssrContext: NuxtSSRContext) => {
const config = useRuntimeConfig(ssrContext.event)
ssrContext.modules = ssrContext.modules || new Set<string>()
ssrContext.modules ||= new Set<string>()
ssrContext.payload.serverRendered = false
ssrContext.config = {
public: config.public,

View File

@ -135,7 +135,7 @@ export default defineNuxtModule<Partial<ImportsOptions>>({
fileFilter: file => !isIgnored(file),
})
for (const i of scannedImports) {
i.priority = i.priority || priorities.find(([dir]) => i.from.startsWith(dir))?.[1]
i.priority ||= priorities.find(([dir]) => i.from.startsWith(dir))?.[1]
}
imports.push(...scannedImports)
}

View File

@ -269,9 +269,7 @@ export default defineNuxtModule({
}
nuxt.hooks.hookOnce('app:templates', async (app) => {
if (!app.pages) {
app.pages = await resolvePagesRoutes(nuxt)
}
app.pages ||= await resolvePagesRoutes(nuxt)
})
nuxt.hook('builder:watch', async (event, relativePath) => {

View File

@ -29,9 +29,7 @@ export const RouteInjectionPlugin = (nuxt: Nuxt) => createUnplugin(() => {
const start = match.index!
const end = start + match[0].length
s.overwrite(start, end, replacement)
if (!replaced) {
replaced = true
}
replaced ||= true
}
}

View File

@ -130,7 +130,7 @@ const plugin: Plugin<{ router: Router }> = defineNuxtPlugin({
nuxtApp._route = shallowReactive(route)
nuxtApp._middleware = nuxtApp._middleware || {
nuxtApp._middleware ||= {
global: [],
named: {},
}

View File

@ -192,7 +192,7 @@ export function extractScriptContent (sfc: string) {
for (const match of sfc.matchAll(SFC_SCRIPT_RE)) {
if (match?.groups?.content) {
contents.push({
loader: match.groups.attrs?.includes('tsx') ? 'tsx' : 'ts',
loader: match.groups.attrs && /[tj]sx/.test(match.groups.attrs) ? 'tsx' : 'ts',
code: match.groups.content.trim(),
})
}

View File

@ -42,6 +42,19 @@ export default {
})
})
it('should parse lang="jsx" from vue files', async () => {
const fileContents = `
<script setup lang="jsx">
const foo = <></>;
definePageMeta({ name: 'bar' })
</script>`
const meta = await getRouteMeta(fileContents, `/app/pages/index.vue`)
expect(meta).toStrictEqual({
name: 'bar',
})
})
// TODO: https://github.com/nuxt/nuxt/pull/30066
it.todo('should handle experimental decorators', async () => {
const fileContents = `

View File

@ -75,7 +75,7 @@
"@types/pify": "5.0.4",
"@types/webpack-bundle-analyzer": "4.7.0",
"@types/webpack-hot-middleware": "2.25.9",
"rollup": "4.34.6",
"rollup": "4.34.8",
"unbuild": "3.3.1",
"vue": "3.5.13"
},

View File

@ -40,12 +40,12 @@
"@types/rollup-plugin-visualizer": "4.2.4",
"@types/webpack-bundle-analyzer": "4.7.0",
"@types/webpack-hot-middleware": "2.25.9",
"@unhead/schema": "1.11.18",
"@unhead/schema": "1.11.19",
"@vitejs/plugin-vue": "5.2.1",
"@vitejs/plugin-vue-jsx": "4.1.1",
"@vue/compiler-core": "3.5.13",
"@vue/compiler-sfc": "3.5.13",
"@vue/language-core": "2.2.0",
"@vue/language-core": "2.2.2",
"c12": "2.0.2",
"chokidar": "4.0.3",
"compatx": "0.1.8",
@ -61,11 +61,11 @@
"ofetch": "1.4.1",
"pkg-types": "1.3.1",
"postcss": "8.5.2",
"sass-loader": "16.0.4",
"sass-loader": "16.0.5",
"scule": "1.3.0",
"unbuild": "3.3.1",
"unctx": "2.4.1",
"unimport": "4.1.1",
"unimport": "4.1.2",
"untyped": "1.5.2",
"vite": "6.1.0",
"vue": "3.5.13",

View File

@ -17,9 +17,9 @@
"prerender": "pnpm build && jiti ./lib/prerender"
},
"devDependencies": {
"@unocss/reset": "65.4.3",
"@unocss/reset": "66.0.0",
"beasties": "0.2.0",
"html-validate": "9.2.2",
"html-validate": "9.3.0",
"htmlnano": "2.1.1",
"jiti": "2.4.2",
"knitwork": "1.2.0",
@ -28,8 +28,8 @@
"scule": "1.3.0",
"svgo": "3.3.2",
"tinyexec": "0.3.2",
"tinyglobby": "0.2.10",
"unocss": "65.4.3",
"tinyglobby": "0.2.11",
"unocss": "66.0.0",
"vite": "6.1.0"
}
}

View File

@ -26,7 +26,7 @@
},
"devDependencies": {
"@nuxt/schema": "workspace:*",
"rollup": "4.34.6",
"rollup": "4.34.8",
"unbuild": "3.3.1",
"vue": "3.5.13"
},

View File

@ -39,13 +39,9 @@ export async function writeManifest (ctx: ViteBuildContext) {
const BASE_RE = new RegExp(`^${escapeRE(buildAssetsDir)}`)
for (const entry of manifestEntries) {
if (entry.file) {
entry.file = entry.file.replace(BASE_RE, '')
}
entry.file &&= entry.file.replace(BASE_RE, '')
for (const item of ['css', 'assets'] as const) {
if (entry[item]) {
entry[item] = entry[item].map((i: string) => i.replace(BASE_RE, ''))
}
entry[item] &&= entry[item].map((i: string) => i.replace(BASE_RE, ''))
}
}

View File

@ -77,7 +77,7 @@
"@types/pify": "5.0.4",
"@types/webpack-bundle-analyzer": "4.7.0",
"@types/webpack-hot-middleware": "2.25.9",
"rollup": "4.34.6",
"rollup": "4.34.8",
"unbuild": "3.3.1",
"vue": "3.5.13"
},

View File

@ -104,9 +104,7 @@ export default class VueSSRClientPlugin {
if (Array.isArray(m.modules)) {
for (const concatenatedModule of m.modules) {
const id = hash(concatenatedModule.identifier!.replace(/\s\w+$/, ''))
if (!webpackManifest.modules[id]) {
webpackManifest.modules[id] = files
}
webpackManifest.modules[id] ||= files
}
}

View File

@ -92,7 +92,7 @@ function createCssLoadersRule (ctx: WebpackConfigContext, cssLoaderOptions: any)
if (ctx.isServer) {
// https://webpack.js.org/loaders/css-loader/#exportonlylocals
if (cssLoader.options.modules) {
cssLoader.options.modules.exportOnlyLocals = cssLoader.options.modules.exportOnlyLocals ?? true
cssLoader.options.modules.exportOnlyLocals ??= true
}
return [cssLoader]
}

File diff suppressed because it is too large Load Diff

View File

@ -27,7 +27,7 @@ export async function loadPackage (dir: string) {
const dep: Dep = { name: e[0], range: e[1] as string, type }
delete data[type][dep.name]
const updated = reviver(dep) || dep
data[updated.type] = data[updated.type] || {}
data[updated.type] ||= {}
data[updated.type][updated.name] = updated.range
}
}

View File

@ -2405,9 +2405,7 @@ describe('component islands', () => {
for (const key in result.head) {
if (key === 'link') {
result.head[key] = result.head[key]?.map((h) => {
if (h.href) {
h.href = resolveUnrefHeadInput(h.href).replace(fixtureDir, '/<rootDir>').replaceAll('//', '/')
}
h.href &&= resolveUnrefHeadInput(h.href).replace(fixtureDir, '/<rootDir>').replaceAll('//', '/')
return h
})
}
@ -2800,16 +2798,12 @@ function normaliseIslandResult (result: NuxtIslandResponse) {
if (result.head.style) {
for (const style of result.head.style) {
if (typeof style !== 'string') {
if (style.innerHTML) {
style.innerHTML =
style.innerHTML &&=
(style.innerHTML as string)
.replace(/data-v-[a-z0-9]+/g, 'data-v-xxxxx')
// Vite 6 enables CSS minify by default for SSR
.replace(/blue/, '#00f')
}
if (style.key) {
style.key = style.key.replace(/-[a-z0-9]+$/i, '')
}
style.key &&= style.key.replace(/-[a-z0-9]+$/i, '')
}
}
}