Commit graph

1630 commits

Author SHA1 Message Date
Alex Kirszenberg
38dafa1609
Turbopack: App Router build POC (#52036)
This PR adds proof-of-concept support for the App Router to `next build
--experimental-turbo`.

It introduces a new way to generate Next.js manifests in Turbopack.
Currently, in dev, we pass proxy objects in lieu of manifests, and rely
on the entries to know which chunks they need loaded on the client.
However, this can't work for builds because it requires control over
Next.js rendering, which is not compatible with a Next->Turbo approach.
We would need to modify Next.js to support these "lazy" entries. So for
now, we add well-known assets (`NextDynamicAsset`,
`NextServerComponentAsset`, `NextClientReferenceAsset`, etc.) to the
graph, which will get picked up when walking it during asset processing.
This lets us collect all possible entries before chunking.

This two-step process (collecting all entries, then chunking them) is
also a good first step towards production chunking.

## Turbopack updates

* https://github.com/vercel/turbo/pull/5494 <!-- Tobias Koppers - add
reporting of console messages -->
* https://github.com/vercel/turbo/pull/5448 <!-- Alex Kirszenberg -
Misc. changes to support App Router build -->
2023-07-12 11:26:48 +02:00
vercel-release-bot
2441ad4760 v13.4.10-canary.4 2023-07-12 06:45:31 +00:00
OJ Kwon
09ef9b48d7
feat(turbopack): support swc transform plugins (#50401)
### What?
WEB-998

This PR enables experimental swc transform plugin support in turbopack.
2023-07-11 22:19:36 +00:00
Tobias Koppers
56fcd7ac33
Turbopack: Source trait (#52511)
### What?

refactoring see https://github.com/vercel/turbo/pull/5483

### Turbopack Changes

* https://github.com/vercel/turbo/pull/5483 <!-- Tobias Koppers - Source
trait -->
2023-07-11 12:34:32 +02:00
vercel-release-bot
63a6cdaf53 v13.4.10-canary.3 2023-07-10 23:02:55 +00:00
vercel-release-bot
4e710645f8 v13.4.10-canary.2 2023-07-10 14:44:00 +00:00
Tobias Koppers
8643014b13
turbopack: Module Trait (#52401)
### What?

refactoring see https://github.com/vercel/turbo/pull/5477

---------

Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2023-07-10 14:35:53 +02:00
vercel-release-bot
62c2c5abc2 v13.4.10-canary.1 2023-07-10 08:01:26 +00:00
Justin Ridgewell
9ccc6fc4a6
[turbopack]: Remove skipped integration tests (#52421)
https://github.com/vercel/next.js/pull/52413 removed all of our skipped tests, and the test suite that runs them will panic if none are found as a safety feature.
2023-07-07 23:41:07 +00:00
Alex Kirszenberg
b8589dfdb0
Update Rust nightly toolchain (#51757)
Matching turbo PR: https://github.com/vercel/turbo/pull/5376

## Turbopack updates

* https://github.com/vercel/turbo/pull/5376 <!-- Alex Kirszenberg -
Update nightly toolchain -->
2023-07-07 18:17:07 -04:00
Will Binns-Smith
d660bc906f
Remove integration tests now in vercel/turbo (#52413)
These tests were moved into vercel/turbo in https://github.com/vercel/turbo/pull/5415.
2023-07-07 20:35:07 +00:00
Donny/강동윤
d11aafb740
Update swc_core to v0.79.13 (#52371)
### What?

Update SWC crates to `v0.79.13`.

### Why?

 - Explicit resource management proposal is now fully implemented, although it's behind a parser flag because it's stage 3
 - Some bugs of `swcMinify` are fixed.

### How?

Closes WEB-1272

## Turbopack updates

* https://github.com/vercel/turbo/pull/5475 


Co-authored-by: Alex Kirszenberg <1621758+alexkirsz@users.noreply.github.com>
2023-07-07 19:37:05 +00:00
Alex Kirszenberg
ffc471cdc7
Turbopack: Use a different chunking context for web entry (#52404)
This fixes Turbopack integration tests.

In https://github.com/vercel/next.js/pull/51928, I made it so all dev chunking contexts output to the same directory. However, in the case of the web entry source, this can lead to conflicts. This PR ensures the chunking context is different for that one case.
2023-07-07 16:28:18 +00:00
vercel-release-bot
b2c6bc4572 v13.4.10-canary.0 2023-07-07 11:14:32 +00:00
Tobias Koppers
a3d5a855eb
add incremental cache for node.js app rendering (#52172)
### What?

adds `incrementalCache` to app rendering to add support for
`unstable_cache`
2023-07-07 11:33:51 +02:00
Alex Kirszenberg
1c2de8330c
Make get_client_chunking_context independent of context (#51928)
The client chunking context must remain the same for a given Next.js compilation. For production builds, we only need to create it once for both the Pages Router and the App Router. As such, it doesn't make sense for it to accept a context type, at least not as an enum. A vector of enums or flags could also work. Considering the only case where the chunking context differes today is the web entry source, we might as well make the web entry source also serve under `_next` (or remove it entirely?).
2023-07-06 22:06:31 +00:00
vercel-release-bot
1045644655 v13.4.9 2023-07-06 20:50:37 +00:00
vercel-release-bot
21392cb4e0 v13.4.9-canary.3 2023-07-06 17:07:58 +00:00
Steven
914158607f
chore: fix next dev turbopack benchmark (#52328)
This is a follow up to PR https://github.com/vercel/next.js/pull/52291
which removed the `next.config.js` which started causing an error during
CI:

```
@next/swc:test-cargo-bench: error: couldn't read packages/next-swc/crates/next-dev/benches/next.config.js: No such file or directory (os error 2)
@next/swc:test-cargo-bench:   --> packages/next-swc/crates/next-dev/benches/bundler.rs:74:13
@next/swc:test-cargo-bench:    |
@next/swc:test-cargo-bench: 74 |             include_bytes!("next.config.js"),
@next/swc:test-cargo-bench:    |             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@next/swc:test-cargo-bench:    |
@next/swc:test-cargo-bench:    = note: this error originates in the macro `include_bytes` (in Nightly builds, run with -Z macro-backtrace for more info)
@next/swc:test-cargo-bench: 
@next/swc:test-cargo-bench: error: could not compile `next-dev` (bench "mod") due to previous error
@next/swc:test-cargo-bench: warning: build failed, waiting for other jobs to finish...
@next/swc:test-cargo-bench:  ELIFECYCLE  Command failed with exit code 101.
```

https://github.com/vercel/next.js/actions/runs/5476339074/jobs/9973767389#step:27:959
2023-07-06 08:58:25 -07:00
Alex Kirszenberg
ec19537127
Named page chunks (#51921)
Depends on https://github.com/vercel/turbo/pull/5398 (and downstack) on
the Turbo side.

This PR makes it so the output path of Node.js entry chunks for pages is
determined solely from the pathname. This isn't actually necessary for
pages, but it makes for easier debugging anyway. See the Turbo PR for
more details.

This also changes the page structure so it also works if there is no
`pages` directory. In this case, we still want to use pages' default
_app, _document, and _error pages, even with existing app routes. So an
empty page structure should still have an effect.

## Turbopack updates

* https://github.com/vercel/turbo/pull/5415 <!-- Will Binns-Smith -
Turbopack: Execution tests in node.js -->
* https://github.com/vercel/turbo/pull/5461 <!-- Tobias Koppers - use a
lock to ensure atomic invalidation from file changes -->
* https://github.com/vercel/turbo/pull/5398 <!-- Alex Kirszenberg -
Configure the path of the Node.js entry chunk -->
* https://github.com/vercel/turbo/pull/5469 <!-- Tobias Koppers - allow
hmr tests to correctly detect hmr event -->
2023-07-06 16:31:22 +02:00
Steven
6dafc4229d
chore(deps): bump react to 7118f5dd7 (#52282)
Fixes #49409

### React upstream changes

- https://github.com/facebook/react/pull/27045
- https://github.com/facebook/react/pull/27051
- https://github.com/facebook/react/pull/27032
- https://github.com/facebook/react/pull/27031
- https://github.com/facebook/react/pull/27029
- https://github.com/facebook/react/pull/27028
- https://github.com/facebook/react/pull/27027
- https://github.com/facebook/react/pull/27019
- https://github.com/facebook/react/pull/26954
- https://github.com/facebook/react/pull/26987
- https://github.com/facebook/react/pull/26985
- https://github.com/facebook/react/pull/26933
- https://github.com/facebook/react/pull/26625
- https://github.com/facebook/react/pull/27011
- https://github.com/facebook/react/pull/27008
- https://github.com/facebook/react/pull/26997
- https://github.com/facebook/react/pull/26989
- https://github.com/facebook/react/pull/26955
- https://github.com/facebook/react/pull/26963
- https://github.com/facebook/react/pull/26983
- https://github.com/facebook/react/pull/26914
- https://github.com/facebook/react/pull/26951
- https://github.com/facebook/react/pull/26977
- https://github.com/facebook/react/pull/26958
- https://github.com/facebook/react/pull/26940
- https://github.com/facebook/react/pull/26939
- https://github.com/facebook/react/pull/26887
- https://github.com/facebook/react/pull/26947
- https://github.com/facebook/react/pull/26945
- https://github.com/facebook/react/pull/26942
- https://github.com/facebook/react/pull/26938
- https://github.com/facebook/react/pull/26844
- https://github.com/facebook/react/pull/25510
- https://github.com/facebook/react/pull/26932
- https://github.com/facebook/react/pull/26896
- https://github.com/facebook/react/pull/26913
- https://github.com/facebook/react/pull/26888
- https://github.com/facebook/react/pull/26827
- https://github.com/facebook/react/pull/26889
- https://github.com/facebook/react/pull/26877
- https://github.com/facebook/react/pull/26873
- https://github.com/facebook/react/pull/26880
- https://github.com/facebook/react/pull/26842
- https://github.com/facebook/react/pull/26858
- https://github.com/facebook/react/pull/26754
- https://github.com/facebook/react/pull/26753
- https://github.com/facebook/react/pull/26881

---------

Co-authored-by: Jiachi Liu <inbox@huozhi.im>
2023-07-06 14:04:21 +02:00
Steven
525ffb4334
chore: remove experimental appDir: true from tests (#52291)
The experimental flag is no longer needed.

https://nextjs.org/blog/next-13-4
2023-07-05 19:17:29 -07:00
JJ Kasper
3fb3bbbcb3
Disable flakey turbopack env test (#52295)
x-ref: [slack
thread](https://vercel.slack.com/archives/C04KC8A53T7/p1688583522551569?thread_ts=1688581436.174189&cid=C04KC8A53T7)
2023-07-05 17:05:31 -07:00
JJ Kasper
5046ee13aa
Revert "Fix stream cancellation in RenderResult.pipe() and sendResponse()" (#52277)
The test here seems to be failing after merge 

x-ref:
https://github.com/vercel/next.js/actions/runs/5467319221/jobs/9953529745
x-ref:
https://github.com/vercel/next.js/actions/runs/5467152519/jobs/9953132439

Reverts vercel/next.js#52157
2023-07-05 11:12:39 -07:00
Justin Ridgewell
ff1f75a873
Fix stream cancellation in RenderResult.pipe() and sendResponse() (#52157)
### What?

I've found 2 more spots that didn't properly cancel the streaming response when the client disconnects. This fixes `RenderResult.pipe()` (called during dynamic render results) and `sendResponse()` (used during Route Handlers using `nodejs` runtime).

It also (finally) adds tests for all the cases I'm aware of.

### Why?

To allow disconnecting from an AI service when a client disconnects. $$$

### How?

Just checks for `response.closed`, which will be closed when the client's connection disconnects.
2023-07-05 17:15:48 +00:00
OJ Kwon
6885b98d35
feat(turbopack): add crypto polyfill (#51622)
### What?

PR attempts to fix WEB-1214, provides a polyfill to globalThis.crypto.
2023-07-05 14:38:34 +00:00
Shu Ding
13e769a301
Improve error message when using per function "use server" in Client Components (#52214)
The current message isn't very clear about `"use server" function` and
`"use server" file`, and there's no link to docs to explain it further:

```
"use server" functions are not allowed in client components. 
You can import them from a "use server" file instead.
```

This PR makes it a bit more verbose:

```
It is not allowed to define inline "use server" annotated Server Actions in Client Components.
You can either mark the entire file by putting "use server" at the top, or pass them down through props from a Server Component.

Read more: https://nextjs.org/docs/app/building-your-application/data-fetching/server-actions#with-client-components
```
2023-07-05 14:34:36 +02:00
vercel-release-bot
0b470753b7 v13.4.9-canary.2 2023-07-05 10:26:56 +00:00
Alex Kirszenberg
3406e13ab0
Update Turbopack (#52198)
## Turbopack updates

* https://github.com/vercel/turbo/pull/5457 
* https://github.com/vercel/turbo/pull/5458
2023-07-04 15:56:09 +00:00
Alex Kirszenberg
13cfc2bf4d
Update CustomModuleType import (#52133)
https://github.com/vercel/turbo/pull/5397

## Turbopack updates

* https://github.com/vercel/turbo/pull/5419 
* https://github.com/vercel/turbo/pull/5397
2023-07-04 12:39:41 +00:00
Tobias Koppers
532f779782
update turbopack (#52186)
* https://github.com/vercel/turbo/pull/5395 
* https://github.com/vercel/turbo/pull/5452
2023-07-04 11:54:40 +00:00
Tobias Koppers
df82f1ac8a
disable flaky test cases (#52184)
### What?

These test cases are too unreliable

---------

Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2023-07-04 12:50:18 +02:00
vercel-release-bot
4f75c79938 v13.4.9-canary.1 2023-07-04 08:30:06 +00:00
Tobias Koppers
b8ae8d210a
update tests list to include all passing tests (#52026)
### What?

Add all passing tests

### Why?

We enforced that they all run turbopack and these are passing.
If any of these tests would become red, that indicated a problem.
2023-07-04 07:40:50 +00:00
vercel-release-bot
f60b5621ac v13.4.9-canary.0 2023-07-04 00:05:08 +00:00
Shu Ding
3a87f0005e
Change the Server Actions feature flag to be validated at compile time (#52147)
Currently we are validating the `experimental.serverActions` flag when creating the actual entries for Server Actions, this causes two problems. One is that syntax errors caught at compilation time are still shown, even if you don't have this flag enabled. Another problem is we still traverse the client graph to collect these action modules even if the flag isn't enabled.

This PR moves that check to be happening at compilation time, which addresses the two above but also brings the extra benefit of showing the exact span and module trace that errors:

<img width="974" alt="CleanShot 2023-07-03 at 20 26 34@2x" src="https://github.com/vercel/next.js/assets/3676859/1676b1f6-e205-4963-bce4-5b515a698e9c">
2023-07-03 20:29:57 +00:00
Jiachi Liu
cd9372c175
Reland "ReverseTopological -> AdjacencyMap"" (#52142)
Reverts vercel/next.js#52139
2023-07-03 19:13:50 +00:00
vercel-release-bot
b4a875eb57 v13.4.8 2023-07-03 17:00:28 +00:00
Jiachi Liu
4b4731dfbe
Revert "ReverseTopological -> AdjacencyMap" (#52139)
Reverts vercel/next.js#52032

Will reland after the release
2023-07-03 16:33:24 +00:00
Alex Kirszenberg
f6a152287a
ReverseTopological -> AdjacencyMap (#52032)
See https://github.com/vercel/turbo/pull/5430

## Turbopack changes

* https://github.com/vercel/turbo/pull/5430 <!-- Alex Kirszenberg -
ReverseTopological -> AdjacencyMap -->
2023-07-03 14:40:41 +02:00
vercel-release-bot
eca315308a v13.4.8-canary.15 2023-07-03 10:21:27 +00:00
Alex Kirszenberg
805bfa45e0
Remove EnvironmentIntention (#51965)
See https://github.com/vercel/turbo/pull/5420

# Turbopack changes

* https://github.com/vercel/turbo/pull/5420 
* https://github.com/vercel/turbo/pull/5387
2023-07-03 09:03:37 +00:00
vercel-release-bot
9f6cf08fd4 v13.4.8-canary.14 2023-06-30 22:36:17 +00:00
Tobias Koppers
d443778163
Refactor ContentSources to RouteTree (#51660)
### What?

This fixes a performance problem when many pages are involved.

fixes WEB-1067

see also https://github.com/vercel/turbo/pull/5360

### Turbopack Changes

* https://github.com/vercel/turbo/pull/5416 
* https://github.com/vercel/turbo/pull/5360
2023-06-30 16:03:24 +00:00
Jiachi Liu
4bfc1eaf54
Revert "Optimize inlined Flight data array format" (#52039)
Reverts vercel/next.js#52028

revert temporarily and will re-land in next round release
2023-06-30 16:12:31 +02:00
Shu Ding
0123a9d5c9
Optimize inlined Flight data array format (#52028)
When looking at [some sites](https://rsc-llm-on-the-edge.vercel.app/) with a large amount of chunks streamed, I noticed that the inlined Flight data array can be optimized quite a lot. Currently we do:

```js
self.__next_f.push([1,"d5:[\"4\",[\"$\",\"$a\",null,..."])
```

1. The `self.` isn't needed (except for the initial bootstrap tag) as React itself has `<script>$RC("B:f","S:f")</script>` too.
2. After the bootstrap script tag, all items are an array with `[1, flight_data]` and `flight_data` is always a string. We can just push only these strings.
3. We use `JSON.stringify(flight_payload)` to inline the payload where the payload itself is a string with a lot of double quotes (`"`), this results in a huge amount of backslashes (`\`). Here we can instead replace it to use a pair of single quotes on the outside and un-escape the double quotes inside.

Here's a side-by-side comparison of a small page:

<img width="1710" alt="CleanShot 2023-06-30 at 11 41 02@2x" src="https://github.com/vercel/next.js/assets/3676859/398356ec-91d5-435c-892d-16fb996029e8">

For a real production page I saw the HTML payload reduced by 11,031 bytes, a 3% improvement.

Note that all the tests are not considering gzip here, so the actual traffic impact will be smaller.
2023-06-30 13:27:38 +00:00
vercel-release-bot
0dd225b128 v13.4.8-canary.13 2023-06-30 12:25:06 +00:00
vercel-release-bot
27953213f8 v13.4.8-canary.12 2023-06-29 23:30:23 +00:00
Delba de Oliveira
18406adf9c
Make sure DevEx can approve docs PRs / Remove Spaces (#51996) 2023-06-29 17:10:53 +00:00
vercel-release-bot
152cfed6e8 v13.4.8-canary.11 2023-06-29 15:40:12 +00:00