- 14 Dec, 2023 6 commits
-
-
vercel-release-bot authored
-
Wyatt Johnson authored
This fixes some of headers (and adds associated tests) for pages when PPR is enabled. Namely, the `Cache-Control` headers are now returning correctly, reflecting the non-cachability of some requests: - Requests that postpone (dynamic data is streamed after the initial static shell is streamed) - Requests for the Dynamic RSC payload Additionally, the `X-NextJS-Cache` header has been updated for better support for PPR: - Requests that postpone no longer return this header as it doesn't reflect the cache state of the request (because it streams) - Requests for the Prefetch RSC now returns the correct cache headers depending on the segment and pre-postpone state This also enables the other pathnames in the test suites
🙌 🏻 Closes NEXT-1840 -
Tim Neutkens authored
## What? Fixes a bug where `useOptimistic` wouldn't trigger a compiler error when imported in Server Components. Adds tests for the following `import { x } from 'react'` in Server Components, where `x` is the value: - Component - createContext - createFactory - PureComponent - useDeferredValue - useEffect - useImperativeHandle - useInsertionEffect - useLayoutEffect - useReducer - useRef - useState - useSyncExternalStore - useTransition - useOptimistic These show a particular error explaining how to add `"use client"`:  <!-- Thanks for opening a PR! Your contribution is much appreciated.i: To make sure your PR is handled as smoothly as possible we request that you follow the checklist sections below. Choose the right checklist for the change(s) that you're making: ## For Contributors ### Improving Documentation - Run `pnpm prettier-fix` to fix formatting issues before opening the PR. - Read the Docs Contribution Guide to ensure your contribution follows the docs guidelines: https://nextjs.org/docs/community/contribution-guide ### Adding or Updating Examples - The "examples guidelines" are followed from our contributing doc https://github.com/vercel/next.js/blob/canary/contributing/examples/adding-examples.md - Make sure the linting passes by running `pnpm build && pnpm lint`. See https://github.com/vercel/next.js/blob/canary/contributing/repository/linting.md ### Fixing a bug - Related issues linked using `fixes #number` - Tests added. See: https://github.com/vercel/next.js/blob/canary/contributing/core/testing.md#writing-tests-for-nextjs - Errors have a helpful link attached, see https://github.com/vercel/next.js/blob/canary/contributing.md ### Adding a feature - Implements an existing feature request or RFC. Make sure the feature request has been accepted for implementation before opening a PR. (A discussion must be opened, see https://github.com/vercel/next.js/discussions/new?category=ideas) - Related issues/discussions are linked using `fixes #number` - e2e tests added (https://github.com/vercel/next.js/blob/canary/contributing/core/testing.md#writing-tests-for-nextjs) - Documentation added - Telemetry added. In case of a feature if it's used or not. - Errors have a helpful link attached, see https://github.com/vercel/next.js/blob/canary/contributing.md ## For Maintainers - Minimal description (aim for explaining to someone not on the team to understand the PR) - When linking to a Slack thread, you might want to share details of the conclusion - Link both the Linear (Fixes NEXT-xxx) and the GitHub issues - Add review comments if necessary to explain to the reviewer the logic behind a change ### What? ### Why? ### How? Closes NEXT- Fixes # --> -
Shohei Maeda authored
Co-authored-by:Delba de Oliveira <32464864+delbaoliveira@users.noreply.github.com>
-
Tim Neutkens authored
## What? Adds two tests for server actions returning client components: - (supported) Importing a server action from a server component. That server action imports a client component and returns it. - (not supported yet) Importing a server action from a client component. The server action imports a client component and returns it. The second case is not supported yet as it would effectively mean a compilation loop: `server` -> `client` -> `server` -> `client` and if that last client component includes another server action it goes even further: `server` -> `client` -> `server` -> `client` -> `server` (and if that server action includes anothe client component it goes further and further) Whereas currently it's only `server` -> `client` -> `server`, so it's limited to that. In the future we should be able to support this server->client->server->client loop in Turbopack specifically because Turbopack has a single module graph. Importing the client component in a server action that is defined in the server compiler (i.e. when created inline or when imported from a server component) it does work correctly already. <!-- Thanks for opening a PR! Your contribution is much appreciated. To make sure your PR is handled as smoothly as possible we request that you follow the checklist sections below. Choose the right checklist for the change(s) that you're making: ## For Contributors ### Improving Documentation - Run `pnpm prettier-fix` to fix formatting issues before opening the PR. - Read the Docs Contribution Guide to ensure your contribution follows the docs guidelines: https://nextjs.org/docs/community/contribution-guide ### Adding or Updating Examples - The "examples guidelines" are followed from our contributing doc https://github.com/vercel/next.js/blob/canary/contributing/examples/adding-examples.md - Make sure the linting passes by running `pnpm build && pnpm lint`. See https://github.com/vercel/next.js/blob/canary/contributing/repository/linting.md ### Fixing a bug - Related issues linked using `fixes #number` - Tests added. See: https://github.com/vercel/next.js/blob/canary/contributing/core/testing.md#writing-tests-for-nextjs - Errors have a helpful link attached, see https://github.com/vercel/next.js/blob/canary/contributing.md ### Adding a feature - Implements an existing feature request or RFC. Make sure the feature request has been accepted for implementation before opening a PR. (A discussion must be opened, see https://github.com/vercel/next.js/discussions/new?category=ideas) - Related issues/discussions are linked using `fixes #number` - e2e tests added (https://github.com/vercel/next.js/blob/canary/contributing/core/testing.md#writing-tests-for-nextjs) - Documentation added - Telemetry added. In case of a feature if it's used or not. - Errors have a helpful link attached, see https://github.com/vercel/next.js/blob/canary/contributing.md ## For Maintainers - Minimal description (aim for explaining to someone not on the team to understand the PR) - When linking to a Slack thread, you might want to share details of the conclusion - Link both the Linear (Fixes NEXT-xxx) and the GitHub issues - Add review comments if necessary to explain to the reviewer the logic behind a change ### What? ### Why? ### How? Closes NEXT- Fixes # --> Closes NEXT-1873
-
Delba de Oliveira authored
- Remove recommendation for client-side rendering - Cut repetition - Improve tone
-
- 13 Dec, 2023 24 commits
-
-
vercel-release-bot authored
-
OJ Kwon authored
-
vercel-release-bot authored
-
Zack Tanner authored
This appears to be causing a build issue and requires deeper investigation. Reverting for now. - Reverts #59430 [slack x-ref](https://vercel.slack.com/archives/C06AARWFZFB/p1702491612961359) Closes NEXT-1870
-
Zack Tanner authored
Moved this to prevent a bundle regression when these constants are used on both client/server. <!-- Thanks for opening a PR! Your contribution is much appreciated. To make sure your PR is handled as smoothly as possible we request that you follow the checklist sections below. Choose the right checklist for the change(s) that you're making: ## For Contributors ### Improving Documentation - Run `pnpm prettier-fix` to fix formatting issues before opening the PR. - Read the Docs Contribution Guide to ensure your contribution follows the docs guidelines: https://nextjs.org/docs/community/contribution-guide ### Adding or Updating Examples - The "examples guidelines" are followed from our contributing doc https://github.com/vercel/next.js/blob/canary/contributing/examples/adding-examples.md - Make sure the linting passes by running `pnpm build && pnpm lint`. See https://github.com/vercel/next.js/blob/canary/contributing/repository/linting.md ### Fixing a bug - Related issues linked using `fixes #number` - Tests added. See: https://github.com/vercel/next.js/blob/canary/contributing/core/testing.md#writing-tests-for-nextjs - Errors have a helpful link attached, see https://github.com/vercel/next.js/blob/canary/contributing.md ### Adding a feature - Implements an existing feature request or RFC. Make sure the feature request has been accepted for implementation before opening a PR. (A discussion must be opened, see https://github.com/vercel/next.js/discussions/new?category=ideas) - Related issues/discussions are linked using `fixes #number` - e2e tests added (https://github.com/vercel/next.js/blob/canary/contributing/core/testing.md#writing-tests-for-nextjs) - Documentation added - Telemetry added. In case of a feature if it's used or not. - Errors have a helpful link attached, see https://github.com/vercel/next.js/blob/canary/contributing.md ## For Maintainers - Minimal description (aim for explaining to someone not on the team to understand the PR) - When linking to a Slack thread, you might want to share details of the conclusion - Link both the Linear (Fixes NEXT-xxx) and the GitHub issues - Add review comments if necessary to explain to the reviewer the logic behind a change ### What? ### Why? ### How? Closes NEXT- Fixes # --> Closes NEXT-1867
-
vercel-release-bot authored
-
Dima Voytenko authored
See related https://github.com/vercel/next.js/issues/51969. It should no longer apply.
-
Andrew Clark authored
When PPR is enabled, the CacheNodeSeedData and FlightRouterState contained in an RSC payload (whether it's static or dynamic) should always have the same tree structure. The only reason the two trees would ever be different is if the server partially renders with `loading.tsx`, but that behavior doesn't exist when PPR is enabled. (In that case, the CacheNodeSeedData would describe only a subset of FlightRouterState.) The behavior is already correct but to make the types a bit closer, this changes the `parallelRoutes` slot of CacheNodeSeedData to be non-nullable; if there are no children, it should be an empty object. It's not semantically important, I'm only changing it to make the types more consistent, since we typically traverse both trees in parallel. Eventually we will probably merge these into a single transport type. Closes NEXT-1868
-
Andrew Clark authored
Follow-up to #59552, I think this one was missed because it landed around the same time as #59538. Closes NEXT-1869
-
Leah authored
### Changes * https://github.com/vercel/turbo/pull/6777 <!-- Leah - fix(turbopack-ecmascript-runtime): handle non encoded CSS paths --> * https://github.com/vercel/turbo/pull/6785 <!-- Tim Neutkens - Ensure turbopack-trace-server doesn't send message in a loop --> Closes PACK-2147
-
Delba de Oliveira authored
-
Zack Tanner authored
This uses the existing PAGE_SEGMENT constant in places where we had `__PAGE__` and introduces a similar constant for `__DEFAULT__`. <!-- Thanks for opening a PR! Your contribution is much appreciated. To make sure your PR is handled as smoothly as possible we request that you follow the checklist sections below. Choose the right checklist for the change(s) that you're making: ## For Contributors ### Improving Documentation - Run `pnpm prettier-fix` to fix formatting issues before opening the PR. - Read the Docs Contribution Guide to ensure your contribution follows the docs guidelines: https://nextjs.org/docs/community/contribution-guide ### Adding or Updating Examples - The "examples guidelines" are followed from our contributing doc https://github.com/vercel/next.js/blob/canary/contributing/examples/adding-examples.md - Make sure the linting passes by running `pnpm build && pnpm lint`. See https://github.com/vercel/next.js/blob/canary/contributing/repository/linting.md ### Fixing a bug - Related issues linked using `fixes #number` - Tests added. See: https://github.com/vercel/next.js/blob/canary/contributing/core/testing.md#writing-tests-for-nextjs - Errors have a helpful link attached, see https://github.com/vercel/next.js/blob/canary/contributing.md ### Adding a feature - Implements an existing feature request or RFC. Make sure the feature request has been accepted for implementation before opening a PR. (A discussion must be opened, see https://github.com/vercel/next.js/discussions/new?category=ideas) - Related issues/discussions are linked using `fixes #number` - e2e tests added (https://github.com/vercel/next.js/blob/canary/contributing/core/testing.md#writing-tests-for-nextjs) - Documentation added - Telemetry added. In case of a feature if it's used or not. - Errors have a helpful link attached, see https://github.com/vercel/next.js/blob/canary/contributing.md ## For Maintainers - Minimal description (aim for explaining to someone not on the team to understand the PR) - When linking to a Slack thread, you might want to share details of the conclusion - Link both the Linear (Fixes NEXT-xxx) and the GitHub issues - Add review comments if necessary to explain to the reviewer the logic behind a change ### What? ### Why? ### How? Closes NEXT- Fixes # --> Closes NEXT-1860
-
Delba de Oliveira authored
Follow-up from: https://github.com/vercel/next.js/pull/59268
-
Andrew Clark authored
The PPR implementation of navigateReducer is expected to diverge significantly from the existing, non-PPR implementation. So this forks them into two separate functions. This will be easier to maintain than two different implementations inside the same function, especially considering we don't expect any more changes to the non-PPR implementation. This also reduces the chances we'll introduce an accidental regression into the non-PPR version, which is the stable one that all users (except for the ones dogfooding PPR) are currently using. For now, the two implementations are identical. I'll start making changes in subsequent PRs. Only one implementation will be included in the final build; the other one will be dead code eliminated because the feature check is statically inlined at build time: ```js export const navigateReducer = process.env.__NEXT_PPR ? navigateReducer_PPR : navigateReducer_noPPR ``` Closes NEXT-1856
-
Tim Neutkens authored
-
Jiachi Liu authored
Found this from build error trace while testing the change in #59569 ``` docs/02-app/01-building-your-application/08-testing/02-jest.mdx": UnexpectedMDXError: Error: Build failed with 1 error: -- _mdx_bundler_entry_point-776983b1-6900-47c0-98cc-0c35882e9532.mdx:297:0: ERROR: [plugin: @mdx-js/esbuild] Unexpected closing tag `</PageOnly>`, expected corresponding closing tag for `<PagesOnly> ``` Closes NEXT-1863
-
Jiachi Liu authored
Inside `test/` folder we should use different path for alias paths Follow up #59550
-
Jiachi Liu authored
-
Jiachi Liu authored
-
Jiachi Liu authored
-
Delba de Oliveira authored
This PR updates the testing guides to use App Router and TypeScript, also updates `/examples` to show `app` and `pages` examples. ## Overview - [x] Create a new "Testing" section that is shared between `app` and `pages`. - [x] Explain the differences between E2E, unit testing, component testing, etc. - [x] Recommend E2E for `async` components as currently none of the tools support it. - [x] Update setup guides for **Cypress**, **Playwright**, and **Jest** with latest config options, and examples for `app` and `pages`. - [x] Add new guide for **Vitest** - [x] Clean up `/examples`: use TS, show `app` and `pages` examples, match docs config ## Cypress - [x] E2E Tests - [x] Component Testing - [x] Client Components - [x] Server Components - [ ] `async` components **Blockers:** - TS: `Option 'bundler' can only be used when 'module' is set to 'es2015' or later`. In **tsconfig.json** compilerOptions, Next.js uses "moduleResolution": "bundler", changing it to "node" fixes the issue but it can have repercussions. - https://github.com/cypress-io/cypress/issues/27731 - Version 14 is currently not supported for component testing - https://github.com/cypress-io/cypress/issues/28185 ## Playwright - [x] E2E Tests ## Jest - [x] Unit Testing - [x] Client Components - [x] Server Components - [ ] `async` components: https://github.com/testing-library/react-testing-library/issues/1209 - [x] 'server-only': https://github.com/vercel/next.js/pull/54891 - [x] Snapshot Testing **Blockers:** - TS: https://github.com/testing-library/jest-dom/issues/546 - None of the solutions in the issue work with Next.js v14.0.4 and TS v5 ## Vitest - [x] Unit Testing - [x] Client Components - [x] Server Components - [ ] `async` components - [x] 'server-only' - [x] Update vitest example - [x] Handles CSS, and CSS modules imports - [x] Handles next/image ## Other - https://github.com/vercel/next.js/issues/47448 - https://github.com/vercel/next.js/issues/47299
-
vercel-release-bot authored
-
Rahul Mishra authored
<!-- Thanks for opening a PR! Your contribution is much appreciated. To make sure your PR is handled as smoothly as possible we request that you follow the checklist sections below. Choose the right checklist for the change(s) that you're making: ## For Contributors ### Improving Documentation - Run `pnpm prettier-fix` to fix formatting issues before opening the PR. - Read the Docs Contribution Guide to ensure your contribution follows the docs guidelines: https://nextjs.org/docs/community/contribution-guide ### Adding or Updating Examples - The "examples guidelines" are followed from our contributing doc https://github.com/vercel/next.js/blob/canary/contributing/examples/adding-examples.md - Make sure the linting passes by running `pnpm build && pnpm lint`. See https://github.com/vercel/next.js/blob/canary/contributing/repository/linting.md ### Fixing a bug - Related issues linked using `fixes #number` - Tests added. See: https://github.com/vercel/next.js/blob/canary/contributing/core/testing.md#writing-tests-for-nextjs - Errors have a helpful link attached, see https://github.com/vercel/next.js/blob/canary/contributing.md ### Adding a feature - Implements an existing feature request or RFC. Make sure the feature request has been accepted for implementation before opening a PR. (A discussion must be opened, see https://github.com/vercel/next.js/discussions/new?category=ideas) - Related issues/discussions are linked using `fixes #number` - e2e tests added (https://github.com/vercel/next.js/blob/canary/contributing/core/testing.md#writing-tests-for-nextjs) - Documentation added - Telemetry added. In case of a feature if it's used or not. - Errors have a helpful link attached, see https://github.com/vercel/next.js/blob/canary/contributing.md ## For Maintainers - Minimal description (aim for explaining to someone not on the team to understand the PR) - When linking to a Slack thread, you might want to share details of the conclusion - Link both the Linear (Fixes NEXT-xxx) and the GitHub issues - Add review comments if necessary to explain to the reviewer the logic behind a change ### What? ### Why? ### How? Closes NEXT- Fixes # --> This PR updates `prompts` to `v2.4.2`, it fixes a bug I found and I haven't seen any reports about it. ## The Bug [Screencast from 2023-11-28 17-58-41.webm](https://github.com/vercel/next.js/assets/130567419/cf17f0d8-39f3-4ced-80ca-9fb5962587d8) There was a bug in `prompts` where it didn't handle <kbd>Home</kbd> and <kbd>End</kbd> button correctly. It has been fixed in later version. I have updated `prompts` along with `@types/prompts` to latest available version which is `v2.4.2`. Co-authored-by:
JJ Kasper <jj@jjsweb.site>
-
JJ Kasper authored
This ensures that `export const dynamic = 'force-static'` is properly honored when a page contains fetches with `cache: 'no-store'`, `cache: 'no-cache'` or `next: { revalidate: 0 }`. Closes NEXT-1858
-
- 12 Dec, 2023 10 commits
-
-
vercel-release-bot authored
-
OJ Kwon authored
-
Wyatt Johnson authored
This updates the some of the logic around updating `PageInfo` entries in the `pageInfos` map. This is a followup to #59420. Closes NEXT-1838
-
Wyatt Johnson authored
Previously when running deployment tests, the testing infrastructure used the Vercel REST API to manage and work with deployments to perform the actual testing. This now utilizes the Vercel CLI instead (while maintaining the same beheviour as before) to simplifiy the implementation. In cases where testing is performed against a locally configured Vercel CLI that's already authenticated it will now use those pre-configured credentials. Closes NEXT-1841
-
akawalsky authored
Implementation of feature request opened here - https://github.com/vercel/next.js/discussions/59427 Approach: ~~We are using micromatch in the csrf protection step of actionHandler to allow for wildcard domains passed in allowedDomains. This is the same library used for matching domains for remote images.~~ If any of the allowed domains match the origin of the request, we skip the downstream error thrown for csrf protection. Edit: Micromatch is not available in this context as it is only compatible with Node. This codepath can be run from the edge, so we need to rely on vanilla js compatible code only. Instead of falling back to allowing the user to pass in a regex, which can be somewhat insecure, we opt into continuing to use a wildcard pattern from a configuration standpoint and instead use a simple function that matches on wildcards using string comparison and iteration. Ideally, Micromatch can be retrofitted to work in non-Node settings and this piece of code can be replaced in the future, without deprecating or changing the next.config interface. --------- Co-authored-by:
Josh Story <story@hey.com>
-
Andrew Clark authored
Adds a new field `prefetchRsc` to CacheNode that will be used by the PPR implementation. It represents a static version of the segment that can be showed immediately, and may or may not contain dynamic holes. It's prefetched before a navigation occurs. During rendering, we will choose whether to render `rsc` or `prefetchRsc` with `useDeferredValue`. As with the `rsc` field, a value of `null` means no value was provided. In this case, the LayoutRouter will go straight to rendering the `rsc` value; if that one is also missing, it will suspend and trigger a lazy fetch. The non-PPR implementation will never set this value. This PR adds the field to the CacheNode type but doesn't implement any of the behavior yet. Mostly this involves updating the router reducer unit tests. Closes NEXT-1855
-
Zack Tanner authored
Passing `NODE_OPTIONS='--inspect'` was failing because a sub-process was getting created (`getRegistry()`) which would trigger a "address already in use" error when the process inherited the same debugger port from the parent process. I had to disable this test in https://github.com/vercel/next.js/pull/59508 because it wasn't passing, CI was just skipping it. This PR fixes the behavior and re-enables the test. Fixes #55862 Closes NEXT-1854
-
C. T. Lin authored
-
Andrew Clark authored
I want to give this field a name that's bit less generic and distinguishes it from `lazyData` (because that one has a different type and is a special case we want to eventually remove). I'm also about to add an optional `prefetchRsc` field that represents a prefetched version of the same value. The common suffix is meant to communicate how they are related. Doing this rename in its own PR because it's a pure find-and-replace, whereas the later steps are not. Closes NEXT-1846
-
OJ Kwon authored
-