Compare commits

...

15 Commits

Author SHA1 Message Date
Michael Brevard
d53f8845a0
Merge b435af1f58 into 160efe7a7f 2025-02-18 11:13:51 +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
Daniel Roe
b435af1f58
Merge branch 'main' into patch-26 2025-01-24 17:18:08 +00:00
tbitw2549
16984b7c7e fix: mark chunk as existent 2024-10-23 21:13:08 +03:00
tbitw2549
c6c4f4efc8 Merge branch 'patch-26' of https://github.com/GalacticHypernova/nuxt into patch-26 2024-10-23 21:10:40 +03:00
tbitw2549
f5bb1aad1c perf: object iterators 2024-10-23 21:09:22 +03:00
Michael Brevard
e155e0483e
perf: initial vite impl 2024-10-23 20:39:54 +03:00
tbitw2549
6613d9fedf Merge branch 'patch-26' of https://github.com/GalacticHypernova/nuxt into patch-26 2024-10-20 21:40:05 +03:00
tbitw2549
f2a9a568b0 perf(kit): unify mode regex 2024-10-20 21:39:35 +03:00
autofix-ci[bot]
9b501e1dd3
[autofix.ci] apply automated fixes 2024-10-20 18:35:23 +00:00
tbitw2549
ee6f91b7e3 perf: unify (j/t)sx regex 2024-10-20 21:33:03 +03:00
tbitw2549
dc4d032246 perf: unify shared patterns 2024-10-20 21:28:29 +03:00
tbitw2549
f49c0497ad perf: extract regex patterns 2024-10-20 21:18:12 +03:00
Michael Brevard
83465c241a
perf: cache regex patterns 2024-10-20 20:11:31 +03:00
23 changed files with 805 additions and 791 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

@ -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

@ -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

@ -33,7 +33,8 @@ async function loadComponents (source = appBaseURL, paths: NuxtIslandResponse['c
const promises: Array<Promise<void>> = []
for (const [component, item] of Object.entries(paths)) {
for (const component in paths) {
const item = paths[component]!
if (!(components!.has(component))) {
promises.push((async () => {
const chunkSource = joinURL(source, item.chunk)
@ -146,10 +147,10 @@ export default defineComponent({
html = html.replace(ISLAND_SCOPE_ID_RE, full => full + ' ' + props.scopeId)
}
if (import.meta.client && !canLoadClientComponent.value) {
for (const [key, value] of Object.entries(payloads.components || {})) {
if (import.meta.client && !canLoadClientComponent.value && payloads.components) {
for (const key in payloads.components) {
html = html.replace(new RegExp(` data-island-uid="${uid.value}" data-island-component="${key}"[^>]*>`), (full) => {
return full + value.html
return full + payloads.components![key]!.html
})
}
}
@ -287,8 +288,8 @@ export default defineComponent({
if (selectiveClient) {
if (import.meta.server) {
if (payloads.components) {
for (const [id, info] of Object.entries(payloads.components)) {
const { html, slots } = info
for (const id in payloads.components) {
const { html, slots } = payloads.components[id]!
let replaced = html.replaceAll('data-island-uid', `data-island-uid="${uid.value}"`)
for (const slot in slots) {
replaced = replaced.replaceAll(`data-island-slot="${slot}">`, full => full + slots[slot])
@ -299,8 +300,8 @@ export default defineComponent({
}
}
} else if (canLoadClientComponent.value && payloads.components) {
for (const [id, info] of Object.entries(payloads.components)) {
const { props, slots } = info
for (const id in payloads.components) {
const { props, slots } = payloads.components[id]!
const component = components!.get(id)!
// use different selectors for even and odd teleportKey to force trigger the teleport
const vnode = createVNode(Teleport, { to: `${isKeyOdd ? 'div' : ''}[data-island-uid='${uid.value}'][data-island-component="${id}"]` }, {

View File

@ -250,8 +250,8 @@ function generateOptionSegments<_ResT, DataT, DefaultT> (opts: UseFetchOptions<_
if (!obj) { continue }
const unwrapped: Record<string, string> = {}
for (const [key, value] of Object.entries(obj)) {
unwrapped[toValue(key)] = toValue(value)
for (const key in obj) {
unwrapped[toValue(key)] = toValue(obj[key])
}
segments.push(unwrapped)
}

View File

@ -144,7 +144,8 @@ export default defineNuxtModule<ComponentsOptions>({
nuxt.hook('build:manifest', (manifest) => {
const sourceFiles = getComponents().filter(c => c.global).map(c => relative(nuxt.options.srcDir, c.filePath))
for (const chunk of Object.values(manifest)) {
for (const chunkId in manifest) {
const chunk = manifest[chunkId]!
if (chunk.isEntry) {
chunk.dynamicImports =
chunk.dynamicImports?.filter(i => !sourceFiles.includes(i))

View File

@ -211,7 +211,8 @@ export const ComponentsChunkPlugin = createUnplugin((options: ComponentChunkOpti
async generateBundle (_opts, bundle) {
const components = options.getComponents().filter(c => c.mode === 'client' || c.mode === 'all')
const pathAssociation: Record<string, string> = {}
for (const [chunkPath, chunkInfo] of Object.entries(bundle)) {
for (const chunkPath in bundle) {
const chunkInfo = bundle[chunkPath]!
if (chunkInfo.type !== 'chunk') { continue }
for (const component of components) {

View File

@ -449,7 +449,8 @@ async function initNuxt (nuxt: Nuxt) {
// TODO: [Experimental] Avoid emitting assets when flag is enabled
if (nuxt.options.features.noScripts && !nuxt.options.dev) {
nuxt.hook('build:manifest', async (manifest) => {
for (const chunk of Object.values(manifest)) {
for (const chunkId in manifest) {
const chunk = manifest[chunkId]!
if (chunk.resourceType === 'script') {
await rm(resolve(nuxt.options.buildDir, 'dist/client', withoutLeadingSlash(nuxt.options.app.buildAssetsDir), chunk.file), { force: true })
chunk.file = ''

View File

@ -412,7 +412,8 @@ export default defineRenderHandler(async (event): Promise<Partial<RenderResponse
}
if (!isRenderingIsland || import.meta.dev) {
const link: Link[] = []
for (const resource of Object.values(styles)) {
for (const resourceId in styles) {
const resource = styles[resourceId]!
// Do not add links to resources that are inlined (vite v5+)
if (import.meta.dev && 'inline' in getURLQuery(resource.file)) {
continue
@ -478,7 +479,9 @@ export default defineRenderHandler(async (event): Promise<Partial<RenderResponse
if (isRenderingIsland && islandContext) {
const islandHead: Head = {}
for (const entry of head.headEntries()) {
for (const [key, value] of Object.entries(resolveUnrefHeadInput(entry.input) as Head)) {
const currentEntry = resolveUnrefHeadInput(entry.input)
for (const key in currentEntry as Head) {
const value = currentEntry[key]
const currentValue = islandHead[key as keyof Head]
if (Array.isArray(currentValue)) {
currentValue.push(...value)
@ -677,9 +680,9 @@ const SSR_CLIENT_SLOT_MARKER = /^island-slot=([^;]*);(.*)$/
function getSlotIslandResponse (ssrContext: NuxtSSRContext): NuxtIslandResponse['slots'] {
if (!ssrContext.islandContext || !Object.keys(ssrContext.islandContext.slots).length) { return undefined }
const response: NuxtIslandResponse['slots'] = {}
for (const [name, slot] of Object.entries(ssrContext.islandContext.slots)) {
for (const name in ssrContext.islandContext.slots) {
response[name] = {
...slot,
...ssrContext.islandContext.slots[name]!,
fallback: ssrContext.teleports?.[`island-fallback=${name}`],
}
}
@ -690,11 +693,11 @@ function getClientIslandResponse (ssrContext: NuxtSSRContext): NuxtIslandRespons
if (!ssrContext.islandContext || !Object.keys(ssrContext.islandContext.components).length) { return undefined }
const response: NuxtIslandResponse['components'] = {}
for (const [clientUid, component] of Object.entries(ssrContext.islandContext.components)) {
for (const clientUid in ssrContext.islandContext.components) {
// remove teleport anchor to avoid hydration issues
const html = ssrContext.teleports?.[clientUid]?.replaceAll('<!--teleport start anchor-->', '') || ''
response[clientUid] = {
...component,
...ssrContext.islandContext.components[clientUid]!,
html,
slots: getComponentSlotTeleport(clientUid, ssrContext.teleports ?? {}),
}

View File

@ -450,7 +450,8 @@ export default defineNuxtModule({
nuxt.hook('pages:extend', (routes) => {
const nitro = useNitro()
let resolvedRoutes: string[]
for (const [path, rule] of Object.entries(nitro.options.routeRules)) {
for (const path in nitro.options.routeRules) {
const rule = nitro.options.routeRules[path]!
if (!rule.redirect) { continue }
resolvedRoutes ||= routes.flatMap(route => resolveRoutePaths(route))
// skip if there's already a route matching this path
@ -496,7 +497,8 @@ export default defineNuxtModule({
if (nuxt.options.dev) { return }
const sourceFiles = nuxt.apps.default?.pages?.length ? getSources(nuxt.apps.default.pages) : []
for (const [key, chunk] of Object.entries(manifest)) {
for (const key in manifest) {
const chunk = manifest[key]!
if (chunk.src && Object.values(nuxt.apps).some(app => app.pages?.some(page => page.mode === 'server' && page.file === join(nuxt.options.srcDir, chunk.src!)))) {
delete manifest[key]
continue

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

@ -18,7 +18,8 @@ export function analyzePlugin (ctx: ViteBuildContext): Plugin[] {
const bundle = outputBundle[_bundleId]
if (!bundle || bundle.type !== 'chunk') { continue }
const minifiedModuleEntryPromises: Array<Promise<[string, RenderedModule]>> = []
for (const [moduleId, module] of Object.entries(bundle.modules)) {
for (const moduleId in bundle.modules) {
const module = bundle.modules[moduleId]!
minifiedModuleEntryPromises.push(
transform(module.code || '', { minify: true })
.then(result => [moduleId, { ...module, code: result.code }]),

View File

@ -14,7 +14,8 @@ export const createSourcemapPreserver = () => {
outputDir = config.build.outDir
},
async writeBundle (_options, bundle) {
for (const chunk of Object.values(bundle)) {
for (const chunkId in bundle) {
const chunk = bundle[chunkId]!
if (chunk.type !== 'chunk' || !chunk.map) { continue }
const id = resolve(outputDir, chunk.fileName)

View File

@ -87,7 +87,8 @@ export const VitePublicDirsPlugin = createUnplugin((options: VitePublicDirsPlugi
}
},
generateBundle (_outputOptions, bundle) {
for (const [file, chunk] of Object.entries(bundle)) {
for (const file in bundle) {
const chunk = bundle[file]!
if (!file.endsWith('.css') || chunk.type !== 'asset') { continue }
let css = chunk.source.toString()

View File

@ -62,7 +62,8 @@ export function ssrStylesPlugin (options: SSRStylePluginOptions): Plugin {
if (options.mode === 'client') { return }
const emitted: Record<string, string> = {}
for (const [file, { files, inBundle }] of Object.entries(cssMap)) {
for (const file in cssMap) {
const { files, inBundle } = cssMap[file]!
// File has been tree-shaken out of build (or there are no styles to inline)
if (!files.length || !inBundle) { continue }
const fileName = filename(file)

View File

@ -197,7 +197,8 @@ export const bundle: NuxtBuilder['bundle'] = async (nuxt) => {
// Remove CSS entries for files that will have inlined styles
ctx.nuxt.hook('build:manifest', (manifest) => {
for (const [key, entry] of Object.entries(manifest)) {
for (const key in manifest) {
const entry = manifest[key]!
const shouldRemoveCSS = chunksWithInlinedCSS.has(key) && !entry.isEntry
if (entry.isEntry && chunksWithInlinedCSS.has(key)) {
// @ts-expect-error internal key

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

@ -33,7 +33,8 @@ export default class VueSSRClientPlugin {
const stats = compilation.getStats().toJson()
const initialFiles = new Set<string>()
for (const { assets } of Object.values(stats.entrypoints!)) {
for (const assetId in stats.entrypoints!) {
const { assets } = stats.entrypoints[assetId]!
if (!assets) { continue }
for (const asset of assets) {

File diff suppressed because it is too large Load Diff