Commit graph

578 commits

Author SHA1 Message Date
vercel-release-bot
80a9454faf v13.3.2-canary.10 2023-04-27 10:56:05 +00:00
Josh Story
7a5ef27b5e
Preload css (#48840)
This PR implements preloading of CSS from RSC.

1. The underlying Flight protocol was extended in
https://github.com/facebook/react/pull/26502 to allow sending hints from
RSC to SSR and Client runtimes. React was updated to include these
changes.
2. We now call `ReactDOM.preload()` for each stylesheet used in a
layout/page layer

There are a few implementation details to take note of
1. we were previously using the `.browser` variant of a few React
packages. This was a holdover from when there was just browser and node
and we wanted to use the browser variant b/c we wanted the same code to
work in edge/node runtimes. React now publishes a `.edge` variant which
is like `.browser` but expects to be server only. This is necessary to
get the opt-in for `AsyncLocalStorage`.
2. Even with the above change, AsyncLocalStorage was not patched on the
global scope until after React was loaded. I moved this into a module
which is loaded first
3. The component passed to RSC's `renderToReadableStream` is not
actually part of the RSC module graph. If I tried to call
`ReactDOM.preload()` inside that function or any other function defined
inside `app-render.tsx` file it would actually see the wrong instance of
`react-dom`. I added a new export on the RSC top level export which
exposes a `preloadStyle(...)` function which just delegates to
`ReactDOM.preload(...)`. This makes the preload run in the right module
graph


~There are a couple of bugs in React that this work uncovered that I
will upstream. We may want to delay merging until they are addressed.
I'll update this comment when that is complete.~
1. ~React, during SSR, can emit a preload for a style twice in some
circumstances because late discovered stylesheets don't consider whether
a preload has already been flushed when preparing to reveal a boundary
they are within~
2. ~React, during RSC updates on the client, can preload a style that is
already in the document because it currently only looks for existing
preload links and does not consider if there is a stylesheet link with
the same href.~

~both of these issues will not break functionality, they just make the
network tab look at bit more noisy. We would expect network deduping to
prevent multiple actual loads~

The above React bugs were fixed and included now in the React update in
this PR

---------

Co-authored-by: Shu Ding <g@shud.in>
2023-04-27 12:51:52 +02:00
vercel-release-bot
ffefb31efb v13.3.2-canary.9 2023-04-27 08:27:05 +00:00
vercel-release-bot
0cfa3fce23 v13.3.2-canary.8 2023-04-27 03:40:24 +00:00
Tobias Koppers
219d1d49c7
update turbopack (#48893)
### What?

* https://github.com/vercel/turbo/pull/4700 <!-- Tobias Koppers - update
deps -->
* https://github.com/vercel/turbo/pull/4706 <!-- Tobias Koppers - make
library code less verbose in stack traces -->
* https://github.com/vercel/turbo/pull/4705 <!-- Tobias Koppers -
improve error handling in update stream -->
* https://github.com/vercel/turbo/pull/4667 <!-- Caleb Webber - remove
box_syntax -->
* https://github.com/vercel/turbo/pull/4714 <!-- Tobias Koppers - chunk
hash need to include availability root -->
* https://github.com/vercel/turbo/pull/4709 <!-- Alex Kirszenberg -
Allow the dev server socket to be reused immediately -->
* https://github.com/vercel/turbo/pull/4716 <!-- Tobias Koppers - errors
lead to consistent exit code in issue detail -->
2023-04-27 00:46:04 +02:00
Kiko Beats
1274713b1a
edge: expose Websocket constructor (#48870)
This PR make possible to use WebSocket in an Edge Function 🙂
2023-04-26 17:38:39 +02:00
vercel-release-bot
1c0c61a66c v13.3.2-canary.7 2023-04-26 08:38:47 +00:00
Tobias Koppers
5a46b01ab9
update turbopack (#48846)
* https://github.com/vercel/turbo/pull/4692 
* https://github.com/vercel/turbo/pull/4595 
* https://github.com/vercel/turbo/pull/4690 
* https://github.com/vercel/turbo/pull/4663
2023-04-26 06:55:37 +00:00
Shu Ding
287e379b92
Vendor react@experimental (#48697)
Part of #47759 (which had been reverted twice so here we only land a part of the change), relates to NEXT-926. Thanks to #48506 we can soon switch between these two channels during runtime.

Also fixes a problem of `renderKind` (only revealed after upgrading React), it should be also based on the `match` kind.
2023-04-25 14:29:02 +00:00
vercel-release-bot
9863935f44 v13.3.2-canary.6 2023-04-25 09:13:29 +00:00
Donny/강동윤
a18f50a321
fix: Update @swc/helpers to v0.5.1 (#48808)
### What?

Update `@swc/helpers` to `v0.5.1`.

### Why?

Webpack merges `@swc/helpers@v0.4.x` and `@swc/helpers@v0.5.x`, due to `resolve.alias` config in 2f6ff0dab3/packages/next/src/build/webpack-config.ts (L1070-L1072)

To workaround it, `@swc/helpers@v0.5.1` reexports from entries just like `v0.4`.

### How?

Closes WEB-948
Fixes #48593
2023-04-25 04:32:27 +00:00
vercel-release-bot
79c73887cd v13.3.2-canary.5 2023-04-25 01:30:47 +00:00
vercel-release-bot
2f6ff0dab3 v13.3.2-canary.4 2023-04-24 22:21:45 +00:00
vercel-release-bot
2196cbe405 v13.3.2-canary.3 2023-04-24 14:16:49 +00:00
Alex Kirszenberg
7fdcb172f9
Lazy DevHtmlAsset chunk generation (#48768)
This fixes a perf regression introduced in the chunking refactor, where
we would be eagerly generating all assets from the web entry and
fallback sources.

See https://github.com/vercel/turbo/pull/4679

This also brings the following updates from vercel/turbo:

* https://github.com/vercel/turbo/pull/4669 <!-- Tobias Koppers - make
the invalidation reason easier to read -->
* https://github.com/vercel/turbo/pull/4670 <!-- Tobias Koppers -
dev-server content might change any time, we can't cache them -->
* https://github.com/vercel/turbo/pull/4653 <!-- OJ Kwon -
fix(ecmascript): displayname for styled_components -->
* https://github.com/vercel/turbo/pull/4679 <!-- Alex Kirszenberg - Lazy
DevHtmlAsset chunk generation --> (this change)
2023-04-24 12:11:24 +02:00
vercel-release-bot
1e9d53ebae v13.3.2-canary.2 2023-04-24 09:23:39 +00:00
vercel-release-bot
e720a1efa4 v13.3.2-canary.1 2023-04-24 08:14:15 +00:00
vercel-release-bot
2bfde63b78 v13.3.2-canary.0 2023-04-23 21:57:48 +00:00
vercel-release-bot
6423285451 v13.3.1 2023-04-21 22:04:41 +00:00
vercel-release-bot
455de08b30 v13.3.1-canary.19 2023-04-21 20:59:00 +00:00
vercel-release-bot
a06fef0906 v13.3.1-canary.18 2023-04-21 17:50:15 +00:00
Sebastian Silbermann
db0086703e
Upgrade @types/react to latest 18.x (#48645)
Required for  https://github.com/vercel/next.js/pull/48641

[React 18 types
changelog](https://github.com/DefinitelyTyped/DefinitelyTyped/pull/56210)

Revealed some bugs in `React.Children` typings that were hidden due to
`{}` being part of `ReactNode` before 18.x types.
The rest is mostly missing `children` props types.
2023-04-21 09:33:23 +00:00
vercel-release-bot
682fb27ab4 v13.3.1-canary.17 2023-04-20 22:14:05 +00:00
JJ Kasper
652ba8a0ec
Fix version bump 2023-04-20 17:47:31 -04:00
Tobias Koppers
ec385decd3
replace defined values and add __NEXT_HAS_REWRITES define (#48628)
### What?

This fixes a problem when the router fails to load the correct JS file
from the page_loader and opts out to full refresh

### Why?

The router behaves incorrect when `__NEXT_HAS_REWRITES` is missing in
turbopack

### How?

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

### Turbopack changes

* https://github.com/vercel/turbo/pull/4650 <!-- Tobias Koppers - reduce
size of TypeType from 32bytes to 16bytes -->
* https://github.com/vercel/turbo/pull/4648 <!-- Tobias Koppers - handle
chunk register in the sync runtime.none correctly -->
* https://github.com/vercel/turbo/pull/4609 <!-- OJ Kwon -
fix(ecmascript): eval assignop to the ident -->
* https://github.com/vercel/turbo/pull/4652 <!-- Tobias Koppers - allow
to pass constant values to free var references -->
* https://github.com/vercel/turbo/pull/4649 <!-- Tobias Koppers - Image
processing improvements -->
2023-04-20 20:02:39 +02:00
Tobias Koppers
189e6a3687
use structured images with metainfo (blur placeholder) (#48531)
### What?

add support for blur placeholder generation to turbopack

add `StructuredImageModuleType` which is used with `ModuleType::Custom`
to allow importing an image as `{ url, width, height, blurDataURL,
blurWidth, blurHeight }`

in contrast to next.js with webpack this will also generate blur
placeholder in development instead of using a _next/image reference.
This should lead to more production-like experience (at the cost of a
little bit of compilation time).

turbo PR: https://github.com/vercel/turbo/pull/4621

### Why?

Turbopack was crashing on `placeholder="blur"` before.

fixes WEB-534

### Turbopack changes

* https://github.com/vercel/turbo/pull/4521 <!-- OJ Kwon -
feat(contextcondition): support InPath contextcondition -->
* https://github.com/vercel/turbo/pull/4601 <!-- Alex Kirszenberg -
Chunking Context Refactor pt. 3: Address PR comments from pt. 2 -->
* https://github.com/vercel/turbo/pull/4623 <!-- Tobias Koppers -
exclude turborepo from turbopack bench tests -->
* https://github.com/vercel/turbo/pull/4399 <!-- Leah - support
require.context -->
* https://github.com/vercel/turbo/pull/4610 <!-- OJ Kwon - test(subset):
add mdx test into subset -->
* https://github.com/vercel/turbo/pull/4624 <!-- Tobias Koppers - run
benchmarks on windows and macOS too -->
* https://github.com/vercel/turbo/pull/4620 <!-- Alex Kirszenberg - Make
ContainmentTree fully generic -->
* https://github.com/vercel/turbo/pull/4600 <!-- Tobias Koppers - add
getChunkPath method -->
* https://github.com/vercel/turbo/pull/4621 <!-- Tobias Koppers - add
turbopack-image -->
* https://github.com/vercel/turbo/pull/4639 <!-- Tobias Koppers -
restrict snapshot path for windows path length limit -->
* https://github.com/vercel/turbo/pull/4641 <!-- Tobias Koppers - put
webp behind a feature flag -->
2023-04-20 02:18:59 +02:00
Tim Neutkens
925bb3b025
Upgrade React (#48589)
Second try for #48561

<!-- 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 or adding/fixing 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: Sophie Alpert <git@sophiebits.com>
Co-authored-by: Shu Ding <g@shud.in>
2023-04-20 02:05:49 +02:00
JJ Kasper
f078da3f31 v13.3.1-canary.16 2023-04-19 19:16:09 +00:00
JJ Kasper
7f2a4ac1d2 v13.3.1-canary.15 2023-04-19 14:25:33 +00:00
JJ Kasper
7350c5fb34 v13.3.1-canary.14 2023-04-18 20:02:39 +00:00
JJ Kasper
3a133d2dde v13.3.1-canary.13 2023-04-18 12:41:57 +00:00
JJ Kasper
6106666d3e v13.3.1-canary.12 2023-04-18 07:04:31 +00:00
Maia Teegarden
43d09ce2fd
Update swc_core to v0.75.23 (#48098)
Depends on https://github.com/vercel/turbo/pull/4470

---

 - Closes https://github.com/vercel/next.js/issues/46989
 - Fixes WEB-879
 - Fixes WEB-813

---------

Co-authored-by: OJ Kwon <1210596+kwonoj@users.noreply.github.com>
Co-authored-by: Donny/강동윤 <kdy1997.dev@gmail.com>
Co-authored-by: Shu Ding <g@shud.in>
2023-04-18 08:59:52 +02:00
JJ Kasper
af64047d99 v13.3.1-canary.11 2023-04-17 22:40:37 +00:00
Connor Prussin
a92c5465ca
Make jest config serializable (#47620)
### What?

This PR ensures the jest configuration is json-serializable. It also
adds a bunch of typescript types.

### Why?

Jest requires that the configuration be json-serializable. See #47407
for details on the issues caused when it isn't. However, prior to this
commit, we were passing the entire next config as a property in the swc
jest transformer options. The next config includes some fields that are
not serializable, such as some functions.

### How?

In this PR we instead pluck the fields out of the next config that we
actually need and pass only those into the swc transformer.

This PR also adds a bunch of more precise typescript types where we were
previously just using `any`. This helps confirm that the configs are
being threaded through correctly. I think this type safety is enough to
confirm this commit and adding tests would just be redundant.

Closes NEXT-901
Fixes #47407
fix NEXT-901 ([link](https://linear.app/vercel/issue/NEXT-901))

---------

Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
Co-authored-by: Jiachi Liu <inbox@huozhi.im>
2023-04-17 18:52:52 +00:00
JJ Kasper
e329b31d90 v13.3.1-canary.10 2023-04-17 17:04:11 +00:00
Tobias Koppers
6be8c59075
app dir fixes (#48025)
### What?

* fix app dir chunking
* fix app dir 404s
* improve app dir performance
* rerender shadowportal on errors to re-add nextjs-portal to avoid empty
page
* inject polyfills before user code
* fix manifest generation

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

### Why?

App dir was very slow and lead to 404 errors

### How?

add included metadata to chunks to allow deduplicate chunk loads at
runtime
2023-04-17 17:58:33 +02:00
JJ Kasper
bc5be2f76c v13.3.1-canary.9 2023-04-17 13:46:08 +00:00
Shu Ding
f6604d4afe
Revert "Re-land "Vendor react@experimental under an experimentalReact flag"" (#48478)
Reverts vercel/next.js#48041
fix NEXT-926
2023-04-17 15:00:02 +02:00
JJ Kasper
20c5a23a90 v13.3.1-canary.8 2023-04-15 15:24:28 +00:00
Tobias Koppers
51defb249a
provide the PORT env var based on server port, update turbopack (#48347)
### What?

gives user code access to `process.env.PORT` as current server port
avoid injecting env vars into code on server

### Why?

it might need construct an addr to fetch from api routes

fixes WEB-868

### Turbopack changes

* https://github.com/vercel/turbo/pull/4565 <!-- Tobias Koppers - Bind
to IPv6 and IPv4 -->
* https://github.com/vercel/turbo/pull/4570 <!-- Tobias Koppers - review
follow ups -->
* https://github.com/vercel/turbo/pull/4585 <!-- Tobias Koppers - fixup
bind v6 PR: add missing listen call -->
* ~https://github.com/vercel/turbo/pull/4546~ <!-- Alex Kirszenberg -
Chunking Context Refactor pt. 3: Address PR comments from pt. 2 -->
* https://github.com/vercel/turbo/pull/4580 <!-- Tobias Koppers - remove
circular dependency -->
* https://github.com/vercel/turbo/pull/4582 <!-- Tobias Koppers - ignore
internal and server-relative url() in CSS -->
* https://github.com/vercel/turbo/pull/4579 <!-- Tobias Koppers - make
node bootstrap asset lazy -->
* https://github.com/vercel/turbo/pull/4581 <!-- Tobias Koppers - allow
to create stress test for client components -->
* https://github.com/vercel/turbo/pull/4584 <!-- Tobias Koppers -
improve node.js receive timeout -->
* https://github.com/vercel/turbo/pull/4583 <!-- Tobias Koppers - remove
panic since this might happen due to eventual consistency -->

fixes WEB-871
2023-04-14 23:04:14 +02:00
JJ Kasper
54fb4b6e0b v13.3.1-canary.7 2023-04-14 17:02:43 +00:00
JJ Kasper
557084a331
Fix fetch cache body handling and update edge-runtime deps (#48365)
This ensures we don't fail to return the full body when storing to
fetch-cache in edge-runtime. Also ensures the fetch cache tests are
running for Node.js v16 correctly.

Fetch handling was also failing on Node.js v16 due to react's use of
`res.clone()` being broken with undici which is fixed in the latest
version of edge-runtime so this bumps that.

x-ref: [slack
thread](https://vercel.slack.com/archives/C03S8ED1DKM/p1681310566927429)
2023-04-13 22:00:20 -07:00
Tobias Koppers
d4d779145c
refactor shared logic for turbopack-cli (#48307)
### What?

* move some shared runtime logic to turbopack
* use relative imports from internal code when possible
* move react-refresh logic to turbopack
* move benchmark code logic to turobpack

see https://github.com/vercel/turbo/pull/4553

### Why?

We want to have benchmarking again for turbopack PRs
We want to have a standalone turbopack cli (eventually)
We want to avoid duplicating the runtime code

### How?

refactoring, moving code
2023-04-13 14:54:34 +02:00
JJ Kasper
e8f6ddcae8 v13.3.1-canary.6 2023-04-13 01:22:55 +00:00
JJ Kasper
8273ba5660 v13.3.1-canary.5 2023-04-12 13:16:22 +00:00
Alex Kirszenberg
ce42173eae
Chunking Refactor pt. 2 (#47961)
See https://github.com/vercel/turbo/pull/4450

This PR updates Turbopack to turbopack-230411.2:

## Miscellaneous

* https://github.com/vercel/turbo/pull/4450 <!-- Alex Kirszenberg -
Chunking Refactor pt. 2 -->
2023-04-11 11:08:37 -07:00
JJ Kasper
b896a12867 v13.3.1-canary.4 2023-04-10 17:07:34 +00:00
Shu Ding
9c0e520896
Re-land "Vendor react@experimental under an experimentalReact flag" (#48041)
Reverts vercel/next.js#48038

fix NEXT-926

---

The root cause was that when copying the package.json, I removed all
fields except for a few (such as `exports`) but missed the `browser`
field. That caused the client bundle to resolve to the Node.js version
of React DOM, and then we had the `async_hooks` error. Added it back in
99c9b9e51f8b0d4e4503ece9d07bce09161f3341.

I reproduced the error with next-site earlier and confirmed that this
fix is good.
2023-04-08 17:16:24 +02:00
JJ Kasper
2bcdfbb6ab v13.3.1-canary.3 2023-04-08 01:47:09 +00:00