Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[pull] canary from vercel:canary #568

Open
wants to merge 1,526 commits into
base: canary
Choose a base branch
from
Open

Conversation

pull[bot]
Copy link

@pull pull bot commented Feb 8, 2024

See Commits and Changes for more details.


Created by pull[bot]

Can you help keep this open source service alive? 💖 Please sponsor : )

@pull pull bot requested a review from timneutkens as a code owner February 8, 2024 01:29
@pull pull bot added the ⤵️ pull label Feb 8, 2024
vercel-release-bot and others added 28 commits May 8, 2024 11:39
This auto-generated PR updates the development integration test manifest
used when testing Turbopack.
* vercel/turbo#8073 <!-- OJ Kwon -
feat(webpack-loaders): support dummy span interface -->
* vercel/turbo#8083 <!-- OJ Kwon - fix(webpack):
print resource, project path when relative calc fails -->
* vercel/turbo#8094 <!-- Tim Neutkens -
Implement bindings for Turbopack trace server -->
* vercel/turbo#8061 <!-- Tobias Koppers - reduce
memory usage in analyser -->
* vercel/turbo#8077 <!-- Alexander Lyon - Remove
async-trait from a few crates -->
* vercel/turbo#8102 <!-- Tobias Koppers - fix
memory counting without custom allocator -->
* vercel/turbo#8096 <!-- Benjamin Woodruff -
turbo-tasks: Expand `<T as TaskOutput>::Return` values in macros -->
* vercel/turbo#8105 <!-- Benjamin Woodruff -
turbopack-node: Use path.join for postcss loader -->
* vercel/turbo#8099 <!-- Tim Neutkens - Replace
websocket with tungstenite for turbo-trace-server -->
* vercel/turbo#8060 <!-- Donny/강동윤 - feat: Add
lint for `grid-template-areas` -->
* vercel/turbo#8110 <!-- Tobias Koppers - fix
lockfile -->
…65321)

### What

* Remove the `private-next-app-dir` condition for
`WEBPACK_LAYERS.appRouteHandler` layer since it's not effective as the
`rule.test` will match the actual file path. App routes are actually
bundled in rsc layer atm as expected.
* Should only let shared-runtime modules working in either ssr layer or
non-layer (unbundling pages router).
* Remove the pages router context modules for app-page runtime. Still
need to keep amp-context as it's used in `head.js` and `head.js` used in
`next/image`. Not easy to remove unless we have separate implementation
of `next/image` for pages and app router

Closes NEXT-3312
### What?

helps in finding the page name on turbopack crashes
Update styled-jsx peer deps to allow react 19 versions

x-ref: vercel/styled-jsx#844 react version bump
x-ref: vercel/styled-jsx#826 types change

Closes NEXT-3356
### What

Follow up for #64294 where we could preload all the JS and CSS chunks
for `next/dynamic` component.

* Rename `preload-css` component to `preload-chunks` and remove the
filter for css chunks
* Preload JS chunks with `defer`

### Why

Preloading all the async chunks of `next/dynamic` can make rendering
more efficiently when combined with the initial chunks. Since those
chunks are splitted on client but still essential for the page

#### After vs Before

We can see the waterfall starts much earlier for the dynamic chunk
(881.8a0e88...js)

<img width="500"
src="https://github.com/vercel/next.js/assets/4800338/9bab2c32-37c3-4c7a-93e2-3aa43b2ec7c8">
<img width="500"
src="https://github.com/vercel/next.js/assets/4800338/0fba7499-bb69-41c4-ab72-e9952f3d7f68">
This PR [configures
sharp](https://sharp.pixelplumbing.com/api-output#timeout) with a
timeout of 10 seconds when optimizing an image.

Anything longer will throw an error which we will catch and [fallback to
serving the unoptimized source
image](https://github.com/vercel/next.js/blob/c942006d83d504822ff2f6822fa2608e8e773324/packages/next/src/server/image-optimizer.ts#L637).



Closes NEXT-3359
* vercel/turbo#8082 <!-- Tobias Koppers - Graph
aggregation refactoring -->
### Why?

To make the git blame show functional changes instead.
Follow up to #65058 to ensure
preloads work below the fold.

Closes NEXT-3364
…modules" (#65558)

Reverts #65321

Missed covering `api` layer, got reported with below error. Revert it
for now and will re-land it with more tests

```
../../node_modules/.pnpm/[email protected]_@[email protected][email protected][email protected]/node_modules/next/dist/client/components/navigation.js
02:23:13
Module not found: shared-runtime module app-router-context cannot be used in api layer
02:23:13
https://nextjs.org/docs/messages/module-not-found
```
This test failed in dev. It has 2 problems:

1. the nanoid only contains named export
2. we should wait for the content changed then check the browser url

```
  ● app-dir action handling › fetch actions › should handle redirects to routes that provide an
invalid RSC response

    expect(received).toBe(expected) // Object.is equality

    Expected: "http://localhost:50473/pages-dir"
    Received: "http://localhost:50473/client"

      891 |
      892 |       await retry(async () => {
    > 893 |         expect(await browser.url()).toBe(`${next.url}/pages-dir`)
 ```


Closes NEXT-3369
### What

Remove the auto appending `.xml` extension to the sitemap routes when
it's a dynamic route.


### Why

Previously we were adding `.xml` to `/[...paths/]sitemap` routes, but
the bad part is when you use it to generate multiple sitemaps with
`generateSitemaps` in format like `/[...paths/]sitemap.xml/[id]`, which
doesn't look good in url format and it can be inferred as xml with
content-type. Hence we don't need to add `.xml` in the url.

Before this change it could also result into the different url between
dev and prod:
dev: `/sitemap.xml/[id]`
prod: `/sitemap/[id].xml` 

Now it's going to be aligned as `/sitemap/[id]`. Users can add extension
flexiblely.

Closes NEXT-3357
Noticed while doing some testing that this route was broken in this
application. We use some parts of this app to generate statistics - I'm
planning to use more of the routes for benchmarking so I wanted to
ensure it was working.

Closes NEXT-3371
### What

Remove the extra `__esModule` and `$$typeof` export for ESM client
module

For a client page reference, it changed on server side in renderer:

Previous: `{ __esModule, $$typeof, default }`
Now: `{ default }`

### Why

The Module object itself appears as a client reference but it can't be
rendered since it's not a real reference. I'm not sure why it was added
but I think the right thing for an ESM module is to not treat the module
itself as a client reference but only the objects inside of it. E.g. the
"default" export. That's what React does upstream for ESM modules.

Closes NEXT-3360
## Why?

Adding an `--empty` flag so we can easily create an empty Create Next
App template.

Closes NEXT-3367

---------

Co-authored-by: Ahmed Abdelbaset <[email protected]>
We've seen too many instances of folks accidentally committing their
`.env` files that I feel it's time to make this change.

Up until now, Next.js has recommended that you use `.env.local` when
working locally to store your environment variables. Some developers do
intentionally want to commit their `.env` file without secret values to
source control. However, the ecosystem is fragmented on `.local`
support.

There are tools which require secrets values that do _not_ support
`.local` and require using `.env`. This means that it's possible to dump
your secret values into a `.env` file and commit to source control,
thinking that the defaults would have you covered.

This change updates the defaults for `create-next-app` to ignore all
`.env` files by default. If you want to commit then, you opt-in by
modifying your `.gitignore`, versus the opposite.

Related: https://x.com/complexlity/status/1755890800527892716

---------

Co-authored-by: Sam Ko <[email protected]>
#65583)

Explain more details about default `metadataBase` (where `metadataBase`
is not defined) when it's on Vercel deployment

x-ref: #65089

---------

Co-authored-by: Delba de Oliveira <[email protected]>
## What

Ensures `nonce` is added to script and link tags Next.js renders.
Additional cases it now handles:

- We already passed `nonce` to the React rendering, though not
consistently on all cases where `renderToStream` is called, I'm
surprised there haven't been more reports of this, but now it will pass
it on all cases where React rendering is called that I could find
- In `get-layer-assets.tsx` we now pass `nonce` to both the `script` and
`link` tags
- When calling `ReactDOM.preload` the nonce was missing as well, ensured
that the nonce is included in that case as well.

Added a test that mimicks the reproduction by adding `next/font` in this
case.

Fixes #64037
Closes PACK-2973  

<!-- Thanks for opening a PR! Your contribution is much appreciated.
To make sure your PR is handled as smoothly as possible we request that
you follow the checklist sections below.
Choose the right checklist for the change(s) that you're making:

## For Contributors

### Improving Documentation

- Run `pnpm prettier-fix` to fix formatting issues before opening the
PR.
- Read the Docs Contribution Guide to ensure your contribution follows
the docs guidelines:
https://nextjs.org/docs/community/contribution-guide

### Adding or Updating Examples

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

### Fixing a bug

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

### Adding a feature

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


## For Maintainers

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

### What?

### Why?

### How?

Closes NEXT-
Fixes #

-->
This test was failing with my changes in
#64932 because it was using the
new Next.js changes, but not the corresponding react-dom changes.

An alternative solution would be to update the react-dom versions to
match those in the rest of the project (19 beta), but I think this is
better overall.

After removing the dependencies, this test works in my branch.
timneutkens and others added 30 commits May 26, 2024 12:25
## What?

Update: Implemented a feature in Turbopack for `typeof window` inlining:
vercel/turbo#8211. Verified the changes in that
PR + this PR fix the test 💯


Turbopack upgrade:

* vercel/turbo#8081 <!-- Alexander Lyon - add
support for upload speed / remaining in the cache upload step -->
* vercel/turbo#7673 <!-- Alexander Lyon -
[turbo-trace] add additional filter modes for allocs over time -->
* vercel/turbo#8191 <!-- Will Binns-Smith -
Turbopack: Register react refresh exports in module factory -->
* vercel/turbo#8195 <!-- Donny/강동윤 - feat:
Remove lint for `grid-template-areas`" -->
* vercel/turbo#8207 <!-- Benjamin Woodruff -
chore: Remove unused `base16` dependency and dead `hex` wrapper function
-->
* vercel/turbo#8185 <!-- Tim Neutkens - Update
contributing guide to mention snapshot test updating -->
* vercel/turbo#8211 <!-- Tim Neutkens - Add
option for inlining typeof window -->
* vercel/turbo#8214 <!-- Will Binns-Smith -
Revert "Turbopack: Register react refresh exports in module factory
(#8191)" -->

---

Previous PR description::

Implements a failing test for issue #66058.
The test only fails when using Turbopack.

While digging into that issue I found that `typeof window` replacement
is either not applied or does not cause `import()` or `require()` to be
removed. In the reproduction that approach is used to load a particular
package only in Node.js and another only in the browser.

<!-- Thanks for opening a PR! Your contribution is much appreciated.
To make sure your PR is handled as smoothly as possible we request that
you follow the checklist sections below.
Choose the right checklist for the change(s) that you're making:

## For Contributors

### Improving Documentation

- Run `pnpm prettier-fix` to fix formatting issues before opening the
PR.
- Read the Docs Contribution Guide to ensure your contribution follows
the docs guidelines:
https://nextjs.org/docs/community/contribution-guide

### Adding or Updating Examples

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

### Fixing a bug

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

### Adding a feature

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


## For Maintainers

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

### What?

### Why?

### How?

Closes NEXT-
Fixes #

-->
### What?

This fixes the "Migrating from Create React App" guide and add some
minor improvements

### Why?

The existing guide was broken due to `next start` not working anymore
when using `output: 'export'` and because the TypeScript configuration
was outdated.

### How?

I've validated the guide by going through each steps on [this
PR](IGassmann/cra-to-nextjs#1).

---------

Co-authored-by: Lee Robinson <[email protected]>
…ty with Yarn recommendations (#65823)

### What?

Updates create-next-app's templates' `.gitignore` files for parity with
[Yarn's official
recommendations](https://v3.yarnpkg.com/getting-started/qa#which-files-should-be-gitignored),
accounting for Yarn's modern Plug-n-Play functionality.

Fixes #65586 

### Why?

New projects initialized with create-next-app presently add various
extraneous files from the Yarn cache to the initial commit. This is most
notable in the case of the Next SWC binary, which may exceed 100M in
some environments and prevent users from pushing their new projects to
free GitHub repositories without rewriting the commit history or setting
up Git LFS.

### How?

I've opted to follow the recommendations for
non-[Zero-Install](https://yarnpkg.com/features/caching#zero-installs)
configurations as Zero-Install may necessitate additional configuration
and present additional complications for unsuspecting users, so I think
it's best left up to the user to opt-in.

Contrary to the example `.gitignore`s provided by Yarn, I've excluded
the `.yarn/sdks` directory as it contains IDE-specific tooling which I
think is also best left up to the user to opt-in to including.

I have retained the current `.gitignore`'s exclusion of the `/.pnp`
directory for backwards compatibility with older versions of Yarn.
…ample (#65316)

#64186 removed the pages router implementation from the `with-apollo`
example and replaced it with an app router implementation.

Unfortunately, it did so in an unsupported way.  
At this point, we can not support any streaming SSR scenario without
additional helper packages - in the case of the app router, it is vital
to use the `@apollo/experimental-nextjs-app-support` package.

This PR switches the example to our officially supported patterns.


<!-- Thanks for opening a PR! Your contribution is much appreciated.
To make sure your PR is handled as smoothly as possible we request that
you follow the checklist sections below.
Choose the right checklist for the change(s) that you're making:

## For Contributors

### Improving Documentation

- Run `pnpm prettier-fix` to fix formatting issues before opening the
PR.
- Read the Docs Contribution Guide to ensure your contribution follows
the docs guidelines:
https://nextjs.org/docs/community/contribution-guide

### Adding or Updating Examples

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

### Fixing a bug

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

### Adding a feature

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


## For Maintainers

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

### What?

### Why?

### How?

Closes NEXT-
Fixes #

-->
Updates `create-next-app` template CSS:

- Declares variable font weights in `localFont` options and removes
instances of `font-synthesis: none`
- Removes Geist font variables from Tailwind config files
- Adds fallback sans typefaces to the `body` CSS

Co-authored-by: Sam Ko <[email protected]>
Revert the revert in #66049 

It was erroring in pages api with importing `react-dom/server` as this
is disallowed in app but shouldn't be in pages. It's caused by we're
validating middleware layer as server components but edge pages api is
still bundled in the same layer, where we shouldn't apply the check.

* Separate the api in api layers, and while handling middleware
warnings, checking api layer as well
* No need to check layers while handling externals in edge compiler
* Found a bug that we shouldn't check if `config.transpilePackages` is
defined then we enable `externalDir`, removed that condition. It fails
the telemetry tests case build with code change from this PR.


Add more tests for pages dir and middleware

|  | `react` condition | `react-dom/server` condition |
| ---- | ---- | ---- |
| middleware (edge) | react-server | not allowed, failed with dev/build
checks |
| pages/api edge | default condition | default condition |
| pages/api node | default condition | default condition |
Fix the Build Error indicator location, it should be located on the
top-right corner. Align the padding with

### Build Error


![image](https://github.com/vercel/next.js/assets/4800338/835506a5-bf29-4f3e-ae0e-091dc9a7b386)

### Runtime Error


![image](https://github.com/vercel/next.js/assets/4800338/2a61a933-58f2-471e-9d3f-84b3954b1460)
Old logic from the pages router was previously being hit during
development. This was more apparent when PPR was enabled as it was
mixing dynamic + static rendering in development which propagated to
errors. This change ensures that requests that are made with `RSC: 1`
are not marked as `/_next/data` URL's, and don't use the same logic
paths.

Previously it was a bit confusing because we used the variable
`isDataReq` in a few places that made it hard to tell what it was
referring to. In this case, the `isDataReq` is actually only used by the
pages router. This renames the `isDataReq` to `isNextDataRequest` to
make it clearer, as well as refactors to ensure that it's not used in
the paths for app routes.

Also to better represent the rendering modes the `supportsDynamicHTML`
variable was renamed to `supportsDynamicResponse`.

Fixes #66241
During integration testing, previously, calls to `next build` could rely
on the project (the Next.js project) level ESLint configuration. In
order to correct this, a new `lint` option was added to `nextBuild` that
can be passed to enabled linting. If this is `false` or `undefined`, a
`--no-lint` argument will be passed to `next build` to prevent it from
running.
Updates `with-react-hook-form` example by bumping react-hook-form and
other dependencies to their latest versions, along with a minor cleanup
of the UI.

---------

Co-authored-by: Sam Ko <[email protected]>
Using the hostname `::` enables dual-stack support. This prevents
`ECONNREFUSED` errors when running tests locally, and `localhost` being
resolved to `::1` (IPv6) instead of `127.0.0.1` (IPv4).
### What 

It's not helpful to see the network issue of fetching error on reading
nextjs version in dev overlay

### Why

Error case:

<img width="400"
src="https://github.com/vercel/next.js/assets/4800338/a7852d9b-1f98-4098-8498-a3b832efdbb0">

This should just be ignored, it's fine that the fetching is failed.
There're so many fetch errors code, it's easy to try-catch on fetch
instead of enumerate all the codes
### What?

Update `lightningcss` **crate**.

### Why?

x-ref: https://vercel.slack.com/archives/C04KC8A53T7/p1716896534206159

### How?
`gh auth status` works:
https://github.com/vercel/next.js/actions/runs/9216143946/job/25355841804#step:4:16

We should fail early to hopefully get a better error message if
authentication with the configured token fails.
#65798)

### What

* Error on case that readable stream controller tries to close but
stream is either errored or unfinished
* Delay the DOMContentLoaded event to avoid "Connection Closed" error


### Why

Regarding to the new error about readbale stream controller, the new
error we added here is for identifying the connection is closing before
the last bit has been received that's an error case not intentional
close. It's not a proper state for close more for erroring.


As for adding the queuing for the task of dom content loaded callback,
after investigation, I found that if the DOMLoaded execute earlier the
readable stream controller cuold close earlier on client, which lead to
the "Connection Closed." error. Hence we added a `queueMicroTask` here
to delay it after hydrate call.

x-ref: [slack
thread](https://vercel.slack.com/archives/C01A2M9R8RZ/p1715188343813489)
x-ref: #65507 

Updating the dynamic sitemap routes output url to the one without `.xml`
extension
## Why?

We get this error when we use `npx` to download the
reproduction-template.

![CleanShot 2024-05-28 at 17 25
40@2x](https://github.com/vercel/next.js/assets/28912696/a2f3c3ce-1a2c-4629-9914-9e88bb9c9632)

Updating the template should fix this error.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet