diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile index 8a3d0b82ac..3c387296d5 100644 --- a/.devcontainer/Dockerfile +++ b/.devcontainer/Dockerfile @@ -1,4 +1,4 @@ -FROM node:lts@sha256:0e910f435308c36ea60b4cfd7b80208044d77a074d16b768a81901ce938a62dc +FROM node:lts@sha256:99981c3d1aac0d98cd9f03f74b92dddf30f30ffb0b34e6df8bd96283f62f12c6 RUN apt-get update && \ apt-get install -fy libnss3 libnspr4 libatk1.0-0 libatk-bridge2.0-0 libcups2 libdbus-1-3 libdrm2 libxkbcommon0 libatspi2.0-0 libxcomposite1 libxdamage1 libxfixes3 libxrandr2 libgbm1 libasound2 && \ diff --git a/.github/workflows/autofix-docs.yml b/.github/workflows/autofix-docs.yml index 221468868a..90d2c5900c 100644 --- a/.github/workflows/autofix-docs.yml +++ b/.github/workflows/autofix-docs.yml @@ -21,7 +21,7 @@ jobs: - run: corepack enable - uses: actions/setup-node@39370e3970a6d050c480ffad4ff0ed4d3fdee5af # v4.1.0 with: - node-version: 22 + node-version: lts/* cache: "pnpm" - name: Install dependencies @@ -33,4 +33,4 @@ jobs: - name: Lint (docs) run: pnpm lint:docs:fix - - uses: autofix-ci/action@ff86a557419858bb967097bfc916833f5647fa8c + - uses: autofix-ci/action@551dded8c6cc8a1054039c8bc0b8b48c51dfc6ef diff --git a/.github/workflows/autofix.yml b/.github/workflows/autofix.yml index ef7cffdf16..2deae847ee 100644 --- a/.github/workflows/autofix.yml +++ b/.github/workflows/autofix.yml @@ -17,14 +17,14 @@ jobs: - run: corepack enable - uses: actions/setup-node@39370e3970a6d050c480ffad4ff0ed4d3fdee5af # v4.1.0 with: - node-version: 22 + node-version: lts/* cache: "pnpm" - name: Install dependencies run: pnpm install - name: Check engine ranges, peer dependency ranges and installed versions - run: pnpm installed-check -d --fix + run: pnpm installed-check --no-include-workspace-root --ignore-dev --workspace-ignore='test/**,playground' --fix - name: Build (stub) run: pnpm dev:prepare @@ -55,4 +55,4 @@ jobs: - name: Lint (code) run: pnpm lint:fix - - uses: autofix-ci/action@ff86a557419858bb967097bfc916833f5647fa8c + - uses: autofix-ci/action@551dded8c6cc8a1054039c8bc0b8b48c51dfc6ef diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml index 3fe89901fd..9ca68fbbb3 100644 --- a/.github/workflows/benchmark.yml +++ b/.github/workflows/benchmark.yml @@ -33,7 +33,7 @@ jobs: - run: corepack enable - uses: actions/setup-node@39370e3970a6d050c480ffad4ff0ed4d3fdee5af # v4.1.0 with: - node-version: 22 + node-version: lts/* cache: "pnpm" - name: Install dependencies diff --git a/.github/workflows/changelog.yml b/.github/workflows/changelog.yml index 23f47acac0..9440a6b164 100644 --- a/.github/workflows/changelog.yml +++ b/.github/workflows/changelog.yml @@ -28,7 +28,7 @@ jobs: - run: corepack enable - uses: actions/setup-node@39370e3970a6d050c480ffad4ff0ed4d3fdee5af # v4.1.0 with: - node-version: 22 + node-version: lts/* cache: "pnpm" - name: Install dependencies diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 6fc0803c60..c31ad28b4e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -41,7 +41,7 @@ jobs: - run: corepack enable - uses: actions/setup-node@39370e3970a6d050c480ffad4ff0ed4d3fdee5af # v4.1.0 with: - node-version: 20 + node-version: lts/* cache: "pnpm" - name: Install dependencies @@ -56,11 +56,8 @@ jobs: - name: Build run: pnpm build - - name: Check types - run: pnpm test:attw - - name: Cache dist - uses: actions/upload-artifact@6f51ac03b9356f520e9adb1b1b7802705f340c2b # v4.5.0 + uses: actions/upload-artifact@65c4c4a1ddee5b72f698fdd19549f0f0fb45cf08 # v4.6.0 with: retention-days: 3 name: dist @@ -81,7 +78,7 @@ jobs: - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 - name: Initialize CodeQL - uses: github/codeql-action/init@48ab28a6f5dbc2a99bf1e0131198dd8f1df78169 # v3.28.0 + uses: github/codeql-action/init@b6a472f63d85b9c78a3ac5e89422239fc15e9b3c # v3.28.1 with: config: | paths: @@ -98,7 +95,7 @@ jobs: languages: ${{ matrix.language }} - name: Perform CodeQL Analysis - uses: github/codeql-action/analyze@48ab28a6f5dbc2a99bf1e0131198dd8f1df78169 # v3.28.0 + uses: github/codeql-action/analyze@b6a472f63d85b9c78a3ac5e89422239fc15e9b3c # v3.28.1 with: category: "/language:${{ matrix.language }}" @@ -118,7 +115,7 @@ jobs: - run: corepack enable - uses: actions/setup-node@39370e3970a6d050c480ffad4ff0ed4d3fdee5af # v4.1.0 with: - node-version: 22 + node-version: lts/* cache: "pnpm" - name: Install dependencies @@ -149,7 +146,7 @@ jobs: - run: corepack enable - uses: actions/setup-node@39370e3970a6d050c480ffad4ff0ed4d3fdee5af # v4.1.0 with: - node-version: 22 + node-version: lts/* cache: "pnpm" - name: Install dependencies @@ -161,6 +158,9 @@ jobs: - name: Lint run: pnpm lint + - name: Check built types + run: pnpm test:attw + test-unit: # autofix workflow will be triggered instead for PRs if: github.event_name == 'push' @@ -173,7 +173,7 @@ jobs: - run: corepack enable - uses: actions/setup-node@39370e3970a6d050c480ffad4ff0ed4d3fdee5af # v4.1.0 with: - node-version: 22 + node-version: lts/* cache: "pnpm" - name: Install dependencies @@ -260,20 +260,18 @@ jobs: with: token: ${{ secrets.CODECOV_TOKEN }} - build-release: + release-nightly: concurrency: group: release permissions: id-token: write if: | github.event_name == 'push' && - github.repository == 'nuxt/nuxt' && + github.repository_owner == 'nuxt' && !contains(github.event.head_commit.message, '[skip-release]') && !startsWith(github.event.head_commit.message, 'docs') needs: - - lint - build - - test-fixtures runs-on: ubuntu-latest timeout-minutes: 20 @@ -284,7 +282,7 @@ jobs: - run: corepack enable - uses: actions/setup-node@39370e3970a6d050c480ffad4ff0ed4d3fdee5af # v4.1.0 with: - node-version: 22 + node-version: lts/* cache: "pnpm" - name: Install dependencies @@ -299,22 +297,15 @@ jobs: - name: Release Edge run: ./scripts/release-edge.sh ${{ github.ref == 'refs/heads/main' && 'latest' || '3x' }} env: - NODE_AUTH_TOKEN: ${{secrets.NODE_AUTH_TOKEN}} + NODE_AUTH_TOKEN: ${{ secrets.NODE_AUTH_TOKEN }} NPM_CONFIG_PROVENANCE: true release-pr: concurrency: group: release - permissions: - id-token: write - pull-requests: write - if: | - github.event_name == 'pull_request' && - contains(github.event.pull_request.labels.*.name, '🧷 edge release') + if: github.repository_owner == 'nuxt' && github.event_name != 'push' needs: - - lint - build - - test-fixtures runs-on: ubuntu-latest timeout-minutes: 20 @@ -325,7 +316,7 @@ jobs: - run: corepack enable - uses: actions/setup-node@39370e3970a6d050c480ffad4ff0ed4d3fdee5af # v4.1.0 with: - node-version: 22 + node-version: lts/* cache: "pnpm" - name: Install dependencies @@ -337,8 +328,4 @@ jobs: name: dist path: packages - - name: Release Edge - run: ./scripts/release-edge.sh pr-${{ github.event.issue.number }} - env: - NODE_AUTH_TOKEN: ${{secrets.NODE_AUTH_TOKEN}} - NPM_CONFIG_PROVENANCE: true + - run: pnpm pkg-pr-new publish --compact './packages/kit' './packages/nuxt' './packages/rspack' './packages/schema' './packages/vite' './packages/webpack' diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml index 342573e564..08bbd42e7b 100644 --- a/.github/workflows/docs.yml +++ b/.github/workflows/docs.yml @@ -25,7 +25,7 @@ jobs: - run: corepack enable - uses: actions/setup-node@39370e3970a6d050c480ffad4ff0ed4d3fdee5af # v4.1.0 with: - node-version: 22 + node-version: lts/* cache: "pnpm" - name: Install dependencies diff --git a/.github/workflows/lint-monorepo.yml b/.github/workflows/lint-monorepo.yml index 3e7930da4b..046f3fe709 100644 --- a/.github/workflows/lint-monorepo.yml +++ b/.github/workflows/lint-monorepo.yml @@ -1,4 +1,4 @@ -name: CI +name: ci on: push: @@ -29,7 +29,7 @@ jobs: - run: corepack enable - uses: actions/setup-node@39370e3970a6d050c480ffad4ff0ed4d3fdee5af # v4.1.0 with: - node-version: 22 + node-version: lts/* cache: "pnpm" - name: Install dependencies @@ -39,4 +39,4 @@ jobs: run: pnpm sherif -r multiple-dependency-versions - name: Check engine ranges, peer dependency ranges and installed versions - run: pnpm installed-check -d + run: pnpm installed-check --no-include-workspace-root --ignore-dev --workspace-ignore='test/**,playground' diff --git a/.github/workflows/lint-workflows.yml b/.github/workflows/lint-workflows.yml index c8d76ec185..a5b382aef3 100644 --- a/.github/workflows/lint-workflows.yml +++ b/.github/workflows/lint-workflows.yml @@ -26,6 +26,6 @@ jobs: - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 # From https://github.com/rhysd/actionlint/blob/main/docs/usage.md#use-actionlint-on-github-actions - name: Check workflow files - uses: docker://rhysd/actionlint:1.7.4@sha256:82244e1db1c60d82c7792180a48dd0bcb838370bb589d53ff132503fc9485868 + uses: docker://rhysd/actionlint:1.7.6@sha256:e3856d413f923accc4120884ff79f6bdba3dd53fd42884d325f21af61cc15ce0 with: args: -color diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index c0b74d25c2..34494d2c6c 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -25,7 +25,7 @@ jobs: - run: corepack enable - uses: actions/setup-node@39370e3970a6d050c480ffad4ff0ed4d3fdee5af # v4.1.0 with: - node-version: 20 + node-version: lts/* registry-url: "https://registry.npmjs.org/" cache: "pnpm" diff --git a/.github/workflows/scorecards.yml b/.github/workflows/scorecards.yml index cd4b3fc9af..21ee3efc2e 100644 --- a/.github/workflows/scorecards.yml +++ b/.github/workflows/scorecards.yml @@ -59,7 +59,7 @@ jobs: # Upload the results as artifacts (optional). Commenting out will disable uploads of run results in SARIF # format to the repository Actions tab. - name: "Upload artifact" - uses: actions/upload-artifact@6f51ac03b9356f520e9adb1b1b7802705f340c2b # v4.5.0 + uses: actions/upload-artifact@65c4c4a1ddee5b72f698fdd19549f0f0fb45cf08 # v4.6.0 if: github.repository == 'nuxt/nuxt' && success() with: name: SARIF file @@ -68,7 +68,7 @@ jobs: # Upload the results to GitHub's code scanning dashboard. - name: "Upload to code-scanning" - uses: github/codeql-action/upload-sarif@48ab28a6f5dbc2a99bf1e0131198dd8f1df78169 # v3.28.0 + uses: github/codeql-action/upload-sarif@b6a472f63d85b9c78a3ac5e89422239fc15e9b3c # v3.28.1 if: github.repository == 'nuxt/nuxt' && success() with: sarif_file: results.sarif diff --git a/.github/workflows/semantic-pull-requests.yml b/.github/workflows/semantic-pull-requests.yml index d563f5045f..41e53837bc 100644 --- a/.github/workflows/semantic-pull-requests.yml +++ b/.github/workflows/semantic-pull-requests.yml @@ -17,7 +17,7 @@ jobs: statuses: write # for amannn/action-semantic-pull-request to mark status of analyzed PR if: github.repository == 'nuxt/nuxt' && !startsWith(github.head_ref, 'v') runs-on: ubuntu-latest - name: Semantic pull request + name: semantic-pr steps: - name: Validate PR title uses: amannn/action-semantic-pull-request@0723387faaf9b38adef4775cd42cfd5155ed6017 # v5.5.3 diff --git a/docs/1.getting-started/12.upgrade.md b/docs/1.getting-started/12.upgrade.md index 4f8620f72c..d6d463dbda 100644 --- a/docs/1.getting-started/12.upgrade.md +++ b/docs/1.getting-started/12.upgrade.md @@ -638,11 +638,11 @@ We have raised PRs to update modules using EJS syntax, but if you need to do thi * Moving your string interpolation logic directly into `getContents()`. * Using a custom function to handle the replacement, such as in https://github.com/nuxt-modules/color-mode/pull/240. -* Continuing to use `lodash`, as a dependency of _your_ project rather than Nuxt: +* Use `es-toolkit/compat` (a drop-in replacement for lodash template), as a dependency of _your_ project rather than Nuxt: ```diff + import { readFileSync } from 'node:fs' -+ import { template } from 'lodash-es' ++ import { template } from 'es-toolkit/compat' // ... addTemplate({ fileName: 'appinsights-vue.js' diff --git a/docs/2.guide/1.concepts/3.rendering.md b/docs/2.guide/1.concepts/3.rendering.md index 535b8bf57a..41aacb6519 100644 --- a/docs/2.guide/1.concepts/3.rendering.md +++ b/docs/2.guide/1.concepts/3.rendering.md @@ -100,6 +100,10 @@ Watch a video from Alexander Lichter about **Building a plain SPA with Nuxt!?**. If you deploy your app to [static hosting](/docs/getting-started/deployment#static-hosting) with the `nuxi generate` or `nuxi build --prerender` commands, then by default, Nuxt will render every page as a separate static HTML file. +::warning +If you prerender your app with the `nuxi generate` or `nuxi build --prerender` commands, then you will not be able to use any server endpoints as no server will be included in your output folder. If you need server functionality, use `nuxi build` instead. +:: + If you are using purely client-side rendering, then this might be unnecessary. You might only need a single `index.html` file, plus `200.html` and `404.html` fallbacks, which you can tell your static web host to serve up for all requests. In order to achieve this we can change how the routes are prerendered. Just add this to [your hooks](/docs/api/advanced/hooks#nuxt-hooks-build-time) in your `nuxt.config.ts`: diff --git a/docs/2.guide/2.directory-structure/1.composables.md b/docs/2.guide/2.directory-structure/1.composables.md index ed96746656..c728be0fb7 100644 --- a/docs/2.guide/2.directory-structure/1.composables.md +++ b/docs/2.guide/2.directory-structure/1.composables.md @@ -71,7 +71,7 @@ export const useFoo = () => { ### Access plugin injections -You can access [plugin injections](/docs/guide/directory-structure/plugins#automatically-providing-helpers) from composables: +You can access [plugin injections](/docs/guide/directory-structure/plugins#providing-helpers) from composables: ```js [composables/test.ts] export const useHello = () => { diff --git a/docs/2.guide/3.going-further/1.experimental-features.md b/docs/2.guide/3.going-further/1.experimental-features.md index d23638e5af..9a4b729e9f 100644 --- a/docs/2.guide/3.going-further/1.experimental-features.md +++ b/docs/2.guide/3.going-further/1.experimental-features.md @@ -61,7 +61,7 @@ This feature will likely be removed in a near future. Emits `app:chunkError` hook when there is an error loading vite/webpack chunks. Default behavior is to perform a reload of the new route on navigation to a new route when a chunk fails to load. -If you set this to `'automatic-immediate'` Nuxt will reload the current route immediatly, instead of waiting for a navigation. This is useful for chunk errors that are not triggered by navigation, e.g., when your Nuxt app fails to load a [lazy component](/docs/guide/directory-structure/components#dynamic-imports). A potential downside of this behavior is undesired reloads, e.g., when your app does not need the chunk that caused the error. +If you set this to `'automatic-immediate'` Nuxt will reload the current route immediately, instead of waiting for a navigation. This is useful for chunk errors that are not triggered by navigation, e.g., when your Nuxt app fails to load a [lazy component](/docs/guide/directory-structure/components#dynamic-imports). A potential downside of this behavior is undesired reloads, e.g., when your app does not need the chunk that caused the error. You can disable automatic handling by setting this to `false`, or handle chunk errors manually by setting it to `manual`. diff --git a/docs/2.guide/4.recipes/4.sessions-and-authentication.md b/docs/2.guide/4.recipes/4.sessions-and-authentication.md index 6a45db6bbb..b4f4e4f211 100644 --- a/docs/2.guide/4.recipes/4.sessions-and-authentication.md +++ b/docs/2.guide/4.recipes/4.sessions-and-authentication.md @@ -162,7 +162,7 @@ export default defineNuxtRouteMiddleware(() => { ## Home Page -Now that we have our app middleware to protect our routes, we can use it on our home page that display our authenticated user informations. If the user is not authenticated, they will be redirected to the login page. +Now that we have our app middleware to protect our routes, we can use it on our home page that display our authenticated user information. If the user is not authenticated, they will be redirected to the login page. We'll use [`definePageMeta`](/docs/api/utils/define-page-meta) to apply the middleware to the route that we want to protect. diff --git a/docs/3.api/2.composables/use-async-data.md b/docs/3.api/2.composables/use-async-data.md index 7619dd1eb7..1a297d253f 100644 --- a/docs/3.api/2.composables/use-async-data.md +++ b/docs/3.api/2.composables/use-async-data.md @@ -69,7 +69,13 @@ const { data: posts } = await useAsyncData( - `immediate`: when set to `false`, will prevent the request from firing immediately. (defaults to `true`) - `default`: a factory function to set the default value of the `data`, before the async function resolves - useful with the `lazy: true` or `immediate: false` option - `transform`: a function that can be used to alter `handler` function result after resolving - - `getCachedData`: Provide a function which returns cached data. A _null_ or _undefined_ return value will trigger a fetch. By default, this is: `key => nuxt.isHydrating ? nuxt.payload.data[key] : nuxt.static.data[key]`, which only caches data when `payloadExtraction` is enabled. + - `getCachedData`: Provide a function which returns cached data. A `null` or `undefined` return value will trigger a fetch. By default, this is: + ```ts + const getDefaultCachedData = (key) => nuxtApp.isHydrating + ? nuxtApp.payload.data[key] + : nuxtApp.static.data[key] + ``` + Which only caches data when `experimental.payloadExtraction` of `nuxt.config` is enabled. - `pick`: only pick specified keys in this array from the `handler` function result - `watch`: watch reactive sources to auto-refresh - `deep`: return data in a deep ref object. It is `false` by default to return data in a shallow ref object for performance. @@ -94,7 +100,13 @@ Learn how to use `transform` and `getCachedData` to avoid superfluous calls to a - `data`: the result of the asynchronous function that is passed in. - `refresh`/`execute`: a function that can be used to refresh the data returned by the `handler` function. - `error`: an error object if the data fetching failed. -- `status`: a string indicating the status of the data request (`"idle"`, `"pending"`, `"success"`, `"error"`). +- `status`: a string indicating the status of the data request: + - `idle`: when the request has not started, such as: + - when `execute` has not yet been called and `{ immediate: false }` is set + - when rendering HTML on the server and `{ server: false }` is set + - `pending`: the request is in progress + - `success`: the request has completed successfully + - `error`: the request has failed - `clear`: a function which will set `data` to `undefined`, set `error` to `null`, set `status` to `'idle'`, and mark any currently pending requests as cancelled. By default, Nuxt waits until a `refresh` is finished before it can be executed again. diff --git a/docs/3.api/2.composables/use-fetch.md b/docs/3.api/2.composables/use-fetch.md index 038082ab65..6f6e522620 100644 --- a/docs/3.api/2.composables/use-fetch.md +++ b/docs/3.api/2.composables/use-fetch.md @@ -109,7 +109,13 @@ All fetch options can be given a `computed` or `ref` value. These will be watche - `immediate`: when set to `false`, will prevent the request from firing immediately. (defaults to `true`) - `default`: a factory function to set the default value of the `data`, before the async function resolves - useful with the `lazy: true` or `immediate: false` option - `transform`: a function that can be used to alter `handler` function result after resolving - - `getCachedData`: Provide a function which returns cached data. A _null_ or _undefined_ return value will trigger a fetch. By default, this is: `key => nuxt.isHydrating ? nuxt.payload.data[key] : nuxt.static.data[key]`, which only caches data when `payloadExtraction` is enabled. + - `getCachedData`: Provide a function which returns cached data. A `null` or `undefined` return value will trigger a fetch. By default, this is: + ```ts + const getDefaultCachedData = (key) => nuxtApp.isHydrating + ? nuxtApp.payload.data[key] + : nuxtApp.static.data[key] + ``` + Which only caches data when `experimental.payloadExtraction` of `nuxt.config` is enabled. - `pick`: only pick specified keys in this array from the `handler` function result - `watch`: watch an array of reactive sources and auto-refresh the fetch result when they change. Fetch options and URL are watched by default. You can completely ignore reactive sources by using `watch: false`. Together with `immediate: false`, this allows for a fully-manual `useFetch`. (You can [see an example here](/docs/getting-started/data-fetching#watch) of using `watch`.) - `deep`: return data in a deep ref object. It is `false` by default to return data in a shallow ref object for performance. @@ -134,7 +140,13 @@ Learn how to use `transform` and `getCachedData` to avoid superfluous calls to a - `data`: the result of the asynchronous function that is passed in. - `refresh`/`execute`: a function that can be used to refresh the data returned by the `handler` function. - `error`: an error object if the data fetching failed. -- `status`: a string indicating the status of the data request (`"idle"`, `"pending"`, `"success"`, `"error"`). +- `status`: a string indicating the status of the data request: + - `idle`: when the request has not started, such as: + - when `execute` has not yet been called and `{ immediate: false }` is set + - when rendering HTML on the server and `{ server: false }` is set + - `pending`: the request is in progress + - `success`: the request has completed successfully + - `error`: the request has failed - `clear`: a function which will set `data` to `undefined`, set `error` to `null`, set `status` to `'idle'`, and mark any currently pending requests as cancelled. By default, Nuxt waits until a `refresh` is finished before it can be executed again. @@ -147,7 +159,7 @@ If you have not fetched data on the server (for example, with `server: false`), ```ts [Signature] function useFetch( - url: string | Request | Ref | (() => string) | Request, + url: string | Request | Ref | (() => string | Request), options?: UseFetchOptions ): Promise> diff --git a/docs/3.api/4.commands/add.md b/docs/3.api/4.commands/add.md index 4ed7d1eb09..c452ed8b80 100644 --- a/docs/3.api/4.commands/add.md +++ b/docs/3.api/4.commands/add.md @@ -19,7 +19,7 @@ npx nuxi add