Commit graph

1266 commits

Author SHA1 Message Date
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
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
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
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
Toru Kobayashi
7b6e336bc5
docs: fix minimum Node.js version to 14.18.0 (#48545)
fixes #42729

According to #42729, the minimum Node.js version of Next is `14.18.0`,
but some docs say `14.6.0`, and it's error-prone.
https://github.com/vercel/next.js/issues/42729#issuecomment-1309947579
pointed out it's a bug rather than wrong documentation.

But Node v14 is going to be EOF this month, so Next will update the
minimum version in the next major release.
https://github.com/nodejs/release#release-schedule

So I feel it's enough to only fix the documentation rather than fixing
the implementation to work with 14.6.0 as a temporary fix.


<!-- 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: Steven <steven@ceriously.com>
2023-04-19 15:16:37 +00:00
Jan Kaifer
902bb40454
Remove unused code from test-pack turbo task (#48487)
We decided in https://github.com/vercel/next.js/pull/48308 that we won't
use `turbo` when packing packages for tests.

This PR removes all code associated with that effort. The whole thing
fas behind a flag, so it shouldn't affect anything.
fix NEXT-1025
2023-04-18 12:12:00 +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
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
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
9448913149
Revert "Vendor react@experimental under an experimentalReact flag" (#48038)
x-ref: [slack
thread](https://vercel.slack.com/archives/C04DUD7EB1B/p1680804950611789?thread_ts=1680791613.468109&cid=C04DUD7EB1B)

Reverts vercel/next.js#47759
fix NEXT-926
2023-04-06 11:48:09 -07:00
Tobias Koppers
dec037a421
fix lint issue (#48023)
### What

Docs changes need to be linted for language
2023-04-06 17:16:29 +02:00
Shu Ding
89b4605f1a
Vendor react@experimental under an experimentalReact flag (#47759)
Next.js includes various feature sets that depend on specific release
channels of React. However, our current setup only includes the `next`
channel of React, which restricts our ability to integrate with features
available on the `experimental` channel.

To address this limitation, this pull request introduces the following
changes:
- Vendors the `react@experimental` version, along with the corresponding
`react-dom` and `scheduler` packages.
- Modifies the `sync-react` script to also update the `experimental`
channel and removes `--version` as they're always synced to the latest
now.
- Retains the default behavior of using the `next` channel in the
`appDir` directory.
- Adds an option to switch to the `experimental` channel by setting
`experimental.experimentalReact: true` in the configuration.

fix NEXT-926 ([link](https://linear.app/vercel/issue/NEXT-926))
2023-04-05 14:05:47 +00:00
Jiachi Liu
d71cbe9116
Vendor @vercel/og and expose ImageResponse (#47715)
- Reverts #47711 
- Disable image response for turbopack
2023-03-31 02:29:10 +00:00
JJ Kasper
2ac022391c
Revert "Vendor @vercel/og and expose ImageResponse (#47657" (#47711)
Reverts vercel/next.js#47657
2023-03-30 12:24:02 -07:00
Shu Ding
6eaca5d5b2
Revert "Revert "Update vendored react to 18.3.0-next-85de6fde5-20230328"" (#47700
Reverts vercel/next.js#47687
2023-03-30 19:40:13 +02:00
Jiachi Liu
99cdb36663
Vendor @vercel/og and expose ImageResponse (#47657
### What?

This PR vendors @vercel/og and export `ImageResponse` from
`next/server`. When you render a opengraph image the below code snippets
will be legit:

```tsx
import { ImageResponse } from 'next/server'

export default function og() {
  return new ImageResponse(<div style={{ width: '100%', height: '100%' }}>hello</div>)
}
```

### Why?

To make development more easier, user can directly use `@vercel/og`
Image Response with nextjs instead of install it and use it. This makes
building metadata icons, og or twitter images more convenient.

### How?

Closes NEXT-899
2023-03-30 13:06:30 +02:00
Shu Ding
90922acd73
Revert "Update vendored react to 18.3.0-next-85de6fde5-20230328" (#47687)
Reverts vercel/next.js#47675
2023-03-30 11:06:04 +00:00
Jiachi Liu
0a94e2221f
Update vendored react to 18.3.0-next-85de6fde5-20230328 (#47675)
Changelog from react side

```
-  85de6fde5 Refactor DOM special cases per tags including controlled fields (#26501) (Sebastian Markbåge)
-  5cbe6258b Remove unnecessary CIRCLE_CI_API_TOKEN checks (#26499) (Mengdi Chen)
-  1f5cdf8c7 Update Suspense fuzz tests to use `act` (#26498) (Andrew Clark)
-  f62cb39ee Make disableSchedulerTimeoutInWorkLoop a static ff (#26497) (Ricky)
-  f71819931 [DevTools] browser extension: improve script injection logic (#26492) (Mengdi Chen)
-  41b4714f1 Remove disableNativeComponentFrames (#26490) (Ricky)
-  fc90eb636 Codemod more tests to waitFor pattern (#26494) (Andrew Clark)
-  e0bbc2662 Improve tests that deal with microtasks (#26493) (Andrew Clark)
-  8faf75193 Codemod some expiration tests to waitForExpired (#26491) (Andrew Clark)
-  8342a0992 Remove unused feature flag disableSchedulerTimeoutBasedOnReactExpirationTime (#26488) (Jan Kassens)
-  afea1d0c5 [flow] make Flow suppressions explicit on the error (#26487) (Jan Kassens)
-  768f965de Suspensily committing a prerendered tree (#26434) (Andrew Clark)
-  d12bdcda6 Fix Flow types of useEffectEvent (#26468) (Sebastian Silbermann)
-  73b6435ca [Float][Fiber] Implement waitForCommitToBeReady for stylesheet resources (#26450) (Josh Story)
-  175962c10 Fix remaining CommonJS imports after Rollup upgrade (#26473) (dan)
-  3fcf209ea React DevTools 4.27.3 -> 4.27.4 (#26470) (Mengdi Chen)
-  bde974ae4 [DevTools] missing file name in package.json (#26469) (Mengdi Chen)
-  909c6dacf Update Rollup to 3.x (#26442) (Mark Erikson)
-  9c54b29b4 Remove ReactFabricPublicInstance and used definition from ReactNativePrivateInterface (#26437) (Rubén Norte)
-  f77099b6f Remove layout effect warning on the server (#26395) (Ricky)
-  51a7c45f8 Bugfix: SuspenseList incorrectly forces a fallback (#26453) (Andrew Clark)
-  afb3d51dc Fix enableClientRenderFallbackOnTextMismatch flag (#26457) (Sebastian Markbåge)
-  8e17bfd14 Make InternalInstanceHandle type opaque in ReactNativeTypes (#26461) (Rubén Norte)
-  8bdf162bc React DevTools 4.27.2 -> 4.27.3 (#26459) (Mengdi Chen)
-  b93b4f074 Should not throw for children of iframe or object (#26458) (Sebastian Markbåge)
-  c0b34bc5f chore: update links of docs and api (#26455) (Leedom)
-  56f7a90e6 chore: update new docs links for react-dom (#26456) (Leedom)
-  bd5e32309 Small Flow upgrade to 0.202.0 (#26435) (Jan Kassens)
-  ffb6733ee fix docs link for useSyncExternalStore (#26452) (Valor(华洛))
-  0018cf224 Add REVISION file to react-fbsource-import (#26448) (Samuel Susla)
```

Also merge react and react-server-dom-webpack vendor job into one
2023-03-29 23:21:33 +00:00
JJ Kasper
bd8ba61bca
Update release package.json scripts (#47529)
We should no longer be starting releases from local and instead use the
GH action so this updates the scripts to point to there.
2023-03-25 12:59:51 -07:00
JJ Kasper
8b761ce453
Update version script 2023-03-23 22:49:36 -07:00
JJ Kasper
d0bdd8f230
Add workflow to trigger release (#47461)
As discussed this adds a publish workflow that can be triggered for
canary or stable releases which ensures we are publishing from a
consistent environment and local config doesn't affect a release.
2023-03-23 16:28:49 -07:00
Jiachi Liu
9150620993
Support dynamic routes for social images and icons (#47425)
Redo #47372 , basically revert #47416 and upgrade og (https://github.com/vercel/og/pull/60)

Closes NEXT-264
Closes NEXT-266
2023-03-23 00:12:22 +00:00
Shu Ding
1d407f27a5
upgrade vendored React to 18.3.0-next-12a1d140e-20230321 (#47405)
Includes the following upstream changes:

- 12a1d140e Don't prerender siblings of suspended component (#26380)
(Andrew Clark)
- 77ba1618a Bugfix: Remove extra render pass when reverting to client
render (#26445) (Andrew Clark)
- 520f7f3ed Refactor ReactDOMComponent to use flatter property
operations (#26433) (Sebastian Markbåge)
- 0131d0cff Check if suspensey instance resolves in immediate task
(#26427) (Andrew Clark)
- 3554c8852 Clean interface for public instances between React and React
Native (#26416) (Rubén Norte)
- c57b90f50 [DiffTrain] Add artifacts for React Native to compiled
(#26204) (Samuel Susla)
- 842bd787a Fix sizebot not working due to missing auth token (#26423)
(Andrew Clark)
- db281b3d9 Feature: Suspend commit without blocking render (#26398)
(Andrew Clark)
-  6310087f0 [ci] Fix download_base_build_for_sizebot (#26422) (lauren)
-  6854a3cf6 [difftrain] Fix broken workflow (#26421) (lauren)
- 55308554e [www] enable enableFilterEmptyStringAttributesDOM flag
(#26410) (Jan Kassens)
-  163d86e19 Updated comment message (#26158) (Ibrahim Amin)
- 108aed083 Fix use of stale props in Fabric events (#26408) (Rubén
Norte)
- 8fa41ffa2 Don't "fix up" mismatched text content with
suppressedHydrationWarning (#26391) (Sebastian Markbåge)
-  87c803d1d Fix a test case in ReactUpdates-test (#26399) (Tianyu Yao)
- eaccf27c2 Revert "Remove hydrate entry point from www builds" (#26413)
(Jan Kassens)
- 480aa7785 Remove hydrate entry point from www builds (#26400)
(Sebastian Markbåge)
- 9941cbaca Fix devtools tests after internal test changes (#26405)
(Ricky)
- e4606c1e0 Add missing `"react-dom/server.bun"` entry in package.json
`"exports"` (#26402) (Jarred Sumner)
- 05777ffb0 Setting transition pending flag shouldn't be part of a
surrounding transition (#26243) (Sophie Alpert)
-  21f6dba6a Sync from oss-experimental, not oss-stable (#26401) (Ricky)
-  99aa082be Remove unstable_flushControlled (#26397) (Jan Kassens)
- 47cf4e578 Restore some guards in ReactFabricGlobalResponderHandler
after refactor (#26394) (Rubén Norte)
- cfc1274e3 Disable IE innerHTML workaround behind a flag (#26390)
(Sebastian Markbåge)
- a57f40d83 Undo dependency injection of batching (#26389) (Sebastian
Markbåge)
- d310d654a Avoid meta programming to initialize functions in module
scope (#26388) (Sebastian Markbåge)
-  21aee59e4 Delete unused DOM files (#26387) (Sebastian Markbåge)
- 56a3c18e5 [Flight fixture] Remove redundant `use` (#26373) (Andrew
Clark)
- 6bd53a5bd Remove FeatureFlags fork for `react-dom/unstable_testing`
(#26383) (Sebastian Markbåge)
- 2788d0d8d Allow empty string to be passed to formAction (#26379)
(Sebastian Markbåge)
- f828bad38 Extracted definition and access to public instances to a
separate module in Fabric (#26321) (Rubén Norte)
- cd20376f0 Remove internal `act` from DevTools e2e test (#26376)
(Andrew Clark)
-  131768166 Support Context as renderable node (#25641) (Andrew Clark)
- d4f58c3b8 Support Promise as a renderable node (#25634) (Andrew Clark)
- f411e8990 Remote `.internal` override from untrusted URL tests
(#26372) (Andrew Clark)
- 633461486 Add disableLegacyContext test gates where needed (#26371)
(Andrew Clark)
- 432ffc9d0 Convert more Scheduler.unstable_flushAll in tests to new
test utils (#26369) (Tianyu Yao)
- 774111855 [Flight Fixture] Fix proxying with compression (#26368)
(Sebastian Markbåge)
- 69fd78fe3 Update Float tests to check for specific errors (#26367)
(Andrew Clark)
- 93c10dfa6 flushSync: Exhaust queue even if something throws (#26366)
(Andrew Clark)
- a22bd995c [DevTools] prevent StyleX plugin from throwing when
inspecting CSS (#26364) (Mengdi Chen)
- be353d251 [Flight Reply] Add undefined and Iterable Support (#26365)
(Sebastian Markbåge)
- ef8bdbecb [Flight Reply] Add Reply Encoding (#26360) (Sebastian
Markbåge)
- a8875eab7 Update more tests to not rely on sync queuing (#26358)
(Andrew Clark)
- d1ad984db [Flight] Add support for returning `undefined` from render
(#26349) (Sebastian Silbermann)
- 39d4b9365 [Internal tests] Close MessageChannel port to prevent leak
(#26357) (Andrew Clark)
2023-03-22 13:26:46 -07:00
JJ Kasper
84a416b5e1
Fix build spinner in TTY env (#47383)
This ensures the build spinner is correctly stopped in a TTY environment
and also adds regression tests for `app` and `pages` to ensure this
behaves as expected.

This updates our docker image to use the `jammy` tag instead of `focal`
to match the Ubuntu version to our CI.
2023-03-22 12:56:39 -07:00
Steven
7060b8c9ef
Revert "Support dynamic routes for social images and icons" (#47416
Reverts vercel/next.js#47372

```
Error occurred prerendering page "/apple-icon". Read more: https://nextjs.org/docs/messages/prerender-error
Error: The `ImageResponse` API is not supported in this runtime, use the `unstable_createNodejsStream` API instead or switch to the Vercel Edge Runtime.
    at new ImageResponse (/tmp/next-install-db63e2a2f25e9feda48affa69456fcbdde8d89bf94645e42abd2aa522224f432/.next/server/chunks/558.js:26416:19)
    at appleIcon (/tmp/next-install-db63e2a2f25e9feda48affa69456fcbdde8d89bf94645e42abd2aa522224f432/.next/server/app/apple-icon/route.js:127:12)
```


https://github.com/vercel/next.js/actions/runs/4490842502/jobs/7899302486#step:6:305
2023-03-22 20:24:09 +01:00
Jiachi Liu
bbd79ac997
Support dynamic routes for social images and icons (#47372)
Allow image responses returning from dynamic image routes for og/twitter
images, and icon/apple-icon images. This PR supports the basic
functionalities for nodejs runtime of image routes. `@vercel/og` is able
to be leveraged for generating dynamic image responses.

Close NEXT-264
Close NEXT-266

---------

Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2023-03-22 15:19:50 +01:00
Will Binns-Smith
66b346ed23
Don't set git config features.manyFiles on post install (#47375)
This reverts #31408, as it also sets the git config value
`index.skipHash` which breaks cargo at the moment:
https://github.com/rust-lang/cargo/issues/11857

Contributors docs have been updated to recommend a shallow clone in
#44158, which should alleviate some of the issues that manyFiles
addresses.
2023-03-21 16:40:44 -07:00
Jan Kaifer
53f29cd633
Add OTEL tests (#47149) 2023-03-16 16:35:07 +00:00
Balázs Orbán
8c98a207f2
feat(cli): introduce --tailwind flag (#46927)
### What?

This PR introduces a new `--tailwind` flag to the `create-next-app` CLI,
to make it easier to bootstrap a Next.js app with Tailwind CSS
pre-configured. This is going to be the **default**. To opt-out of
Tailwind CSS, you can use the `--no-tailwind` flag.

### Why?

Tailwind CSS is one of the most popular styling solutions right now, and
we would like to make it easier to get started.

Currently, the closest you can come to this is by running `pnpm create
next-app -e with-tailwindcss` which will clone the
https://github.com/vercel/next.js/tree/canary/examples/with-tailwindcss
example. But that example is not configured for the App Router. This PR
will let you add Tailwind CSS to both `app/`, `pages/`, and start out
with TypeScript or JavaScript via the CLI prompts.

(Some community feedback
https://twitter.com/dev_jonaskaas/status/1632367991827443713,
https://twitter.com/samselikoff/status/1634662473331617794)

### How?

We are adding 4 new templates to the CLI bundle.

> Note: The styling is not pixel-perfect compared to the current
templates (using CSS modules) to require fewer overrides, but I tried to
match it as close as possible. Here are a few screenshots:

<details>
<summary><b>Current, light</b></summary>
<img
src="https://user-images.githubusercontent.com/18369201/224733372-9dba86fe-9191-471d-ad9f-ab904c47f544.png"/>
</details>

<details>
<summary><b>Tailwind (new), light</b></summary>
<img
src="https://user-images.githubusercontent.com/18369201/224733610-038d9d0f-634d-4b69-b5c2-a5056b56760c.png"/>
</details>

<details>
<summary><b>Current, dark, responsive</b></summary>
<img
src="https://user-images.githubusercontent.com/18369201/224733790-9b4d730c-0336-4dbe-bc10-1cae1d7fd145.png"/>
</details>

<details>
<summary><b>Tailwind (new), dark, responsive</b></summary>
<img
src="https://user-images.githubusercontent.com/18369201/224734375-28384bbc-2c3a-4125-8f29-c102f3b7aa1d.png"/>
</details>

#### For reviewers

This introduces 4 new templates, with a very similar code base to the
original ones. To keep the PR focused, I decided to copy over duplicate
code, but we could potentially create a shared folder for files that are
the same across templates to somewhat reduce the CLI size. Not sure if
it's worth it, let me know. Probably fine for now, but something to
consider if we are adding more permutations in the future.

---

~Work remaining:~

- [x] app+ts
	- [x] layout
	- [x] dark mode
	- [x] media queries
	- [x] animations
- [x] app+js
- [x] pages+ts
- [x] pages+js
- [x] prompt/config
- [x] deprecate Tailwind CSS example in favor of CLI
- [x] update docs
- [x] add test
- [x] add [Prettier
plugin](https://github.com/tailwindlabs/prettier-plugin-tailwindcss)
 
Closes NEXT-772
Related #45814, #44286
2023-03-16 16:06:27 +01:00
Jiachi Liu
1e7f4a58fe
Update vendored react (#46970)
Update to latest next channel of react

mainly for https://github.com/facebook/react/pull/26353

```
-  3706edb81 [Float][Fizz]: Don't preload nomodule scripts (#26353) (Josh Story)
-  2b003a5cc Split out ServerReferenceMetadata into Id and Bound Arguments (#26351) (Sebastian Markbåge)
-  62cd5af08 Codemod redundant async act scopes (#26350) (Andrew Clark)
-  037378202 Internal `act`: Call scope function after an async gap (#26347) (Andrew Clark)
-  d8e49f2af Use setTimeout to schedule work on the server in Edge environments (#26348) (Sebastian Markbåge)
-  83643778b Internal test helpers: Use Node's MessageChannel to queue task (#26345) (Andrew Clark)
-  f36ab0e37 Remove timers from ReactDOMSuspensePlaceholder tests (#26346) (Andrew Clark)
-  44d380794 Move internalAct to internal-test-utils package (#26344) (Andrew Clark)
-  8c100620c Build: specify Node.js 16 as minimum for dev (#26343) (Jan Kassens)
-  d81447304 [Internal API only] Delete non-awaited form of act (#26339) (Andrew Clark)
-  702fc984e Codemod act -> await act (4/?) (#26338) (Andrew Clark)
-  9fb2469a6 Restore definition of NativeMethods as an object for React Native (#26341) (Rubén Norte)
-  aef930314 [DevTools] upgrade electron to latest version & security improvements (#26337) (Mengdi Chen)
-  161f6ae42 Codemod act -> await act (3/?) (#26336) (Andrew Clark)
-  58605f798 Codemod act -> await act (2/?) (#26335) (Andrew Clark)
```
2023-03-09 11:44:33 -08:00
Jiachi Liu
292f65f6d3
Fix unexpected hoist meta tags by react in app dir (#46917)
### Bug Fix

Update vendor react to fix the unexpected hoist tags issue

x-ref: https://github.com/facebook/react/pull/26256

* Fixes #42648
* Closes NEXT-655
* tests added
2023-03-08 11:34:51 +00:00
Shu Ding
7e933a094c
Revert "Revert "Update vendored React"" (#46881)
Reverts vercel/next.js#46861. This requires
https://github.com/vercel/turbo/pull/4102 to be released and bindings to
be updated first.

~Also depends on #46896 to be merged first, and conflicts to be
resolved.~
2023-03-07 13:04:08 -08:00
Sukka
26768571ad
test(unit): add cases for cssnano simple (#46862)
Continues from #46380. The PR migrates the unit test cases from the original repo into the Next.js repo.
2023-03-07 06:28:53 +00:00
JJ Kasper
0f621cb133
Revert "Update vendored React" (#46861)
Reverting temporarily as this breaks turbopack support for app dir 

x-ref:
https://github.com/vercel/next.js/actions/runs/4349458918/jobs/7600147372
x-ref:
https://github.com/vercel/next.js/actions/runs/4349607013/jobs/7600148420

Reverts vercel/next.js#46826
2023-03-06 21:17:15 -08:00
Shu Ding
003b3af700
Update vendored React (#46826)
This PR updates vendored React to the latest `@next` version, as well as
corresponding changes to the manifest and module reference generation
code.

The new React version includes the following upstream changes:

- 49f741046 Fix: Infinite act loop caused by wrong shouldYield (#26317)
(Andrew Clark)
-  106ea1c58 Support Iterables in Flight (#26313) (Sebastian Markbåge)
- f905da227 [Flight] Send server reference error chunks to the client
(#26293) (Hendrik Liebau)
- e0241b660 Simplify Webpack References by encoding file path + export
name as single id (#26300) (Sebastian Markbåge)
- 25685d8a9 Codemod tests to waitFor pattern (9/?) (#26309) (Andrew
Clark)
- 64dde7082 Codemod tests to waitFor pattern (8/?) (#26308) (Andrew
Clark)
- 3cb5afb82 Codemod tests to waitFor pattern (7/?) (#26307) (Andrew
Clark)
- e98695db9 Codemod tests to waitFor pattern (6/?) (#26305) (Andrew
Clark)
- 9a52cc8bc Convert ReactLazy-test to waitFor pattern (#26304) (Andrew
Clark)
- 03462cfc7 [Fizz] External runtime: fix bug in processing existing
elements (#26303) (mofeiZ)
- faacefb4d Codemod tests to waitFor pattern (4/?) (#26302) (Andrew
Clark)
- 06460b6fb Remove unnecessary (and incorrect) code for compatibility
with Paper in the Fabric version of GlobalResponderHandler (#26290)
(Rubén Norte)
- e64a8f403 Codemod tests to waitFor pattern (3/?) (#26299) (Andrew
Clark)
- ce8a72fd4 Codemod tests to waitFor pattern (2/?) (#26296) (Andrew
Clark)
- 1f1f8eb55 [Float][Fizz][Fiber]: Refactor <style> Resource
implementation to group on flush (#26280) (Josh Story)
- 5c633a48f Add back accidentally deleted test comments (#26294) (Andrew
Clark)
- b073104c2 [DevTools] improve troubleshooting in README (#26235)
(Mengdi Chen)
- fcf218791 [DevTools] Remove renderer.js from extension build (#26234)
(Mengdi Chen)
- b72ed698f Fixed incorrect value returned as public instance from
reconciler (#26283) (Rubén Norte)
- 25a8b9735 Codemod tests to waitFor pattern (1/?) (#26288) (Andrew
Clark)
- e52446733 New internal testing helpers: waitFor, waitForAll,
waitForPaint (#26285) (Andrew Clark)
- d49e0e0be Removed unused imperative events implementation from React
Native renderer (#26282) (Rubén Norte)

---------
2023-03-06 16:51:10 -08:00
JJ Kasper
ed6cd410d7
Ensure test-unit includes package unit tests (#46707)
Seems the unit tests from our packages haven't been running as a few haven't been updated and had failing assertions.
2023-03-02 23:09:48 +00:00
Andrew Clark
2e23cd7535
Add script to automate updating vendored React version (#46663)
Since we intend to update our vendored copy of React frequently, I wrote
a script to automate the steps.

Basic usage (defaults to most recent React canary version):

```sh
pnpm run sync-react
```

Specify a canary version:

```sh
pnpm run sync-react --version 18.3.0-next-41110021f-20230301
```

Update package.json but skip installing the dependencies automatically:

```sh
pnpm run sync-react --no-install
```

At the end it will print out a changelog so you can copy/paste it into
the PR description.

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

## Bug

- [ ] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [ ] Errors have a helpful link attached, see
[`contributing.md`](https://github.com/vercel/next.js/blob/canary/contributing.md)

## Feature

- [ ] Implements an existing feature request or RFC. Make sure the
feature request has been accepted for implementation before opening a
PR.
- [ ] Related issues linked using `fixes #number`
- [ ]
[e2e](https://github.com/vercel/next.js/blob/canary/contributing/core/testing.md#writing-tests-for-nextjs)
tests added
- [ ] Documentation added
- [ ] Telemetry added. In case of a feature if it's used or not.
- [ ] Errors have a helpful link attached, see
[`contributing.md`](https://github.com/vercel/next.js/blob/canary/contributing.md)

## Documentation / Examples

- [ ] Make sure the linting passes by running `pnpm build && pnpm lint`
- [ ] The "examples guidelines" are followed from [our contributing
doc](https://github.com/vercel/next.js/blob/canary/contributing/examples/adding-examples.md)
2023-03-02 02:15:02 +00:00
Andrew Clark
5c18e9ac92
Update vendored React packages to next-41110021f (#46636)
Notable changes:

- https://github.com/facebook/react/pull/26275
- https://github.com/facebook/react/pull/26232
- https://github.com/facebook/react/pull/26239
- https://github.com/facebook/react/pull/26237

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

## Bug

- [ ] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [ ] Errors have a helpful link attached, see
[`contributing.md`](https://github.com/vercel/next.js/blob/canary/contributing.md)

## Feature

- [ ] Implements an existing feature request or RFC. Make sure the
feature request has been accepted for implementation before opening a
PR.
- [ ] Related issues linked using `fixes #number`
- [ ]
[e2e](https://github.com/vercel/next.js/blob/canary/contributing/core/testing.md#writing-tests-for-nextjs)
tests added
- [ ] Documentation added
- [ ] Telemetry added. In case of a feature if it's used or not.
- [ ] Errors have a helpful link attached, see
[`contributing.md`](https://github.com/vercel/next.js/blob/canary/contributing.md)

## Documentation / Examples

- [ ] Make sure the linting passes by running `pnpm build && pnpm lint`
- [ ] The "examples guidelines" are followed from [our contributing
doc](https://github.com/vercel/next.js/blob/canary/contributing/examples/adding-examples.md)

Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2023-03-01 20:15:50 +01:00
Shu Ding
877f2f5996
Upgrade precompiled react packages (#46365)
Co-authored-by: Jiachi Liu <inbox@huozhi.im>
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2023-02-28 10:13:02 +01:00
Jiachi Liu
5a304817cb
Update app-dir react bundle to leverage edge build (#46208)
Leverage edge build of react-server-dom-webpack on server and keep
browser build of it for client build

Closes NEXT-606

---------

Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2023-02-23 00:24:26 +01:00
Balázs Orbán
be5a9f53a8
chore(deps): use external @edge-runtime/cookies (#42736)
Co-authored-by: JJ Kasper <jj@jjsweb.site>
2023-02-17 15:10:09 +01:00
Tim Neutkens
1faa599568
Add additional tests for @next/mdx (#45585)Co-authored-by: Shu Ding <g@shud.in>
Adds additional integration tests for `@next/mdx`.

- Test mdx-rs
- Test `mdx-components.tsx`
- Tests development and production. Previously it only checked
development.

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

## Bug

- [ ] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [ ] Errors have a helpful link attached, see
[`contributing.md`](https://github.com/vercel/next.js/blob/canary/contributing.md)

## Feature

- [ ] Implements an existing feature request or RFC. Make sure the
feature request has been accepted for implementation before opening a
PR.
- [ ] Related issues linked using `fixes #number`
- [ ]
[e2e](https://github.com/vercel/next.js/blob/canary/contributing/core/testing.md#writing-tests-for-nextjs)
tests added
- [ ] Documentation added
- [ ] Telemetry added. In case of a feature if it's used or not.
- [ ] Errors have a helpful link attached, see
[`contributing.md`](https://github.com/vercel/next.js/blob/canary/contributing.md)

## Documentation / Examples

- [ ] Make sure the linting passes by running `pnpm build && pnpm lint`
- [ ] The "examples guidelines" are followed from [our contributing
doc](https://github.com/vercel/next.js/blob/canary/contributing/examples/adding-examples.md)

---------

Co-authored-by: Shu Ding <g@shud.in>
2023-02-11 13:37:00 +01:00
SCG82
4a472abc89
chore: simplify package scripts (#45226)
<!--
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 that you're making:
-->

## Bug

- [ ] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [ ] Errors have a helpful link attached, see
[`contributing.md`](https://github.com/vercel/next.js/blob/canary/contributing.md)

## Feature

- [ ] Implements an existing feature request or RFC. Make sure the
feature request has been accepted for implementation before opening a
PR.
- [ ] Related issues linked using `fixes #number`
- [ ]
[e2e](https://github.com/vercel/next.js/blob/canary/contributing/core/testing.md#writing-tests-for-nextjs)
tests added
- [ ] Documentation added
- [ ] Telemetry added. In case of a feature if it's used or not.
- [ ] Errors have a helpful link attached, see
[`contributing.md`](https://github.com/vercel/next.js/blob/canary/contributing.md)

## Documentation / Examples

- [x] Make sure the linting passes by running `pnpm build && pnpm lint`
- [ ] The "examples guidelines" are followed from [our contributing
doc](https://github.com/vercel/next.js/blob/canary/contributing/examples/adding-examples.md)

Co-authored-by: JJ Kasper <jj@jjsweb.site>
2023-02-07 15:30:02 -08:00
Jiachi Liu
c6fe3f3224
Update app dir react for client reference updates (#45490)
x-ref: https://github.com/facebook/react/pull/26059
x-ref: https://github.com/facebook/react/pull/26083
x-ref: https://github.com/facebook/react/pull/26093
x-ref: https://github.com/facebook/react/pull/26083
Closes NEXT-445

* Remove extra `await`
* Check if a component result is client reference, then we access for
other exports
2023-02-07 19:32:49 +01:00
Wyatt Johnson
57ba24e39a
Improved pnpm clean (#45312)
When incompatibilities with upgrades to `swc` occur between releases,
these changes expand the existing `pnpm clean` script to additionally
run any `clean` script under any of the lerna packages. In this case, a
new script was created under `packages/next-swc` that removes
`packages/next-swc/native/*`, allowing the default to automatically use
the WASM build.

Users wanting to reset their repository can now run:

```sh
pnpm clean
```

Future packages or outputs that are built should have their `clean`
script remove them to allow for easy repository resetting.
2023-01-26 13:24:19 -08:00
JJ Kasper
8f05c0c07e
Update flakey test cases (#45290) 2023-01-25 22:55:49 -08:00
Jan Kaifer
d7307cffb7
Fix turbo usage in tests (#44715) 2023-01-18 20:35:28 +01:00
JJ Kasper
8613297cd4
Fix prepublish compiled handling (#44914) 2023-01-15 20:21:39 -08:00
JJ Kasper
d4a3c66479
Update pre-compiled (#44874) 2023-01-13 17:52:35 -08:00
Valentin Politov
9168dffc02
examples: Bump SWR to v2.0.0 (#44790) 2023-01-12 09:36:29 -08:00
JJ Kasper
12bfabd179
Update to latest version of pnpm (#44791) 2023-01-11 17:36:52 -08:00
Steven
862deb5a13
Disable telemetry for pnpm next when contributing locally (#44610)
This PR fixes telemetry so it no longer reports `pnpm next` when
contributing to Next.js
2023-01-05 13:27:05 -08:00
Jan Kaifer
cafbe2a0ad
Revert "Use turbo for packing files in test setup (#44074)" (#44566)
This reverts commit fd9ec646ac.

It seems that there is an issue with caching of inputs which uses stale
files.

We also had to disable caching of `pnpm-lock.yaml` because it requires
stable package locations chich we removed.
2023-01-04 10:23:21 -08:00
JJ Kasper
87c3578cc4
Update json5 dependency to latest (#44548)
Updates to latest version of the dependency.
2023-01-03 15:45:05 -08:00
Jan Kaifer
d6a09be303
add testonly variants for all test modes and refactored test as alias of testheadless (#44528)
So that we don't need to use `NEXT_TEST_MODE=...` ever again manually.
2023-01-03 14:43:55 -08:00
Jan Kaifer
fd9ec646ac
Use turbo for packing files in test setup (#44074) 2022-12-22 16:36:24 +01:00
Jiachi Liu
e27a7bd7a4
Update styled-jsx (#44070)
x-ref: https://github.com/vercel/styled-jsx/releases/tag/v5.1.1
2022-12-19 23:58:50 +00:00
Tim Neutkens
e45bbbe734
Add jsdoc/no-types eslint rule for TypeScript files (#44049)
Co-authored-by: JJ Kasper <jj@jjsweb.site>
2022-12-19 10:21:08 +01:00
Jiachi Liu
6aae39c759
Fix app client entry key for windows (#44011)
## Bug

The app client entry key was in win32 slashes like `app\blog`, and when
we add the new layer checking logic in #43197, `name.startsWith('app/')`
doesn't work.

Fixes #43854
Fixes #43902

<img width="862" alt="image"
src="https://user-images.githubusercontent.com/4800338/207641886-08ffc159-0516-4609-9a1f-8c8693586122.png">


- [x] Related issues linked using `fixes #number`
- [x] Integration tests added
- [ ] Errors have a helpful link attached, see
[`contributing.md`](https://github.com/vercel/next.js/blob/canary/contributing.md)
2022-12-14 19:52:52 +01:00
Jiachi Liu
a97e6fff31
Upgrade playwright to 1.28.1 (#43818)
Upgrade playwright to see if the playwright installation job will be
back to normal

x-ref:
https://github.com/vercel/next.js/actions/runs/3639757976/jobs/6143653702
2022-12-07 14:14:55 -08:00
JJ Kasper
a704b71cba
Lock pnpm version during publish (#43820)
x-ref: [slack thread](https://vercel.slack.com/archives/C04DUD7EB1B/p1670409758653869)
2022-12-07 17:24:43 +00:00
Jan Kaifer
aa7cdf35ea
Remove notifications emitted during pnpm dev (#43801)
Co-authored-by: Tim Neutkens <tim@timneutkens.nl>
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2022-12-07 17:11:29 +01:00
JJ Kasper
90f022aeb6
Update test config (#43661)
Updates our test config to take advantage of more concurrency and also
updates to leverage the playwright docker image to reduce flakes from
actions/setup-node stalling or playwright dependencies stalling on `apt
install`.

This reduces our test times from upwards of 30 minutes down to back
around 15 minutes.
2022-12-03 19:49:00 -08:00
Jiachi Liu
48290c6a05
Update react next tag (#43617)
Fixes #43033

Also remove the unsued react-dom files: bundles for bun, and
react-dom-test-utils

x-ref: https://github.com/facebook/react/pull/25713

## Bug

- [x] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [ ] Errors have a helpful link attached, see
[`contributing.md`](https://github.com/vercel/next.js/blob/canary/contributing.md)
2022-12-01 20:15:54 -08:00
Jiachi Liu
e901feffc3
Update precompiled react (#43288)
Update pre-compiled react to fix the streaming issue with node 18.
x-ref: https://github.com/facebook/react/pull/25645

Fixes: #42466
Manually tested locally works for the reproduction from the issue

## Bug

- [x] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [ ] Errors have a helpful link attached, see [`contributing.md`](https://github.com/vercel/next.js/blob/canary/contributing.md)
2022-11-23 15:57:38 +00:00
Donny/강동윤
3d62f467cf
chore: Update swc_core to v0.43.23 (#42977)
This PR updates swc crates to
a4ed624f81

---

 - Closes https://github.com/vercel/next.js/issues/42978
 - Closes https://github.com/vercel/next.js/issues/42801

<img width="1840" alt="image"
src="https://user-images.githubusercontent.com/29931815/202788043-4ba0c3a4-b4c5-43e7-8eb3-42b8341e5d5f.png">

 - Closes https://github.com/vercel/next.js/issues/43027
<img width="1840" alt="image"
src="https://user-images.githubusercontent.com/29931815/202788522-e4884f91-c83c-45e8-983a-f210144effef.png">

 - Closes https://github.com/vercel/next.js/issues/43042
<img width="1840" alt="image"
src="https://user-images.githubusercontent.com/29931815/202788866-2c319588-5a01-4628-95cc-47bb51e19153.png">

 - Closes https://github.com/vercel/next.js/issues/43060

<img width="1840" alt="image"
src="https://user-images.githubusercontent.com/29931815/202789993-2bf3af55-9752-4aa8-bcc2-98f08ecd47b7.png">


 - Closes https://github.com/vercel/next.js/issues/42852

<img width="1840" alt="image"
src="https://user-images.githubusercontent.com/29931815/202804509-88bb3d55-182d-457d-b59e-d12b30c52100.png">
2022-11-19 18:18:31 -08:00
JJ Kasper
c3993c828f
Update to latest version of turbo CLI (#42803)
Continuation of https://github.com/vercel/next.js/pull/42711 fixing
latest turbo usage in musl environment

## Bug

- [ ] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [ ] Errors have a helpful link attached, see `contributing.md`

## Feature

- [ ] Implements an existing feature request or RFC. Make sure the
feature request has been accepted for implementation before opening a
PR.
- [ ] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [ ] Documentation added
- [ ] Telemetry added. In case of a feature if it's used or not.
- [ ] Errors have a helpful link attached, see `contributing.md`

## Documentation / Examples

- [ ] Make sure the linting passes by running `pnpm build && pnpm lint`
- [ ] The "examples guidelines" are followed from [our contributing
doc](https://github.com/vercel/next.js/blob/canary/contributing/examples/adding-examples.md)
2022-11-14 11:52:12 -08:00
Jiachi Liu
b180becad5
Update bundle analyzer dependency and output (#42797)
* Update `webpack-bundle-analyzer` to 4.7.0
* Change the output file paths of bundle analyzing results to
`./next/analyze/<nodejs|edge|client>.html`
2022-11-11 16:39:45 -08:00
Shu Ding
f612acffbc
Add test case for image generation (#42693)
This PR adds a basic test case to ensure Next.js and Edge Runtime
changes don't break the image generation feature, as well as record the
usage.

## Bug

- [ ] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [ ] Errors have a helpful link attached, see `contributing.md`

## Feature

- [ ] Implements an existing feature request or RFC. Make sure the
feature request has been accepted for implementation before opening a
PR.
- [ ] Related issues linked using `fixes #number`
- [x] Integration tests added
- [ ] Documentation added
- [x] Telemetry added. In case of a feature if it's used or not.
- [ ] Errors have a helpful link attached, see `contributing.md`

## Documentation / Examples

- [ ] Make sure the linting passes by running `pnpm build && pnpm lint`
- [ ] The "examples guidelines" are followed from [our contributing
doc](https://github.com/vercel/next.js/blob/canary/contributing/examples/adding-examples.md)
2022-11-10 09:26:36 -08:00
JJ Kasper
abaaf80f51
Revert "Update to latest version of turbo CLI (#42711)"
This reverts commit 2c199c4c19.
2022-11-09 21:15:36 -08:00
JJ Kasper
2c199c4c19
Update to latest version of turbo CLI (#42711)
Ensures we have latest patches in turbo CLI. 

## Bug

- [ ] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [ ] Errors have a helpful link attached, see `contributing.md`

## Feature

- [ ] Implements an existing feature request or RFC. Make sure the
feature request has been accepted for implementation before opening a
PR.
- [ ] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [ ] Documentation added
- [ ] Telemetry added. In case of a feature if it's used or not.
- [ ] Errors have a helpful link attached, see `contributing.md`

## Documentation / Examples

- [ ] Make sure the linting passes by running `pnpm build && pnpm lint`
- [ ] The "examples guidelines" are followed from [our contributing
doc](https://github.com/vercel/next.js/blob/canary/contributing/examples/adding-examples.md)
2022-11-09 18:22:15 -08:00
Josh Story
677c04f088
update react builtin deps for next channel (#42639)
Updates builtin react to latest release on next channel

## Bug

- [ ] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [ ] Errors have a helpful link attached, see `contributing.md`

## Feature

- [ ] Implements an existing feature request or RFC. Make sure the
feature request has been accepted for implementation before opening a
PR.
- [ ] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [ ] Documentation added
- [ ] Telemetry added. In case of a feature if it's used or not.
- [ ] Errors have a helpful link attached, see `contributing.md`

## Documentation / Examples

- [ ] Make sure the linting passes by running `pnpm build && pnpm lint`
- [ ] The "examples guidelines" are followed from [our contributing
doc](https://github.com/vercel/next.js/blob/canary/contributing/examples/adding-examples.md)
2022-11-08 10:35:17 -08:00
OJ Kwon
5654cae2d7
feat(next/mdx): support experimental mdx-rs loader (#41919)
<!--
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 that you're making:
-->

This PR implements a configuration option in `next.config.js` to support
for rust-based MDX compiler (https://github.com/wooorm/mdxjs-rs).
Currently it is marked as experimental, as mdx-rs and loader both may
need some iteration to fix regressions.

When a new experimental flag is set (`mdxRs: true`), instead of using
`@mdx/js` loader `next/mdx` loads a new webpack loader instead.
Internally, it mostly mimics mdx/js's loader behavior, however actual
compilation will be delegated into next/swc's binding to call mdx-rs's
compiler instead.

I choose to use next-swc to expose its binding function, as mdx-rs
internally uses swc already and creating new binary can double up
bytesize (with all the complex processes of publishing new package).

## Bug

- [ ] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [ ] Errors have a helpful link attached, see `contributing.md`

## Feature

- [ ] Implements an existing feature request or RFC. Make sure the
feature request has been accepted for implementation before opening a
PR.
- [ ] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [ ] Documentation added
- [ ] Telemetry added. In case of a feature if it's used or not.
- [ ] Errors have a helpful link attached, see `contributing.md`

## Documentation / Examples

- [ ] Make sure the linting passes by running `pnpm lint`
- [ ] The "examples guidelines" are followed from [our contributing
doc](https://github.com/vercel/next.js/blob/canary/contributing/examples/adding-examples.md)
2022-11-02 18:24:05 -07:00
Jiachi Liu
6dbf9c32ec
Handle dynamic css-in-js styles under suspense (#42293)
We insert the content returning from `useServerInsertedHTML` to head
element for app dir, but it shouldn't only inject once since there're
suspense boundaries that could hold insertions.

## Bug

- [ ] Related issues linked using `fixes #number`
- [x] Integration tests added
- [ ] Errors have a helpful link attached, see `contributing.md`

Co-authored-by: JJ Kasper <jj@jjsweb.site>
2022-11-02 14:18:08 +01:00
Kiko Beats
137008e613
[middleware] add tests for body reading methods #37980 (#41718) 2022-11-01 20:45:58 -07:00
Jiachi Liu
70e7e58c37
Update react next channel (#42021)
Update react channel for `fetch` patching updates 

x-ref: [slack
thread](https://vercel.slack.com/archives/C03ENM5HB4K/p1666802006931969?thread_ts=1666799939.726859&cid=C03ENM5HB4K)
2022-10-27 17:33:47 -07:00
Kiko Beats
288144c7e5
Upgrade Edge Runtime (#41987)
dropped node12 support

Co-authored-by: Steven <steven@ceriously.com>
2022-10-27 15:07:05 -04:00
Steven
a5d674237a
Bump minimum Node.js version to 14.6.0 (#41765)
We found a case where 14.0.0 breaking with private class methods, such
as:

```js
class C {
  #x() { return 42; }
  x() {
    return this.#x();
  }
}
```

This feature was introduced in Node.js 14.6.0, so we can bump the
minimum version.

See https://node.green
2022-10-24 21:47:54 -07:00
Jiachi Liu
78bf0a792b
Update react next channel (#41761)
apply react updates x-ref: https://github.com/facebook/react/pull/25560
2022-10-25 02:32:20 +00:00
Kiko Beats
89355298f2
Upgrade Edge Runtime v.1.1.0 (#41727)
Co-authored-by: Balázs Orbán <info@balazsorban.com>
2022-10-24 10:49:49 -07:00
Jiachi Liu
20f5db06fa
Update precompiled react to next channel (#41708)
Precompile `react@next` and to unlock `cache` and `use` API
2022-10-24 00:31:52 -07:00
JJ Kasper
b6ed1a7e5f
Update to latest react experimental (#41671)
x-ref: [slack
thread](https://vercel.slack.com/archives/C035J346QQL/p1666452328526929)
2022-10-23 13:10:44 -07:00
Jiachi Liu
b0f87fbc7c
Bundle ssr client layer excepts react externals (#41606)
Bundle the ssr client layer for RSC, this solves the problem when
there's an esm package is using on client components, but esm imports
the installed react instead of the built-in react version since esm
imports is not intercepted by require hook.

After bundling the ssr client layer and treating react as externals, now
react compiles as cjs externals and could be intercepted by require
hook, other code are bundled together which can also get optimized.

## Feature

- [ ] Implements an existing feature request or RFC. Make sure the
feature request has been accepted for implementation before opening a
PR.
- [ ] Related issues linked using `fixes #number`
- [x] Integration tests added
- [ ] Documentation added
- [ ] Telemetry added. In case of a feature if it's used or not.
- [ ] Errors have a helpful link attached, see `contributing.md`

Co-authored-by: Shu Ding <g@shud.in>
Co-authored-by: JJ Kasper <jj@jjsweb.site>
2022-10-22 16:33:51 -07:00
Javi Velasco
392c4d0b7c
Update @types/node to 14.14.31 (#41634)
This PR updates `@types/node` to `14.14.31`. The most important type is
that `ParsedUrlQuery` can hold `undefined` so we are updating the code
here to explicitly handle those cases. Aside from it we are adding a
global definition taken from NodeJS for `AsyncLocalStorage` that we
export in `server.d.ts`
2022-10-22 11:19:14 -07:00
Jiachi Liu
3a87e816fc
Disable using prebundled of react for appDir (#41635)
reverting https://github.com/vercel/next.js/pull/41337

Co-authored-by: JJ Kasper <jj@jjsweb.site>
2022-10-21 23:55:19 -07:00
Tim Neutkens
14c9376899
BREAKING CHANGE: Remove React 17 (#41629)
Next.js 13 will require React 18.

In this PR I've only updated the peerDependency and removed the test runs in GH actions. Further cleanup will follow later, this allows us to remove the code supporting it later.



## Bug

- [ ] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [ ] Errors have a helpful link attached, see `contributing.md`

## Feature

- [ ] Implements an existing feature request or RFC. Make sure the feature request has been accepted for implementation before opening a PR.
- [ ] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [ ] Documentation added
- [ ] Telemetry added. In case of a feature if it's used or not.
- [ ] Errors have a helpful link attached, see `contributing.md`

## Documentation / Examples

- [ ] Make sure the linting passes by running `pnpm lint`
- [ ] The "examples guidelines" are followed from [our contributing doc](https://github.com/vercel/next.js/blob/canary/contributing/examples/adding-examples.md)


Co-authored-by: Jiachi Liu <4800338+huozhi@users.noreply.github.com>
2022-10-21 22:20:36 +00:00
Jiachi Liu
bc335d7ef7
Prebundle react for appDir (#41337)
Inline a react and react-dom for app dir, when `appDir` flag is enabled
opt into the built-in version for all.

For server layer react, use the react share subset for server
components.
For all server side of react-dom usage, use the server-rendering-stub.

Co-authored-by: Shu Ding <g@shud.in>
Co-authored-by: JJ Kasper <jj@jjsweb.site>
2022-10-18 16:32:23 -07:00
Kiko Beats
ebae05eeed
Update edge runtime to 1.1.0-beta.40 (#41513)
changes: https://github.com/vercel/edge-runtime/compare/edge-runtime@1.1.0-beta.39...edge-runtime@1.1.0-beta.40
2022-10-18 13:57:11 +00:00
Kiko Beats
8c4ef5cbc7
Update edge runtime to 1.1.0-beta.39 (#41418)
https://github.com/vercel/edge-runtime/compare/edge-runtime%401.1.0-beta.37...edge-runtime%401.1.0-beta.39
2022-10-14 09:48:32 -07:00
Tim Neutkens
8f49ffc488
Upgrade React experimental (#41419) 2022-10-14 16:25:49 +02:00
Shu Ding
24b600303f
Do not bundle react-dom in the SSR build (#41227)
Currently `react-dom` isn't handled as an external dependency in SSR,
unlike `react`. This means that the ReactDOM imported by client
components isn't the same instance as the ReactDOM that does SSR.

This PR also upgrades React experimental to the latest version.

## Bug

- [ ] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [ ] Errors have a helpful link attached, see `contributing.md`

## Feature

- [ ] Implements an existing feature request or RFC. Make sure the
feature request has been accepted for implementation before opening a
PR.
- [ ] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [ ] Documentation added
- [ ] Telemetry added. In case of a feature if it's used or not.
- [ ] Errors have a helpful link attached, see `contributing.md`

## Documentation / Examples

- [ ] Make sure the linting passes by running `pnpm lint`
- [ ] The "examples guidelines" are followed from [our contributing
doc](https://github.com/vercel/next.js/blob/canary/contributing/examples/adding-examples.md)
2022-10-06 20:27:24 +02:00
Shu Ding
c6dc62ef04
Upgrade React experimental (#41222)
<!--
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 that you're making:
-->

## Bug

- [ ] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [ ] Errors have a helpful link attached, see `contributing.md`

## Feature

- [ ] Implements an existing feature request or RFC. Make sure the
feature request has been accepted for implementation before opening a
PR.
- [ ] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [ ] Documentation added
- [ ] Telemetry added. In case of a feature if it's used or not.
- [ ] Errors have a helpful link attached, see `contributing.md`

## Documentation / Examples

- [ ] Make sure the linting passes by running `pnpm lint`
- [ ] The "examples guidelines" are followed from [our contributing
doc](https://github.com/vercel/next.js/blob/canary/contributing/examples/adding-examples.md)
2022-10-06 18:06:14 +02:00
Meno Abels
374ab4bf66
Update edge runtime to 1.1.0-beta.37 (#41211)
update of the edge-runtime to 1.1.0-beta.37.



Co-authored-by: Kiko Beats <2096101+Kikobeats@users.noreply.github.com>
2022-10-06 11:45:16 +00:00
JJ Kasper
51552c1a02
Update minimum required Node.js version to v14 (#41150)
As discussed this updates our required minimum Node.js version to `v14` as `v12` is no longer being maintained. Since our targets for babel and swc already target the actively used Node.js version no change has been made there.
2022-10-04 08:59:35 +00:00
Jiachi Liu
3e8af93220
Align pnpm version (#41123)
Align pnpm version in build pipelines with 7.3.0 to make sure lock files
are generated correctly
2022-10-03 17:07:52 +02:00
Balázs Orbán
a83cfcdc78
chore: make sure polyfills are built for pnpm dev (#41062)
Re-lands #40335 but without modifying the lock file.


## Bug

- [ ] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [ ] Errors have a helpful link attached, see `contributing.md`

## Feature

- [ ] Implements an existing feature request or RFC. Make sure the feature request has been accepted for implementation before opening a PR.
- [ ] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [ ] Documentation added
- [ ] Telemetry added. In case of a feature if it's used or not.
- [ ] Errors have a helpful link attached, see `contributing.md`

## Documentation / Examples

- [ ] Make sure the linting passes by running `pnpm lint`
- [ ] The "examples guidelines" are followed from [our contributing doc](https://github.com/vercel/next.js/blob/canary/contributing/examples/adding-examples.md)
2022-09-30 14:54:38 +00:00
Tim Neutkens
a78ce92ede Revert "chore: make sure polyfills are built for pnpm dev (#40335)"
This reverts commit 24f573f8be.
2022-09-30 15:16:17 +02:00
Balázs Orbán
24f573f8be
chore: make sure polyfills are built for pnpm dev (#40335)
Utilize `turbo` for `dev`, and make sure polyfills are built. Fixes #40334

Another option would be to document that an initial `pnpm build` is necessary in  [`CONTRIBUTING.md`](https://github.com/vercel/next.js/blob/canary/contributing.md#developing).

## Bug

- [ ] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [ ] Errors have helpful link attached, see `contributing.md`

## Feature

- [ ] Implements an existing feature request or RFC. Make sure the feature request has been accepted for implementation before opening a PR.
- [ ] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [ ] Documentation added
- [ ] Telemetry added. In case of a feature if it's used or not.
- [ ] Errors have helpful link attached, see `contributing.md`

## Documentation / Examples

- [ ] Make sure the linting passes by running `pnpm lint`
- [ ] The examples guidelines are followed from [our contributing doc](https://github.com/vercel/next.js/blob/canary/contributing.md#adding-examples)
2022-09-30 02:03:47 +00:00
Jaril
06607e3dd1
Add Replay integration for dev e2e tests (#40955)
<!--
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 that you're making:
-->

## Bug

- [ ] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [ ] Errors have a helpful link attached, see `contributing.md`

## Feature

- [ ] Implements an existing feature request or RFC. Make sure the
feature request has been accepted for implementation before opening a
PR.
- [ ] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [ ] Documentation added
- [ ] Telemetry added. In case of a feature if it's used or not.
- [ ] Errors have a helpful link attached, see `contributing.md`

## Documentation / Examples

- [ ] Make sure the linting passes by running `pnpm lint`
- [ ] The "examples guidelines" are followed from [our contributing
doc](https://github.com/vercel/next.js/blob/canary/contributing/examples/adding-examples.md)

@ijjk moving this here.

Co-authored-by: JJ Kasper <jj@jjsweb.site>
2022-09-29 14:45:10 -07:00
Tim Neutkens
3211b3f672
Upgrade react@experimental (#40885) 2022-09-25 21:35:05 +02:00
Tim Neutkens
f6e37fd32e
Apply #40833 (#40872) 2022-09-25 11:45:00 +02:00
Kiko Beats
2e02204dc9
build: upgrade edge-runtime (#40788)
**TODO**

- [x] Ensure [body-stream](https://github.com/kikobeats/next.js/blob/edge-runtime/packages/next/server/body-streams.ts) is up-to-date with https://github.com/vercel/edge-runtime/blob/main/packages/runtime/src/server/body-streams.ts

Changelog: https://github.com/vercel/edge-runtime/releases/tag/edge-runtime%401.1.0-beta.33
2022-09-23 12:01:36 +00:00
Hannes Bornö
1264196897
Add next font package (#40227)
For some context:
https://vercel.slack.com/archives/CGU8HUTUH/p1662124179102509

Adds `@next/font` package.

`scripts/update-google-fonts.js` generates functions and metadata for
all available google fonts. The metadata is used in `loader.ts` to
validate font options (from #40221). It then fetches the CSS from google
fonts, downloads the font files and emits them as static assets.

The actual integration with `packages/next` and integration tests
depends on #40221, will follow up with new PR.

Co-authored-by: JJ Kasper <jj@jjsweb.site>
2022-09-21 15:10:24 -07:00
Henrik Wenz
3943b20f55
fix: InferGetServerSidePropsType and InferGetStaticPropsType (#40635)
## Problem

Currently the Next.js infer utility (`InferGetServerSidePropsType` and
`InferGetStaticPropsType`) types can lead to a wrong inferred types
(`never`). This happens if these functions return something different
than: `{props: {}}`.

**Example:** `getServerSideProps`

```typescript
export async function getServerSideProps({ query }: GetServerSidePropsContext) {
  if (query.foo) {
    return {
      notFound: true,
    }
  }

  return {
    props: { 
      foo: "bar"
    },
  }
}

type PageProps = InferGetServerSidePropsType<typeof getServerSideProps>
// => type PageProps = never
```

**Example:** `getStaticProps`

```typescript
import type { InferGetStaticPropsType, GetStaticPropsContext } from 'next'

export async function getStaticProps(context: GetStaticPropsContext) {
  if (context.params?.bar) {
    return {
      notFound: true,
    }
  }

  return {
    props: {
      foo: 'bar',
    },
  }
}

type PageProps = InferGetStaticPropsType<typeof getStaticProps>
// => type PageProps = never
```

This is because the first infer condition of the utility type is not
satified leading to a never result.

```typescript
export type InferGetServerSidePropsType<T> = T extends GetServerSideProps<
  infer P, // <- NOT SATISFIED
  any
>
  ? P
  : T extends (
      context?: GetServerSidePropsContext<any>
    ) => Promise<GetServerSidePropsResult<infer P>>
  ? P
  : never  // <- NOT SATISFIED
```

## Solution

I have experimented with different solutions ending with a much simpler
type, that is faster to execute, easier to read and universally usable
for both prop variations.

```typescript
/**
 * Flow:
 * - Make sure getStaticProps is a function
 * - Get its return type
 * - Extract the one that contains {props: any}
 * - Return the props
 */
export type InferGetStaticPropsType<T extends (args: any) => any> = Extract<
  Awaited<ReturnType<T>>,
  { props: any }
>['props']
```

## Bug

- [x] Related issues: fixes #36615, #15913,
https://twitter.com/leeerob/status/1563540593003106306
- [x] Type tests added

## Future thoughts

Since `InferGetStaticPropsType` and `InferGetServerSidePropsType` are
now the same, it's api could be merged into one utility type (e.g:
InferNextProps). I recommend doing this in a different PR.

## Additional info

I have tested this approach using the following [external
package](https://www.npmjs.com/package/infer-next-props-type)
(@timneutkens sorry for the late PR). Since about 12 Month I haven't
received any negative feedback (issues) regarding this approach.

Co-authored-by: JJ Kasper <jj@jjsweb.site>
2022-09-20 15:25:01 -07:00
Jimmy Lai
9b0c00a5b2
misc: update caniuse-lite to latest (#40680)
Fixes build errors related to
https://github.com/browserslist/caniuse-lite/issues/102

see
https://github.com/vercel/next.js/actions/runs/3082979772/jobs/4983345078


## Bug

- [ ] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [ ] Errors have a helpful link attached, see `contributing.md`

## Feature

- [ ] Implements an existing feature request or RFC. Make sure the
feature request has been accepted for implementation before opening a
PR.
- [ ] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [ ] Documentation added
- [ ] Telemetry added. In case of a feature if it's used or not.
- [ ] Errors have a helpful link attached, see `contributing.md`

## Documentation / Examples

- [ ] Make sure the linting passes by running `pnpm lint`
- [ ] The "examples guidelines" are followed from [our contributing
doc](https://github.com/vercel/next.js/blob/canary/contributing/examples/adding-examples.md)
2022-09-19 16:48:41 +02:00
Tim Neutkens
6df8770734
Upgrade to latest React experimental (#40672)
Only upgrade react-exp.


## Bug

- [ ] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [ ] Errors have a helpful link attached, see `contributing.md`

## Feature

- [ ] Implements an existing feature request or RFC. Make sure the feature request has been accepted for implementation before opening a PR.
- [ ] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [ ] Documentation added
- [ ] Telemetry added. In case of a feature if it's used or not.
- [ ] Errors have a helpful link attached, see `contributing.md`

## Documentation / Examples

- [ ] Make sure the linting passes by running `pnpm lint`
- [ ] The "examples guidelines" are followed from [our contributing doc](https://github.com/vercel/next.js/blob/canary/contributing/examples/adding-examples.md)
2022-09-19 13:26:06 +00:00
Balázs Orbán
3ff21ed178
refactor: split up CONTRIBUTING.md (#40515)
Continues #39778

Closes #40499

## Bug

- [ ] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [ ] Errors have helpful link attached, see `contributing.md`

## Feature

- [ ] Implements an existing feature request or RFC. Make sure the
feature request has been accepted for implementation before opening a
PR.
- [ ] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [ ] Documentation added
- [ ] Telemetry added. In case of a feature if it's used or not.
- [ ] Errors have helpful link attached, see `contributing.md`

## Documentation / Examples

- [ ] Make sure the linting passes by running `pnpm lint`
- [ ] The examples guidelines are followed from [our contributing
doc](https://github.com/vercel/next.js/blob/canary/contributing.md#adding-examples)

Co-authored-by: Tim Neutkens <tim@timneutkens.nl>
Co-authored-by: JJ Kasper <jj@jjsweb.site>
2022-09-16 14:54:58 -07:00
Tim Neutkens
385e3f0380
Wrap parallel routes tests in describe (#40546)
Small changes:
- Group parallel routes tests
- Upgrade tests to latest react experimental
2022-09-14 09:09:01 +00:00
Tim Neutkens
629c7f584e
Clean up startTransition in Link (#40505)
- Use React.startTransition instead of useTransition
- Upgrade to latest React experimental
- Split router cache invalidate into separate function

Some minor cleanup while verifying behaviors.
2022-09-13 11:47:20 +00:00
Wyatt Johnson
c6ef857d57
Subresource Integrity for App Directory (#39729)
<!--
Thanks for opening a PR! Your contribution is much appreciated.
In order 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 that you're making:
-->

This serves to add support for [Subresource
Integrity](https://developer.mozilla.org/en-US/docs/Web/Security/Subresource_Integrity)
hashes for scripts added from the new app directory. This also has
support for utilizing nonce values passed from request headers (expected
to be generated per request in middleware) in the bootstrapping scripts
via the `Content-Security-Policy` header as such:

```
Content-Security-Policy: script-src 'nonce-2726c7f26c'
```

Which results in the inline scripts having a new `nonce` attribute hash
added. These features combined support for setting an aggressive Content
Security Policy on scripts loaded.

## Bug

- [ ] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [ ] Errors have helpful link attached, see `contributing.md`

## Feature

- [ ] Implements an existing feature request or RFC. Make sure the
feature request has been accepted for implementation before opening a
PR.
- [ ] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [ ] Documentation added
- [ ] Telemetry added. In case of a feature if it's used or not.
- [x] Errors have helpful link attached, see `contributing.md`

## Documentation / Examples

- [x] Make sure the linting passes by running `pnpm lint`
- [x] The examples guidelines are followed from [our contributing
doc](https://github.com/vercel/next.js/blob/canary/contributing.md#adding-examples)

Co-authored-by: Steven <steven@ceriously.com>
2022-09-08 15:17:15 -07:00
Jiachi Liu
c8d3fa6a77
Update react-server-dom-webpack (#40356)
Bump `react-server-dom-webpack` for support of `experimental_use` API
2022-09-08 18:10:32 +00:00
Donny/강동윤
6356095481
chore: Update swc (#39965)
This PR updates SWC crates to f2a0eef4f1

---


 - Closes #17056

Co-authored-by: Jiachi Liu <inbox@huozhi.im>
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2022-09-04 12:13:22 +02:00
Jiachi Liu
8668020a54
Upgrade typescript to 4.8.2 (#39979)
Typescript published 4.8.2 today and it fails CI, bump our typescript version to 4.8.2 and tweak some typings to make existing e2e typescript tests work properly

* Bump web-vitals from 3.0.0-beta to 3.0.0 stable for typing fix (there's an undefined type but it wasn't caught by ts 4.7), also force compiled it as CJS for pre-compiled
* Bump ncc to 3.34.0 for ts-loader compatibility for new typescript version, ncc 3.33.x cannot work with ts 4.8
* Update pre-compiled
2022-08-29 16:56:02 +00:00
Jiachi Liu
b4f74ee1c1
Handle async module for client components (#39953)
### Problem

esm modules imports from client components will be compiled to `m = import('module-name')` when webpack bundles them for server components flight rendering. In this case, they will all become async modules since dyanmic imports will return a promise which react flight cannot handle it then results into module resolving error on server flight rendering.

### Solution

* React flight renderer supports handling async modules in https://github.com/facebook/react/pull/25138
* On next.js side leverage the module proxy change for each client reference, to make sure it always resolve the correct client module

The idea is wrapping each module with a module proxy, and if the module is async and accessed as thenable, it will return a new module reference with `async` label to tell react to handle it as async modules:

exported client reference `*` --> not async module (non thenable) --> original module reference `''`
exported client reference `*` --> it's async module (thenable) --> wrapped module reference `'*'` with `async` label

### Note

Since we need to check if user having incorrect gSSP/gSP specifying in layout client componet, so we still need to parse it and assign those info to the proxy (Does client module containing `ssr`, `ssg` exports). Otherwise the proxy will return the cached module reference
2022-08-29 14:47:06 +00:00
Kiko Beats
8958867d91
build: upgrade edge-runtime (#39898)
https://github.com/vercel/edge-runtime/compare/v1.1.0-beta.27...v1.1.0-beta.31

Related: https://github.com/vercel/next.js/issues/38658
2022-08-24 23:59:12 +00:00
Kiko Beats
28746520b6
build: upgrade edge-runtime (#39749)
https://github.com/vercel/edge-runtime/compare/v1.1.0-beta.26...v1.1.0-beta.27
2022-08-22 09:28:58 +00:00
Shu Ding
c79b67cced
Improved server CSS handling (#39664)
Upgrade experimental React, and render link tags directly in the tree during development. The client bundle won't import CSS anymore, and server CSS imports will be transpiled into no-op strings just for HMR to use.

## Follow Ups
- [ ] Flash of unstyled elements when reloading styles
- [ ] Collect client style imports
- [ ] Console warning for duplicated resources
- [ ] Tests

## Bug

- [ ] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [ ] Errors have helpful link attached, see `contributing.md`

## Feature

- [ ] Implements an existing feature request or RFC. Make sure the feature request has been accepted for implementation before opening a PR.
- [ ] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [ ] Documentation added
- [ ] Telemetry added. In case of a feature if it's used or not.
- [ ] Errors have helpful link attached, see `contributing.md`

## Documentation / Examples

- [ ] Make sure the linting passes by running `pnpm lint`
- [ ] The examples guidelines are followed from [our contributing doc](https://github.com/vercel/next.js/blob/canary/contributing.md#adding-examples)
2022-08-17 10:56:52 +00:00
Steven
53f0e2b31c
Update image tests files from *.js to *.ts (#39663)
Let's utilize typescript for our tests
2022-08-16 23:29:55 +00:00
JJ Kasper
6fd2a7fa31
Remove webpack4 types (#39631)
These types are no longer needed as we are only leveraging webpack 5 so this finishes migrating our types away from webpack 4's types.
2022-08-16 09:55:37 +00:00
Gal Schlezinger
b899d01fff
Bump edge-runtime packages (#39450)
This version fixes a bug where [crypto buffers (ArrayBuffer, Uint8Array) not compatible with text decoding](17475e4df7).
2022-08-10 09:19:48 +00:00
Jiachi Liu
71f5f258ab
Setup require hook in next-server for styled-jsx resolving (#39305)
* Use require hook and alias to resolve styled-jsx

* re-export styled-jsx types from compiled

* fix lint

* add test for styled-jsx css

* setup require hook in server

* compile import path to styled-jsx/style

* revert require hook

* add test for server styled-jsx resolving

* update test

* pre copy styled-jsx assets

* fix styled-jsx dts

* add npmrc for styled-jsx e2e test

* load require hook directly

* rm legacy test

* fix lint

* fix pnpm install error

* split require hook

* only alias styled-jsx

* make styled-jsx resolving statically analyzable

* update test

Co-authored-by: JJ Kasper <jj@jjsweb.site>
2022-08-08 20:27:42 -05:00
Michael Novotny
ab48f54786
Adds eslint-plugin-eslint-plugin to ensure eslint-plugin-next rules follow ESLint rule best practices along with enforcing some consistency. (#37920)
* Adds eslint-plugin-eslint-plugin and recommended rules.

* Removes `fixable` as none of the rules contain fixers.

* Adds description and url rules.

* Adds message format.

* Removes optional dependencies.

* Lints eslint-plugin-next tests too.

* Removes optional dependencies from pnpm lock file.

* Resets pnpm lock file.

* Resets package.json too.

* Fixes pnpm lockfile.
2022-08-07 23:52:02 -05:00
Jiachi Liu
4d0783d9be
Flush styles effects (#39268)
Use flush effects to custom apply css-in-js solution to app. Re-introduce flush effects to app-render, and remove default support of styled-jsx in `app/`. So that users will choose their own css-in-js solution if they need any customization. styled-jsx won't appear in client bundle if you didn't use it.

For now we have to inject the initial styles before `</head>` to avoid hydration errors. Later on we can remove this once react can handle it.

- [x] inject styles before end of head element
- [x] add tests
2022-08-03 16:21:20 +00:00
Gal Schlezinger
e3181c2d77
Export URLPattern from next/server (#39219)
This commit allows the users to import URLPattern from `next/server`,
by defining a key that uses `global.URLPattern`.

Why is this any good? or: why don't we add URLPattern to the global namespace?

URLPattern is exposed as global on Edge Runtime _only_. This means that if we define a
constructor in global namespace in our TypeScript definitions, people might
have runtime errors in their Node.js functions.

Importing from `next/server` enables users to get the constructor without
risking in runtime errors and wrong type definitions.

Keep in mind, that with the current implementation, we do not check if the
constructor actually exists, but `next/server` shouldn't be imported in
Node.js functions, AFAIK.

## Related

- Fixes #38131

## Bug

- [x] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [ ] Errors have helpful link attached, see `contributing.md`


Co-authored-by: JJ Kasper <22380829+ijjk@users.noreply.github.com>
2022-08-02 02:04:08 +00:00
Kiko Beats
0ebd53fdb5
fix: print Request & Response properties (#38903)
* Add inspect symbol for request

WIP

* Add inspect symbol for response

* build: upgrade edge-runtime
2022-07-27 09:16:16 -05:00
JJ Kasper
90ddd0dc83
Replace node-sass test dependency with sass (#39053)
* Replace node-sass test dependency with sass

* breakup css/scss tests for more parallelism

* update compiled
2022-07-26 23:12:54 -05:00
Tobias Koppers
8324cf5218
update webpack (#38988)
https://github.com/webpack/webpack/releases/tag/v5.74.0

There is a nice little performance fix for rebuild performance in this release.
It also fixes the edge case @Kikobeats did run into: https://vercel.slack.com/archives/CGU8HUTUH/p1656505879286119
2022-07-25 15:47:11 +00:00
Javi Velasco
14463ddd10
Update Edge Runtime (#38862)
This PR updates the Edge Runtime to use a new version that loads dependencies differently. This addresses https://github.com/vercel/next.js/pull/38766 so `instanceof` works as expected.

It involved a few code changes, mostly regarding to types. The most important change is that the `Runner` function in the sandbox doesn't take a `ReadableStream` as `body` anymore since this implies creating the instance on "node land" and makes the runtime `fetch` function not to be able to compare with `ReadableStream` using `instanceof`.  Instead we introduce a "clonable body" abstraction that allows to create the `ReadableStream` from `Readable` by using the edge runtime primitive which would hold the correct prototype.

Also, this PR changes the way we pre-compile the Edge Runtime to adapt it to the new version.
2022-07-21 18:29:19 +00:00
JJ Kasper
ff148a0fb4
Update to latest version of turbo (#38629)
Updates to latest turbo which includes patches for cached files. 

x-ref: [slack thread](https://vercel.slack.com/archives/C02CDC2ALJH/p1657767763630359?thread_ts=1657757803.039099&cid=C02CDC2ALJH)

## Bug

- [ ] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [ ] Errors have helpful link attached, see `contributing.md`

## Feature

- [ ] Implements an existing feature request or RFC. Make sure the feature request has been accepted for implementation before opening a PR.
- [ ] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [ ] Documentation added
- [ ] Telemetry added. In case of a feature if it's used or not.
- [ ] Errors have helpful link attached, see `contributing.md`

## Documentation / Examples

- [ ] Make sure the linting passes by running `pnpm lint`
- [ ] The examples guidelines are followed from [our contributing doc](https://github.com/vercel/next.js/blob/canary/contributing.md#adding-examples)
2022-07-14 09:03:35 +00:00
Tim Neutkens
1e2b30dd51
Pass server context to Flight render (#38582)
Ensures you can use server context when navigating.


## Bug

- [ ] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [ ] Errors have helpful link attached, see `contributing.md`

## Feature

- [ ] Implements an existing feature request or RFC. Make sure the feature request has been accepted for implementation before opening a PR.
- [ ] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [ ] Documentation added
- [ ] Telemetry added. In case of a feature if it's used or not.
- [ ] Errors have helpful link attached, see `contributing.md`

## Documentation / Examples

- [ ] Make sure the linting passes by running `pnpm lint`
- [ ] The examples guidelines are followed from [our contributing doc](https://github.com/vercel/next.js/blob/canary/contributing.md#adding-examples)
2022-07-13 09:40:09 +00:00
Gal Schlezinger
62eb16b603
Upgrade edge-runtime + make EdgeRuntime value overridable with an env var on compilation (#38331)
This PR introduces an environment variable that allows to modify the `EdgeRuntime` value on compilation time.
This is done to allow cloud providers like Vercel to have a different value, and enable user code and 3rd party libraries to have different code paths depending on the Edge Functions provider.

## Related

- Related to #30739

## Bug

- [x] Related issues linked using `fixes #number`
- [x] Integration tests added
- [ ] Errors have helpful link attached, see `contributing.md`
2022-07-12 15:18:59 +00:00
Tim Neutkens
f113141389
Implement new client-side router (#37551)
## Client-side router for `app` directory

This PR implements the new router that leverages React 18 concurrent features like Suspense and startTransition.
It also integrates with React Server Components and builds on top of it to allow server-centric routing that only renders the part of the page that has to change.

It's one of the pieces of the implementation of https://nextjs.org/blog/layouts-rfc.

## Details

I'm going to document the differences with the current router here (will be reworked for the upgrade guide)

### Client-side cache

In the current router we have an in-memory cache for getStaticProps data so that if you prefetch and then navigate to a route that has been prefetched it'll be near-instant. For getServerSideProps the behavior is different, any navigation to a page with getServerSideProps fetches the data again.

In the new model the cache is a fundamental piece, it's more granular than at the page level and is set up to ensure consistency across concurrent renders. It can also be invalidated at any level.

#### Push/Replace (also applies to next/link)

The new router still has a `router.push` / `router.replace` method.

There are a few differences in how it works though:

- It only takes `href` as an argument, historically you had to provide `href` (the page path) and `as` (the actual url path) to do dynamic routing. In later versions of Next.js this is no longer required and in the majority of cases `as` was no longer needed. In the new router there's no way to reason about `href` vs `as` because there is no notion of "pages" in the browser.
- Both methods now use `startTransition`, you can wrap these in your own `startTransition` to get `isPending`
- The push/replace support concurrent rendering. When a render is bailed by clicking a different link to navigate to a completely different page that still works and doesn't cause race conditions.
- Support for optimistic loading states when navigating

##### Hard/Soft push/replace

Because of the client-side cache being reworked this now allows us to cover two cases: hard push and soft push.

The main difference between the two is if the cache is reused while navigating. The default for `next/link` is a `hard` push which means that the part of the cache affected by the navigation will be invalidated, e.g. if you already navigated to `/dashboard` and you `router.push('/dashboard')` again it'll get the latest version. This is similar to the existing `getServerSideProps` handling.

In case of a soft push (API to be defined but for testing added `router.softPush('/')`) it'll reuse the existing cache and not invalidate parts that are already filled in. In practice this means it's more like the `getStaticProps` client-side navigation because it does not fetch on navigation except if a part of the page is missing.

#### Back/Forward navigation

Back and Forward navigation ([popstate](https://developer.mozilla.org/en-US/docs/Web/API/Window/popstate_event)) are always handled as a soft navigation, meaning that the cache is reused, this ensures back/forward navigation is near-instant when it's in the client-side cache. This will also allow back/forward navigation to be a high priority update instead of a transition as it is based on user interaction. Note: in this PR it still uses `startTransition` as there's no way to handle the high priority update suspending which happens in case of missing data in the cache. We're working with the React team on a solution for this particular case.

### Layouts

Note: this section assumes you've read [The layouts RFC](https://nextjs.org/blog/layouts-rfc) and [React Server Components RFC](https://reactjs.org/blog/2020/12/21/data-fetching-with-react-server-components.html)

React Server Components rendering leverages the Flight streaming mechanism in React 18, this allows sending a serializable representation of the rendered React tree on the server to the browser, the client-side React can use this serialized representation to render components client-side without the JavaScript being sent to the browser. This is one of the building blocks of Server Components. This allows a bunch of interesting features but for now I'll keep it to how it affects layouts.

When you have a `app/dashboard/layout.js` and `app/dashboard/page.js` the page will render as children of the layout, when you add another page like `app/dashboard/integrations/page.js` that page falls under the dashboard layout as well. When client-side navigating the new router automatically figures out if the page you're navigating to can be a smaller render than the whole page, in this case `app/dashboard/page.js` and `app/dashboard/integrations/page.js` share the `app/dashboard/layout.js` so instead of rendering the whole page we render below the layout component, this means the layout itself does not get re-rendered, the layout's `getServerSideProps` would not be called, and the Flight response would only hold the result of `app/dashboard/integrations/page.js`, effectively giving you the smallest patch for the UI.

---

Note: the commits in this PR were mostly work in progress to ensure it wasn't lost along the way. The implementation was reworked a bunch of times to where it is now.

Co-authored-by: Jiachi Liu <4800338+huozhi@users.noreply.github.com>
Co-authored-by: JJ Kasper <22380829+ijjk@users.noreply.github.com>
2022-07-06 21:16:47 +00:00
JJ Kasper
9573174196
Replace pre-commit with husky (#38350)
* Replace pre-commit with husky

* update lock

* actually update lock
2022-07-06 11:14:16 -05:00
Steven
fb8686055a
Revert "chore: remove workspace from package.json since we have `pnpm-works…" (#38376)
Revert "chore: remove workspace from `package.json` since we have `pnpm-works… (#38166)"

This reverts commit a37abc62ee.
2022-07-06 17:08:00 +02:00
Anjorin Damilare
a37abc62ee
chore: remove workspace from package.json since we have `pnpm-works… (#38166)
chore: remove workspace from `package.json` since we have `pnpm-workspace`
2022-07-06 16:26:20 +02:00
Jiachi Liu
bfaffbdd3f
Alias react and react-dom by default (#38245)
Previously we use custom webpack alias for specific react versions for non server side node runtime aliases. This PR alias the entire folders of `react/` and `react-dom/` so that no more alias in next.config is required but only the nodejs require hook.

* Alias `react` and `react-dom` by default
* Use `react@experimental` to run server components integration test
* Drop with-react-17 test util, add `__NEXT_REACT_CHANNEL` as an env var for testing and development to specify the react channel is 17 or new experimental version
2022-07-01 23:57:45 +00:00
Michael Novotny
edd395a7d3
Adds tests to ensure eslint-plugin-next's available rules are properly exported and recommended rules are correctly defined. (#38183)
* Adds tests to ensure `eslint-plugin-next`'s available rules are properly exported and recommended rules are defined correctly.

* Condenses imports.

* Sets default recommended value.

* replace Object.hasOwn for node 14

Co-authored-by: JJ Kasper <jj@jjsweb.site>
2022-06-30 11:31:33 -05:00
Wyatt Johnson
23b8b982df
Fix missing trace script devDependencies (#38172)
Adds missing devDependencies required by the `trace-to-tree.mjs` script used here to the workspace root.

c64af8aa34/scripts/trace-to-tree.mjs (L2-L3)
2022-06-29 20:57:51 +00:00
Kiko Beats
9cc1c3c576
Upgrade Edge Runtime (#38105) 2022-06-28 07:48:23 -05:00
Kiko Beats
5819dd5540
Upgrade Edge Runtime (#38069)
This new version renamed `globalThis.Edge` into `globalThis.EdgeRuntime`.
2022-06-27 18:44:02 +00:00
Steven
8302a3ff7c
Move rimraf from root packages using it (#37996)
In a previous PR (#37278), the dependencies for benchmarks were moved to a subdirectory.

This ensures the same is done for other packages using `rimraf` which means we can remove it from the root package.json
2022-06-24 21:08:52 +00:00
Steven
880d4fb5c9
Bump release to 6.3.1 (#37995) 2022-06-24 15:02:40 -05:00
JJ Kasper
658a7f550f
Update to latest version of turbo (#37976) 2022-06-24 09:31:26 -05:00
Leah
7c20918bc7
feat: enable configuration of styled-components transform and enable css prop support (#37861)
This allows configuring / overriding the default options of the `styled-components` swc transform and allows using the `css` prop support, which was already implemented, but not available.

Edit: made the CSS prop transform run before the display name, so it gets picked up by that and receives the (deterministic) name.

Relates to #30802
2022-06-23 16:55:05 +00:00
Donny/강동윤
ee7648ae0a
Update swc (#37607)
* Update swc

* Update again

* fixup

* Bump

* Update

* fixup

* Update test refs

* Update minifier

* Parser

* Update swc

* Bump version

* Update

* fixup

* Update test refs

* Bump

* Update `@swc/helpers`

* lockfile

* lints

* FIx

* [TRY] Update @swc/core
2022-06-21 10:51:47 -05:00
JJ Kasper
081c21bc1c
Revert "Enable externalHelpers when pre compiling Next.js' code" (#37829)
Revert "Enable `externalHelpers` when pre compiling Next.js' code (#37164)"

This reverts commit 4671010169.
2022-06-19 13:19:23 -05:00
Sukka
4671010169
Enable externalHelpers when pre compiling Next.js' code (#37164)
* chore: enable `externalHelpers` for pre-compile

* chore(devDeps): update @swc/core@1.2.203
2022-06-19 10:03:50 -05:00
JJ Kasper
924582b52c
Update to use latest version of pnpm (#37794)
* Update to use latest version of pnpm

* add packageManager field
2022-06-17 12:36:37 -05:00
Damien Simonin Feugas
c2b8006485
refactor(middleware): leverages edge-runtime builtins to decorate errors in dev (#37718)
### What's in there?

This is a followup of https://github.com/vercel/next.js/pull/37695.
For the dev server to clean stacktraces, we're decorating errors caught during code evaluation (`getServerSideProps` or middleware).
However, when these errors are asynchronously raised, we can't decorate them before processing them, leading to this fallback logic:

bf7bf8217f/packages/next/server/dev/next-dev-server.ts (L775-L779)

Thanks to latest improvement of the edge-runtime in 1.1.0-beta.4, we can now catch unhandled rejection and uncaught exception, and decorate them.

### How to test?

Please reuse the existing tests who already covered these cases:
`pnpm testheadless --testPathPattern middleware-dev-errors`


Co-authored-by: JJ Kasper <22380829+ijjk@users.noreply.github.com>
2022-06-17 15:06:30 +00:00
Jiachi Liu
40b0dae558
chore: bump react dev dep to 18.2 (#37697)
* chore: bump react dev dep to 18.2

* fix test and exclude inc cache path for edge

* update compiled

Co-authored-by: JJ Kasper <jj@jjsweb.site>
2022-06-15 10:14:43 -05:00