Commit graph

18147 commits

Author SHA1 Message Date
Leah
a19b1ef796
fix(turbopack): make layout in group not cause a 404 (#57471)
### What?

Given the structure:
`/page.js`
`/(group)/layout.js`

Going to `/` would 404

Closes WEB-1878
2023-10-26 05:16:28 +00:00
Leah
c80fb27446
fix turbopack invalidations (#57362)
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2023-10-26 07:04:04 +02:00
vercel-release-bot
18d797e3fd v13.5.7-canary.31 2023-10-26 04:47:54 +00:00
JJ Kasper
d670c5c860
Update publish-native script for wasm change (#57472)
x-ref:
https://github.com/vercel/next.js/actions/runs/6649134570/job/18067246584
x-ref: https://github.com/vercel/next.js/pull/57437
2023-10-25 21:41:43 -07:00
Jon Meyers
4bc549bf95
Fix: catch expected error in with-supabase example (#57378)
### What?

[1] Use camelCase for SVG properties
[2] Catch expected error in cookie functions

### Why?

[1] Prints error to the console
[2] If the cookies `set` or `delete` methods are called in a Server Component, an error is thrown

### How?

[1] Change property names from kebab-case to camelCase
[2] Catch error
2023-10-26 04:37:32 +00:00
Jimmy Lai
907f37978e
perf: enable webpack build worker (#57346)
This PR enables the `experimental.webpackBuildWorker` to be on by
default. This flag enables logic inside Next.js to run the compilation
in an isolated worker. The reason for this is that the webpack
compilation process retains a lot of memory for the whole duration of
the build process because it uses some packages that leak. We don't need
it for the rest of the process so it's best to use it in a worker and
leave the memory to be used for static generation.

This will improve memory usage during build, avoiding OOMs caused by
webpack exceeding memory.


<!-- 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 #

-->

---------

Co-authored-by: JJ Kasper <jj@jjsweb.site>
2023-10-25 21:19:29 -07:00
Shu Ding
63b7b90985
Fix Regex (#57461)
It should be `\.` here.
2023-10-26 04:07:13 +00:00
Justin Ridgewell
7c0e66f8d8
turbopack: Fix Server Actions in Edge runtime (#57462)
### What?

Changes Server Actions to use a lazy `require()` statement instead of a
lazy dynamic `import()`, to fix SA in the Edge runtime.

### Why?

The Edge runtime has a restriction that it's not allowed to lazy load
more files. The problem is that dynamic `import()` does exactly that, it
defers importing those files until the call time. `require()` doesn't
have this issue, because the chunks it would load are included instead
of deferred.

### How?

Just needed to modify the actions loader entry point… after hours of
trying to get the action loader to evaluate in the node runtime and then
import the actions in the edge runtime.


Closes WEB-1874
2023-10-26 05:51:11 +02:00
vercel-release-bot
668820100a v13.5.7-canary.30 2023-10-26 03:34:50 +00:00
Jimmy Lai
b118ffd154
misc: fix build output (#57466)
mark dynamic routes as always dynamic

<!-- 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 #

-->
2023-10-25 19:51:43 -07:00
Jimmy Lai
6b6eddb50e
misc: fix unhandled err worker hook (#57465)
<!-- 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 #

-->
2023-10-25 19:51:11 -07:00
Zack Tanner
0052c59022
add better messaging around wrapping postpone with try/catch (#57446)
when calls to `maybePostpone` throw but there's no postpone state, we want to handle those errors differently so that we can provide clearer messaging around how to prevent them, while still retaining any errors that were re-thrown by the user.

ex:
![CleanShot 2023-10-25 at 16 05 56@2x](https://github.com/vercel/next.js/assets/1939140/d86cce9f-f9ed-477d-8d1c-0ce7c934d073)
2023-10-26 02:50:58 +00:00
Maia Teegarden
f412c8a991
Remove wasm target (#57437)
This PR removes the wasm target for the next-swc build for the next major version.  The main motivation is that Turbopack does not support targeting wasm yet, and it would be a significant amount of work to add. We plan to make Turbopack the default zero-config experience in a minor version, possibly before we are able to support a wasm target, so we need to make this breaking change now. We also plan to make more improvements to the webpack experience with shared Rust code, which we have so far been blocked from implementing because of the current wasm restrictions. We would like to support a wasm target again in the future, but cannot say at this time when that would be.


Closes WEB-1865
2023-10-26 02:29:07 +00:00
Jiachi Liu
6b18f397cb
Apply react-server condition for pages api (#57459)
Apply react-server condition and related API checks for pages API.

if you're doing react SSR with renderToString in middleware it should be disallowed. Imaging it could send the rendered html code to client and you display it in browser. But it might require hydration so it can be broken.

Follow up for #57448 , same reason explained in #57448
Closes NEXT-1653
2023-10-26 02:07:27 +00:00
vercel-release-bot
b27aa57908 v13.5.7-canary.29 2023-10-26 01:57:13 +00:00
Leah
c616582d4b
feat(turbopack): add support for parallel routes and route interception (#57450)
### What?

We have to walk the directory tree recursively for every page (instead
of once) to get the correct loaderTree.

With this PR we walk the directory tree and for every
`page.(js,jsx,ts,tsx)` (entrypoint) we find we walk it again to get the
loader tree for that page


Closes WEB-1868
Closes WEB-1609
2023-10-25 18:50:00 -07:00
Tobias Koppers
f7a7a8efa3
use postcss transforms consistently also on server side (#57434)
### What?

Server side should also apply postcss transforms in node_modules

### Why?

### How?


Closes WEB-1863
2023-10-26 03:09:37 +02:00
vercel-release-bot
1df027f46e v13.5.7-canary.28 2023-10-26 01:01:59 +00:00
Sebastian Markbåge
fcc2b6fa15
Ignore postponed rejections (#57456)
We also don't warn for awaiting a Promise late. That's a fine pattern in
Next.js because it allows for fetching early and awaiting late.

If a Promise does reject before that we still log an error which is fine
because an error actually did happen even if we didn't await it.

We ignore postpones though because they are not unexpected.

---------

Co-authored-by: Jimmy Lai <laijimmy0@gmail.com>
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2023-10-25 17:53:01 -07:00
Jiachi Liu
8fa15f4c77
refactor: simplify swc loaders configuration (#57457)
Reduce the times that we re-create loaders, down to 3 loaders:
* swc loader for server layer 
* swc loader for client layer
* babel loader

This change let us only create some loaders for once, and make the code
easier to read.
`babelLoader` will only available when babel config is enabled, so we
use filters to skip it when it's empty.
2023-10-25 17:24:04 -07:00
Tobias Koppers
43150fc677
Turbopack: Improve error handling (#57386)
### What?

* avoid some crash with server actions parsing
* don't send serverComponentChanges when there are errors

### Why?

### How?



Closes WEB-1852
2023-10-26 01:59:38 +02:00
Maia Teegarden
5ad8ada198
Add deprecation warning for disabling swc minifier (#57453)
First is without config option enabled and second is with:
<img width="599" alt="Screenshot 2023-10-25 at 2 51 11 PM" src="https://github.com/vercel/next.js/assets/2865858/3a3e6430-c8ea-49eb-af54-844ffea301d8">


Closes WEB-1870
2023-10-25 23:52:15 +00:00
OJ Kwon
0f55e292cf
fix(next-core): fix determining dynamic route (#57435)
### What

Fixes how to determine if given route is dynamic to match next-dev does:

462b8585b6/packages/next/src/lib/metadata/get-metadata-route.ts (L79)

We were passing calculated route instead to check if it's dynamic, so
`/sitemap` always considered as static since calculated route is
`/sitemap.xml`.

Closes WEB-1864

Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2023-10-26 01:29:39 +02:00
Leah
32e2317b67
fix(turbopack): don't emit issues when parsing the segment config for non js files (#57452)
### Why?

Calling `parse` will emit issues with error severity, causing the build
to get marked as failed


Closes WEB-1869
2023-10-26 01:29:11 +02:00
Jiachi Liu
17bd232cf2
Apply react-server transform and valication to middleware (#57448)
Apply `react-server` resolving and server components invalid APIs
checking to middleware. We want to limit the react usage in in
middleware as so far it's not aimed for rendering purpose.

Another invalid case could be: if you're doing react SSR with
`renderToString` in middleware it should be disallowed. Imaging it could
send the rendered html code to client and you display it in browser. But
it might require hydration so it can be broken.

This PR will only let you import `react-server` export condition
packages.
2023-10-26 01:22:50 +02:00
Justin Ridgewell
aa28fa5260
Process Client -> RSC Server Actions as TS (#57454)
### What?

Fixes Client -> RSC (client importing a `"user server"` file) Server
Actions that are using TS.

### Why?

### How?

I check if the source module is using TS before "processing" the module
into the RSC layer.

Closes WEB-1871
2023-10-26 01:13:31 +02:00
Jiachi Liu
164e43912d
codemods: migrate viewport related metadata export to viewport export (#57436)
This PR adds the codemods transforming certain fields from `metadata`
export to `viewport` export, will still preserve rest metadata export
properties. We don't cover `generateMetadata` to `generateViewport` as
there might be more complex logic inside the function which is hard to
apply the codemods rules.

TLDR: Codemods for #57302
2023-10-25 16:02:14 -07:00
JJ Kasper
691613f8e8
Fix deploy id env handling when disabled (#57374)
Ensure we properly omit the `dpl` fields when the experimental config
isn't enabled but the env is present.
2023-10-25 14:41:56 -07:00
Jiachi Liu
23f32465d7
types: mark ImageResponse from next/server deprecated (#57372)
* Should show `ImageResponse` is deprecated if you still import from `"next/server"`

<img width="708" alt="image" src="https://github.com/vercel/next.js/assets/4800338/38f9b9db-2cfb-48ec-99cc-08e7d1477155">


* If you build it will fail to compile, this might not be super ideal but at least it's not working. For pure js it will throw errors.

```ts
./app/icon.tsx:7:10
Type error: Only a void function can be called with the 'new' keyword.

   5 |
   6 | export default function icon() {
>  7 |   return new ImageResponse(
     |          ^
   8 |     (
   9 |       <div
  10 |         style={{
 ELIFECYCLE  Command failed with exit code 1.
 ```
2023-10-25 20:48:33 +00:00
vercel-release-bot
7274296681 v13.5.7-canary.27 2023-10-25 20:35:14 +00:00
Josh Story
fcc28999bf
Update React from b8e47d988 to a9985529f. (#57442)
React upstream changes:

- https://github.com/facebook/react/pull/27586
- https://github.com/facebook/react/pull/27577
- https://github.com/facebook/react/pull/27576

Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2023-10-25 13:29:47 -07:00
Jimmy Lai
da6562e4a1
misc: build output rework (#57440)
This PR updates the build output in order to reflect the changes brought
by PPR and also to make it more consistent.

before
```
○  (Static)                  automatically pre-rendered as static HTML
◐  (Partially Pre-Rendered)  static parts of the page were pre-rendered and the dynamic parts will be streamed
ℇ  (Streaming)               server-side renders with streaming (uses React 18 SSR streaming or Server Components)
λ  (Server)                  server-side renders at runtime (uses getInitialProps or getServerSideProps)
```

after

```
○  (Static)             prerendered as static HTML
◐  (Partial Prerender)  prerendered as static HTML with dynamic server-streamed content
λ  (Dynamic)            server-rendered on demand using Node.js
ℇ  (Edge Runtime)       server-rendered on demand using the Edge Runtime
```




<!-- 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 #

-->
2023-10-25 13:19:42 -07:00
vercel-release-bot
2b400f8fc3 v13.5.7-canary.26 2023-10-25 20:06:39 +00:00
Tobias Koppers
9677ff5444
remove invalid argument (#57438)
### What?

not sure how this can even pass the CI

### Why?

### How?


Closes WEB-1866
2023-10-25 12:55:40 -07:00
Tobias Koppers
474e804e4d
handle finish building message on client side (#57363)
removes warning for client hmr code

Closes WEB-1846

---------

Co-authored-by: Leah <github.leah@hrmny.sh>
2023-10-25 12:53:46 -07:00
Tobias Koppers
5f0cfd41be
update turbopack (#57420)
* https://github.com/vercel/turbo/pull/6269 <!-- Tobias Koppers - Upload
data even for non-scheduled runs -->
* https://github.com/vercel/turbo/pull/6270 <!-- Tobias Koppers - Put
ESM in strict mode -->

Closes WEB-1855

Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2023-10-25 21:53:31 +02:00
Tobias Koppers
dee316c40e
Turbopack: avoid sending serverComponentChanges with errors (#57425)
We don't want to send the serverComponentChanges event until the
compilation is free of errors.

Closes WEB-1859
2023-10-25 20:41:01 +02:00
Tobias Koppers
8a4b0f16c8
Turbopack: avoid crashing when server actions can't parse the file (#57424)
Introducting syntax errors in files throws an error in the server
actions parsing, which hides the actual syntax error reported

Closes WEB-1858

Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2023-10-25 20:36:43 +02:00
Tobias Koppers
d11156c2d2
Turbopack: disable webpack specific test cases (#57423)
These tests test webpack specific behavior

Closes WEB-1857
2023-10-25 20:35:35 +02:00
Tobias Koppers
462b8585b6
enable e2e tests with turbopack (#57432)
Closes WEB-1862

---------

Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2023-10-25 19:46:31 +02:00
OJ Kwon
945edacceb
fix(next-core): adjust og alias (#57431)
### What?

minor adjustment to the alias to reflect latest changes: 

9c87ea5a3d/packages/next/src/server/web/spec-extension/image-response.ts (L3)

Closes WEB-1861
2023-10-25 17:31:04 +00:00
Jiachi Liu
9c87ea5a3d
Fix logging removed experiments in start logs (#57373)
Do not log the removed experiments in the start server logs, for instance `experimental.appDir` should get warned as unexpected option but it's not the valid experiment anymore
2023-10-25 16:08:14 +00:00
Tim Neutkens
d8160e0541
Ensure unstable_cache revalidate option enables ISR (#57390)
Noticed that if you use `unstable_cache` it did not opt-in to ISR even though fetch() does opt-in. This ensures the prerender-manifest holds the revalidate value.
2023-10-25 15:31:08 +00:00
Tobias Koppers
509b88ae4c
update manifest (#57421)
update manifest from daily test run

Closes WEB-1856
2023-10-25 16:41:30 +02:00
Jiachi Liu
305bb01506
Refactor swc options (#57369)
* Rename swc option `is_server` to `is_server_compiler`
* Rename swc plugin `config.is_server` to `config.is_react_server_layer`
* Remove unused `bundle_target`, which could be covered by composing `is_server_compiler` and `is_react_server_layer`
2023-10-25 06:51:17 +00:00
Justin Ridgewell
656202fe0c
turbopack: Implement Server Actions from Client Components (#57391)
### What?

This completes Turbopack's Server Actions implementation!

It also cleans up several things:
- Removes `server_actions` configuration, it's enabled by default now.
- Fixes the transform that runs in the SSR layer (it actually needs to
use the client transform)
- Generates a new encryption key

### Why?

### How?

It crawls the client layer modules for additional Server Actions
imports, and adds them to our generated `actions.js` entry point.

Closes NEXT-
Fixes #


Closes WEB-1854

---------

Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2023-10-24 23:16:59 -07:00
Tom Occhino
1038fd53ef
Add websocket to server-external-packages (#57389)
Ensures websocket does not get bundled by Webpack/Turbopack.
2023-10-25 05:39:38 +00:00
Jiachi Liu
a301eb6a9f
Viewport exports (#57302)
## Story Time

Metadata API introduced two exports `metadata` and `generateMetadata` to the pages and layouts under app router, as partial prerendering work is going on and people are desiring to render the metadata asynchronizly, this change will be the preparation for moving to the dynamic & asynchronized land. In short, if we can render the metadata asynchronizedly, it will benefit the performance of the initial page loading and client page transiation a lot. Any slow data fetching can be handled while the essential page "shell" is rendered. 

For meta tags, there're few ones will visually affect your web page, such as `<meta name="viewport">`, `<meta name="theme color">` and `<meta name="color-scheme">`, rendering them lately after the page frame is ready might bring flickering to the page such as revreting whole page's theme color or shaking due to viewport updates. Those meta are not majorly the "metadata" for SEO, but more for user experience when opening the page. If we're rendering everything as async meta tags, it won't be ideal due to the flickering on your web pages.

## Solution Preparation 

We'll want to render the meta tags separately to make sure the visual ones are rendered as blocking along with web page, and then the ones for SEO or bots can be flushed later by later, like a suspense boundary keeps emitting them into the head of html. 

We optionally picked up 3 meta tag "viewport", "theme-color" and "color-scheme" to be render first into the web page with html "shell", to guarantee the layout viewport and basic styling are rendered first.

This PR introduced two module export in the page and layout files: `viewport` and `generateViewport`, in order to separate the visual meta tags from the SEO metadata.

### API

```ts
// page.js | layout.js
export const viewport = {
  // viewport meta tag
  width: 'device-width',
  initialScale: 1,
  maximumScale: 1,
  interactiveWidget: 'resizes-visual',
  // visual meta tags
  colorScheme: 'dark',
  themeColor: { color: 'cyan', media: '(prefers-color-scheme: dark)' },
}
```

There's also a dynamic API like what we did for metadata API

```ts
// page.js | layout.js
export function generateViewport() {
   return { ... }
}
```

## Notice 

This PR won't get SEO metadata rendered asyncronizedly, instead it's a preparation for the later work in partial prerendering and async metadata. We'll encourage the Next.js community moving to the new metadata viewport API if you're customzing those 3 meta tags. Usually you don't have to change viewport itself, so mostly like only theme-color and color-scheme could relate to it.
2023-10-25 05:20:23 +00:00
Tobias Koppers
18fe1eb4e9
Turbopack: inject chunk group list file into the page for server component CSS (#57376)
### What?

incjects the script tag for CSS reloading

### Why?

### How?


Closes WEB-1851

---------

Co-authored-by: Will Binns-Smith <wbinnssmith@gmail.com>
2023-10-24 20:06:46 -07:00
Shu Ding
59ebfbea9e
Fix request body hanging when middleware is preset (#57381)
Instead of `Readable.toWeb` we're gonna manually convert the Node.js stream to a Web stream. `toWeb` is either having a bug, or not compatible with middleware-cloned `PassThrough` streams.

Closes #56286. The case should be already covered with existing tests.
2023-10-25 02:44:10 +00:00