From 3678a4f5d029154c30111362c57d3226e1101b06 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Tue, 27 Feb 2024 09:09:37 +0000 Subject: [PATCH 001/259] chore(deps): update all non-major dependencies (main) (#25968) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> --- .github/workflows/ci.yml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a6f9d36556..f50805f2cc 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -91,7 +91,7 @@ jobs: queries: +security-and-quality - name: Restore dist cache - uses: actions/download-artifact@eaceaf801fd36c7dee90939fad912460b18a1ffe # v4.1.2 + uses: actions/download-artifact@87c55149d96e628cc2ef7e6fc2aab372015aec85 # v4.1.3 with: name: dist path: packages @@ -124,7 +124,7 @@ jobs: run: pnpm install - name: Restore dist cache - uses: actions/download-artifact@eaceaf801fd36c7dee90939fad912460b18a1ffe # v4.1.2 + uses: actions/download-artifact@87c55149d96e628cc2ef7e6fc2aab372015aec85 # v4.1.3 with: name: dist path: packages @@ -247,7 +247,7 @@ jobs: run: pnpm playwright-core install chromium - name: Restore dist cache - uses: actions/download-artifact@eaceaf801fd36c7dee90939fad912460b18a1ffe # v4.1.2 + uses: actions/download-artifact@87c55149d96e628cc2ef7e6fc2aab372015aec85 # v4.1.3 with: name: dist path: packages @@ -261,7 +261,7 @@ jobs: TEST_CONTEXT: ${{ matrix.context }} SKIP_BUNDLE_SIZE: ${{ github.event_name != 'push' || matrix.env == 'dev' || matrix.builder == 'webpack' || matrix.context == 'default' || runner.os == 'Windows' }} - - uses: codecov/codecov-action@0cfda1dd0a4ad9efc75517f399d859cd1ea4ced1 # v4.0.2 + - uses: codecov/codecov-action@54bcd8715eee62d40e33596ef5e8f0f48dbbccab # v4.1.0 if: github.event_name != 'push' && matrix.env == 'built' && matrix.builder == 'vite' && matrix.context == 'default' && matrix.os == 'ubuntu-latest' && matrix.manifest == 'manifest-on' with: token: ${{ secrets.CODECOV_TOKEN }} @@ -296,7 +296,7 @@ jobs: run: pnpm install - name: Restore dist cache - uses: actions/download-artifact@eaceaf801fd36c7dee90939fad912460b18a1ffe # v4.1.2 + uses: actions/download-artifact@87c55149d96e628cc2ef7e6fc2aab372015aec85 # v4.1.3 with: name: dist path: packages @@ -335,7 +335,7 @@ jobs: run: pnpm install - name: Restore dist cache - uses: actions/download-artifact@eaceaf801fd36c7dee90939fad912460b18a1ffe # v4.1.2 + uses: actions/download-artifact@87c55149d96e628cc2ef7e6fc2aab372015aec85 # v4.1.3 with: name: dist path: packages From 40c3a3918e5aab7a9c53161d6a898a18f537a770 Mon Sep 17 00:00:00 2001 From: Mehmet Date: Tue, 27 Feb 2024 12:11:27 +0300 Subject: [PATCH 002/259] fix(nuxt): don't try to strip directory file extensions (#25965) --- packages/nuxt/src/imports/module.ts | 13 ++++++++----- packages/nuxt/src/utils.ts | 6 ++++++ 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/packages/nuxt/src/imports/module.ts b/packages/nuxt/src/imports/module.ts index 175d8627b8..01ccd89488 100644 --- a/packages/nuxt/src/imports/module.ts +++ b/packages/nuxt/src/imports/module.ts @@ -1,3 +1,4 @@ +import { existsSync } from 'node:fs' import { addTemplate, addVitePlugin, addWebpackPlugin, defineNuxtModule, isIgnored, logger, resolveAlias, tryResolveModule, updateTemplates, useNuxt } from '@nuxt/kit' import { isAbsolute, join, normalize, relative, resolve } from 'pathe' import type { Import, Unimport } from 'unimport' @@ -5,6 +6,7 @@ import { createUnimport, scanDirExports } from 'unimport' import type { ImportPresetWithDeprecation, ImportsOptions } from 'nuxt/schema' import { lookupNodeModuleSubpath, parseNodeModulePath } from 'mlly' +import { isDirectory } from '../utils' import { TransformPlugin } from './transform' import { defaultPresets } from './presets' @@ -140,13 +142,10 @@ export default defineNuxtModule>({ function addDeclarationTemplates (ctx: Unimport, options: Partial) { const nuxt = useNuxt() - // Remove file extension for benefit of TypeScript - const stripExtension = (path: string) => path.replace(/\.[a-z]+$/, '') - const resolvedImportPathMap = new Map() const r = ({ from }: Import) => resolvedImportPathMap.get(from) - async function cacheImportPaths(imports: Import[]) { + async function cacheImportPaths (imports: Import[]) { const importSource = Array.from(new Set(imports.map(i => i.from))) await Promise.all(importSource.map(async (from) => { if (resolvedImportPathMap.has(from)) { @@ -163,11 +162,15 @@ function addDeclarationTemplates (ctx: Unimport, options: Partial (value: T | T[]): T[] { return Array.isArray(value) ? value : [value] } + +export async function isDirectory (path: string) { + return (await fsp.lstat(path)).isDirectory() +} From 05919660800e4225a919eb97a602e69d80085b25 Mon Sep 17 00:00:00 2001 From: Till Sanders Date: Tue, 27 Feb 2024 10:12:44 +0100 Subject: [PATCH 003/259] docs: add `domEnvironment` option to testing example (#25972) --- docs/1.getting-started/11.testing.md | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/1.getting-started/11.testing.md b/docs/1.getting-started/11.testing.md index 2051ded616..dba218d7dd 100644 --- a/docs/1.getting-started/11.testing.md +++ b/docs/1.getting-started/11.testing.md @@ -88,6 +88,7 @@ export default defineVitestConfig({ // environmentOptions: { // nuxt: { // rootDir: fileURLToPath(new URL('./playground', import.meta.url)), + // domEnvironment: 'happy-dom', // 'happy-dom' (default) or 'jsdom' // overrides: { // // other Nuxt config you want to pass // } From 15a4a080acb441a5978c7d08f683c27f46f09c06 Mon Sep 17 00:00:00 2001 From: Alexander Lichter Date: Tue, 27 Feb 2024 11:57:26 +0100 Subject: [PATCH 004/259] fix(nuxt): produce valid css selector from `useId` (#25969) --- packages/nuxt/src/app/composables/id.ts | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/packages/nuxt/src/app/composables/id.ts b/packages/nuxt/src/app/composables/id.ts index 728ebcf238..c5019b0c2b 100644 --- a/packages/nuxt/src/app/composables/id.ts +++ b/packages/nuxt/src/app/composables/id.ts @@ -3,6 +3,7 @@ import { useNuxtApp } from '../nuxt' import { clientOnlySymbol } from '#app/components/client-only' const ATTR_KEY = 'data-n-ids' +const SEPARATOR = '-' /** * Generate an SSR-friendly unique identifier that can be passed to accessibility attributes. @@ -13,7 +14,8 @@ export function useId (key?: string): string { throw new TypeError('[nuxt] [useId] key must be a string.') } // TODO: implement in composable-keys - key = key.slice(1) + // Make sure key starts with a letter to be a valid selector + key = `n${key.slice(1)}` const nuxtApp = useNuxtApp() const instance = getCurrentInstance() @@ -26,11 +28,11 @@ export function useId (key?: string): string { instance._nuxtIdIndex ||= {} instance._nuxtIdIndex[key] ||= 0 - const instanceIndex = key + ':' + instance._nuxtIdIndex[key]++ + const instanceIndex = key + SEPARATOR + instance._nuxtIdIndex[key]++ if (import.meta.server) { const ids = JSON.parse(instance.attrs[ATTR_KEY] as string | undefined || '{}') - ids[instanceIndex] = key + ':' + nuxtApp._id++ + ids[instanceIndex] = key + SEPARATOR + nuxtApp._id++ instance.attrs[ATTR_KEY] = JSON.stringify(ids) return ids[instanceIndex] } From 3258cacc2893487f87e9ca42adce6e1bb1f13199 Mon Sep 17 00:00:00 2001 From: Andrea Basile <57828270+Evobaso-J@users.noreply.github.com> Date: Tue, 27 Feb 2024 16:31:46 +0100 Subject: [PATCH 005/259] fix(schema): add `vueCompilerOptions` property to `tsConfig` (#25924) --- packages/schema/build.config.ts | 1 + packages/schema/package.json | 1 + packages/schema/src/config/typescript.ts | 2 +- packages/schema/src/types/hooks.ts | 7 ++++++- pnpm-lock.yaml | 3 +++ 5 files changed, 12 insertions(+), 2 deletions(-) diff --git a/packages/schema/build.config.ts b/packages/schema/build.config.ts index 04a306a6c4..49c2520e6f 100644 --- a/packages/schema/build.config.ts +++ b/packages/schema/build.config.ts @@ -53,6 +53,7 @@ export default defineBuildConfig({ 'sass-loader', 'c12', 'unenv', + '@vue/language-core', // Implicit '@vue/compiler-core', '@vue/shared', diff --git a/packages/schema/package.json b/packages/schema/package.json index af8b508f11..119738a0a8 100644 --- a/packages/schema/package.json +++ b/packages/schema/package.json @@ -42,6 +42,7 @@ "@vitejs/plugin-vue": "5.0.4", "@vitejs/plugin-vue-jsx": "3.1.0", "@vue/compiler-core": "3.4.20", + "@vue/language-core": "^1.8.27", "c12": "1.9.0", "esbuild-loader": "4.0.3", "h3": "1.11.1", diff --git a/packages/schema/src/config/typescript.ts b/packages/schema/src/config/typescript.ts index e2ae05df6f..69e13d5094 100644 --- a/packages/schema/src/config/typescript.ts +++ b/packages/schema/src/config/typescript.ts @@ -43,7 +43,7 @@ export default defineUntypedSchema({ /** * You can extend generated `.nuxt/tsconfig.json` using this option. - * @type {typeof import('pkg-types')['TSConfig']} + * @type {0 extends 1 & VueCompilerOptions ? typeof import('pkg-types')['TSConfig'] : typeof import('pkg-types')['TSConfig'] & { vueCompilerOptions?: typeof import('@vue/language-core')['VueCompilerOptions']}} */ tsConfig: {}, diff --git a/packages/schema/src/types/hooks.ts b/packages/schema/src/types/hooks.ts index 72d74aab67..51e06f82d9 100644 --- a/packages/schema/src/types/hooks.ts +++ b/packages/schema/src/types/hooks.ts @@ -9,6 +9,7 @@ import type { Compiler, Configuration, Stats } from 'webpack' import type { Nitro, NitroConfig } from 'nitropack' import type { Schema, SchemaDefinition } from 'untyped' import type { RouteLocationRaw } from 'vue-router' +import type { VueCompilerOptions } from '@vue/language-core' import type { NuxtCompatibility, NuxtCompatibilityIssues, ViteConfig } from '..' import type { Component, ComponentsOptions } from './components' import type { Nuxt, NuxtApp, ResolvedNuxtTemplate } from './nuxt' @@ -20,6 +21,10 @@ export type TSReference = { types: string } | { path: string } export type WatchEvent = 'add' | 'addDir' | 'change' | 'unlink' | 'unlinkDir' +// If the user does not have `@vue/language-core` installed, VueCompilerOptions will be typed as `any`, +// thus making the whole `VueTSConfig` type `any`. We only augment TSConfig if VueCompilerOptions is available. +export type VueTSConfig = 0 extends 1 & VueCompilerOptions ? TSConfig : TSConfig & { vueCompilerOptions?: VueCompilerOptions } + export type NuxtPage = { name?: string path: string @@ -282,7 +287,7 @@ export interface NuxtHooks { * @param options Objects containing `references`, `declarations`, `tsConfig` * @returns Promise */ - 'prepare:types': (options: { references: TSReference[], declarations: string[], tsConfig: TSConfig }) => HookResult + 'prepare:types': (options: { references: TSReference[], declarations: string[], tsConfig: VueTSConfig }) => HookResult /** * Called when the dev server is loading. * @param listenerServer The HTTP/HTTPS server object diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index f95d103caf..4db50b5fb6 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -493,6 +493,9 @@ importers: '@vue/compiler-core': specifier: 3.4.20 version: 3.4.20 + '@vue/language-core': + specifier: ^1.8.27 + version: 1.8.27(typescript@5.3.3) c12: specifier: 1.9.0 version: 1.9.0 From fa79b86d4ab286c3c43735b5d589006e95d9182f Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Tue, 27 Feb 2024 20:06:52 +0100 Subject: [PATCH 006/259] chore(deps): pin devdependency @vue/language-core to 1.8.27 (main) (#25980) --- packages/schema/package.json | 2 +- pnpm-lock.yaml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/schema/package.json b/packages/schema/package.json index 119738a0a8..2f17516291 100644 --- a/packages/schema/package.json +++ b/packages/schema/package.json @@ -42,7 +42,7 @@ "@vitejs/plugin-vue": "5.0.4", "@vitejs/plugin-vue-jsx": "3.1.0", "@vue/compiler-core": "3.4.20", - "@vue/language-core": "^1.8.27", + "@vue/language-core": "1.8.27", "c12": "1.9.0", "esbuild-loader": "4.0.3", "h3": "1.11.1", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 4db50b5fb6..56694791c1 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -494,7 +494,7 @@ importers: specifier: 3.4.20 version: 3.4.20 '@vue/language-core': - specifier: ^1.8.27 + specifier: 1.8.27 version: 1.8.27(typescript@5.3.3) c12: specifier: 1.9.0 From 96f72f923d0a01ee201cece758a17f061bda7413 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Sat, 2 Mar 2024 10:23:33 +0100 Subject: [PATCH 007/259] chore(deps): update devdependency vue-tsc to v2 (main) (#26039) --- package.json | 2 +- pnpm-lock.yaml | 58 +++++++++++++++++++++++++++++++++++++++----------- 2 files changed, 47 insertions(+), 13 deletions(-) diff --git a/package.json b/package.json index 4c65f35a5b..faeaca21e6 100644 --- a/package.json +++ b/package.json @@ -88,7 +88,7 @@ "vue": "3.4.20", "vue-eslint-parser": "9.4.2", "vue-router": "4.3.0", - "vue-tsc": "1.8.27" + "vue-tsc": "2.0.1" }, "packageManager": "pnpm@8.15.4", "engines": { diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 56694791c1..89580c2e39 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -152,8 +152,8 @@ importers: specifier: 4.3.0 version: 4.3.0(vue@3.4.20) vue-tsc: - specifier: 1.8.27 - version: 1.8.27(typescript@5.3.3) + specifier: 2.0.1 + version: 2.0.1(typescript@5.3.3) packages/kit: dependencies: @@ -645,7 +645,7 @@ importers: version: 1.3.1(@types/node@20.11.20) vite-plugin-checker: specifier: ^0.6.4 - version: 0.6.4(eslint@8.57.0)(typescript@5.3.3)(vite@5.1.4)(vue-tsc@1.8.27) + version: 0.6.4(eslint@8.57.0)(typescript@5.3.3)(vite@5.1.4)(vue-tsc@2.0.1) vue-bundle-renderer: specifier: ^2.0.0 version: 2.0.0 @@ -3473,16 +3473,28 @@ packages: resolution: {integrity: sha512-dOcNn3i9GgZAcJt43wuaEykSluAuOkQgzni1cuxLxTV0nJKanQztp7FxyswdRILaKH+P2XZMPRp2S4MV/pElCw==} dependencies: '@volar/source-map': 1.11.1 + dev: true + + /@volar/language-core@2.1.0: + resolution: {integrity: sha512-BrYEgYHx92ocpt1OUxJs2x3TAXEjpPLxsQoARb96g2GdF62xnfRQUqCNBwiU7Z3MQ/0tOAdqdHNYNmrFtx6q4A==} + dependencies: + '@volar/source-map': 2.1.0 /@volar/source-map@1.11.1: resolution: {integrity: sha512-hJnOnwZ4+WT5iupLRnuzbULZ42L7BWWPMmruzwtLhJfpDVoZLjNBxHDi2sY2bgZXCKlpU5XcsMFoYrsQmPhfZg==} dependencies: muggle-string: 0.3.1 + dev: true - /@volar/typescript@1.11.1: - resolution: {integrity: sha512-iU+t2mas/4lYierSnoFOeRFQUhAEMgsFuQxoxvwn5EdQopw43j+J27a4lt9LMInx1gLJBC6qL14WYGlgymaSMQ==} + /@volar/source-map@2.1.0: + resolution: {integrity: sha512-VPyi+DTv67cvUOkUewzsOQJY3VUhjOjQxigT487z/H7tEI8ZFd5RksC5afk3JelOK+a/3Y8LRDbKmYKu1dz87g==} dependencies: - '@volar/language-core': 1.11.1 + muggle-string: 0.4.1 + + /@volar/typescript@2.1.0: + resolution: {integrity: sha512-2cicVoW4q6eU/omqfOBv+6r9JdrF5bBelujbJhayPNKiOj/xwotSJ/DM8IeMvTZvtkOZkm6suyOCLEokLY0w2w==} + dependencies: + '@volar/language-core': 2.1.0 path-browserify: 1.0.1 /@vue-macros/common@1.10.1(rollup@4.12.0)(vue@3.4.20): @@ -3581,6 +3593,24 @@ packages: path-browserify: 1.0.1 typescript: 5.3.3 vue-template-compiler: 2.7.14 + dev: true + + /@vue/language-core@2.0.1(typescript@5.3.3): + resolution: {integrity: sha512-TZ9xKj3WhZol2hWvXcCjGDiOVkmQ1aG7MS3YJkhVMeoLYyopP5XFn9Obc9qorxG6vZDWapRxBkyEzJ9d6xL3Zg==} + peerDependencies: + typescript: '*' + peerDependenciesMeta: + typescript: + optional: true + dependencies: + '@volar/language-core': 2.1.0 + '@vue/compiler-dom': 3.4.20 + '@vue/shared': 3.4.20 + computeds: 0.0.1 + minimatch: 9.0.3 + path-browserify: 1.0.1 + typescript: 5.3.3 + vue-template-compiler: 2.7.14 /@vue/reactivity@3.4.20: resolution: {integrity: sha512-P5LJcxUkG6inlHr6MHVA4AVFAmRYJQ7ONGWJILNjMjoYuEXFhYviSCb9BEMyszSG/1kWCZbtWQlKSLasFRpThw==} @@ -7960,6 +7990,10 @@ packages: /muggle-string@0.3.1: resolution: {integrity: sha512-ckmWDJjphvd/FvZawgygcUeQCxzvohjFO5RxTjj4eq8kw359gFF3E1brjfI+viLMxss5JrHTDRHZvu2/tuy0Qg==} + dev: true + + /muggle-string@0.4.1: + resolution: {integrity: sha512-VNTrAak/KhO2i8dqqnqnAHOa3cYBwXEZe9h+D5h/1ZqFSTEFHdM65lR7RoIqq3tBBYavsOXV84NoHXZ0AkPyqQ==} /nanoid@3.3.7: resolution: {integrity: sha512-eSRppjcPIatRIMC1U6UngP8XFcz8MQWGQdt1MTBQ7NaAmvXDfvNxbvWV3x2y6CdEUciCSsDHDQZbhYaB8QEo2g==} @@ -10911,7 +10945,7 @@ packages: - supports-color - terser - /vite-plugin-checker@0.6.4(eslint@8.57.0)(typescript@5.3.3)(vite@5.1.4)(vue-tsc@1.8.27): + /vite-plugin-checker@0.6.4(eslint@8.57.0)(typescript@5.3.3)(vite@5.1.4)(vue-tsc@2.0.1): resolution: {integrity: sha512-2zKHH5oxr+ye43nReRbC2fny1nyARwhxdm0uNYp/ERy4YvU9iZpNOsueoi/luXw5gnpqRSvjcEPxXbS153O2wA==} engines: {node: '>=14.16'} peerDependencies: @@ -10960,7 +10994,7 @@ packages: vscode-languageserver: 7.0.0 vscode-languageserver-textdocument: 1.0.11 vscode-uri: 3.0.8 - vue-tsc: 1.8.27(typescript@5.3.3) + vue-tsc: 2.0.1(typescript@5.3.3) dev: false /vite-plugin-inspect@0.8.1(@nuxt/kit@packages+kit)(rollup@4.12.0)(vite@5.1.4): @@ -11293,14 +11327,14 @@ packages: de-indent: 1.0.2 he: 1.2.0 - /vue-tsc@1.8.27(typescript@5.3.3): - resolution: {integrity: sha512-WesKCAZCRAbmmhuGl3+VrdWItEvfoFIPXOvUJkjULi+x+6G/Dy69yO3TBRJDr9eUlmsNAwVmxsNZxvHKzbkKdg==} + /vue-tsc@2.0.1(typescript@5.3.3): + resolution: {integrity: sha512-a4Il11tE8khq8tZn0DucITCr3+q2B9cxL6uTQAoprnhBrxBu6vc//hp3zyTnIS1t/zCTCfdipkY7M2dqiR2plQ==} hasBin: true peerDependencies: typescript: '*' dependencies: - '@volar/typescript': 1.11.1 - '@vue/language-core': 1.8.27(typescript@5.3.3) + '@volar/typescript': 2.1.0 + '@vue/language-core': 2.0.1(typescript@5.3.3) semver: 7.6.0 typescript: 5.3.3 From ea343ecc04f116effa082959259be5e273042fb4 Mon Sep 17 00:00:00 2001 From: gangan <44604921+shinGangan@users.noreply.github.com> Date: Sat, 2 Mar 2024 18:24:38 +0900 Subject: [PATCH 008/259] docs: update VS Code settings (#25985) --- docs/5.community/4.contribution.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/5.community/4.contribution.md b/docs/5.community/4.contribution.md index 764730c668..3702d845a8 100644 --- a/docs/5.community/4.contribution.md +++ b/docs/5.community/4.contribution.md @@ -146,8 +146,8 @@ We recommend using [VS Code](https://code.visualstudio.com) along with the [ESLi ```json [settings.json] { "editor.codeActionsOnSave": { - "source.fixAll": false, - "source.fixAll.eslint": true + "source.fixAll": "never", + "source.fixAll.eslint": "explicit" } } ``` From e890c9a64ba14d9622a58254fef0f20623df44d9 Mon Sep 17 00:00:00 2001 From: Julien Huang Date: Sat, 2 Mar 2024 10:24:56 +0100 Subject: [PATCH 009/259] docs: mention island features are SFC only (#26013) --- docs/2.guide/2.directory-structure/1.components.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/docs/2.guide/2.directory-structure/1.components.md b/docs/2.guide/2.directory-structure/1.components.md index 929d2b6a42..655cb98bd9 100644 --- a/docs/2.guide/2.directory-structure/1.components.md +++ b/docs/2.guide/2.directory-structure/1.components.md @@ -295,6 +295,10 @@ Now you can register server-only components with the `.server` suffix and use th Server-only components use [``](/docs/api/components/nuxt-island) under the hood, meaning that `lazy` prop and `#fallback` slot are both passed down to it. +::alert{type=warning} +Most features for server-only components and island components, such as slots and client components, are only available for single file components. +:: + #### Client components within server components ::alert{type=info} From 2d3f495a7f3f58da91f3026c6430392072f9d834 Mon Sep 17 00:00:00 2001 From: Francesco Scutellaro Date: Sat, 2 Mar 2024 14:08:42 +0100 Subject: [PATCH 010/259] docs: improve pick and transform doc (#26043) --- packages/nuxt/src/app/composables/asyncData.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/packages/nuxt/src/app/composables/asyncData.ts b/packages/nuxt/src/app/composables/asyncData.ts index b97bcd00ab..79a7813ba9 100644 --- a/packages/nuxt/src/app/composables/asyncData.ts +++ b/packages/nuxt/src/app/composables/asyncData.ts @@ -63,11 +63,13 @@ export interface AsyncDataOptions< */ getCachedData?: (key: string) => DataT /** - * A function that can be used to alter handler function result after resolving + * A function that can be used to alter handler function result after resolving. + * Do not use it along with the `pick` option. */ transform?: _Transform /** - * Only pick specified keys in this array from the handler function result + * Only pick specified keys in this array from the handler function result. + * Do not use it along with the `transform` option. */ pick?: PickKeys /** From 8e6d2306c0ca7ca9c8dc915f46172b08f39c53bb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Chopin?= Date: Sun, 3 Mar 2024 14:33:43 +0100 Subject: [PATCH 011/259] docs: fix 404 link --- docs/3.api/2.composables/use-id.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/3.api/2.composables/use-id.md b/docs/3.api/2.composables/use-id.md index 9cd649696b..63a470a5db 100644 --- a/docs/3.api/2.composables/use-id.md +++ b/docs/3.api/2.composables/use-id.md @@ -4,7 +4,7 @@ description: Generate an SSR-friendly unique identifier that can be passed to ac --- ::important -This composable is available since [Nuxt v3.10](/v3-10#ssr-safe-accessible-unique-id-creation). +This composable is available since [Nuxt v3.10](/blog/v3-10#ssr-safe-accessible-unique-id-creation). :: `useId` generates an SSR-friendly unique identifier that can be passed to accessibility attributes. From 4fbbc10f62aae02beb0c59e946c5fd18cd0d63f3 Mon Sep 17 00:00:00 2001 From: Daniel Roe Date: Sun, 3 Mar 2024 21:36:12 +0000 Subject: [PATCH 012/259] fix(nuxt): skip vue style blocks in unctx transform (#26059) --- packages/nuxt/src/core/plugins/unctx.ts | 2 +- test/fixtures/basic/pages/styles.vue | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/nuxt/src/core/plugins/unctx.ts b/packages/nuxt/src/core/plugins/unctx.ts index 1e458eda49..c6ef9eb054 100644 --- a/packages/nuxt/src/core/plugins/unctx.ts +++ b/packages/nuxt/src/core/plugins/unctx.ts @@ -17,7 +17,7 @@ export const UnctxTransformPlugin = createUnplugin((options: UnctxTransformPlugi name: 'unctx:transform', enforce: 'post', transformInclude (id) { - return isVue(id) || isJS(id) + return isVue(id, { type: ['template', 'script']}) || isJS(id) }, transform (code) { // TODO: needed for webpack - update transform in unctx/unplugin? diff --git a/test/fixtures/basic/pages/styles.vue b/test/fixtures/basic/pages/styles.vue index 2aadb5da0e..a8f5f2fa02 100644 --- a/test/fixtures/basic/pages/styles.vue +++ b/test/fixtures/basic/pages/styles.vue @@ -18,6 +18,8 @@ import '~/assets/assets.css' ``` -## Documentation +## 📖 Documentation We highly recommend you take a look at the [Nuxt documentation](https://nuxt.com/docs) to level up. It’s a great resource for learning more about the framework. It covers everything from getting started to advanced topics. -## Modules +## 🧩 Modules Discover our [list of modules](https://nuxt.com/modules) to supercharge your Nuxt project, created by the Nuxt team and community. -## Contribute +## ❤️ Contribute We invite you to contribute and help improve Nuxt 💚 @@ -79,21 +96,20 @@ Here are a few ways you can get involved: - **Suggestions:** Have ideas to enhance Nuxt? We'd love to hear them! Check out the [contribution guide](https://nuxt.com/docs/community/contribution#creating-an-issue) to share your suggestions. - **Questions:** If you have questions or need assistance, the [getting help guide](https://nuxt.com/docs/community/getting-help) provides resources to help you out. -## Local Development +## 🏠 Local Development Follow the docs to [Set Up Your Local Development Environment](https://nuxt.com/docs/community/framework-contribution#setup) to contribute to the framework and documentation. -## Nuxt 2 +## ⛰️ Nuxt 2 You can find the code for Nuxt 2 on the [`2.x` branch](https://github.com/nuxt/nuxt/tree/2.x) and the documentation at [v2.nuxt.com](https://v2.nuxt.com). -## Follow us +## 🔗 Follow us

Discord  Twitter  GitHub

-## License +## ⚖️ License [MIT](./LICENSE) - From e9082ad28e484dc3f7b98f907b4090deee5a4337 Mon Sep 17 00:00:00 2001 From: Daniel Roe Date: Thu, 7 Mar 2024 01:17:40 +0000 Subject: [PATCH 051/259] fix(nuxt): handle external redirects from `routeRules` (#26120) --- packages/nuxt/src/app/middleware/manifest-route-rule.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/packages/nuxt/src/app/middleware/manifest-route-rule.ts b/packages/nuxt/src/app/middleware/manifest-route-rule.ts index 30f51c993b..ef3d2e1d37 100644 --- a/packages/nuxt/src/app/middleware/manifest-route-rule.ts +++ b/packages/nuxt/src/app/middleware/manifest-route-rule.ts @@ -1,3 +1,4 @@ +import { hasProtocol } from 'ufo' import { defineNuxtRouteMiddleware } from '../composables/router' import { getRouteRules } from '../composables/manifest' @@ -5,6 +6,10 @@ export default defineNuxtRouteMiddleware(async (to) => { if (import.meta.server || import.meta.test) { return } const rules = await getRouteRules(to.path) if (rules.redirect) { + if (hasProtocol(rules.redirect, { acceptRelative: true })) { + window.location.href = rules.redirect + return false + } return rules.redirect } }) From 8f7724133f8f8d723ba16cde08e1efb0dfc619e5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Damian=20G=C5=82owala?= Date: Fri, 8 Mar 2024 08:19:46 +0100 Subject: [PATCH 052/259] chore: update .npmrc (#26135) --- .npmrc | 1 - 1 file changed, 1 deletion(-) diff --git a/.npmrc b/.npmrc index e2ad808f8d..8fb0b90fee 100644 --- a/.npmrc +++ b/.npmrc @@ -1,3 +1,2 @@ shamefully-hoist=true -strict-peer-dependencies=false shell-emulator=true From a9af9e02887d97fd262e4861c7781e7780bb66f5 Mon Sep 17 00:00:00 2001 From: Ryota Watanabe <43837308+wattanx@users.noreply.github.com> Date: Fri, 8 Mar 2024 16:21:56 +0900 Subject: [PATCH 053/259] docs: added bridge `macros.pageMeta` and `typescript.esbuild` option (#26136) --- docs/6.bridge/10.configuration.md | 10 ++++++++++ docs/6.bridge/4.plugins-and-middleware.md | 19 ++++++++++++++++++- 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/docs/6.bridge/10.configuration.md b/docs/6.bridge/10.configuration.md index 1adf1fc48d..da0fd85432 100644 --- a/docs/6.bridge/10.configuration.md +++ b/docs/6.bridge/10.configuration.md @@ -22,6 +22,16 @@ export default defineNuxtConfig({ // Enable Nuxt 3 compatible useHead // meta: true, + // Enable definePageMeta macro + // macros: { + // pageMeta: true + // }, + + // Enable transpiling TypeScript with esbuild + // typescript: { + // esbuild: true + // }, + // -- Default features -- // Use legacy server instead of Nitro diff --git a/docs/6.bridge/4.plugins-and-middleware.md b/docs/6.bridge/4.plugins-and-middleware.md index c379b3f801..2250b8bad5 100644 --- a/docs/6.bridge/4.plugins-and-middleware.md +++ b/docs/6.bridge/4.plugins-and-middleware.md @@ -42,7 +42,24 @@ export default defineNuxtRouteMiddleware((to) => { Use of `defineNuxtRouteMiddleware` is not supported outside of the middleware directory. :: -::note +## definePageMeta + You can also use [`definePageMeta`](https://nuxt.com/docs/api/utils/define-page-meta) in Nuxt Bridge. + +You can be enabled with the `macros.pageMeta` option in your configuration file + +```ts [nuxt.config.ts] +import { defineNuxtConfig } from '@nuxt/bridge' + +export default defineNuxtConfig({ + bridge: { + macros: { + pageMeta: true + } + } +}) +``` + +::note But only for `middleware` and `layout`. :: From cd3cf0b41a1a18b5b96791e25f53a6c385a90e9b Mon Sep 17 00:00:00 2001 From: k-karen <40630915+k-karen@users.noreply.github.com> Date: Fri, 8 Mar 2024 16:24:24 +0900 Subject: [PATCH 054/259] docs: fix bracket escape on `definePageMeta` page (#26139) --- docs/3.api/3.utils/define-page-meta.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/3.api/3.utils/define-page-meta.md b/docs/3.api/3.utils/define-page-meta.md index 074229ae36..c70da355a3 100644 --- a/docs/3.api/3.utils/define-page-meta.md +++ b/docs/3.api/3.utils/define-page-meta.md @@ -200,7 +200,7 @@ The two routes "/test-category" and "/1234-post" match both `[postId]-[postSlug] To make sure that we are only matching digits (`\d+`) for `postId` in the `[postId]-[postSlug]` route, we can add the following to the `[postId]-[postSlug].vue` page template: -```vue [pages/[postId]-[postSlug].vue] +```vue [pages/[postId\\]-[postSlug\\].vue] ` - , 'hello.server.vue') + , 'hello.server.vue') expect(normalizeLineEndings(result)).toMatchInlineSnapshot(` "