Commit graph

1219 commits

Author SHA1 Message Date
Tim Neutkens
819a163fce
Update dd-trace used for internal tools (#54214)
This is only used for internal tools 👍
2023-08-18 13:55:22 +00:00
Kiko Beats
b676fce090
upgrade edge-runtime dependency (#54117)
Hello,

This PR upgrades `edge-runtime` and associated packages, mostly fixing issues.
2023-08-16 13:57:01 +00:00
Josh Story
2b38118ea0
Update React ot latest canary (#53881)
Updated React from cb3404a0c to f359f9b41.

### React upstream changes

- https://github.com/facebook/react/pull/27191
- https://github.com/facebook/react/pull/27209
- https://github.com/facebook/react/pull/27199
- https://github.com/facebook/react/pull/27218
- https://github.com/facebook/react/pull/27217
- https://github.com/facebook/react/pull/27212
2023-08-12 17:20:14 +00:00
Dima Voytenko
4c14482553
[chore] Upgrade playwright to 1.35.1 (#53875) 2023-08-11 23:25:01 +00:00
Josh Story
f0dab3a8da
update vendored React packages to the the latest canary (#53742)
Updated React from 9377e1010 to cb3404a0c.

### React upstream changes

- https://github.com/facebook/react/pull/27190
- https://github.com/facebook/react/pull/27189
- https://github.com/facebook/react/pull/27201
- https://github.com/facebook/react/pull/27147
- https://github.com/facebook/react/pull/26949
- https://github.com/facebook/react/pull/27058
- https://github.com/facebook/react/pull/27142
- https://github.com/facebook/react/pull/27133
- https://github.com/facebook/react/pull/27130
- https://github.com/facebook/react/pull/27105
- https://github.com/facebook/react/pull/27117
- https://github.com/facebook/react/pull/27057
2023-08-08 20:16:24 +00:00
Thomas Knickman
3db5c16546
fix(node): pnpm 8.6 needs node 16.14 (#53677)
The `pnpm` version was recently updated to `8.6`, however the node version was left at `16.8`. `pnpm@8.6` requires at least `node@16.14` ([source](https://github.com/pnpm/pnpm/blob/main/pnpm/package.json#L145)).

This fixes the engines spec to avoid conflicting versions.
2023-08-07 15:15:26 +00:00
JJ Kasper
6483903372
Add update fonts workflow (#53645)
This adds a workflow to auto update our fonts data so we can stay up to date easier. 

Closes: https://github.com/vercel/next.js/pull/53246
Closes: https://github.com/vercel/next.js/pull/53510
2023-08-07 00:11:03 +00:00
JJ Kasper
7bf3d77b5e
Revert "Implement new forking technique for vendored packages. (#51083)" (#53640)
This reverts commit e06880ea4c.

reverts: https://github.com/vercel/next.js/pull/51083

x-ref: [slack
thread](https://vercel.slack.com/archives/C04DUD7EB1B/p1691349686136519)
x-ref: [slack
thread](https://vercel.slack.com/archives/C03S8ED1DKM/p1691349579712979?thread_ts=1691217652.833079&cid=C03S8ED1DKM)
2023-08-06 13:00:12 -07:00
Josh Story
e06880ea4c
Implement new forking technique for vendored packages. (#51083)
## Vendoring

Updates all module resolvers (node, webpack, nft for entrypoints, and nft for next-server) to consider whether vendored packages are suitable for a given resolve request and resolves them in an import semantics preserving way.

### Problem

Prior to the proposed change, vendoring has been accomplished but aliasing module requests from one specifier to a different specifier. For instance if we are using the built-in react packages for a build/runtime we might replace `require('react')` with `require('next/dist/compiled/react')`.

However this aliasing introduces a subtle bug. The React package has an export map that considers the condition `react-server` and when you require/import `'react'` the conditions should be considered and the underlying implementation of react may differ from one environment to another. In particular if you are resolving with the `react-server` condition you will be resolving the `react.shared-subset.js` implementation of React. This aliasing however breaks these semantics because it turns a bare specifier resolution of `react` with path `'.'` into a resolution with bare specifier `next` with path `'/dist/compiled/react'`. Module resolvers consider export maps of the package being imported from but in the case of `next` there is no consideration for the condition `react-server` and this resolution ends up pulling in the `index.js` implementation inside the React package by doing a simple path resolution to that package folder.

To work around this bug there is a prevalence of encoding the "right" resolution into the import itself. We for instance directly alias `react` to `next/dist/compiled/react/react.shared-subset.js` in certain cases. Other times we directly specify the runtime variant for instance `react-server-dom-webpack/server.edge` rather than `react-server-dom-wegbpack/server`, bypassing the export map altogether by selecting the runtime specific variant. However some code is meant to run in more than one runtime, for instance anything that is part of the client bundle which executes on the server during SSR and in the browser. There are workaround like using `require` conditionally or `import(...)` dynamically but these all have consequences for bundling and treeshaking and they still require careful consideration of the environment you are running in and which variant needs to load.

The result is that there is a large amount of manual pinning of aliases and additional complexity in the code and an inability to trust the package to specify the right resolution potentially causing conflicts in future versions as packages are updated.

It should be noted that aliasing is not in and of itself problematic when we are trying to implement a sort of lightweight forking based on build or runtime conditions. We have good examples of this for instance with the `next/head` package which within App Router should export a noop function. The problem is when we are trying to vendor an entire package and have the package behave semantically the same as if you had installed it yourself via node_modules

### Solution

The fix is seemingly straight forward. We need to stop aliasing these module specifiers and instead customize the resolution process to resolve from a location that will contain the desired vendored packages. We can then start simplifying our imports to use top level package resources and generally and let import conditions control the process of providing the right variant in the right context.

It should be said that vendoring is conditional. Currently we only vendor react pacakges for App Router runtimes. The implementation needs to be able to conditionally determine where a package resolves based on whether we're in an App Router context vs a Page Router one.

Additionally the implementation needs to support alternate packages such as supporting the experimental channel for React when using features that require this version.

### Implementation

The first step is to put the vendored packages inside a node_modules folder. This is essential to the correct resolving of packages by most tools that implement module resolution. For packages that are meant to be vendored, meaning whole package substitution we move the from `next/(src|dist)/compiled/...` to `next/(src|dist)/vendored/node_modules`. The purpose of this move is to clarify that vendored packages operate with a different implementation. This initial PR moves the react dependencies for App Router and `client-only` and `server-only` packages into this folder. In the future we can decide which other precompiled dependencies are best implemented as vendored packages and move them over.

It should be noted that because of our use of `JestWorker` we can get warnings for duplicate package names so we modify the vendored pacakges for react adding either `-vendored` or `-experimental-vendored` depending on which release channel the package came from. While this will require us to alter the request string for a module specifier it will still be treating the react package as the bare specifier and thus use the export map as required.

#### module resolvers
The next thing we need to do is have all systems that do module resolution implement an custom module resolution step. There are five different resolvers that need to be considered

##### node runtime
Updated the require-hook to resolve from the vendored directory without rewriting the request string to alter which package is identified in the bare specifier. For react packages we only do this vendoring if the `process.env.__NEXT_PRIVATE_PREBUNDLED_REACT` envvar is set indicating the runtime is server App Router builds. If we need a single node runtime to be able to conditionally resolve to both vendored and non vendored versions we will need to combine this with aliasing and encode whether the request is for the vendored version in the request string. Our current architecture does not require this though so we will just rely on the envvar for now

##### webpack runtime
Removed all aliases configured for react packages. Rely on the node-runtime to properly alias external react dependencies. Add a resolver plugin `NextAppResolverPlugin` to preempt perform resolution from the context of the vendored directory when encountering a vendored eligible package.

##### turbopack runtime
updated the aliasing rules for react packages to resolve from the vendored directory when in an App Router context. This implementation is all essentially config b/c the capability of doing the resolve from any position (i.e. the vendored directory) already exists

##### nft entrypoints runtime
track chunks to trace for App Router separate from Pages Router. For the trace for App Router chunks use a custom resolve hook in nft which performs the resolution from the vendored directory when appropriate.

##### nft next-server runtime
The current implementation for next-server traces both node_modules and vendored version of packages so all versions are included. This is necessary because the next server can run in either context (App vs Page router) and may depend on any possible variants. We could in theory make two traces rather than a combined one but this will require additional downstream changes so for now it is the most conservative thing to do and is correct

Once we have the correct resolution semantics for all resolvers we can start to remove instances targeting our precompiled instances for instance making `import ... from "next/dist/compiled/react-server-dom-webpack/client"` and replacing with `import ... from "react-server-dom-webpack/client"`

We can also stop requiring runtime specific variants like `import ... from "react-server-dom-webpack/client.edge"` replacing it with the generic export `"react-server-dom-webpack/client"`

There are still two special case aliases related to react
1. In profiling mode (browser only) we rewrite `react-dom` to `react-dom/profiling` and `scheduler/tracing` to `scheduler/tracing-profiling`. This can be moved to using export maps and conditions once react publishses updates that implement this on the package side.
2. When resolving `react-dom` on the server we rewrite this to `react-dom/server-rendering-stub`. This is to avoid loading the entire react-dom client bundle on the server when most of it goes unused. In the next major react will update this top level export to only contain the parts that are usable in any runtime and this alias can be dropped entirely

There are two non-react packages currently be vendored that I have maintained but think we ought to discuss the validity of vendoring. The `client-only` and `server-only` packages are vendored so you can use them without having to remember to install them into your project. This is convenient but does perhaps become surprising if you don't realize what is happening. We should consider not doing this but we can make that decision in another discussion/PR.

#### Webpack Layers
One of the things our webpack config implements for App Router is layers which allow us to have separate instances of packages for the server components graph and the client (ssr) graph. The way we were managing layer selection was a but arbitrary so in addition to the other webpack changes the way you cause a file to always end up in a specific layer is to end it with `.serverlayer`, `.clientlayer` or `.sharedlayer`. These act as layer portals so something in the server layer can import `foo.clientlayer` and that module will in fact be bundled in the client layer.

#### Packaging Changes
Most package managers are fine with this resolution redirect however yarn berry (yarn 2+ with PnP) will not resolve packages that are not defined in a package.json as a dependency. This was not a problem with the prior strategy because it was never resolving these vendored packages it was always resolving the next package and then just pointing to a file within it that happened to be from react or a related package.

To get around this issue vendored packages are both committed in src and packed as a tgz file. Then in the next package.json we define these vendored packages as `optionalDependency` pointing to these tarballs. For yarn PnP these packed versions will get used and resolved rather than the locally commited src files. For other package managers the optional dependencies may or may not get installed but the resolution will still resolve to the checked in src files. This isn't a particularly satisfying implemenation and if pnpm were to be updated to have consistent behavior installing from tarballs we could actually move the vendoring entirely to dependencies and simplify our resolvers a fair bit. But this will require an upstream chagne in pnpm and would take time to propogate in the community since many use older versions

#### Upstream Changes

As part of this work I landed some other changes upstream that were necessary. One was to make our packing use `npm` to match our publishing step. This also allows us to pack `node_modules` folders which is normally not supported but is possible if you define the folder in the package.json's files property.

See: #52563

Additionally nft did not provide a way to use the internal resolver if you were going to use the resolve hook so that is now exposed

See: https://github.com/vercel/nft/pull/354

#### additional PR trivia
* When we prepare to make an isolated next install for integration tests we exclude node_modules by default so we have a special case to allow `/vendored/node_modules`

* The webpack module rules were refactored to be a little easier to reason about and while they do work as is it would be better for some of them to be wrapped in a `oneOf` rule however there is a bug in our css loader implementation that causes these oneOf rules to get deleted. We should fix this up in a followup to make the rules a little more robuts.


## Edits
* I removed `.sharedlayer` since this concept is leaky (not really related to the client/server boundary split) and it is getting refactored anyway soon into a precompiled runtime.
2023-08-04 23:47:10 +00:00
Leah
542c4fc26a
chore: update to pnpm@8.6.11 (#50923)
https://github.com/pnpm/pnpm/releases/tag/v8.0.0
2023-08-04 19:40:20 +00:00
Steven
8c6da3f72d
chore(test): move build-spinners node-pty test to isolated (#53408)
Co-authored-by: JJ Kasper <22380829+ijjk@users.noreply.github.com>
2023-08-01 00:30:22 +00:00
Josh Goldberg ✨
fc52e02787
chore: enable typescript-eslint's recommended and stylistic configs internally (#52948)
Spinning out from #37151 and my draft PR #52845, this enables the two
basic recommended rulesets from
[typescript-eslint](https://typescript-eslint.io) for the Next.js
monorepo source code:

*
[`plugin:@typescript-eslint/recommended`](https://typescript-eslint.io/linting/configs#recommended):
Our base recommended rules that detect common bugs or _(non-stylistic)_
TypeScript bad practices
*
[`plugin:@typescript-eslint/stylistic`](https://typescript-eslint.io/linting/configs#stylistic):
Our base starting stylistic recommended for keeping codebases visually
consistent and avoiding out-of-practice visual constructs

The process I used is pretty standard (see
https://github.com/typescript-eslint/typescript-eslint/issues/6760 for
other repos it was done on):

1. Enable those base recommended presets
2. Remove any rule settings that are now redundant
3. Reconfigure any rule whose default settings didn't seem to make sense
for this codebase
4. Add a `// Todo: ...` comment, and under it, add a disable for any
rule that immediately reported a lot of complaints

Note that this only enables the presets internally. It doesn't impact
what end-users of published packages such as Next.js or
`create-next-app` experience. That's a separate task in #52845.

I also didn't fix any existing warning from the `canary` branch. Would
you like me to do that? My preference would be a separate PR to get it
in more quickly.

Any code changes are commented inline.

---------

Co-authored-by: Steven <steven@ceriously.com>
2023-07-31 16:32:54 -07:00
Zack Tanner
0d2c5520ed
refactor smooth scroll bailout logic in app navigations (#53186)
This refactors the changes from my previous PR to allow smooth scrolling for the appDir case -- `componentDidUpdate` isn't a reliable way to check if only the hash has changed. This adds a property to `focusAndScrollRef` and compares canonicalUrls (sans hash fragment)

- Original https://github.com/vercel/next.js/pull/52915

Co-authored-by: Tim Neutkens <6324199+timneutkens@users.noreply.github.com>
2023-07-27 14:39:51 +00:00
JJ Kasper
728fd7572a
Update to latest version of turborepo (#52979)
x-ref: [slack
thread](https://vercel.slack.com/archives/C03LMQZL205/p1689895062566699?thread_ts=1688753294.342269&cid=C03LMQZL205)
2023-07-21 10:04:06 +02:00
Jiachi Liu
ec8af55833
Update vendor @vercel/og (#52897)
Upgrade `@vercel/og` to latest version

https://github.com/vercel/og/releases/tag/0.5.9
2023-07-19 21:04:27 +00:00
Janicklas Ralph
009b6a19d6
Setting up third-parties package (#51194)
This PR Introduces `next/third-parties`

- `@next/third-parties` is a new package in the Next.js monorepo. 
- The package contains collection of components that can be used to
efficiently load third party libraries into your Next.js application.
- This package uses [Third Party
Capital](https://github.com/GoogleChromeLabs/third-party-capital/) under
the hood to fetch the best loading recommendations.
- This PR mainly sets up the package to run a script at build time to
auto generate the components from [Third Party
Capital](https://github.com/GoogleChromeLabs/third-party-capital/)
config.

Packages are grouped by company, for eg:

`import { GoogleMapsEmbed } from '@next/third-parties/google'`


cc: @housseindjirdeh @kara 
<!-- 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

- Read the Docs Contribution Guide to ensure your contribution follows
the docs guidelines:
https://nextjs.org/docs/community/contribution-guide

### Adding or Updating Examples

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

### Fixing a bug

- Related issues linked using `fixes #number`
- Tests added. See:
https://github.com/vercel/next.js/blob/canary/contributing/core/testing.md#writing-tests-for-nextjs
- Errors have a helpful link attached, see
https://github.com/vercel/next.js/blob/canary/contributing.md

### Adding a feature

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



## For Maintainers

- Minimal description (aim for explaining to someone not on the team to
understand the PR)
- When linking to a Slack thread, you might want to share details of the
conclusion
- Link both the Linear (Fixes NEXT-xxx) and the GitHub issues
- Add review comments if necessary to explain to the reviewer the logic
behind a change

### What?

### Why?

### How?

Closes NEXT-
Fixes #

-->

---------
2023-07-18 10:52:39 -07:00
Steven
76cb8cf361
chore(deps): bump react@18.3.0-canary-9377e1010-20230712 (#52649)
### React upstream changes

- https://github.com/facebook/react/pull/27096
- https://github.com/facebook/react/pull/27069
- https://github.com/facebook/react/pull/27033
- https://github.com/facebook/react/pull/27061
- https://github.com/facebook/react/pull/27030
- https://github.com/facebook/react/pull/27056
2023-07-13 11:19:01 -04:00
su
4c4bee7112
Remove unnecessary body-parser (#52580)
Since the `body-parser`  middleware is already built-in `express.js` after v4.16.0, so we can clean some code
2023-07-12 23:11:20 +00:00
Steven
6dafc4229d
chore(deps): bump react to 7118f5dd7 (#52282)
Fixes #49409

### React upstream changes

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

---------

Co-authored-by: Jiachi Liu <inbox@huozhi.im>
2023-07-06 14:04:21 +02:00
Tobias Koppers
12f2a66ff0
Revert "chore(deps): bump react 18.3.0-canary-1fdacbefd-20230630" (#52192)
Reverts vercel/next.js#52005
2023-07-04 12:59:14 +02:00
Steven
9e4b87d502
chore(deps): bump react 18.3.0-canary-1fdacbefd-20230630 (#52005)
This PR updates the vendored react dependencies using `pnpm sync-react`

### React upstream changes

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

### Related

Closes #49409 (by https://github.com/facebook/react/pull/26977)
fix NEXT-1189

Co-authored-by: Shu Ding <g@shud.in>
2023-07-04 11:32:31 +02:00
Leah
5d54eaaf18
type check tests (and convert next-test-utils.js to ts) (#51071)
Enables type checking for tests in CI and fixes a bunch of things related to that
2023-06-23 17:42:50 +00:00
Leah
c1c3675fc4
refactor tests for readability (#51051)
You'll probably want to disable whitespace in the diff

## Description

This allows for better editor support by using `describe` or functions called `describe` with the same syntax instead of custom names.

Changes:
- `nextTestSetup` can be used instead of `createNextDescribe` keeping the same behaviour but being called inside a `describe` "block" (not applied everywhere)
- `getSnapshotTestDescribe` replaced with a custom `describe.each`
- `sandbox` helper function for `acceptance`/`acceptance-app` merged into a single shared one
- `outdent` to remove the indent from inline files in tests which helps with consistent snapshots
2023-06-21 19:47:21 +00:00
JJ Kasper
056ab7918f
Revert "Fix pnpm ERR_INVALID_THIS on Node 20" (#51539)
Reverts vercel/next.js#51406

This pnpm bump seems to be causing lockfile issues with the react
versions which causes context issues since we need to share the same
react version in the monorepo.
2023-06-19 23:38:15 -07:00
Nick McCurdy
1602c2af25
Fix pnpm ERR_INVALID_THIS on Node 20 (#51406)
### What?

Fixes pnpm/pnpm#6424

### Why?

So users of Node 20 can contribute to Next.js

### How?

Upgrades pnpm with back compatibility to patch `ERR_INVALID_THIS` error.
If Node 14 support isn't necessary, I'd recommend upgrading to pnpm 8
for continued feature support and committing the lockfile.

---------

Co-authored-by: JJ Kasper <jj@jjsweb.site>
2023-06-16 05:37:11 -07:00
JJ Kasper
6dcc4fbc23
Increase remote cache timeout for swc builds (#51270)
These occasionally timeout and start building even when they don't need
to so this increases them a bit from the default.
2023-06-13 21:31:40 -07:00
OJ Kwon
bcb63f3250
ci(workflow): enable test trace upload (#51107)
### What?

WEB-1150. 

This PR is an attempt to upload next.js's test results into datadog test trace to track its status. 

Originally it tried to use automatic trace injection (dd-trace/ci/init). However, due to some of custom environments / setup we use it was not compatible out of the box. Instead, this PR injects a new test reportert to generate junit report, then upload it at once at the end of the testing pipeline.

The reporter is configured to run when necessary variables set, local run should not be affected. 

One thing to note is this report will not count retry results, as it'll create duplicated test entry with multiple results since we runts jest per individual test. This'll allow to detect flaky test easier, but also it means we'll get bit of skewed test results compare to the real world as first failure will be accounted as test fail immediately.
2023-06-12 17:14:13 +00:00
Steven
2226d2935f
chore: drop unused @webassemblyjs (#51045)
Remove these dependencies since they appear to be unused

- Closes https://github.com/vercel/next.js/pull/50928
- Closes https://github.com/vercel/next.js/pull/50123
2023-06-09 16:03:15 +00:00
Michael Novotny
55b29fb351
Updates prettier to latest version. (#51000)
There are some incoming docs / MDX changes where prettier will throw an error when using the older version. Updating prettier before I bring in those changes.

Looks like the most notable change is adding parentheses around `typeof` checks in TypeScript. 

**Before**

```
export type Locale = typeof i18n['locales'][number]
```

**After**

```
export type Locale = (typeof i18n)['locales'][number]
```
2023-06-09 14:58:19 +00:00
Jiachi Liu
f2e637d24d
Upgrade webpack to 5.86.0 (#50992)
To resolve issue #49382, we found layer doesn't get applied for dynamic imports, so we fixed it on webpack side in https://github.com/webpack/webpack/pull/17310

This PR is to upgrade webpack to 5.86.0 with that patch as a precedence. After this we need to fix the `next/image` client components is missing in client reference manifest when using dynamic imports to fix the issue.
2023-06-08 20:35:12 +00:00
Steven
9a9d095b54
Bump to typescript@5.1 (#50557)
We need to upgrade TypeScript to land the following fixes:

- https://github.com/vercel/next.js/pull/50289
- https://github.com/vercel/next.js/pull/48018

And it should fix async components:
- https://twitter.com/sebsilbermann/status/1664356039876124672

Also see this related TS 5.0 issue:

- https://github.com/microsoft/TypeScript/issues/53402
2023-06-08 17:18:37 +00:00
Jiachi Liu
a035224dc3
Pick esm main fields and condition names first for RSC server layer (#50548)
For RSC server layer so far we bundle all dependencies, ESM format is the better one rather than CJS to analyze and tree-shake out the unused parts. This PR changes pick the condition names that are in ESM format first for server layer.

Also fixes the misorder of condition names of edge runtime, `conditionNames` should only contain either ESM or CJS, previously the main fields are mixed with conditon names which is not expected for webpack, we separate them now.

Since we're picking ESM instead CJS now, the error of require `exports * from` doesn't exist anymore, but if you're using a CJS dependency which require a ESM package, it will error. This is the existing behavior for our webpack configuration but could happen on server layer bundling

Other related changes:

* Imports are hoisted in ESM, so migrate`enhanceGlobals` to a imported module
* Use `...` to pick the proper imports by import expression, and prefer the `react-server` / `edge-light` condition names for corresponding cases
* Remove edge SSR duplicated `middleware` export checking
2023-06-08 16:24:03 +00:00
Wyatt Johnson
ea63e92e87
Bump @types/node (#50940)
This bumps @types/node to 20.2.5 to prepare for upgrades to other packages requiring updated Node.js typescript types.
2023-06-08 15:52:17 +00:00
OJ Kwon
534414d54e
ci(workflow): enable test trace again (#50817)
### What?

Another attempt to https://github.com/vercel/next.js/pull/50619 and WEB-1150, trying to apply setup guard more throughly.

I still do not know why original PR passed CI but fails to subsequent PRs after merge, but hope this could be a right guard to prevent unexpected failures.
2023-06-08 10:52:49 +00:00
Jiachi Liu
e562ddf990
remove unused dev dep ts-node (#50939)
`ts-node` was added in #44715 but not used anymore, it has a `@types/node` dep, this alsos helps to bump node typing later
2023-06-08 02:44:16 +00:00
Josh Story
92b29d2f17
Update react to latest versions (#50604)
Update Vendored React Dependencies
2023-06-07 09:50:27 +00:00
Kiko Beats
218c683db7
upgrade edge-runtime dependency (#50636)
Hello,

We removed some core non-necessary dependencies that make Edge Runtime
smaller 🙂.

Also, Edge Runtime is exposing `WebSocket`, so nothing additional should
be done.

Closes https://github.com/vercel/next.js/issues/50760

---------

Co-authored-by: Wyatt Johnson <accounts+github@wyattjoh.ca>
2023-06-06 16:13:44 +02:00
Gal Schlezinger
a2c27aab1c
[edge] bump @edge-runtime/* package suite (#49092)
Bumping `@edge-runtime/*` <picture data-single-emoji=":edge-runtime:" title=":edge-runtime:"><img class="emoji" width="20" height="auto" src="https://emoji.slack-edge.com/T0CAQ00TU/edge-runtime/b940e917443aa49f.png" alt=":edge-runtime:" align="absmiddle"></picture>  packages to their latest beta, as we had some huge improvements and big changes on how it works internally.

* Using the latest `undici` which provides a WebSocket implementation
* Less polyfill usage as we load modules in the Node.js realm, and can reuse modules from Node.js as time goes on <picture data-single-emoji=":just-right2:" title=":just-right2:"><img class="emoji" width="20" height="auto" src="https://emoji.slack-edge.com/T0CAQ00TU/just-right2/588cf34d02f4b3bd.png" alt=":just-right2:" align="absmiddle"></picture> 
* `instanceof` checks now work within the realm <picture data-single-emoji=":mind_blown:" title=":mind_blown:"><img class="emoji" width="20" height="auto" src="https://emoji.slack-edge.com/T0CAQ00TU/mind_blown/0186b6f181040126.gif" alt=":mind_blown:" align="absmiddle"></picture>
2023-05-31 08:03:20 +00:00
JJ Kasper
a3ab542630
Add new build and test workflow (#50436)
This adds new `build and test` and `build and deploy` workflows in favor
of the existing massive `build, test, and deploy` workflow. Since the
new workflows will use `pull_request_target` this waits to remove the
existing workflow until the new one is tested.

While testing this new workflow flakey behavior in tests have also been
addressed. Along with the new workflow we will also be leveraging new
runners which allow us to run tests against the production binary of
`next-swc` so this avoids slight differences in tests we've seen due to
running against the dev binary.

Furthermore we will have a new flow for allowing workflow runs on PRs
from external forks which will either require a comment be checking a
box approving the run after each change or a label added by the team.

The new flow also no longer relies on `actions/cache` or similar which
have proven to be pretty unreliable.

Tests runs with the new workflow can be seen here
https://github.com/vercel/next.js/actions/runs/5100673508/jobs/9169416949
2023-05-27 21:02:31 -07:00
Jiachi Liu
b993949155
Upgrade vendored @vercel/og (#50395)
* upgrade `@vercel/og` to latest
* fix precompile script
2023-05-26 19:02:53 +00:00
Steven
11a7117d40
chore: cross-platform rm -rf script (#49529)
- Closes https://github.com/vercel/next.js/issues/42433
- Closes https://github.com/vercel/next.js/pull/43105
- Closes https://github.com/vercel/next.js/pull/49522
2023-05-10 01:14:37 +00:00
Andrew Clark
7e02f11e3a
Upgrade React to 18.3.0-canary-16d053d59-20230506 (#49402)
Fixes a bug where `useFormStatus` crashed during SSR.

Includes the following upstream changes:

- [16d053d59](https://github.com/facebook/react/commits/16d053d59) Add useFormStatus to server rendering stub ([#26788](https://github.com/facebook/react/pull/26788)) (Andrew Clark)
- [efb381bbf](https://github.com/facebook/react/commits/efb381bbf) [Release Script] Print a hint where to get the token ([#26783](https://github.com/facebook/react/pull/26783)) (dan)
- [b00e27342](https://github.com/facebook/react/commits/b00e27342) Use native scheduler if defined in global scope ([#26554](https://github.com/facebook/react/pull/26554)) (Samuel Susla)
- [783e7fcfa](https://github.com/facebook/react/commits/783e7fcfa) React DevTools 4.27.6 -> 4.27.7 ([#26780](https://github.com/facebook/react/pull/26780)) (Ruslan Lesiutin)
- [377c5175f](https://github.com/facebook/react/commits/377c5175f) DevTools: fix backend activation ([#26779](https://github.com/facebook/react/pull/26779)) (Ruslan Lesiutin)
2023-05-07 16:43:06 +00:00
Jiachi Liu
d37043f51a
Upgrade react types (#49222) 2023-05-05 01:03:26 +02:00
Jiachi Liu
1db5a9133f
types: upgrade react/react-dom types (#49213)
### What

Upgrade react/react-dom typing to latest 

```
"@types/react": "18.2.5",
"@types/react-dom": "18.2.3",
```
2023-05-04 16:31:36 +02:00
Andrew Clark
d543fd19db
Upgrade React to 18.3.0-canary-aef7ce554-20230503 (#49181)
Includes the following upstream changes:

- [aef7ce554](https://github.com/facebook/react/commits/aef7ce554)
[Flight] Progressively Enhanced Server Actions
([#26774](https://github.com/facebook/react/pull/26774)) (Sebastian
Markbåge)
- [c10010a6a](https://github.com/facebook/react/commits/c10010a6a)
[Fizz] Gracefully handle suspending in DOM configs
([#26768](https://github.com/facebook/react/pull/26768)) (Sebastian
Markbåge)
- [f533cee8c](https://github.com/facebook/react/commits/f533cee8c) Add
useFormStatus to Flight fixture
([#26773](https://github.com/facebook/react/pull/26773)) (Andrew Clark)
- [2c1117a8d](https://github.com/facebook/react/commits/2c1117a8d) Reuse
request so that a ReabableStream body does not become disturbed
([#26771](https://github.com/facebook/react/pull/26771)) (Andrew Gadzik)
- [fa7a447b9](https://github.com/facebook/react/commits/fa7a447b9)
[Fizz] Check for nullish values on ReactCustomFormAction
([#26770](https://github.com/facebook/react/pull/26770)) (Sebastian
Markbåge)

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

-->
2023-05-04 01:48:40 +00:00
Andrew Clark
e659653e48
Upgrade React to 18.3.0-canary-b7972822b-20230503 (#49158)
Includes the following upstream changes:

- [b7972822b](https://github.com/facebook/react/commits/b7972822b)
useOptimisticState -> useOptimistic
([#26772](https://github.com/facebook/react/pull/26772)) (Andrew Clark)
- [388686f29](https://github.com/facebook/react/commits/388686f29) Add
"canary" to list of allowed npm dist tags
([#26767](https://github.com/facebook/react/pull/26767)) (Andrew Clark)
- [8a25302c6](https://github.com/facebook/react/commits/8a25302c6)
fix[dynamic-scripts-injection]: unregister content scripts before
registration ([#26765](https://github.com/facebook/react/pull/26765))
(Ruslan Lesiutin)
- [2c2476834](https://github.com/facebook/react/commits/2c2476834)
Rename "next" prerelease channel to "canary"
([#26761](https://github.com/facebook/react/pull/26761)) (Andrew Clark)
- [fa4314841](https://github.com/facebook/react/commits/fa4314841)
Remove deprecated workflow key from Circle config
([#26762](https://github.com/facebook/react/pull/26762)) (Andrew Clark)
- [5dd90c562](https://github.com/facebook/react/commits/5dd90c562) Use
content hash for react-native builds
([#26734](https://github.com/facebook/react/pull/26734)) (Samuel Susla)
- [559e83aeb](https://github.com/facebook/react/commits/559e83aeb)
[Fizz] Allow an action provide a custom set of props to use for
progressive enhancement
([#26749](https://github.com/facebook/react/pull/26749)) (Sebastian
Markbåge)
- [67f4fb021](https://github.com/facebook/react/commits/67f4fb021) Allow
forms to skip hydration of hidden inputs
([#26735](https://github.com/facebook/react/pull/26735)) (Sebastian
Markbåge)
- [8ea96ef84](https://github.com/facebook/react/commits/8ea96ef84)
[Fizz] Encode external fizz runtime into chunks eagerly
([#26752](https://github.com/facebook/react/pull/26752)) (Josh Story)
- [491aec5d6](https://github.com/facebook/react/commits/491aec5d6)
Implement experimental_useOptimisticState
([#26740](https://github.com/facebook/react/pull/26740)) (Andrew Clark)
- [9545e4810](https://github.com/facebook/react/commits/9545e4810) Add
nonce support to bootstrap scripts and external runtime
([#26738](https://github.com/facebook/react/pull/26738)) (Dan Ott)
- [86b0e9199](https://github.com/facebook/react/commits/86b0e9199) Gate
DevTools test to fix CI
([#26742](https://github.com/facebook/react/pull/26742)) (Andrew Clark)
- [b12bea62d](https://github.com/facebook/react/commits/b12bea62d)
Preinits should support a nonce option
([#26744](https://github.com/facebook/react/pull/26744)) (Josh Story)
- [efbd68511](https://github.com/facebook/react/commits/efbd68511)
Remove unused `initialStatus` parameter from `useHostTransitionStatus`
([#26743](https://github.com/facebook/react/pull/26743)) (Sebastian
Silbermann)
- [18282f881](https://github.com/facebook/react/commits/18282f881) Fix:
Update while suspended fails to interrupt
([#26739](https://github.com/facebook/react/pull/26739)) (Andrew Clark)
- [540bab085](https://github.com/facebook/react/commits/540bab085)
Implement experimental_useFormStatus
([#26722](https://github.com/facebook/react/pull/26722)) (Andrew Clark)

---------
2023-05-03 14:03:19 -07:00
Shu Ding
5bc1e65efd
Add flag to switch to the experimental channel (#48896)
This PR does three things:
- Vendors the package `react-server-dom-webpack@experimental` as
`react-server-dom-webpack-experimental` similar to React and React DOM
- Upgrades all vendored React packages
- Re-lands the `experimentalReact` flag to switch between `@next` and
`@experimental` channels of React for app dir.

Fix NEXT-926.
2023-05-01 15:49:10 +02:00
Jiachi Liu
986039db6e
Update google fonts (#48984)
### What?

* Update google fonts for `next/font` with `scripts/update-google-fonts.js.`
* Add npm script `pnpm update-google-fonts`

### How?

Run `pnpm update-google-fonts`
2023-04-29 15:03:22 +00:00
Balázs Orbán
88a033fa1f
chore: expose globalThis.crypto when not available (#48941)
### What?

Exposing `globalThis.crypto`, based on [Node.js' WebCrypto
API](https://nodejs.org/api/globals.html#crypto_1)

### Why?

Similar to `fetch`, `crypto` is a popular API that is currently not
available on `globalThis` in all active Node.js versions yet.

This can help library authors to create runtime-agnostic packages.

### How?

Node.js already has the WebCrypto API that can be imported, we just
expose it on `globalThis` in Node.js versions where this is not
available.

Closes NEXT-1063

[Slack
thread](https://vercel.slack.com/archives/C03KAR5DCKC/p1681821510191059)
2023-04-28 11:18:55 +02:00
Donny/강동윤
e260adb805
fix: Enable CJS annotations for next.js files (#48811)
### What?

Enable import/export annotations for next.js files.

### Why?

It's required to allow importing next.js modules from node.
`cjs-module-lexer` needs these annotations to import CJS modules.

### How?

Closes WEB-949
Fixes #48801
2023-04-27 23:13:40 +00:00