Commit graph

18170 commits

Author SHA1 Message Date
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
Shu Ding
8158262960
Refactor code (#57382)
The conditions are not used and the function can be simplified.
2023-10-25 02:35:14 +00:00
vercel-release-bot
1d8764cd1b v13.5.7-canary.25 2023-10-24 23:22:49 +00:00
Tobias Koppers
f42b69209d
disable test temporarily (#57368)
It's flaky

Closes WEB-1849
2023-10-24 15:39:29 -07:00
OJ Kwon
8433970213
test(next-image): adjust assertion compatible to turbopack (#57350)
### What

Updating test assertions to work with turbopack as well.


Closes WEB-1843
2023-10-24 22:25:57 +00:00
vercel-release-bot
2b2ad9c7c4 v13.5.7-canary.24 2023-10-24 22:05:40 +00:00
OJ Kwon
a3e771a338
test(turbopack): update test manifest (#57366)
### What

Enabling test from https://github.com/vercel/next.js/pull/57300. There may be some other test cases passing by fix, but this is the known direct offending test can be enabled.

Closes WEB-1847
2023-10-24 21:55:38 +00:00
OJ Kwon
8b083c30dd
fix(next-core): apply correct jsx transform context for ssr (#57300)
### What

Running `test/e2e/app-dir/emotion-js/index.test.ts` fails with turbopack as emotion skips necessary runtime transforms for the styles. Digging further, it was due to not applying correct importSource for the transform (`@emotion/react`) against ssr component when running with turbopack. Peeking next-dev, we apply `client` side context if issuer layer origin is either ssr or pages for the browser while turbopack doesn't.

PR uses `type` for the module context as equivalent to the issuer layer, and then apply client context for the transform for those modules.

`test/e2e/app-dir/emotion-js/index.test.ts` is passing with this PR.

Closes WEB-1834
2023-10-24 21:38:20 +00:00
Zack Tanner
d6a933edbf
disable opentelemetry test in turbopack (#57361)
`experimental.instrumentationHook` is not currently supported by
Turbopack, so this skips the tests.
2023-10-24 14:15:57 -07:00
Jimmy Lai
1d185c0707
perf: avoid using raw-body for server actions (#57358)
This PR removes the usage of `raw-body` for App Router pages by parsing
the body for an action ourselves whilst assuming that it is encoded with
UTF-8. This is already what we do for the Edge Runtime version of Server
Actions and will only break if your page overrides the page encoding,
which should not happen and that we don't need to support.

This should remove a third of a serverless function zip size 


<!-- 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-24 14:15:04 -07:00
Tim Neutkens
77c03136e9
Split jsconfig-paths and jsconfig-paths-wildcard tests (#57360)
A large part of these tests are passing in Turbopack, only the wildcard
one causes an infinite resolving issue so I've split them out.

<!-- 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-24 13:58:15 -07:00
Zack Tanner
8461071d83
update turbopack test manifest (#57357) 2023-10-24 22:33:38 +02:00
OJ Kwon
cad1200131
fix(next_core): align remove trailing slash (#57344)
### What

minor fix to match behavior to ae10b5c82b/packages/next/src/shared/lib/router/utils/remove-trailing-slash.ts (L2C4-L9)

as we're seeing a panic when route is /

```
Panic: PanicInfo { payload: Any { .. }, message: Some(byte index 1 is out of bounds of ``), location: Location { file: "packages/next-swc/crates/next-core/src/next_edge/route_regex.rs", line: 202, col: 59 }, can_unwind: true, force_no_backtrace: false }
Backtrace:    0: backtrace::backtrace::libunwind::trace
```

Closes WEB-1841
2023-10-24 19:56:55 +00:00
Shu Ding
7aef93dd14
Get rid of semver from the server bundle (#57321)
This is a 6.6kB (gzipped) win for the Node.js worker size baseline. `jsonwebtoken` uses semver to ensure that the Node.js version is larger than `16.9.0` (which is always true with Next.js) so we can just alias it to be a noop function that returns `true`.
2023-10-24 18:05:56 +00:00
Jiachi Liu
8734a03ff5
fix metadata url resolving with path posix (#57343)
x-ref: [https://dev.azure.com/nextjs/next.js/_build/results?buildId=71881&view=logs&jobId=8[…]-584d-6f5c-57bad8880974&t=7ae70e63-3625-50f4-6764-5b3e72b4bd7a](https://dev.azure.com/nextjs/next.js/_build/results?buildId=71881&view=logs&jobId=8af7cf9c-43a1-584d-6f5c-57bad8880974&j=8af7cf9c-43a1-584d-6f5c-57bad8880974&t=7ae70e63-3625-50f4-6764-5b3e72b4bd7a)

Follow up for: https://github.com/vercel/next.js/pull/57265
2023-10-24 17:16:25 +00:00
Zack Tanner
fdd8bd95e0
fix async-modules test (#57320)
Doesn't seem like we need a `.babelrc` here and it's causing turbopack test failures
2023-10-24 17:03:23 +00:00
JJ Kasper
ae10b5c82b
Fix app ISR error handling (#57332)
This ensures when an error occurs during a revalidate in app router that
properly throw the error fully and don't store the error page in the
cache which matches the expected behavior for full route ISR as errors
are not meant to update the cache so that the last successful cache
entry can continue being served.

Fix was tested against the provided reproduction here
https://app-dir-example-ghl01cxtn-basement.vercel.app/

Fixes: https://github.com/vercel/next.js/issues/53195
2023-10-24 09:38:30 -07:00
Zack Tanner
63aa0fe8ac
taint flag should enable experimental react in turbopack (#57315)
Matches behavior here: https://github.com/vercel/next.js/blob/canary/packages/next/src/lib/needs-experimental-react.ts#L4
2023-10-24 16:37:37 +00:00
Wyatt Johnson
741a08bc25
fix: ensure generateStaticParams isn't required for PPR (#57333) 2023-10-24 14:18:11 +00:00
Wyatt Johnson
06b9fb7bb8
PPR Support (#57319) 2023-10-24 09:23:52 +00:00
vercel-release-bot
2fc2a52652 v13.5.7-canary.23 2023-10-24 08:22:51 +00:00
JJ Kasper
5428e5a7a1
Fix trace ignores (#57331)
Fixes some of the ignores that were moved around in
https://github.com/vercel/next.js/pull/57280

x-ref:
https://github.com/vercel/vercel/actions/runs/6620930801/job/17989126942?pr=10756
2023-10-24 00:43:34 -07:00
Donny/강동윤
2b16a745ae
feat: Add __nextjs_pure back (#57328)
### What?

Add a magic to next-swc, agina.


### Why?

It's required, but it causes some issues with build process.

### How?



Closes WEB-1838
2023-10-24 07:29:24 +00:00
Wyatt Johnson
c05a11924d
PPR Fetch Fix (#57327) 2023-10-24 06:48:26 +00:00
JJ Kasper
02fad82933
Revert "Increase build-native CI job timeout (#57314)" (#57325)
This reverts commit 003ec7a15b.

Re-adding this as a safe guard as the stalling was a real issue
2023-10-24 06:19:28 +00:00
Zack Tanner
56d74f42f4
bundle analyzer artifacts (#57307)
This uploads bundle analyzer artifacts during CI
2023-10-24 05:48:41 +00:00
vercel-release-bot
c77fec827f v13.5.7-canary.22 2023-10-24 05:34:15 +00:00
JJ Kasper
2275bf1a22
Revert "Add __nextjs_pure helper " (#57318)
This seems to be causing our Windows x86_64 next-swc build to stall for
some reason so reverting so we can unblock canaries while we investigate
further

Reverts vercel/next.js#57286

x-ref:
https://github.com/vercel/next.js/actions/runs/6620707993/job/17986458061
x-ref:
https://github.com/vercel/next.js/actions/runs/6620707993/job/17986458061
2023-10-23 22:06:36 -07:00