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

Open
wants to merge 10,000 commits into
base: canary
Choose a base branch
from
Open

[pull] canary from vercel:canary #188

wants to merge 10,000 commits into from

Conversation

pull[bot]
Copy link

@pull pull bot commented Sep 13, 2022

See Commits and Changes for more details.


Created by pull[bot]

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

arlyon and others added 14 commits November 7, 2024 20:15
A small PR to start inserting nft on the critical path. This is only enabled in production builds and implements the bare minimum to get NFT outputs by inserting it into the server assets.

Followed up by another PR and inserts more hooks / flags elsewhere in the APIs.
## Description
At #68771,
[`api-routes`](https://github.com/vercel/next.js/tree/canary/examples/api-routes)
example was renamed
[`route-handlers`](https://github.com/vercel/next.js/tree/canary/examples/route-handlers).
However,
[`.gitignore`](https://github.com/vercel/next.js/blob/canary/examples/api-routes/.gitignore)
wasn't deleted and a new
[`.gitignore`](https://github.com/vercel/next.js/blob/canary/examples/route-handlers/.gitignore)
file isn't updated.

In addition, some `api-routes` names exist in the other place.
That's why I update those.

### Improving Documentation

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

Co-authored-by: JJ Kasper <[email protected]>
If a user creates a custom fetch implementation in module scope, the
logic to preload entries during `next start` will result in fetch not
being patched before the userland implementation. As a result, it won't
opt into any caching heuristics from our patched fetch.

Fixes #71881 (in addition to the other PR in this stack)
## Description
At #72178,
[ESLint](https://nextjs.org/docs/app/api-reference/config/eslint) docs
was moved.
So update the old URLs.

### Improving Documentation

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

Co-authored-by: Zack Tanner <[email protected]>
# Summary
Update
[`example.test.ts`](https://github.com/vercel/next.js/blob/canary/test/examples/examples.test.ts)
and
[`turbopack-dev-examples-manifest.json`](https://github.com/vercel/next.js/blob/canary/test/turbopack-dev-examples-manifest.json)
by removing deleted examples.

## Descriptions
[examples: cleanup #57845](#57845)
deleted ...

- amp-first
- amp-story
- data-fetch
- fast-refresh-demo
- hello-world-esm
- progressive-render
- using-router
- with-app-layout
- with-env-from-next-config-js
- with-loading

[updated the example of modularize-imports to utilize the App Router
#69771](#69771) deleted ...

- modularize-imports

[docs: Add docs on CSP and nonce generation
#54601](https://github.com/vercel/next.js/pull/54601/files) deleted ...

- styled-jsx-with-csp

[Updated the example of with-draft-js to utilize the App Router.
#70045](#70045) deleted ...

- with-draft-js

[Remove deprecated library example
#62813](#62813) deleted ...

- with-react-with-styles

[Remove with-reasonml-todo example
#62812](https://github.com/vercel/next.js/pull/62812/files) deleted ...

- with-reasonml-todo

[Remove with-semantic-ui example
#62811](https://github.com/vercel/next.js/pull/62811/files) deleted ...

- with-semantic-ui

[Updated the example of with-vercel-fetch to utilize the App Router.
#70069](#70069) deleted ...

- with-vercel-fetch

Co-authored-by: JJ Kasper <[email protected]>
## Description
At #72178,
[TypeScript](https://nextjs.org/docs/app/api-reference/config/typescript)
docs was moved.
So update the old URLs.

### Improving Documentation

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

---------

Co-authored-by: Zack Tanner <[email protected]>
### What?

switches the database for persistent caching from lmdb to rocksdb.

### Why?

* No preallocated sparse file which cause problems
* Compression support
* Multiple files instead of a big single file
* Better performance
## Why?

The current error message when you have have a set `weight: ['400', '700']` and set `axes: ['wdth']` for a variable font is confusing—it should mention to correct your weight property (e.g., `weight: 'variable'` or nothing at all for `weight`).

- Fixes #72413
Need to investigate why this flakes only in Turbopack. Disabling in that
context for now.
Adds tracing settings to the various contexts that are used for nft

There are cases where we need to know whether tracing is useful, this PR sets up that state ahead of the next one(s) which actually take advantage of them.

Closes PACK-3377
leerob and others added 30 commits November 21, 2024 11:41
Reverts #72988

Right now, we're focused on making sure the examples linked are
guaranteed to work and placed inside the Next.js community GitHub
organization.
### What?

The bench need to run in the correct directory
When handling a redirect through a server action, we pass in the current
href rather than the destination href to `handleExternalUrl`, which is
incorrect since that won't reflect the updated URL from a server
action's redirect response.

While looking into this, I noticed a handful of server action branches
that weren't properly rejecting or resolving the action promises. This
would cause the transitions to stall until they were fulfilled, so I
updated all of the existing branches where we early return to also
resolve the promise.

Fixes #72842
- The waitFor function now supports a predicate. Unlike retry, waitFor
does not include a timeout. Use it only when the predicate is guaranteed
to evaluate to true before proceeding to the next test. If it runs
indefinitely, Jest enforces a 120-second timeout per test.
- The getCliOutputFromHere utility provides a convenient string getter
that captures CLI output in between.
## Why?

Add documentation for experimental `inlineCss`.

```
import type { NextConfig } from 'next'

const nextConfig: NextConfig = {
  experimental: {
    inlineCss: true,
  },
}
```

- x-ref: #72195
## Why?

The `latest` tag currently points to v15, so we need to update the tag to `next-14`.
…ding (#73030)

## History
In a previous PR #65846 the chroma
subsampling setting was removed for AVIF images. This caused the default
of `4:4:4` to be used which increased the image size and CPU a lot.

I considered switching back to `4:2:0` but found that reducing the
`effort: 3` actually yielded significantly better performance with only
a slight difference in size.

## Benchmark

For example, take this PNG that has a width of 1805.

```
curl -JO https://images.bookroo.com/site/landing/homepage/book-collection.png
```

Using `w=1850` and `q=75`:
```
Current: 2_778ms and 153_364 bytes
 Chroma: 2_214ms and 132_927 bytes
This PR: 1_265ms and 158_862 bytes
```

Using `w=1500` and `q=75`:
```
Current: 625ms and 95_810 bytes
 Chroma: 524ms and 89_500 bytes
This PR: 185ms and 99_127 bytes
```

Using `w=1200` and `q=75`:
```
Current: 506ms and 74_738 bytes
 Chroma: 407ms and 68_998 bytes
This PR: 144ms and 77_955 bytes
```

For this particular image, the size will increase a bit but there are
other images I tested where the size was actually smaller. So its a big
improve in CPU usage compared to reverting to the chroma subsampling
setting.

We also are keeping AVIF smaller than WebP which is the expected
behavior.

## Learn More
[Chroma subsampling](https://en.wikipedia.org/wiki/Chroma_subsampling)
is the practice of encoding images by implementing less resolution for
[chroma](https://en.wikipedia.org/wiki/Chrominance)
[information](https://en.wikipedia.org/wiki/Information) than for
[luma](https://en.wikipedia.org/wiki/Luma_(video)) information, taking
advantage of the human visual system's lower acuity for color
differences than for luminance

Image compression deep-dive video:
https://www.youtube.com/watch?v=F1kYBnY6mwg

Sharp Options: https://sharp.pixelplumbing.com/api-output#avif
# Context

[Test
run](https://github.com/vercel/next.js/actions/runs/11962411287/job/33382985253?pr=73030#step:29:421)
fails due to

```
   ▲ Next.js 15.0.4-canary.22
   - Local:        http://[::1]:35903
   - Network:      http://[::]:35903

 ✓ Starting...
Error: "next start" does not work with "output: export" configuration. Use "npx serve@latest out" instead.
    at <unknown> (dist/server/next.js:215:31)
    at async NextServer.prepare (dist/server/next.js:154:24)
    at async initializeImpl (dist/server/lib/render-server.js:92:5)
    at async initialize (dist/server/lib/router-server.js:436:22)
    at async Server.<anonymous> (dist/server/lib/start-server.js:272:36)
```

However, there was no `output: export` specified in the [test
setup](https://github.com/vercel/next.js/tree/jude/which-config-are-we-using/test/integration/edge-runtime-configurable-guards).
**Mysterious!**

# Hypothesis

`next start` recursively finds the `next.config` upwards in the
directory tree and happens to locate an extraneous `next.config` that
specified `output: export`.

# Changes

- Output the config file path in test mode for future debugging
- Short-circuit `findUp` for the broken test by placing an empty config
in the project directory
## Improving Documentation

dynamic `params` from `generateStaticParams` is now a promise but is now
promise in type.
Type has been changed for every Promise `params`.

Co-authored-by: Delba de Oliveira <[email protected]>
Co-authored-by: JJ Kasper <[email protected]>
Hi, Team.
It seems Promise is missing when defining params type.

---------

Co-authored-by: hyungji <[email protected]>
Co-authored-by: Maikel <[email protected]>
…on) (#73018)

This PR has two main goals:

- **Consolidate the detection of server directives in modules and function bodies.** Previously, these were two separate implementations with significant overlap, but also some [questionable discrepancies](#72811 (comment)).
- **Model the current directive (in a file or function) using an enum instead of two separate booleans.** This change prevents any confusion that both directives might be present simultaneously. Additionally, we're now emitting an error if multiple directives (`"use server"` and `"use cache"`) are defined in the same location (at the top of a file or function body).

A mixed usage of `"use server"` and `"use cache"` _across different locations_ is still allowed, e.g. `"use cache"` at the top of a file, and `"use server"` in a function.

> [!NOTE]  
> The diff may be tricky to review because chunks from two different functions are combined into a single function. Fortunately, we have comprehensive test coverage for the transforms, which instills high confidence that these changes are correct.
- `expirePath` and `expireTag` are not yet available in a stable
version, so we don't want these APIs leaking into stable docs.
## Improving Documentation
I just add **Good to know** to below path note which was in a block but
not add the tag.
> Pages > Rendering > Automatic Static Optimization

**Before:**
> Statically generated pages are still reactive: Next.js will hydrate
your application client-side to give it full interactivity.

**Now:**
> **Good to know:** Statically generated pages are still reactive.
Next.js will hydrate your application client-side to give it full
interactivity.

Co-authored-by: Sam Ko <[email protected]>
…3053)

While the React Compiler is still in beta, this functionality was not
yet documented. I also updated this to remove the 15 RC since 15 is now
stable.

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

This PR changes `NextCustomServer` to no longer subclass `NextServer` and instead just delegate all methods to `this.renderServer`. I've also added an interface implemented by both `NextServer` and `NextCustomServer` to make it explicit what we're actually exposing. (Note that we're currently exposing too much for legacy reasons. we might want to decide to clean this up a bit, i've started that in #73021)

I've also cleaned up some random `(_ as any)`s and unnecessary indirections around the area.

### Why

currently, `NextCustomServer` is a subclass of `NextServer`, which makes it very confusing to reason about, because in  `prepare()` it creates *a nested `NextServer`* (stored in `this.renderServer`). this isn't immediately visible in the code, but that's what `getRequestHandlers` ends up doing.
https://github.com/vercel/next.js/blob/58b993c239689f22641682bbcb0d8dea6d85fdf1/packages/next/src/server/next.ts#L281
then, it delegates *some* methods to that (`render`, `getRequestHandler`, `setAssetPrefix`). But some methods (e.g. `render404`) *aren't* overridden/delegated and just run the implementation inherited from `NextServer`. And those implementations are unaware of `this.renderServer`, so they end up initializing a *second* `NextNodeServer` (`this.server` vs `this.renderServer.server`) and run against that instead. that's bad! and it's why e.g. #61676 was necessary -- we needed to update both servers! 

i think that this is a leftover of the old implementation where we ran a separate process for rendering. for historical context, see:
- #49805 which seems to have introduced this split (the proxy only overrides `prepare`, `getRequestHandler`, and `render`)
- #53523 which turned the proxy code into `NextCustomServer`

also apparently `render404` and others were broken in development (try running the tests in the first commit
I've changed `NextCustomServer` and see the server hang forever).
## Description
Follow up #72617.
I have already fixed at #72944.
`app/api/redirects/route.ts` is ts extension.

### Improving Documentation

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

Co-authored-by: Sam Ko <[email protected]>
## Why?

Update params type to be async (v15).

- x-ref: #72070
## Why?

The default config of fetch, which is `auto no cache`, is slightly different from the fetch option `{ cache: 'no-store' }` (this opts the whole route out of statically prerendering), so we need to clarify that further.

- https://nextjs.org/docs/canary/app/api-reference/functions/fetch#optionscache
- x-ref: #72982
- Fixes #73109
…73058)

This is a follow-up fix for #72969. Method or function properties of exported objects in `"use cache"` or `"use server"` files must not be compiled into server functions, unless they have an inline server directive.
Accessing `this` or `arguments` in server functions is not allowed. With
this PR, we are now emitting build errors in this case.

---------

Co-authored-by: Janka Uryga <[email protected]>
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.