Commit graph

11960 commits

Author SHA1 Message Date
Jiachi Liu
8b82225fea
Fix ASL bundling for dynamic css (#64451)
### Why

For app page rendering on edge, the `AsyncLocalStorage` (ALS) should be
bundled as same instance across layers. We're accessing the ALS in
`next/dynamic` modules during SSR for preloading CSS chunks. There's a
bug that we can't get the ALS store during SSR in edge, I digged into it
and found the root cause is:

We have both import paths:
`module (rsc layer) -> request ALS (shared layer)`
`module (ssr layer) -> request ALS (shared layer)`

We expect the ALS to be the same module since we're using the same layer
but found that they're treated as different modules due to applying
another loader transform on ssr layer. They're resulted in the same
`shared` layer, but with different resource queries. This PR excluded
that transform so now they're identical across layers.


### What

For webpack, we aligned the loaders applying to the async local storage,
so that they're resolved as the same module now.

For turbopack, we leverage module transition, sort of creating a new
`app-shared` layer for these modules, and apply the transition to all
async local storage instances therefore the instances of them are only
bundled once.
To make the turbopack chanegs work, we change how the async local
storage modules defined, separate the instance into a single file and
mark it as "next-shared" layer with import:

```
any module -> async local storage --- use transition, specify "next-shared" layer ---> async local storage instance
```

Closes NEXT-3085
2024-04-17 10:18:09 +02:00
Zack Tanner
f93ae7c89e
fix TypeError edge-case for parallel slots rendered multiple times (#64271)
### What
When rendering a parallel slot multiple times in a single layout, in
conjunction with using an error boundary, the following TypeError is
thrown:

> Cannot destructure property 'parallelRouterKey' of 'param' as it is
null

### Why
I'm not 100% sure of the reason, but I believe this is because of how
React attempts to dededupe (more specifically, "detriplficate") objects
that it sees getting passed across the RSC -> client component boundary
(and an error boundary is necessarily a client component). When React
sees the same object twice, it'll create a reference to that object and
then use that reference in future places where it sees the object. My
assumption is that there's a bug somewhere here, as the `LayoutRouter`
component for the subsequent duplicated parallel slots (after the first
one) have no props, hence the TypeError.

### How
Rather than passing the error component as a prop to `LayoutRouter`,
this puts it as part of the `CacheNodeSeedData` data structure. This is
more aligned with other properties anyway (such as `loading` and `rsc`
for each segment), and seems to work around this bug as the
`initialSeedData` prop is only passed from RSC->client once.

EDIT: Confirmed this is also fixed after syncing the latest React, due
to https://github.com/facebook/react/pull/28669

Fixes #58485
Closes NEXT-2095
2024-04-17 01:18:06 +00:00
Zack Tanner
ddf2af59c6
fix incorrect refresh request when basePath is set (#64589)
`initialCanonicalUrl` differs from the `canonicalUrl` that gets set on
the client, such as when there's a basePath set.

This hoists the `canonicalUrl` construction up so we can re-use it when
adding refetch markers to the tree.

This also renames `pathname` -> `path` since it also includes search
params. I added a test to confirm no extra erroneous fetches happened in
both cases.

Fixes #64584


Closes NEXT-3130
2024-04-16 18:01:46 -07:00
Zack Tanner
e9aeb9e1b9
memoize layout router context (#64575)
Since `AppRouterState` is promise-based (so we can `use` the values and
suspend in render), the state itself isn't stable between renders. Each
action corresponds with a new Promise object. When a link is hovered, a
prefetch action is dispatched, even if the prefetch never happens (for
example, if there's already a prefetch entry in the cache, and it
doesn't need to prefetch again). In other words, the prefetch action
will be dispatched but won't necessarily change the state.

This means that these no-op actions that don't actually change the state
values will trigger a re-render. Most of the context providers in
`AppRouter` are memoized with the exception of `LayoutRouter` context.
This PR memoizes those values so that consumers are only notified of
meaningful updates.

Fixes #63159


Closes NEXT-3127
2024-04-16 16:23:39 -07:00
vercel-release-bot
a9ff94f466 v14.3.0-canary.6 2024-04-16 23:22:28 +00:00
OJ Kwon
cc4f7f204e
fix(next-swc): correctly set wasm fallback for known target triples (#64567)
### What

Fixes a regression to enable wasm fallback for the know target triples
(that does not have native bindings). The condition was skewed when
introducing `useWasmBinary` flag.

Closes PACK-2969
2024-04-16 16:29:26 +00:00
hrmny
ce69d02cf9
chore: remove unused rust dependencies (#62176)
### What?

Toolchain is updated as well.

Should improve compile times marginally, also added the new parallel
frontend.

Depends on https://github.com/vercel/turbo/pull/7409

Closes PACK-2526
2024-04-16 17:48:06 +02:00
Jiachi Liu
2a1e17063b
fix: filter out middleware requests in logging (#64549)
### What

When middleware.js is present, the logging is duplicated. We should
filter out the 1st middleware request and only log the actual one going
through request handler / renderer

Closes NEXT-3125
2024-04-16 16:17:06 +02:00
vercel-release-bot
649a07c7f4 v14.3.0-canary.5 2024-04-16 14:16:19 +00:00
Zack Tanner
9fb775e2f8
fix refresh behavior for discarded actions (#64532)
When an action is marked as "discarded", we enqueue a refresh, since the
navigation event will be invoked immediately without waiting for the
action to finish. We refresh because it's possible that the discarded
action triggered some sort of mutation/revalidation, and we want the
router to still be able to respond to that new data.

However there's a bug in this logic -- it'll only enqueue the refresh
action if there were no other actions in the queue, ignoring the case
where something is still in the queue. This makes sure that the refresh
is handled after `runRemainingActions` finishes.

When adding a test for the server component case (which doesn't hit this
refresh branch), I noticed `LayoutRouter` caused React to suspend
indefinitely, because it got stuck in the `use(unresolvedThenable)`
case. We should only suspend indefinitely if we kicked off a the
`SERVER_PATCH` action, as otherwise it's possible nothing will ever
break out of that branch.

Fixes #64517
Closes NEXT-3124
2024-04-16 06:56:48 -07:00
Jiachi Liu
fa30290353
Fix cjs client components tree-shaking (#64558)
## What

Determine if the client module is a CJS file and `default` export is
imported, then we include the whole module instead of using webpack
magic comments to only extract `default` export.

## Why

Unlike ESM, The `default` export of CJS module is not just `.default`
property, we need to include `__esModule` mark along with `default`
export to make it function properly with React client module proxy


Fixes #64518
Closes NEXT-3119
2024-04-16 15:06:42 +02:00
Jimmy Lai
d52d32f423
perf: improve Pages Router server rendering performance (#64461)
### What

This PR's goal is to improve the throughput performance of the Next.js
server when handling Pages Router routes.

Note that the results from this are very synthetic and do not represent
the real-life performance of an application. If we only wanted to handle
hello worlds, we could probably make this even faster but on production,
a slow fetch call to your DB is probably what's slowing you down.

I'll look into App Router next.

### Why?

I guess I got nerd-sniped into it 😃 

### How?

A few optimizations:
- I looked deeply at the pipeline for rendering a Pages Router page. I
noticed a lot of intermediary streams being created here and there to
eventually be concatenated to a simple string. I think this is probably
left over code from when we wanted to support streaming there and so
there's some code that was shared with the App Router, which we
absolutely don't need I think. I refactored it to be slightly simpler
with just a few string concats here and there.
- misc: I removed some redundant Promises being created here and there
and added a small inline optimisation to eliminate `if (renderOpts.dev)`
code in production.

### Nummies

Test setup: hello world pages router app, next start + autocannon

- requests handled in 10s: 18k  -> 33K, **~80% improvement**
- avg latency: 4.89ms -> 2.8ms, **~42% improvement**
- avg req/res: 1846.5 -> 2983.5, **~61% improvement**

Before

<img width="742" alt="image"
src="https://github.com/vercel/next.js/assets/11064311/658e7ade-eba7-4604-a7c9-619bd51a5ec8">

vs

after

<img width="880" alt="image"
src="https://github.com/vercel/next.js/assets/11064311/2f46cf69-b788-4db2-bf90-6f65dc7abd82">




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

-->


Closes NEXT-3103
2024-04-16 14:25:45 +02:00
Tobias Koppers
064788fee3
fix HMR for cases where chunking changes (#64367)
* test case for https://github.com/vercel/turbo/pull/7947
* fix source map retrieval for HMR-updated assets

Closes PACK-2944
2024-04-16 12:36:41 +02:00
Donny/강동윤
f1ad9c9430
feat: Add a validation for postcss with useLightningcss (#64379)
### What?

Add validation to ensure that the user is not using postcss when `experimental.useLightningcss` is enabled.


### Why?

It's confusing.

### How?

Closes PACK-2928
2024-04-16 04:07:44 +00:00
Wyatt Johnson
bef015e0f3
Enhance types for Node and Edge envionments (#64454)
<!-- 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 enhances the typings in the `BaseServer`, `NextNodeServer`, and
`NextWebServer` to simplify types for request and responses across the
entire server. Rather than relying on manual environment checks only as
the source with error-prone type casts, this adds basic guards (albeit
naive) that assert the typings depending on the runtime environment
variables. This greatly enhances the typings used across the servers as
the servers no longer use the `as` keyword when working with these
request and response types.

This is a precursor to future planned work to further split the
different rendering runtimes to assist with code elimination and
framework organization.

### Why?

As a step to utilizing these more unified types, the `app-render.tsx`
(App Pages rendering pipeline) has been modified to instead accept the
abstract `BaseNextRequest` and `BaseNextResponse` types. This is a
precursor to future work to split the streaming behaviour based on the
runtime environment (ie, in Node.js, we can utilize the native streams
instead of web streams, which offer significant performance gains).

### How?

The server types were modified to be generic, allowing the three server
implementations to have their types flow safely between the different
methods. This enables us to only reference the `NodeNextRequest` within
the `NextNodeServer`, and the `WebNextRequest` within the
`NextWebServer` for example.

🎥 [Loom
Video](https://www.loom.com/share/76af2225cf0246d0b4f609ab3e35fff9?sid=c948a919-ac9e-4571-8a75-bd9d0a0776e2)

Closes NEXT-3102
2024-04-16 02:38:27 +00:00
vercel-release-bot
cb744ecfbd v14.3.0-canary.4 2024-04-15 23:22:22 +00:00
Evan Winter
8f85d9f7e9
Typo "Minifer" in config.ts (#64359) 2024-04-15 22:35:01 +00:00
Jaaneek
2646cd04b6
feat: add information that revalidate interval is in seconds (#64229)
Add information that revalidate interval is in seconds to unstable_cache

It's not obvious as "usually" time is in milliseconds

Co-authored-by: JJ Kasper <jj@jjsweb.site>
2024-04-15 15:19:04 -07:00
Sam Ko
be2c20a6e2
chore(next/font): update @capsizecss/metrics package (#64528)
## Why?

Having the latest `@capsizecss/metrics` package allows us to have the
latest font fallbacks when using
[`next/font`](https://nextjs.org/docs/app/building-your-application/optimizing/fonts).

- x-ref:
https://github.com/vercel/next.js/issues/47115#issuecomment-2051755660
- x-ref:
https://github.com/vercel/next.js/issues/47115#issuecomment-2055079526
-
https://github.com/seek-oss/capsize/releases/tag/%40capsizecss%2Fmetrics%403.0.0

Closes NEXT-3123
2024-04-15 15:14:58 -07:00
vercel-release-bot
b647facf0b v14.3.0-canary.3 2024-04-15 22:05:01 +00:00
Adam Jones
f563940f69
next/script: Correctly apply async and defer props (#52939)
### Summary

Fixes #52935

`next/script` has a `Script` component that supports an `async` prop.
However, when scripts are loaded with the `async` prop set to false, the
script is loaded as if async was set to true. This may cause scripts to
execute out of order. Repro:
https://github.com/domdomegg/next-async-script-reproduction

I think this is occurring because Next uses setAttribute to set the
async and defer attributes. However, this is not a valid way to set
these properties on a script. This is because . Demo:
https://jsfiddle.net/6ktpfae1/

This PR fixes this behaviour by using removeAttribute after calling
setAttribute (rather than using setAttribute "false"). This appears to
result in correct behaviour.

Given it appears this workaround was already applied in `next/head`,
I've harmonised the code between these two.

### Next steps

I think this PR is ready for review. I acknowledge there are no test
changes, but there are no existing tests for `next/script` at all and
creating them I think would be disproportionally difficult given issues
in #52943.

---------

Co-authored-by: Tim Neutkens <tim@timneutkens.nl>
Co-authored-by: Sam Ko <sam@vercel.com>
Co-authored-by: JJ Kasper <jj@jjsweb.site>
2024-04-15 15:01:50 -07:00
vercel-release-bot
a9adf0db67 v14.3.0-canary.2 2024-04-15 21:45:17 +00:00
Will Binns-Smith
cd36a8f217
Turbopack: don’t show long internal stack traces on build errors (#64427)
Turbopack: don’t show long internal stack traces on build errors
    
Fixes PACK-2909

Looks like this may have been introduced in #61929, when code was moved
out of `setup-dev-bundler.ts`, `ModuleBuildError` was duplicated and no
longer satisfied the `instanceof` check.

Closes PACK-2951
2024-04-15 14:40:56 -07:00
Jiachi Liu
d1e7847ad1
refactor: remove always truthy flag (#64522)
Remove the `this.exportRuntime` flag in build manifest plugin where it's
always true

Closes NEXT-3118
2024-04-15 23:33:07 +02:00
Will Binns-Smith
f79440260c
Turbopack: Allow client components to be imported in app routes (#64520)
Resolves #64412

This adds a client transition to the app route `ModuleAssetContext` and
the corresponding transforms so that client components can be safely
imported and referenced (as their proxies) in app routes.

Test Plan: Added an integration test


Closes PACK-2964
2024-04-15 14:18:56 -07:00
vercel-release-bot
19c206038b v14.3.0-canary.1 2024-04-15 21:13:24 +00:00
Tobias Koppers
3491417ac5
update turbopack (#64501)
* https://github.com/vercel/turbo/pull/7858 <!-- Tobias Koppers -
refactor GlobalCssAsset to fix dynamic import of css -->
* https://github.com/vercel/turbo/pull/7944 <!-- Will Binns-Smith -
Update lockfile for compatibility with next.js -->
* https://github.com/vercel/turbo/pull/7936 <!-- Tobias Koppers - fix
panic when searching an the root span -->
* https://github.com/vercel/turbo/pull/7959 <!-- Tobias Koppers - fix
missing async loader -->
2024-04-15 22:19:31 +02:00
Tobias Koppers
6178693b39
disable production chunking in dev (#64488)
### What?

The production chunking plugin shouldn't be enabled in development

### Why?

It doesn't handle HMR yet


Closes PACK-2956
2024-04-15 21:22:22 +02:00
Jiwon Choi
2bd27e72e5
fix(next): Metadata.openGraph values not resolving basic values when type is set (#63620)
### What?

The string value of `Metadata.openGraph.emails` throws error:

```tsx
export const metadata = {
  openGraph: {
    type: 'article',
    emails: 'author@vercel.com',
  },
};
```

Error:

```sh
r.map is not a function
```

The type is:

```tsx
type OpenGraphMetadata = {
  // ...
  emails?: string | Array<string>
}
```

### Why?

Basic values such as `emails` and `phoneNumbers` were not included when
`ogType` was set while resolving the values.

### How?

Include basic values when resolving the metadata.

Fixes #63415
2024-04-15 21:17:48 +02:00
Ethan Arrowood
64da71cfc9
fix: lib/helpers/install.ts to better support pnpm and properly respect root argument (#64418)
This fixes and improves the `lib/helpers/install.ts` file (`install()`)
method to better support pnpm and properly respect the `root` argument.

I encountered an issue where by running `next <command> <project-dir>`,
and the `<command>` involved installing missing dependencies (like
`lint` or my upcoming `experimental-test`), it was not executing pnpm in
my `<project-dir>` because pnpm doesn't have a `--cwd` flag.



Closes NEXT-3092

Co-authored-by: Zack Tanner <1939140+ztanner@users.noreply.github.com>
2024-04-15 17:26:41 +00:00
vercel-release-bot
03b7a0fb12 v14.3.0-canary.0 2024-04-15 17:24:31 +00:00
JJ Kasper
4024a89ee8
Fix DynamicServerError not being thrown in fetch (#64511)
This ensures we properly skip calling a fetch during build-time that has
`cache: 'no-store'` as it should only be called during runtime instead.

Fixes: https://github.com/vercel/next.js/issues/64462

Closes NEXT-3114
2024-04-15 10:09:57 -07:00
Jiwon Choi
c325ecd69c
chore(next): add keywords on package.json (#64173)
I'm assuming leaving keywords blank is intended, but with 🖤 for Next.js,
I added 10 keywords to increase the traction of users.

- react
- web
- server
- node
- nextjs
- vercel

Also, included relative keywords that can be easily accessed from the
landing of [npm](https://www.npmjs.com).
 
 - framework
 - front-end
 - back-end
 - cli
 
![Screenshot 2024-04-07 at 11 27
50 PM](https://github.com/vercel/next.js/assets/120007119/37bfe915-61e5-42db-94c3-597391b6e74c)

Co-authored-by: Shu Ding <g@shud.in>
2024-04-15 16:33:32 +00:00
Jiwon Choi
30521f20ff
fix(next): global not-found not working on multi-root layouts (#63053)
## Why?

For multi-root layouts (route groups on the root with their root
layouts, no layout file on the root), it is not possible to use global
`not-found` since the `layout` is missing on the root.

```sh
.
└── app/
    ├── (main)/
    │   └── layout.js
    ├── (sub)/
    │   └── layout.js
    └── not-found.js --> ERR: missing layout
```

Current Behavior:

```sh
not-found.js doesn't have a root layout. To fix this error, make sure every page has a root layout.
```

## What?

Let multi-root layouts also benefit from the global `not-found`.

## How?

Wrap root `not-found` with default layout if root layout does not exist.
Although this solution is not `multi-root` specific, it won't produce
critical issues since a root `layout` is required for other cases.

Fixes #55191 #54980 #59180
2024-04-15 18:25:53 +02:00
vercel-release-bot
97b4a99b0b v14.2.1-canary.7 2024-04-15 16:21:28 +00:00
Arne Wiese
2be9ccb658
Fix typo in dynamic-rendering.ts (#64365)
Super small PR - "oustide" should be "outside"

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

-->
2024-04-15 15:50:04 +00:00
Jeffrey Zutt
512cabc1ee
feat: strip traceparent header from cachekey (#64499)
### What?
We strip the `traceparent` header from the cache-key.

### Why?
The traceparent header forms part of the W3C Trace Context standard,
installed to track individual HTTP requests from start to end across
multiple services. That means each individual HTTP request will have a
unique traceparent value, reflecting its unique journey across servers
and services.

If we include the traceparent header in the cache key, the uniqueness of
the traceparent means the cache key would always be different even for
requests that should yield the same response. This would cause the cache
to always miss and re-process the request.

Effectively rendering fetch-cache useless.

Co-authored-by: Jeffrey <jeffrey@jeffreyzutt.nl>
2024-04-15 15:24:27 +00:00
Damien Simonin Feugas
e7a8645cb8
BREAKING CHANGE: remove deprecated analyticsId from config, and the corresponding performance-relayer files and tests (#64199)
### 🤔 What's in there?

We've deprecated config's `analyticsId` in 14.1.1 [almost 3 months
ago](https://github.com/vercel/next.js/releases/tag/v14.1.1-canary.2).
Users can opt in fot `@vercel/speed-insights`, or use
`useReportWebVitals` to report to any provider they'd like.

This PR:
- removes `analyticsId` key from configuration
- stops setting `__NEXT_PUBLIC_ANALYTICS_ID` env variable when the key
was present
- stops injecting `performance-relayer` file, when the variable is set
- cleans up related test code.
2024-04-15 15:23:30 +00:00
Vercel Release Bot
bf8aecb182
Update font data (#64481)
This auto-generated PR updates font data with latest available

Co-authored-by: JJ Kasper <jj@jjsweb.site>
2024-04-15 15:10:22 +00:00
vercel-release-bot
f9cd55ff32 v14.2.1-canary.6 2024-04-15 10:45:59 +00:00
Tobias Koppers
2766ebc8d3
improve turborepo caching (#64493)
### What?

There is a race condition in the `pull-build-cache` script. When the
remote cache entry was removed between the dry run and the real run, it
will run the command and caches whatever is in the native folder.

Seems like there are some very old leftover files there which lead to an
broken publish.

This changes the command to fail when there are no files and empties the
folder before running the script. This should lead to pull-build-cache
to failing instead.

Closes PACK-2957
Fixes #64468
2024-04-15 12:42:28 +02:00
vercel-release-bot
33e8334d35 v14.2.1-canary.5 2024-04-14 21:39:40 +00:00
Jiachi Liu
cb8fb3291a
Fix client boundary inheritance for barrel optimization (#64467)
### What

Inherit the client boudaries from the found matched target in load
barrel

### Why
The root cause with the barrel transform, we missed the client boundary
directive during the transform.
Since the new version of mui's case looks like this:

Import path
page.js (server module) -> `<module>/index.js` (shared module) ->
`<module/subpath>/index.js` (client module) ->
`<module/subpath/sub-module.js> (client module)

After our transform, we lost the `"use client"` which causes the
mismatch of the transform:

In `rsc` layer: the file pointing to the sub module entry
(`<module/subpath>/index.js`), but without the client boundary.


Fixes #64369 
Closes NEXT-3101
2024-04-14 23:36:20 +02:00
vercel-release-bot
2a605af154 v14.2.1-canary.4 2024-04-13 23:23:45 +00:00
Zack Tanner
a5bb7c46b1
router restore should take priority over pending actions (#64449)
Since the router processes events sequentially, we special case
`ACTION_NAVIGATE` events to "discard" a pending server action so that it
can process the navigation with higher priority. We should apply this
same logic to `ACTION_RESTORE` events (e.g. `router.back()`) for the
same reason.

Fixes #64432


Closes NEXT-3098
2024-04-13 10:49:57 -07:00
Zack Tanner
f602b2979c
default fetchCache to no-store when force-dynamic is set (#64145)
`fetchCache` is a more fine-grained segment level cache-control
configuration that most people shouldn't have to use. Current semantics
of `dynamic = "force-dynamic"` will still treat the fetch as cacheable
unless explicitly overriding it in the fetch, or setting a segment level
`fetchCache`.

The `dynamic` cache configuration should be seen as a "top-level"
configuration, while more fine-grained controls should inherit logical
defaults from the top-level. Otherwise this forces people to opt-into
the `fetchCache` configuration, or manually override each `fetch` call,
which isn't what you'd expect when forcing a segment to be dynamic.

This will default to not attempting to cache the fetch when
`force-dynamic` is used. As a result, I had to update one of the
`app-static` tests to use `revalidate: 0` rather than `force-dynamic`,
as the revalidate behavior is slightly different in that it won't modify
the revalidation time on a fetch if it's non-zero.

Closes NEXT-2067
2024-04-13 17:05:47 +00:00
Jiachi Liu
7ef6c4eb17
Revert "Fix: css in next/dynamic component in edge runtime" (#64442)
The fix is not correct, we already have request ALS wrapping the request
in app-render, shouldn't get another one for edge adapter. This is
actually a bundler bug

Reverts vercel/next.js#64382

Closes NEXT-3097
2024-04-13 13:32:18 +02:00
vercel-release-bot
68f722ba2d v14.2.1-canary.3 2024-04-12 23:19:45 +00:00
Colton Ehrman
9994e74a6c
fix(next-lint): update option --report-unused-disable-directives to --report-unused-disable-directives-severity (#64405)
## Why?

The Option name and type has been incorrect for
`--report-unused-disable-directives` (it's likely that
https://github.com/vercel/next.js/pull/61877 exposed this.

For correctness, we have updated the name to
`--report-unsed-disable-directives-severity` →
https://eslint.org/docs/v8.x/use/command-line-interface#--report-unused-disable-directives-severity.

- Fixes https://github.com/vercel/next.js/issues/64402

---------

Co-authored-by: samcx <sam@vercel.com>
2024-04-12 22:09:05 +00:00
Shu Ding
d06c54767b
Fix the method prop case in Server Actions transform (#64398)
This PR fixes the case where object method and class method prop
functions are not considered as a new scope. Closes #63603.

Closes NEXT-3088
2024-04-13 00:05:50 +02:00
Shu Ding
52ae1f8a55
Improve rendering performance (#64408)
This PR improves the server rendering performance a bit, especially for
the App Router. It has mainly 2 changes.

A rough benchmark test with a 300kB Lorem Ipsum page, SSR is about 18%
faster.

### Improve `getServerInsertedHTML`

- Avoid an extra `renderToReadableStream` if we already know the content
will be empty
- Avoid `await stream.allReady` for better parallelism with
`streamToString()`
- Increase the `progressiveChunkSize`

### Improve `createHeadInsertionTransformStream`

- Only do chunk splitting and enqueuing if the inserted string is not
empty
2024-04-13 00:03:11 +02:00
vercel-release-bot
6fb9efbcaa v14.2.1-canary.2 2024-04-12 18:01:43 +00:00
Tobias Koppers
fbf9e12de0
use pathToFileUrl to make esm import()s work with absolute windows paths (#64386)
### What?

Fixes #64371
Fixes #63359


Closes PACK-2946

---------

Co-authored-by: Tim Neutkens <tim@timneutkens.nl>
Co-authored-by: Jiachi Liu <inbox@huozhi.im>
2024-04-12 19:58:13 +02:00
Tim Neutkens
c9c074c18d
Fix more Turbopack build tests (#64384)
## What?

- Removes the node-file-trace options from being unsupported as they are
passed to node-file-trace in build/index.ts
- Ensures `import next from 'next'` is handled in the same way as
webpack: creating an empty module. Currently it tried to bundle all
Next.js internals which is wrong.

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

-->


Closes NEXT-3086
2024-04-12 15:52:32 +02:00
vercel-release-bot
c2b62d49c7 v14.2.1-canary.1 2024-04-12 10:09:21 +00:00
Jiachi Liu
56d0988af7
Fix: css in next/dynamic component in edge runtime (#64382)
### What

Wrap async local storage for all edge runtime routes in adapter 

Basically fixed the case reported in [this
tweet](https://x.com/keegandonley/status/1778538456458854880)

### Why

We're relying on the ALS for dynamic css preloading but we didn't wrap
the ALS for request handlers for edge. So if you have CSS imports in
`next/dynamic` in edge runtime it would break.

Closes NEXT-3085
2024-04-12 10:52:40 +02:00
Wyatt Johnson
b016c3c61f
Freeze loaded manifests (#64313)
Manifests in the runtime should be treated as immutable objects to
ensure that side effects aren't created that depend on the mutability of
these shared objects. Instead, mutable references should be used in
places where this is desirable.

This also introduces the new `DeepReadonly` utility type, which when
paired with existing manifest types, will modify every field to be read
only, ensuring that the type system will help catch accidental
modifications to these loaded manifest values as well.

Future work could eliminate these types by modifying the manifest types
themselves to be read only, only allowing code that generated them to be
writable.

Closes NEXT-3069
2024-04-11 21:07:37 -06:00
Wyatt Johnson
6bc9f79e48
Shared Revalidate Timings (#64370)
<!-- 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 creates a new `SharedRevalidateTimings` type that is safe to share
amongst different points within the framework for sharing revalidation
timings. This is a precursor to #64313 which freezes loaded manifests.

### Why?

Using the `SharedRevalidateTimings` type, we no-longer have to modify
the in-memory instance of the prerender manifest to share the
revalidation timings for different routes.

Closes NEXT-3083
2024-04-11 17:55:30 -06:00
Shu Ding
34524f01ad
Fix Server Action error logs for unhandled POST requests (#64315)
## Why

Currently, Server Action handlers are just normal routes and they
accepting POST requests. The only way to differentiate a normal request
(page access, API route, etc.) from a Server Action request is to check
that if it's a POST and has a Server Action ID set via headers or body
(e.g. `multipart/form-data`).

Usually, for existing page and API routes the correct handlers (page
renderer, API route handler) will take precedence over Server Action's.
But if the route doesn't exist (e.g. 404) it will still go through
Server Action's handler and result in an error. And we're eagerly
logging out that error because it might be an application failure, like
passing a wrong Action ID.

## How

In this PR we are making sure that the error is only logged if the
Action ID isn't `null`. This means that it's an intentional Server
Action request with a wrong ID. If the ID is `null`, we just handle it
like 404 and log nothing.

Fixes #64214.

Closes NEXT-3071
2024-04-12 01:21:28 +02:00
vercel-release-bot
6d96c3f468 v14.2.1-canary.0 2024-04-11 20:33:27 +00:00
Jiachi Liu
23bfce621f
refactor: next-flight-client-module-loader return conditions (#64348)
* Early return if the `this._module` doesn't exist, aligning with the
type
* If the source is changed, we should return the changed source
otherwise the indexes in source map will be wrong unless the modified
code is appended to the source code, but in this loader it's a different
case

Closes NEXT-3075
2024-04-11 21:56:36 +02:00
vercel-release-bot
774563f2b9 v14.2.0 2024-04-11 19:35:36 +00:00
vercel-release-bot
7aabb1d5ce v14.2.0-canary.67 2024-04-11 17:23:54 +00:00
Tobias Koppers
cbee70991f
update turbopack (#64347)
* https://github.com/vercel/turbo/pull/7409 <!-- hrmny - chore: add
parallel rust frontend and remove unused rust dependencies -->
* https://github.com/vercel/turbo/pull/7920 <!-- Tobias Koppers - remove
warning when there is no PostCSS config -->
* https://github.com/vercel/turbo/pull/7856 <!-- Donny/강동윤 - build:
Update `swc_core` to `v0.90.29` -->
* https://github.com/vercel/turbo/pull/7941 <!-- Tobias Koppers - fix
recursion cycle when having a cycle of dynamic imports -->
* https://github.com/vercel/turbo/pull/7943 <!-- Tobias Koppers - fix
HMR by removing chunks from chunk list hash -->
2024-04-11 19:16:27 +02:00
Tobias Koppers
b912492392
Turbopack: import webpack loader rules conditions (#64205)
### What?

* remove custom next-* conditions
* add `foreign` condition
* allow `false` in turbo.rules
* improve schema for turbo.rules

### Why?

### How?



Closes PACK-2913

---------

Co-authored-by: Tim Neutkens <tim@timneutkens.nl>
2024-04-11 17:35:43 +02:00
vercel-release-bot
265d7b97ba v14.2.0-canary.66 2024-04-11 15:14:55 +00:00
Jiachi Liu
ce81bbb383
metadata: prefer og title rather than metadata title for fallback twitter title (#64331)
Like the No.2 point mentioned in #63489, metadata's title and
description should be the last fallback, if you specify `title` or
`description` in `openGraph` but not in `metadata.twitter`, they should
inherit from open graph first.

For `metadata.twitter`'s fallback order should be: 

twitter's title/description > opengraph's title/description > metadata's
title/description

Resolves #63489 
Closes NEXT-3073
2024-04-11 16:07:57 +02:00
Tobias Koppers
6224b9e29f
Revert "build: Update swc_core to v0.90.30" (#64329)
Reverts vercel/next.js#63790
2024-04-11 11:47:50 +02:00
Jiachi Liu
cd09f8b815
Inject preview props into edge manifest (#64108)
### What

Bump the edge runtime manifest version and add `environments` property
to each route for inlining values for deployment build.

### Why

In edge runtime, extract the preview props into edge functions manifest
that holding the non-deterministic inline values, then the output build
will be more deterministic that helps deployment speed

x-ref: https://github.com/vercel/vercel/pull/11390
x-ref: https://github.com/vercel/vercel/pull/11395
Closes NEXT-3012
Closes NEXT-1912
2024-04-11 11:18:49 +02:00
Will Binns-Smith
11575a45da
Escape url-unsafe characters in names of app router scripts and styles (#64131)
Building on #58293, this expands escaping of url-unsafe characters in
paths to “required” scripts and styles in the app renderer.
    
This also refactors the test introduced in #58293 and expands it to
include stylesheet references as well as checking resources in the head,
which include special characters like turbopack references like
`[turbopack]`.
    
Test Plan: `TURBOPACK=1 pnpm test-dev
test/e2e/app-dir/resource-url-encoding`

Closes PACK-2911
2024-04-10 17:42:53 -07:00
Donny/강동윤
02dd1e55f0
build: Update swc_core to v0.90.30 (#63790)
# Turbopack


* https://github.com/vercel/turbo/pull/7409 <!-- hrmny - chore: add
parallel rust frontend and remove unused rust dependencies -->
* https://github.com/vercel/turbo/pull/7920 <!-- Tobias Koppers - remove
warning when there is no PostCSS config -->
* https://github.com/vercel/turbo/pull/7929 <!-- Tim Neutkens - Remove
environment variables page from Turbopack docs -->
* https://github.com/vercel/turbo/pull/7926 <!-- Tim Neutkens - Remove
outdated section -->
* https://github.com/vercel/turbo/pull/7925 <!-- Tim Neutkens - Update
Turbopack CSS docs -->
* https://github.com/vercel/turbo/pull/7928 <!-- Tim Neutkens - Update
Next.js mention in Turbopack docs -->
* https://github.com/vercel/turbo/pull/7856 <!-- Donny/강동윤 - build:
Update `swc_core` to `v0.90.29` -->



### What?

Update SWC crates.

### Why?

1. To keep in sync
2. Prepare usage of source map range mappings.
https://github.com/getsentry/rust-sourcemap/pull/77

### How?



Closes PACK-2860
2024-04-11 00:09:18 +00:00
vercel-release-bot
22754faff6 v14.2.0-canary.65 2024-04-10 23:22:42 +00:00
Jeongjin Oh
04c87ae2d7
fix: show the error message if images.loaderFile doesn't export a default function (#64036)
<!-- 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

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

-->

fixes #63803 

## What I do?

- If the loader file export the function as `named`, Next.js throws the
error.
- But this error is a bit confusing for the developers.
- So I open this PR for showing the accurate error message.

## AS-IS / TO-BE

### AS-IS

```
TypeError: Cannot use 'in' operator to search for '__next_img_default' in undefined
```
<img width="1202" alt="스크린샷 2024-03-28 16 10 53"
src="https://github.com/vercel/next.js/assets/33178048/e7c81cb5-7976-46ff-b86f-9c8fd9a7a681">

### TO-BE

```
Error: The loader file must export a default function that returns a string.
See more info here: https://nextjs.org/docs/messages/invalid-images-config
```
<img width="500" alt="스크린샷 2024-03-28 16 10 53"
src="https://github.com/vercel/next.js/assets/33178048/c391e61b-6a44-4f85-8600-28ab6cb5b0eb">

---------

Co-authored-by: Steven <steven@ceriously.com>
2024-04-10 18:11:38 +00:00
Jiachi Liu
a7107a3df4
[turbopack] Fix css FOUC in dynamic component (#64021)
Follow up for #64294 to make turbopack side work as well

---------

Co-authored-by: Tobias Koppers <tobias.koppers@googlemail.com>
2024-04-10 18:44:17 +02:00
Jiachi Liu
142050ddc0
Fix css FOUC in dynamic component (#64294)
### What

CSS imports in components that loaded by `next/dynamic` in client
components will cause the css are missing initial in
SSR, and loaded later on client side which will lead to FOUC. This PR
fixes the issue and get CSS preloaded in the SSR for dynamic components.

### Why

The CSS from client components that created through `next/dynamic` are
not collected in the SSR, unlike RSC rendering we already collect the
CSS resources for each entry so we included them in the server rendering
so the styles are availble at that time. But for client components, we
didn't traverse all the client components and collect the CSS resources.

In pages router we kinda collect all the dynamic imports and preload
them during SSR, but this approach is not able to be applied to app
router due to different architecture. Since we already have all the
dynamic imports info and their related chunks in
react-loadable-manifest, so we can do the similar "preloading" thing in
app router. We use the current dynamic module key (`app/page.js ->
../components/foo.js`) which created by SWC transform and match it in
the react loadable manifest that accessed from `AsyncLocalStorage`, to
get the css files created by webpack then render them as preload
styleshee links. In this way we can SSR all the related CSS resources
for dynamic client components.

The reason we pass down the react loadable manifest through
`AsyncLocalStorage` is that it's sort of exclude the manifest from RSC
payload as it's not required for hydration, but only required for SSR.

Note: this issue only occurred in dynamic rendering case for client
components.

### Other Changes Overview

- Change the react loadable manifest key from pages dir based relative
path to a source dir based relative path, to support cases with both
directory or only one of them

Closes NEXT-2578
Fixes #61212
Fixes #61111
Fixes #62940

Replacement for #64021 but only with production test
2024-04-10 16:16:20 +02:00
Vercel Release Bot
7e49208ac7
Update font data (#64277)
This auto-generated PR updates font data with latest available
2024-04-10 04:47:07 -07:00
Tim Neutkens
4c128a5d6b
Ensure configuration is checked for Turbopack build (#64247)
## What?

Currently any configuration issue like including `.babelrc` was not
highlighted during Turbopack build. This PR solves that issue as well as
ensuring the warnings are not double-logged because of a change that was
supposed to be development-only.

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

-->


Closes NEXT-3049
2024-04-10 10:09:03 +02:00
Ahsan Moin
90b3ddd671
chore: fix some typos (#64276)
`functionaility` -> `functionality`
`programatically` -> `programmatically`
`recored` -> `record`
`specfy` -> `specify`

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

-->
2024-04-10 04:04:52 +00:00
vercel-release-bot
167ea3382f v14.2.0-canary.64 2024-04-09 21:36:28 +00:00
Tobias Koppers
dedf385450
update turbopack (#64257)
* https://github.com/vercel/turbo/pull/7912 <!-- Tobias Koppers - fix
edge condition in environment -->
* https://github.com/vercel/turbo/pull/7914 <!-- hrmny - feat: support
interop for namespace importing cjs function exports -->
2024-04-09 23:33:01 +02:00
Sam Ko
5e7e4bc02b
chore(cli): fix the order --experimental-debug-memory-usage so it's alphabetical (#64264)
## Why?

This fixes the ordering of `--experimental-debug-memory-usage` so the
help output for experimental options are alphabetical/ordered properly
(grouped at the end).

- Related https://github.com/vercel/next.js/pull/63869

Closes NEXT-3054
2024-04-09 17:28:12 +00:00
Zack Tanner
85b9ed5eb8
provide revalidateReason to getStaticProps (#64258)
Provides a `revalidateReason` argument to `getStaticProps` ("stale" |
"on-demand" | "build").

- Build indicates it was run at build time
- On-demand indicates it was run as a side effect of [on-demand
revalidation](https://nextjs.org/docs/pages/building-your-application/data-fetching/incremental-static-regeneration#on-demand-revalidation)
- Stale indicates the resource was considered stale (either due to being
in dev mode, or an expired revalidate period)

This will allow changing behavior based on the context in which it's
called.

Closes NEXT-1900
2024-04-09 09:53:08 -07:00
Sam Ko
39a1c2aa0b
fix(fetch-cache): add check for updated tags when checking same cache key (#63547)
## Why?

When we fetch the same cache key (URL) but add an additional tag, the
revalidation does not re-fetch correctly (the bug just uses in-memory
cache again) when deployed.

:repro: →
https://github.com/lostip/nextjs-revalidation-demo/tree/main

---------

Co-authored-by: Ethan Arrowood <ethan@arrowood.dev>
2024-04-09 16:36:32 +00:00
Steven
8c9c1d2b6d
feat(next/image): add overrideSrc prop (#64221)
- Fixes https://github.com/vercel/next.js/discussions/60888
- Related
https://merj.com/blog/optimising-nextjs-image-component-for-image-search
2024-04-09 10:48:01 -04:00
Zack Tanner
136979fedb
forward missing server actions to valid worker if one exists (#64227)
### What
When submitting a server action on a page that doesn't import the action
handler, a "Failed to find server action" error is thrown, even if
there's a valid handler for it elsewhere.

### Why
Workers for a particular server action ID are keyed by their page
entrypoints, and the client router invokes the current page when
triggering a server action, since it assumes it's available on the
current page. If an action is invoked after the router has moved away
from a page that can handle the action, then the action wouldn't run and
an error would be thrown in the server console.

### How
We try to find a valid worker to forward the action to, if one exists.
Otherwise it'll fallback to the usual error handling. This also adds a
header to opt out of rendering the flight tree, as if the action calls a
`revalidate` API, then it'll return a React tree corresponding with the
wrong page.

Fixes #61918
Fixes #63915

Closes NEXT-2489
2024-04-09 07:10:06 -07:00
mknichel
a01f825592
Add a mode to next build to make it easier to debug memory issues (#63869)
This PR adds a `--experimental-debug-memory-usage` flag to `next build`
to make it easier to debug memory performance. This mode does the
following things:

- Periodically prints the current memory usage of the process
- Records garbage collection events and warns about long running GC
events
- Kills the process if it detects GC thrashing near heap limit
- Automatically takes a heap snapshot if heap usage rises above 70% of
the total heap
- Automatically takes a heap snapshot if the process is close to running
out of memory
- Prints a report at the end of the build with information about peak
memory usage and time spent in garbage collection

---------

Co-authored-by: JJ Kasper <jj@jjsweb.site>
2024-04-09 06:53:34 -07:00
Jiachi Liu
5e2ac0986f
chore: externalize undici for bundling (#64209)
Currently acornjs has an issue with compiling undici, add undici
externalize, once it's resolved we can remove the externalization for it

```
You may need an additional loader to handle the result of these loaders.
|       // 5. If object is not a default iterator object for interface,
|       //    then throw a TypeError.
>       if (typeof this !== 'object' || this === null || !(#target in this)) {
|         throw new TypeError(
|           `'next' called on an object that does not implement interface ${name} Iterator.`

Import trace for requested module:
../../../../node_modules/.pnpm/undici@6.12.0/node_modules/undici/lib/web/fetch/util.js
../../../../node_modules/.pnpm/undici@6.12.0/node_modules/undici/lib/web/fetch/headers.js
../../../../node_modules/.pnpm/undici@6.12.0/node_modules/undici/index.js
./app/undici/page.js
```

Closes NEXT-3030
2024-04-09 07:26:53 +00:00
Tobias Koppers
4016c73d2b
Turbopack: prefer local opentelemetry version (#64206)
### What?

align `@opentelemetry/api` alias with webpack

### Why?

### How?


Closes PACK-2914

---------

Co-authored-by: Dima Voytenko <dima.voytenko@vercel.com>
2024-04-09 00:35:37 +00:00
Donny/강동윤
5aa984de75
feat: Do not mangle AbortSignal to avoid breaking node-fetch (#58534)
### What?

Add `AbortSignal` to the reserved list of the name mangler.

### Why?

We don't want `node-fetch`  to throw an exception.

x-ref: https://vercel.slack.com/archives/C04KC8A53T7/p1700123182211619?thread_ts=1700090771.304599&cid=C04KC8A53T7

### How?


This PR modifies the mangle option from the Rust side code.

Closes PACK-1977
2024-04-09 09:28:03 +09:00
vercel-release-bot
c289063517 v14.2.0-canary.63 2024-04-08 23:22:35 +00:00
Benjamin Woodruff
f9ad49fc6f
test(turbopack): Add -Wl,--warn-unresolved-symbols to next-swc-napi on Linux (#64049)
I'm not sure why this issue is impacting me and seemingly not others,
but on Debian 12 with the default linker options (gcc with ld) I get the
following compilation error regarding unresolved symbols:

https://gist.github.com/bgw/92da94f46b0994514a144b8938aa2f6c

This flag downgrades that linker error to a warning (which cargo hides).

I've checked that this flag is supported by ld, gold, lld, and mold.
I've also tried building with mold in addition to ld. I'm restricting
the option to linux to avoid potentially breaking other platforms.

Tested by running:

```
cargo test -p next-swc-napi
```

Which now gives:

```
running 2 tests
test transform::test_deserialize_transform_regenerator ... ok
test transform::test_deser ... ok
```
2024-04-08 10:49:24 -07:00
Jiachi Liu
530382aeea
Fix hydration error higlight when tag matched multi times (#64133)
### What

We introduced a new algorithm to find the matched hydration error tags,
when there're two tags indicating children and parent as bad descendence
relationship. Now we search for the child first from the last index, and
then from found child to search its above parent. This way we can find
the two related tags in O(1), since they could be not directly nested.

### Why

When a hydration error occurred, such as bad nesting `div` under `p`,
one of the tag `div` is matched multiple times in the component stack,
it shouldn't be highlighted multiple times. This PR fixes the bad
matching about multiple nested tags, e.g. when there're many `div` tag
and `div` is one of the bad tag, only the one directly under p should be
highlited.

Case
```
Page > div > div > p > div
```

Current Result: all `div` and `p` get highlighted, `[]` represents
highlighted.
```
Page > [div] > [div] > [p] > [div]
```

Expected: only the related 2 tags are highlighted, `[]` represents
highlighted.
```
Page > div > div > [p] > [div]
```

Thanks @JohnPhamous for reporting the issue


Closes NEXT-3022
2024-04-08 19:12:03 +02:00
Zack Tanner
b103f73bf9
ensure seeded prefetch entry is renewed after expiry (#64175)
When we seed the prefetch cache with an entry for the loaded page, we
should also mark `lastUsedTime` to be the current time. Otherwise, if
the prefetch entry has technically expired, it'll incorrectly be
considered "reusable" because the `lastUsedTime` will be set to when
it's first routed to client-side.

x-ref:
https://github.com/vercel/next.js/discussions/54075#discussioncomment-9031149
<!-- 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 #

-->


Closes NEXT-3025
2024-04-08 06:49:58 -07:00
Julius Marminge
a7c24aca6f
feat: allow module: Preserve tsconfig option (#64110)
Fixes #64018

Adds support for modern configurations introduced in TS 5.4

Expected output: not modifying the `module`, `esModuleInterop` configs
since `module: preserve` is present

```
   We detected TypeScript in your project and reconfigured your tsconfig.json file for you. Strict-mode is set to false
 by default.
   The following suggested values were added to your tsconfig.json. These values can be changed to fit your project's n
eeds:

        - lib was set to dom,dom.iterable,esnext
        - allowJs was set to true
        - skipLibCheck was set to true
        - strict was set to false
        - noEmit was set to true
        - incremental was set to true
        - include was set to ['next-env.d.ts', '**/*.ts', '**/*.tsx']
        - exclude was set to ['node_modules']

   The following mandatory changes were made to your tsconfig.json:

        - isolatedModules was set to true (requirement for SWC / Babel)
        - jsx was set to preserve (next.js implements its own optimized jsx transform)
```

---------

Co-authored-by: Jiachi Liu <inbox@huozhi.im>
2024-04-08 11:30:04 +00:00
Donny/강동윤
697ae8af5b
feat(turbopack): Align behavior for link rel="preconnect" with webpack mode (#64011)
### What?

Emit `<link data-next-font="size-adjust" rel="preconnect" href="/"
crossorigin="anonymous"/>` in more cases.

### Why?

To align with the default mode

### How?
2024-04-08 08:24:18 +02:00
vercel-release-bot
e46d088aec v14.2.0-canary.62 2024-04-07 23:22:18 +00:00
vercel-release-bot
42f8ac16c6 v14.2.0-canary.61 2024-04-06 23:21:38 +00:00
Jiwon Choi
3b24c347e2
hotfix(next):next lint installs eslint@9 which includes breaking changes (#64141)
This is a hotfix since it breaks `next lint`, I'll start to implement
eslint v9 for canary.

x-ref: #64114
x-ref: [eslint v9
release](https://github.com/eslint/eslint/releases/tag/v9.0.0)
Fixes #64136

---------

Co-authored-by: Zack Tanner <zacktanner@gmail.com>
2024-04-06 07:45:21 -07:00
vercel-release-bot
acaf642fbd v14.2.0-canary.60 2024-04-05 23:22:28 +00:00
Jiachi Liu
14c8900e70
style(dev-overlay): refine the error message header styling (#63823)
### What

Polish the UX based on the feedbacks from @sambecker 

* Fix the font that still use mono
* Align the color, to use red for the warnings
* Give the title to build error
* Only highlight the nextjs doc url as link

### After vs Before

#### Runtime Error


<img width="335" alt="image"
src="https://github.com/vercel/next.js/assets/4800338/64f2f692-1eae-41db-9287-046aff9ba112">
<img width="335" alt="image"
src="https://github.com/vercel/next.js/assets/4800338/2d4bad15-745e-4083-ba57-8968c0f321c2">

#### Build Error

<img width="335" alt="image"
src="https://github.com/vercel/next.js/assets/4800338/ecfc3883-4522-40c6-b042-6d85e7ea970e">
<img width="335" alt="image"
src="https://github.com/vercel/next.js/assets/4800338/bbf37ec5-b639-4b95-a87f-9911182e431c">



Closes NEXT-2958
2024-04-05 23:39:22 +02:00
vercel-release-bot
a00bed86d0 v14.2.0-canary.59 2024-04-05 18:36:31 +00:00
Dima Voytenko
b953257c27
Fix @opentelemetry/api aliasing for webpack (#64085)
Next creates an alias for `@opentelemetry/api` to a prebundled version
[here](a9f85d14c0/packages/next/src/build/create-compiler-aliases.ts (L108-L110)).
However, there's a bug in `hasExternalOtelApiPackage` - it currently
always fails to remove `@opentelemetry/api/package.json` because it's
not one of the exports.
2024-04-05 10:39:21 -07:00
JJ Kasper
2f567da817
Rework experimental preload entries handling (#64125)
Follow-up to https://github.com/vercel/next.js/pull/64084 this refactors
it a bit and renames the flag.

Closes NEXT-3018
2024-04-05 17:38:39 +00:00
Tobias Koppers
f6baf61b61
fix encoding for filenames containing ? or # (#58293)
Closes PACK-1935

---------

Co-authored-by: Will Binns-Smith <wbinnssmith@gmail.com>
2024-04-05 10:25:30 -07:00
Tim Neutkens
e4b85d55c2
Ensure empty config with Turbopack does not show webpack warning (#64109)
## What?

There's a bug currently that shows the "webpack has been configured"
warning incorrectly:

```
pnpm next dev --turbo examples/hello-world

> nextjs-project@0.0.0 next /Users/timneutkens/projects/next.js
> cross-env NEXT_TELEMETRY_DISABLED=1 node --trace-deprecation --enable-source-maps packages/next/dist/bin/next "dev" "--turbo" "examples/hello-world"

  ▲ Next.js 14.2.0-canary.58 (turbo)
  - Local:        http://localhost:3000

 ✓ Starting...
 ✓ Ready in 791ms
 ⚠ Webpack is configured while Turbopack is not, which may cause problems.
 ⚠ See instructions if you need to configure Turbopack:
  https://nextjs.org/docs/app/api-reference/next-config-js/turbo
```

This PR ensures the warning is only shown when you have actually
configured `webpack` in `next.config.js`.


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

-->


Closes NEXT-3013
2024-04-05 16:53:03 +00:00
Wyatt Johnson
bb74ece14e
Ensure static generation storage is accessed correctly (#64088)
<!-- 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?

Primarily, this is fixing the code highlighted here:


073cd74433/packages/next/src/server/lib/patch-fetch.ts (L228-L230)

As `(fetch as any).__nextGetStaticStore?.()` returns
`StaticGenerationAsyncStorage | undefined`, and not
`StaticGenerationStore`. A call to `.getStore()` as the previous line
does corrects this issue.

Secondarily, this improves the `as any` type access being done on the
patched fetch object to make it more type safe and easier to work with.
Since this was added, some features like the `.external` files were
added that allowed files to import the correct async local storage
object in client and server environments correctly to allow for direct
access. Code across Next.js no-longer uses this mechanism to access the
storage, and instead relies on this special treated import.

Types were improved within the `patch-fetch.ts` file to allow for safer
property access by adding consistent types and guards.

### Why?

Without this change, checks like:


073cd74433/packages/next/src/server/lib/patch-fetch.ts (L246)

Always fail, because when `(fetch as any).__nextGetStaticStore?.()`
returns `StaticGenerationAsyncStorage`, it isn't the actual store, so
the type is wrong.

Closes NEXT-3008
2024-04-05 07:14:14 -07:00
Balázs Orbán
d9b724405c
fix(log): tweak coloring (#64106) 2024-04-05 13:13:28 +02:00
Sukka
fe24bb86d7
perf: improve next server static performance (#64098)
Previously, the `serve-static` utility function in Next.js would
determine which codepath to use based on the version of `mime` **for
every incoming request**. The PR changes so that the codepath **will be
determined in advance**, thereby reducing the overhead.
2024-04-05 08:09:35 +01:00
vercel-release-bot
073cd74433 v14.2.0-canary.58 2024-04-04 23:48:21 +00:00
Zack Tanner
51549d92de
fix refreshing inactive segments that contained searchParams (#64086)
When adding refresh markers for refetching segments that are "stale"
(the soft navigation case where they are still in the Router State Tree
but not part of the page that we're rendering), they only contained a
reference to the pathname. Once the actual refresh was triggered we
added the current search params to the request.

However, this causes an issue: segments in the `FlightRouterState` can
contain searchParams (ie, `__PAGE__?{"foo": "bar}` is what the segment
becomes when adding `?foo=bar` to a page). This means that when we
refresh those nodes from the server, it won't know how to find the
`CacheNode` for the stale segment since we won't have them in the
refetch tree. This updates to keep a reference to the searchParams that
were part of the request that made it active.

While fixing this, I also noticed that we were missing a spot to add the
refetch marker in `applyRouterStatePatchToTree` in the case of a root
refresh (caught by these tests failing in PPR)


[x-ref](https://github.com/vercel/next.js/discussions/63900#discussioncomment-9002137)

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

-->


Closes NEXT-3007
2024-04-04 23:44:54 +00:00
Will Binns-Smith
3d3311b150
Update rust-toolchain to nightly-2024-04-03 (#64048)
Depends on https://github.com/vercel/turbo/pull/7874, which should be
merged first.

Test Plan: `cargo check`


Closes PACK-2903
2024-04-04 23:28:02 +00:00
vercel-release-bot
710cf7c27f v14.2.0-canary.57 2024-04-04 23:22:38 +00:00
JJ Kasper
a9f85d14c0
Add flag for preloading all server chunks (#64084)
This adds an experimental flag to allow testing preloading all server
chunks including webpack chunks during the server initialization. It is
disabled by default and only opt-in for experimenting.

Closes NEXT-3005
2024-04-04 14:13:13 -07:00
Nikhil Mehta
c502308bca
fix: cookie override during redirection from server action (#61633)
### What?
Fixes #61611

### Why?
Any one having custom server may be having logic to set cookies during
GET requests too. Currently nextjs in app directory does not allow to do
so but with custom server its very much possible.

### How?
By merging cookies of redirect response and server action POSt response

### Tests
I have added one more test to existing suite and it passing with fix in
place.

![image](https://github.com/vercel/next.js/assets/6815560/858afdbb-c377-49eb-9002-fcbdf06583a4)

### Notes
This bug is reproducible only if developer has custom server on top of
next app but still very probable

---------

Co-authored-by: Shu Ding <g@shud.in>
Co-authored-by: JJ Kasper <jj@jjsweb.site>
2024-04-04 14:08:13 -07:00
Jiachi Liu
02197bc364
Fix status code for /_not-found route (#64058)
### What

Fix the status code in static generation metadata for `/_not-found`
route, aligning it as 404 for both dev and build

### Why
`/_not-found` route should still return 404 code as it's reserved as
default not found route

Closes NEXT-3001
2024-04-04 17:35:27 +02:00
Donny/강동윤
3ae6e1c9fe
feat(turbopack): Print error message for next/font fetching failure (#64008)
### What?

Print an error message to stdout if stylesheet fetching fails.

### Why?

To align behavior with the default mode. This PR fixes one integration
test case.

### How?



Closes PACK-2896
2024-04-04 23:56:10 +09:00
vercel-release-bot
e273b335da v14.2.0-canary.56 2024-04-03 23:23:53 +00:00
OJ Kwon
16f4b96e3e
fix(turbopack): emit loadable manifest for app (#64046)
### What

Seems we only emit loadable manifest for the pages so far, adding quick
fix for app.

Closes PACK-2902
2024-04-03 20:57:53 +00:00
OJ Kwon
fd73584c7f
fix(turbopack): throws api issues (#64032)
### What

Correctly raises error for the /api, unlike other places we were
suppressing it.

Closes PACK-2900
2024-04-03 13:50:30 -07:00
vercel-release-bot
e8ffd337df v14.2.0-canary.55 2024-04-03 16:07:20 +00:00
Zack Tanner
ad98cda23b
fix interception route refresh behavior with dynamic params (#64006)
### What
When triggering an interception route that has a parent with dynamic
params, and then later going to "refresh" the tree, either by calling
`router.refresh` or revalidating in a server action, the refresh action
would silently fail and the router would be in a bad state.

### Why
Because of the dependency that interception routes currently have on
`FlightRouterState` for dynamic params extraction, we need to make sure
the refetch has the full tree so that it can properly extract earlier
params. Since the refreshing logic traversed parallel routes and scoped
the refresh to that particular segment, it would skip over earlier
segments, and so when the server attempted to diff the tree, it would
return an updated tree that corresponded with the wrong segment
(`[locale]` rather than `["locale", "en", "d]`).

Separately, since a page segment might be `__PAGE__?{"locale": "en"}`
rather than just `__PAGE__`, this updates the refetch marker logic to do
a partial match on the page segment key.

### How
This keeps a reference to the root of the updated tree so that the
refresh always starts at the top. This has the side effect of
re-rendering more data when making the "stale" refetch request, but this
is necessary until we can decouple `FlightRouterState` from interception
routes.

shout-out to @steve-marmalade for helping find this bug and providing
excellent Replays to help track it down 🙏

x-ref:

- https://github.com/vercel/next.js/discussions/63900

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

-->


Closes NEXT-2986
2024-04-03 09:03:58 -07:00
JJ Kasper
6a1e70ae55
Ensure unstable_cache bypasses for draft mode (#64007)
Currently we aren't detecting the draft mode case properly in
`unstable_cache` so the cache is unexpectedly being leveraged. This
ensures we bypass the cache for `unstable_cache` in draft mode the same
way we do for the fetch cache handling.

Fixes: https://github.com/vercel/next.js/issues/60445

Closes NEXT-2987
2024-04-03 08:08:28 -07:00
Balázs Orbán
add2e6ea05
fix(log): skip logging non-route requests (#63973) 2024-04-03 12:16:20 +02:00
vercel-release-bot
2db296e4fa v14.2.0-canary.54 2024-04-02 23:22:33 +00:00
JJ Kasper
d49e2c2c4c
Fix abort condition for requests (#64000)
This ensures we don't attempt passing a closed body to a
Request/Response object when a request is aborted as this triggers the
disturbed/locked error condition.

<details>

<summary>Example error</summary>

```sh
TypeError: Response body object should not be disturbed or locked
        at extractBody (node:internal/deps/undici/undici:4507:17)
        at new Request (node:internal/deps/undici/undici:5487:48)
        at new NextRequest (/private/var/folders/cw/z0v1fby13ll4ytx_j3t8hhqh0000gn/T/next-install-d72b2dfb54a1417294505ab189942a38fd6bc139c24b9a8089fc3248568ff902/node_modules/.pnpm/file+..+next-repo-aef41a0c8a591889bcb0dc2e751aa71aa1c2e78c82d9e9b2fe3515c3d40f6c03+packages+n_wd7e7pnjmf2re4cc3l4tp6yzqe/node_modules/next/dist/server/web/spec-extension/request.js:33:14)
        at NextRequestAdapter.fromNodeNextRequest (/private/var/folders/cw/z0v1fby13ll4ytx_j3t8hhqh0000gn/T/next-install-d72b2dfb54a1417294505ab189942a38fd6bc139c24b9a8089fc3248568ff902/node_modules/.pnpm/file+..+next-repo-aef41a0c8a591889bcb0dc2e751aa71aa1c2e78c82d9e9b2fe3515c3d40f6c03+packages+n_wd7e7pnjmf2re4cc3l4tp6yzqe/node_modules/next/dist/server/web/spec-extension/adapters/next-request.js:94:16)
        at NextRequestAdapter.fromBaseNextRequest (/private/var/folders/cw/z0v1fby13ll4ytx_j3t8hhqh0000gn/T/next-install-d72b2dfb54a1417294505ab189942a38fd6bc139c24b9a8089fc3248568ff902/node_modules/.pnpm/file+..+next-repo-aef41a0c8a591889bcb0dc2e751aa71aa1c2e78c82d9e9b2fe3515c3d40f6c03+packages+n_wd7e7pnjmf2re4cc3l4tp6yzqe/node_modules/next/dist/server/web/spec-extension/adapters/next-request.js:70:35)
        at doRender (/private/var/folders/cw/z0v1fby13ll4ytx_j3t8hhqh0000gn/T/next-install-d72b2dfb54a1417294505ab189942a38fd6bc139c24b9a8089fc3248568ff902/node_modules/.pnpm/file+..+next-repo-aef41a0c8a591889bcb0dc2e751aa71aa1c2e78c82d9e9b2fe3515c3d40f6c03+packages+n_wd7e7pnjmf2re4cc3l4tp6yzqe/node_modules/next/dist/server/base-server.js:1365:73)
```

</details>

Fixes: https://github.com/vercel/next.js/issues/63481

Closes NEXT-2984
Closes NEXT-2904
2024-04-02 15:30:13 -07:00
Jiwon Choi
1511433212
fix(next): next build --debug log output layout is broken (#63193)
### Why?

The output layout breaks when running `next build --debug`

#### Current

```sh
 ✓ Generating static pages (10/10) 
   Finalizing page optimization  .   Collecting build traces  .Redirects

┌ source: /:path+/
├ destination: /:path+
└ permanent: true
 

 ✓ Collecting build traces    
 ✓ Finalizing page optimization    
```

#### Expected

```sh
✓ Generating static pages (4/4) 
   Finalizing page optimization ...
   Collecting build traces ...


Redirects
┌ source: /:path+/
├ destination: /:path+
└ permanent: true
```

### How?

Moved the `debug` output right above the `routes` output.
Also, ensured that the output layout has a consistent number of line
breaks (example below marked as `>`):

> Two line breaks for the next `option`, a single line break within the
same content.

```sh
   Collecting build traces ...
>
>
Redirects
┌ source: /:path+/
├ destination: /:path+
└ permanent: true
>
┌ source: /redirects
├ destination: /
└ permanent: true
>
>
Headers
┌ source: /
└ headers:
  └ x-custom-headers: headers
>
>
Rewrites
┌ source: /rewrites
└ destination: /
>
>
Route (app)                              Size     First Load JS
┌ ○ /                                    141 B          86.2 kB
└ ○ /_not-found                          876 B          86.9 kB
```

Fixes #63192

---------
2024-04-02 15:05:28 -07:00
Zack Tanner
17907b4316
fix server actions not bypassing prerender cache in all cases when deployed (#63978)
Trying to submit a server action when JS is disabled (ie, no action
header in the request, and in the "progressively enhanced" case) for a
static resource results in a 405 error when deployed to Vercel. In the
absence of an action ID header, the request content-type is used to
signal that it shouldn't try and hit the static cache. However with
multipart/form-data, this will include the boundary. This updates the
matcher to consider a boundary string.

Fixes #58814
Closes NEXT-2980
2024-04-02 14:32:52 -07:00
vercel-release-bot
94b19bbad2 v14.2.0-canary.53 2024-04-02 21:15:15 +00:00
Zack Tanner
eddd1ee186
add telemetry events for ppr & staleTimes experimental flags (#63981)
Adds `NextConfig.experimental.ppr` and
`NextConfig.experimental.staletimes` to the `NEXT_BUILD_FEATURE_USAGE`
telemetry event.

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

-->


Closes NEXT-2981
2024-04-02 21:11:47 +00:00
Fellipe Utaka
3e449b235d
fix(create-next-app): validate --import-alias value (#63855)
Fixes #63854

Previously, there was no check when a path was passed with the
--import-alias flag. Furthermore, the regex used before did not check
for possible invalid paths.

The current regex checks the following conditions:
- It must follow the pattern `<prefix>/*`
- The prefix cannot contain invalid characters for folders, such as:
(whitespaces, /, <, >, :, ", /, \, |, ? and *)

---------

Co-authored-by: JJ Kasper <jj@jjsweb.site>
2024-04-02 13:10:14 -07:00
Zack Tanner
86cbc1f526
add experimental client router cache config (#62856)
This introduces an experimental router flag (`experimental.staleTimes`)
to change the router cache behavior. Specifically:

```ts
// next.config.js
module.exports = {
  experimental: {
    staleTimes: {
      dynamic: <seconds>,
      static: <seconds>,
    },
  },
};
```

- `dynamic` is the value that is used when the `prefetch` `Link` prop is
left unspecified. (Default 30 seconds)
- `static` is the value that is used when the `prefetch` `Link` prop is
`true`. (Default 5 minutes)

Additional details:
- Loading boundaries are considered reusable for the time period
indicated by the `static` property (default 5 minutes)
- This doesn't disable partial rendering support, **meaning shared
layouts won't automatically be refetched every navigation, only the new
segment data**.
- This also doesn't change back/forward caching behavior to ensure
things like scroll restoration etc still work nicely.

Please see the original proposal
[here](https://github.com/vercel/next.js/discussions/54075#discussioncomment-6754339)
for more information. The primary difference is that this is a global
configuration, rather than a per-segment configuration, and it isn't
applied to layouts. (We expect this to be a "stop-gap" and not the final
router caching solution)

Closes NEXT-2703
2024-04-02 05:42:18 -07:00
Kevin Mårtensson
d2ac9c6c77
fix: pass nonce to next/script properly (#56995)
### What?

This fixes an issue where the `nonce` attribute isn't set on
`next/script` elements that has the `afterInteractive` (the default)
strategy resulting in `<link rel="preload" as="script"/>` tags without a
nonce.

### Why?

For apps that uses 3rd party scripts (or any script) with a nonce loaded
via `next/script` this is necessary unless you want them all to use
`beforeInteractive` which isn't super nice for performance.

---------

Co-authored-by: JJ Kasper <jj@jjsweb.site>
2024-04-01 23:27:38 +00:00
vercel-release-bot
f4aeebf099 v14.2.0-canary.52 2024-04-01 23:23:00 +00:00
Nick Muller
e4a831c188
Update hover behaviour note in Link JSDoc comment (#60525)
<!-- 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?
Removed "When `prefetch` is set to `false`, prefetching will still occur
on hover." from prefetch field documentation.

### Why?
This behaviour no longer happens when using the app router. It's really
misleading, since it creates the assumption that this behaviour always
exists.

<!-- 
### How?

Closes NEXT-
Fixes #

-->

---------

Co-authored-by: JJ Kasper <jj@jjsweb.site>
2024-04-01 11:37:30 -07:00
CreeJee
f76fe61e99
chore: remove useless any (#63910)
<!-- 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 #

-->

Co-authored-by: JJ Kasper <jj@jjsweb.site>
2024-04-01 10:01:48 -07:00
Zack Tanner
38775152a9
ensure custom amp validator path is used if provided (#63940)
We noticed that despite passing a custom validator path in #63838, it
was still attempting to use the CDN version
([x-ref](https://github.com/vercel/next.js/actions/runs/8509901629/job/23306398959?pr=63879#step:27:1570)),
revealing a spot where we weren't passing the custom validator path.
This updates the types for `validateAmp` to be more explicit and fixes
the missing spot.

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

-->


Closes NEXT-2968
2024-04-01 09:43:18 -07:00
Zack Tanner
de049f8165
fix logic error in parallel route catch-all normalization (#63879)
### What & Why
There was some code added in the catch-all route normalization that
doesn't seem to make sense -- it was checking if the provided `appPath`
depth was larger than the catch-all route depth, prior to inserting it.
But it was comparing depths in an inconsistent way (`.length` vs
`.length - 1`), and the catch all path was also considering the `@slot`
and `/page` suffix as part of the path depth.

This means that if you had a `@modal/[...catchAll]` slot, it wouldn't be
considered for a page like `/foo/bar/baz`, because `/foo/bar/baz`
(depth: 4 with the current logic) and `/@modal/[...catchAll]/page`
(depth: 3 with the current logic) signaled that the `/foo/bar/baz` route
was "more specific" and shouldn't match the catch-all.

I think this was most likely added to resolve a bug where we were
inserting optional catch-all (`[[...catchAll]]`) routes into parallel
slots. However, optional catch-all routes are currently unsupported with
parallel routes, so this feature didn't work properly and the partial
support introduced a bug for regular catch-all routes.

### How
This removes the confusing workaround and skips optional catch-all
segments in this handling. Separately, we can add support for optional
catch-all parallel routes, but doing so will require quite a bit more
changes & also similar handling in Turbopack. Namely, if have a
top-level optional catch-all, in both the Turbopack & current Webpack
implementation, that top-level catch-all wouldn't be matched. And if you
tried to have an optional catch-all slot, in both implementations, the
app would error with:
> You cannot define a route with the same specificity as a optional
catch-all route ("/" and "/[[...catchAll]]")

because our route normalization logic does not treat slots specificity
differently than pages.

**Note**: This keeps the test that was added when this logic was first
introduced in #60776 to ensure that the case this was originally added
for still passes.

Fixes #62948
Closes NEXT-2728
2024-04-01 08:50:54 -07:00
vercel-release-bot
952da876f7 v14.2.0-canary.51 2024-03-31 23:21:05 +00:00
vercel-release-bot
1c5aa7fa09 v14.2.0-canary.50 2024-03-30 23:21:02 +00:00
Maikel
4efe14238b
fix: bundle fetching with asset prefix (#63627)
Closes: https://github.com/vercel/next.js/issues/63623

When a relative assetPrefix was set (e.g. `/custom-asset-prefix`),
bundle fetching would always return a 404 as the assetPrefix was not
removed from filesystem path

---------

Co-authored-by: JJ Kasper <jj@jjsweb.site>
2024-03-29 16:38:24 -07:00
Evelyn Hathaway
5cfb7a0878
fix: skip checking rewrites with an empty has array in isInterceptionRouteRewrite (#63873)
<!-- 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?

Fixes #63871

-->

### What?

Adds safe traversal to rewrite `has` items in a certain new
(`isInterceptionRouteRewrite()` added in the v14.2.0 canaries) check to
the rewrite routes.

### Why?

The new check assumed that all `has` arrays had at least one item, when
previously Next.js accepted rewrites with empty `has`. Adding safe
traversal doesn't negatively impact the check, as the check only needs
rewrites with the first item.

Fixes #63871

---------

Co-authored-by: JJ Kasper <jj@jjsweb.site>
2024-03-29 16:38:06 -07:00
vercel-release-bot
274a764625 v14.2.0-canary.49 2024-03-29 22:36:19 +00:00
OJ Kwon
9e7d9ceaf5
fix(turbopack): loosen warning log guards (#63880)
### What

issue's filepath can be outside of turbopack root (`[project]/..`).
Loosening check to include any node_modules path.


Closes PACK-2876
2024-03-29 22:32:22 +00:00
Donny/강동윤
29d53c87ea
feat(next-swc): Pass names of side-effect-free packages (#63268)
### What?

Pass the names of side-effect-free packages specified in `experimental.optimizePackageImports`.

Turbopack counterpart: https://github.com/vercel/turbo/pull/7731

### Why?

Some packages like `@tremor/react` causes a problem without `optimizePackageImports`.

### How?

Closes PACK-2527
2024-03-29 06:28:48 +00:00
JJ Kasper
b434ea401c
Ensure we dedupe fetch requests properly during page revalidate (#63849) 2024-03-29 01:56:11 +00:00
OJ Kwon
b90dcdd049
feat(next-core): set nextconfigoutput correctly (#63848)
### What

PR updates route's template injection correctly sets `nextConfigOutput`.
2024-03-28 17:35:35 -07:00
Jiachi Liu
389ea36673
fix: avoid metadata viewport warning during manually merging metadata (#63845)
We're incorrectly showing warnings for `viewport` if you manually merge
metadata.
Found this while fixing #63843 

Closes NEXT-2964
2024-03-29 00:32:22 +00:00
Jiwon Choi
19c1916460
fix(next-typescript-plugin): allow call expression for server actions (#63748)
cc @shuding

### Why?

The typescript plugin in #63667 does not target the call expression or
assigned actions.

```ts
'use server'

function action() {
  return async function() {
    return 'foo'
  }
}

async function action2() {
  return 'foo'
}

export const callAction = action() // call expression
export const assignedAction = action2 // assigned
```

### Current

![Screenshot 2024-03-27 at 2 29
04 PM](https://github.com/vercel/next.js/assets/120007119/7b35edba-c423-402b-94e7-9725c4d3cccc)

### Fixed

![Screenshot 2024-03-27 at 2 29
41 PM](https://github.com/vercel/next.js/assets/120007119/e9b7c164-4053-4c56-a4fb-eb4722094355)

x-ref: https://github.com/vercel/next.js/pull/63667
Closes #63743
2024-03-28 23:55:04 +00:00
vercel-release-bot
cbf901ca69 v14.2.0-canary.48 2024-03-28 23:21:44 +00:00
Jiachi Liu
488984cc03
fix: default relative canonical url should not contain search (#63843)
### What

Strip the search query for the `urlPathname` passed down to metadata
handling.

### Why
This is because the `urlPathname` from `staticGenerationStore` contains
query, so it will contain `?rsc` query for client navigation, which lead
to the relative path canonical url (e.g. `./`) will have the search
query along with it. This PR is to remove that and make sure always uses
pathname.

Reported by @pacocoursey 

Closes NEXT-2963
2024-03-28 23:16:22 +00:00
Zack Tanner
c116da32de
fix double redirect when using a loading boundary (#63786)
### What & Why
When an RSC triggers `navigate` after the shell has already been sent to
the client, a meta tag is inserted to signal to the browser it needs to
perform an MPA navigation. This is primarily used for bot user agents,
since we wouldn't have been able to provide a proper redirect status
code (since it occurred after the initial response was sent).

However, the router would trigger a SPA navigation, while the `<meta>`
tag lagged to perform an MPA navigation, resulting in 2 navigations to
the same URL.

### How
When the client side code attempts to handle the redirect, we treat it
like an MPA navigation. This will suspend in render and trigger a
`location.push`/`location.replace` to the targeted URL. As a result,
only one of these navigation events will win.

Fixes #59800
Fixes #62463

Closes NEXT-2952
Closes NEXT-2719
2024-03-28 16:08:39 -07:00
Shu Ding
ae61e7e0bc
Move key generation to the earlier stage (#63832)
Currently, the encryption key for Server Actions is generated during the
manifest creation. This PR moves it to be in the same position as the
build ID generation, and we will later leverage that key for other use
cases.

Closes NEXT-2959
2024-03-28 23:40:23 +01:00
Will Binns-Smith
e519634c81
Turbopack: Fail when next/font is used in _document (#63788)
Test Plan:
d01a621961/test/development/next-font/font-loader-in-document-error.test.ts (L19)


Closes PACK-2858
2024-03-28 15:29:03 -07:00
Dima Voytenko
d0ea2894b7
OTEL: use the current context when creating a root span (#63825)
Fixes: https://github.com/vercel/next.js/issues/63783
2024-03-28 20:26:37 +00:00
Zack Tanner
dfeb3d10ed
skip HEAD request in server action redirect (#63819)
When a server action performs a redirect, we currently initiate a `HEAD`
request to the targeted URL to verify if it has a proper RSC response.
If it does, it then invokes a GET and streams the response. This leads
to an extra request to the server which can be costly and poor for
performance. If the `GET` returns an invalid RSC response, we'll discard
the response. The client router will also see the invalid response which
will signal that it needs to perform an MPA navigation to the targeted
URL.

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

-->


Closes NEXT-2956
2024-03-28 12:54:29 -07:00
OJ Kwon
7b2563da00
feat(custom-transform): more static info warning (#63837)
### What

Add few more warning assertions for the page static info.

requires https://github.com/vercel/next.js/pull/63780.

Closes PACK-2868
2024-03-28 19:31:13 +00:00
OJ Kwon
f6ad1c06ba
feat(turbopack): emit warning into logger (#63780)
### What

Adjusting issue filter to print out warning into logger.


Closes PACK-2857
2024-03-28 12:10:21 -07:00
Tim Neutkens
96978d9fe9
Ensure Webpack config shows a warning when using Turbopack (#63822)
## What?

There was a logic error causing the warning to never show, the default
should be `false` and turned to `true` when `experimental.turbo` is
found.

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

-->


Closes NEXT-2957
2024-03-28 18:05:14 +01:00
OJ Kwon
493130b789
feat(custom-transforms): partial page-static-info visitors (#63741)
### What

Supports partial `get-page-static-info` in turbopack. Since turbopack
doesn't have equivalent place to webpack's ondemandhandler, it uses
turbopack's build time transform rule instead.

As noted, this is partial implementation to pagestatic info as it does
not have existing js side evaluations. Assertions will be added
gradually to ensure regressions, for now having 1 assertion for
getstaticparams.

Closes PACK-2849
2024-03-28 09:47:33 -07:00
vercel-release-bot
fe9ce66262 v14.2.0-canary.47 2024-03-28 13:38:44 +00:00
Zack Tanner
d2548b5435
fix router revalidation behavior for dynamic interception routes (#63768)
### What
When calling `revalidatePath` or `revalidateTag` in a server action for
an intercepted route with dynamic segments, the page would do a full
browser refresh.

### Why
When constructing rewrites for interception routes, the route params
leading up to the interception route are "voided" with a
`__NEXT_EMPTY_PARAM__` demarcation. When it comes time to look up the
values for these dynamic segments, since the params aren't going to be
part of the URL, they get matched via `FlightRouterState`
([ref](d67d658ce7/packages/next/src/server/app-render/app-render.tsx (L153-L201))).

The `shouldProvideFlightRouterState` variable only passes it through for
RSC requests; however, since the server action will perform the action &
return the flight data in a single pass, that means the updated tree
from the server action isn't going to receive the `FlightRouterState`
when constructing the new tree. This means the old tree will have a
`["locale", "en", "d"]` segment, and the new tree from the server action
will have `"[locale]"`. When the router detects this kind of segment
mismatch, it assumes the user navigated to a new root layout, and
triggers an MPA navigation.

### How
This unconditionally provides the `FlightRouterState` to
`makeGetDynamicParamFromSegment` so that it can properly extract dynamic
params for interception routes. We currently enforce interception routes
to be dynamic due to this `FlightRouterState` dependency.

Fixes #59796
Closes NEXT-2079
2024-03-28 13:35:22 +00:00
Zack Tanner
68de4c0357
fix revalidation/refresh behavior with parallel routes (#63607)
`applyRouterStatePatchToTree` had been refactored to support the case of
not skipping the `__DEFAULT__` segment, so that `router.refresh` or
revalidating in a server action wouldn't break the router. (More details
in this #59585)

This was a stop-gap and not an ideal solution, as this behavior means
`router.refresh()` would effectively behave like reloading the page,
where "stale" segments (ones that went from `__PAGE__` -> `__DEFAULT__`)
would disappear.

This PR reverts that handling. The next PR in this stack (#63608) adds
handling to refresh "stale" segments as well.

Note: We expect the test case that was added in #59585 to fail here, but
it is re-enabled in the next PR in the stack.

Note 2: #63608 was accidentally merged into this PR, despite being a
separate entry in the stack. As such, I've copied the issues from that
PR into this one so they can be linked. See the notes from that PR for
the refresh fix details.

Fixes #60815
Fixes #60950
Fixes #51711
Fixes #51714
Fixes #58715
Fixes #60948
Fixes #62213
Fixes #61341

Closes [NEXT-1845](https://linear.app/vercel/issue/NEXT-1845)
Closes [NEXT-2030](https://linear.app/vercel/issue/NEXT-2030)

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

-->


Closes NEXT-2903
2024-03-28 12:59:27 +00:00
vercel-release-bot
0c21ff7df6 v14.2.0-canary.46 2024-03-27 23:21:35 +00:00
vercel-release-bot
1d9833bc63 v14.2.0-canary.45 2024-03-27 19:12:36 +00:00
Tobias Koppers
ab5d0a2002
update turbopack (#63778)
* https://github.com/vercel/turbo/pull/7797 <!-- Tobias Koppers - fix
externals in side-effect optimized modules -->
* https://github.com/vercel/turbo/pull/7830 <!-- Tobias Koppers - Avoid
showing import map description in resolving issue when there is no
import map mapping -->
* https://github.com/vercel/turbo/pull/7833 <!-- Tobias Koppers - add
next.js trace format -->
* https://github.com/vercel/turbo/pull/7835 <!-- Tobias Koppers -
correct global start by first start time -->
* https://github.com/vercel/turbo/pull/7812 <!-- Will Binns-Smith -
Turbopack docs: Fix broken webpack loaders link -->
* https://github.com/vercel/turbo/pull/7847 <!-- Will Binns-Smith -
Turbo tasks: Reuse aggregation context and apply queued updates -->
* https://github.com/vercel/turbo/pull/7840 <!-- Tobias Koppers - add
concurrency corrected duration -->
* https://github.com/vercel/turbo/pull/7854 <!-- Tobias Koppers - fix
size_hint on count hash set -->
2024-03-27 20:09:08 +01:00
Tobias Koppers
916174b7ff
remove left-over debugging (#63774)
Closes PACK-2856
2024-03-27 19:28:59 +01:00
Tobias Koppers
f56a674f58
add tracing to server actions transform (#63773)
### What?

The transform seem to be quite inefficient regarding memory usage. Just
leaving a trace here to allow inspecting performance and memory of it
separately from the normal `parse` function.


Closes PACK-2855
2024-03-27 19:24:21 +01:00
OJ Kwon
e820e92dc3
fext(next-core): inherit root layout segment config for the routes (#63683)
### What

Supports root segment config inherit from layout. Currently route
segment config only runs agasint own source, so individual route segment
config works but if the config is set in layout level it is being
ignored. PR introduces root segment and pass into each route if tree
level have a corresponding layout.

Closes PACK-2839
2024-03-27 16:38:23 +00:00
Tobias Koppers
00e9cf9dd9
fixes to next.js tracing (#63673)
### What?

* fix the span name generated for webpack build-module
* fix the time base for spans reported by manualTraceChild


Closes PACK-2835
2024-03-27 16:23:56 +00:00
Tobias Koppers
7d82b68233
Turbopack: parallelize app structure (#63707)
### What?

Allow to scan app structure in parallel


Closes PACK-2845
2024-03-27 17:01:06 +01:00
Jiachi Liu
93aac0e39b
Respect non 200 status to page static generation response (#63731)
### What

In static generation phase of app page, if there's any case that we're
receiving 3xx/4xx status code from the response, we 're setting it into
the static generation meta now to make sure they're still returning the
same status after build.

### Why

During static generation if there's any 3xx/4xx status code that is set
in the response, we should respect to it, such as the ones caused by
using `notFound()` to mark as 404 response or `redirect` to mark as
`307` response.

Closes NEXT-2895
Fixes #51021
Fixes #62228
2024-03-27 16:20:02 +01:00
Josh Story
7425d51172
Fix ServerAction rejection reason (#63744)
Recently the serverActionReducer was updated to no longer use React's
thenable type to carry resolution/rejection information. However the
rejection reason was not updated so now when a server action fails we
were rejecting with `undefined` rather than the rejected reason. This
change updates the reject to use the rejection value.


Closes NEXT-2943
2024-03-26 17:46:50 -07:00
vercel-release-bot
2fc408d66d v14.2.0-canary.44 2024-03-26 23:23:31 +00:00
Tobias Koppers
1b76aa9ec1
Turbopack: fix allocation inefficiency (#63738)
### What?

- remove unnecessary clones

### Why?

### How?


Closes PACK-2847
2024-03-26 23:39:49 +01:00
Zack Tanner
9b4a055033
prevent router markers from leaking (#63606)
While looking into bugfixes related to router refreshing (the other PRs
in this stack), I noticed there were situations where the `Next-URL`
header would include `/children`, or where `page$` would be present in
LoaderTree for a segment.

This updates a few spots to prevent these markers from leaking into
places they shouldn't, and shouldn't have any behavioral changes.

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

-->


Closes NEXT-2902
2024-03-26 21:41:55 +00:00
Sukka
a70e55eac9
perf: download and save mkcert in stream (#63527)
Previously, Next.js would buffer the `mkcert` binary in memory and write
it to disk all at once. The pull request changes this to pipe the
download stream to the disk. This improves memory consumption by
avoiding having to load the entire `mkcert` binary into memory.

---------

Co-authored-by: JJ Kasper <jj@jjsweb.site>
2024-03-26 20:54:03 +00:00
Zack Tanner
3fc65bac75
ensure null loading boundaries still render a Suspense boundary (#63726)
This ensures that even if a `loading.js` returns `null`, that we still
render a `Suspense` boundary, as it's perfectly valid to have an empty
fallback.

This was accidentally lost in #62346 -- this brings back the
`hasLoading` prop which will check the loading module itself (rather
than the `ReactNode`) for truthiness, and I've added a test to avoid
another regression.

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

-->


Closes NEXT-2936
2024-03-26 18:45:22 +00:00
Shu Ding
f840cb4882
Rename encryption key generation code (#63730)
This PR renames the API to be not specifically related to Server
Actions, as in the future it might be used by other things. It also adds
the `__next_encryption_key_generation_promise` variable to avoid
double-generating of the key when it's called concurrently (e.g. by the
node server and edge server compilers).

Closes NEXT-2938
2024-03-26 18:25:23 +00:00
Wyatt Johnson
4ee00d4f88
[PPR] Dynamic API Debugging (#61798)
<!-- 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 adds dynamic usage logging when the `__nextppronly` query parameter
is set and partial prerendering has been enabled. This will print the
stack trace for the accesses for all Dynamic API's that were called.
This includes those API's that were called during the flight render if
they were called before the static shell was ready.

### Why?

To take the most advantage of partial prerendering, it's important to
track where Dynamic API's are called so developers can determine what
has caused part of the component tree not to be included in the static
shell. This also helps debug situations where the error thrown by
Dynamic API's (used internally for tracking and interruption) are caught
but not re-thrown, but due to the implementation of the flight renderer
provided by React, we are unable to distinguish between errors that are
swallowed by user code or by the flight renderer.

### How?

Instead of using a boolean to track **if** a dynamic API was used, this
actually captures the stack at the callsite, allowing developers to find
the location in the codebase that invoked it.

Closes NEXT-2399
2024-03-26 18:19:07 +00:00
Jiachi Liu
d01a621961
Polish dev-overlay text styling (#63721)
Follow up for #63522 

Adding more polish details for the dev overlay header
- The quoted text uses lighter color of text and use default font weight
- Use the same color for the link and give it a bold font weight
- Use the wilder support sans font for apple devices


### After vs Before
<img width="335" alt="image"
src="https://github.com/vercel/next.js/assets/4800338/a401f958-a5a1-443d-b2e9-f011de44f882">

<img width="335" alt="image"
src="https://github.com/vercel/next.js/assets/4800338/4b1340b7-6664-47ef-8935-cf715d6a3f63">




Closes NEXT-2935
2024-03-26 16:29:06 +00:00
Vercel Release Bot
8bb1a79d1b
Update font data (#63691)
This auto-generated PR updates font data with latest available

Co-authored-by: JJ Kasper <jj@jjsweb.site>
2024-03-26 16:02:26 +00:00
Balázs Orbán
7569c8087a
feat(log): improve dev/build logs (#62946)
Co-authored-by: Jiachi Liu <inbox@huozhi.im>
2024-03-26 15:33:09 +01:00
Tobias Koppers
459e8fe96e
generate the same next/font modules for the same options (#63513)
### What?

Improves caching of next/font generated modules (make them independent
on importer context)


Closes PACK-2796
2024-03-26 10:13:03 +00:00
vercel-release-bot
c7dbbd9a54 v14.2.0-canary.43 2024-03-25 23:22:56 +00:00
JJ Kasper
866b418123
Add Next.js version to process title (#63686)
Makes debugging a little easier by showing the Next.js version in the
process title as well.

x-ref: [slack
thread](https://vercel.slack.com/archives/C03KAR5DCKC/p1711401562557429?thread_ts=1711400819.248569&cid=C03KAR5DCKC)

Closes NEXT-2924
2024-03-25 21:44:39 +00:00
JJ Kasper
cf9e647f41
Auto map optimizePackageImports to transpilePackages for pages (#63537)
This ensures `optimizePackageImports` doesn't unexpectedly fail to apply
for `pages` as they aren't transpiled/bundled by default without either
`transpilePackages` being used or `experimental.bundlePagesExternals`.
This also ensures our docs correctly show this config in the pages docs
as currently in only shows in `app`.

x-ref: [slack
thread](https://vercel.slack.com/archives/C0676QZBWKS/p1710967294942029)

Closes NEXT-2884
2024-03-25 12:17:02 -07:00
Balázs Orbán
752d6e49d5
feat(error-overlay): style tweaks (#63522) 2024-03-25 12:37:12 -06:00
grajen3
043bbaa731
perf: conditionally import Telemetry (#63574)
<!-- 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?

Make Telemetry import in `packages/next/src/server/lib/router-server.ts`
lazy and conditional

### Why?

`Telemetry` in that module is only used when `opts.dev` is truthy, so in
production mode the module is imported and used.

Cost of importing that module is quite significant chunk of starting
`standalone` server. Those are example logs I got from
https://www.npmjs.com/package/require-times (with updates to make it
work as that is pretty old package that wasn't updated and doesn't work
as is) on the server:

Before the change:
```
total: 658ms
646ms node_modules/next/dist/server/lib/start-server.js
  479ms node_modules/next/dist/server/lib/router-server.js
    149ms node_modules/next/dist/telemetry/storage.js
      87ms node_modules/next/dist/compiled/@edge-runtime/ponyfill/index.js
        86ms node_modules/next/dist/compiled/@edge-runtime/primitives/index.js
          1ms node_modules/next/dist/compiled/@edge-runtime/primitives/load.js
            23ms node_modules/next/dist/compiled/@edge-runtime/primitives/fetch.js.text.js
            12ms node_modules/next/dist/compiled/@edge-runtime/primitives/url.js.text.js
            1ms node_modules/next/dist/compiled/@edge-runtime/primitives/events.js.text.js
            1ms node_modules/next/dist/compiled/@edge-runtime/primitives/structured-clone.js.text.js
      41ms node_modules/next/dist/compiled/conf/index.js
        12ms node_modules/next/dist/compiled/semver/index.js
      12ms node_modules/next/dist/telemetry/project-id.js
      3ms node_modules/next/dist/telemetry/post-payload.js
      1ms node_modules/next/dist/compiled/is-docker/index.js
      1ms node_modules/next/dist/telemetry/anonymous-meta.js
        1ms node_modules/next/dist/compiled/is-wsl/index.js
    100ms node_modules/next/dist/server/base-server.js
      17ms node_modules/next/dist/server/future/route-matcher-providers/app-page-route-matcher-provider.js
        7ms node_modules/next/dist/lib/is-app-page-route.js
        7ms node_modules/next/dist/server/future/normalizers/built/app/index.js
          3ms node_modules/next/dist/server/future/normalizers/built/app/app-page-normalizer.js
            2ms node_modules/next/dist/server/future/normalizers/absolute-filename-normalizer.js
              1ms node_modules/next/dist/shared/lib/page-path/absolute-path-to-page.js
            1ms node_modules/next/dist/lib/page-types.js
          2ms node_modules/next/dist/server/future/normalizers/built/app/app-bundle-path-normalizer.js
            1ms node_modules/next/dist/shared/lib/page-path/normalize-page-path.js
          1ms node_modules/next/dist/server/future/normalizers/built/app/app-filename-normalizer.js
          1ms node_modules/next/dist/server/future/normalizers/built/app/app-pathname-normalizer.js
        1ms node_modules/next/dist/server/future/route-matcher-providers/manifest-route-matcher-provider.js
      15ms node_modules/next/dist/server/app-render/strip-flight-headers.js
      13ms node_modules/next/dist/server/future/route-modules/helpers/response-handlers.js
        13ms node_modules/next/dist/server/web/spec-extension/adapters/request-cookies.js
      8ms node_modules/next/dist/server/future/normalizers/locale-route-normalizer.js
      4ms node_modules/next/dist/server/api-utils/index.js
        2ms node_modules/next/dist/server/web/spec-extension/adapters/headers.js
          1ms node_modules/next/dist/server/web/spec-extension/adapters/reflect.js
      4ms node_modules/next/dist/server/render-result.js
        3ms node_modules/next/dist/server/stream-utils/node-web-streams-helper.js
          1ms node_modules/next/dist/lib/scheduler.js
      4ms node_modules/next/dist/server/future/route-matcher-providers/pages-api-route-matcher-provider.js
        3ms node_modules/next/dist/server/future/normalizers/built/pages/index.js
          1ms node_modules/next/dist/server/future/normalizers/built/pages/pages-filename-normalizer.js
          1ms node_modules/next/dist/server/future/normalizers/built/pages/pages-pathname-normalizer.js
        1ms node_modules/next/dist/lib/is-api-route.js
      2ms node_modules/next/dist/server/future/route-matcher-managers/default-route-matcher-manager.js
        1ms node_modules/next/dist/server/future/route-matchers/locale-route-matcher.js
      2ms node_modules/next/dist/server/future/route-matcher-providers/app-route-route-matcher-provider.js
      2ms node_modules/next/dist/server/lib/match-next-data-pathname.js
      2ms node_modules/next/dist/server/future/route-modules/checks.js
      1ms node_modules/next/dist/lib/is-edge-runtime.js
      1ms node_modules/next/dist/shared/lib/runtime-config.external.js
      1ms node_modules/next/dist/server/lib/revalidate.js
      1ms node_modules/next/dist/shared/lib/router/utils/escape-path-delimiters.js
      1ms node_modules/next/dist/server/future/route-matcher-providers/pages-route-matcher-provider.js
        1ms node_modules/next/dist/server/future/route-matchers/pages-route-matcher.js
      1ms node_modules/next/dist/server/send-response.js
      1ms node_modules/next/dist/shared/lib/router/utils/get-route-from-asset-path.js
      1ms node_modules/next/dist/server/lib/server-action-request-meta.js
    83ms node_modules/next/dist/server/lib/router-utils/filesystem.js
      22ms node_modules/next/dist/lib/load-custom-routes.js
        4ms node_modules/next/dist/lib/try-to-parse-path.js
          2ms node_modules/next/dist/lib/is-error.js
            1ms node_modules/next/dist/shared/lib/is-plain-object.js
          1ms node_modules/next/dist/compiled/path-to-regexp/index.js
        2ms node_modules/next/dist/lib/redirect-status.js
          1ms node_modules/next/dist/client/components/redirect-status-code.js
        1ms node_modules/next/dist/shared/lib/escape-regexp.js
      16ms node_modules/next/dist/server/future/normalizers/request/rsc.js
      13ms node_modules/next/dist/shared/lib/router/utils/index.js
        10ms node_modules/next/dist/shared/lib/router/utils/is-dynamic.js
          3ms node_modules/next/dist/server/future/helpers/interception-routes.js
            1ms node_modules/next/dist/shared/lib/router/utils/app-paths.js
              1ms node_modules/next/dist/shared/lib/page-path/ensure-leading-slash.js
        1ms node_modules/next/dist/shared/lib/router/utils/sorted-routes.js
      9ms node_modules/next/dist/shared/lib/page-path/normalize-path-sep.js
      4ms node_modules/next/dist/shared/lib/router/utils/middleware-route-matcher.js
        4ms node_modules/next/dist/shared/lib/router/utils/prepare-destination.js
          1ms node_modules/next/dist/client/components/app-router-headers.js
          1ms node_modules/next/dist/server/api-utils/get-cookie-parser.js
      4ms node_modules/next/dist/lib/metadata/get-metadata-route.js
        2ms node_modules/next/dist/server/server-utils.js
        1ms node_modules/next/dist/lib/metadata/is-metadata-route.js
      1ms node_modules/next/dist/compiled/lru-cache/index.js
      1ms node_modules/next/dist/lib/file-exists.js
      1ms node_modules/next/dist/lib/recursive-readdir.js
      1ms node_modules/next/dist/shared/lib/router/utils/path-match.js
      1ms node_modules/next/dist/shared/lib/router/utils/route-regex.js
      1ms node_modules/next/dist/shared/lib/router/utils/route-matcher.js
      1ms node_modules/next/dist/server/future/normalizers/request/postponed.js
        1ms node_modules/next/dist/shared/lib/page-path/denormalize-page-path.js
      1ms node_modules/next/dist/server/future/normalizers/request/prefetch-rsc.js
    35ms node_modules/next/dist/server/lib/router-utils/resolve-routes.js
      11ms node_modules/next/dist/server/body-streams.js
      1ms node_modules/next/dist/server/lib/server-ipc/utils.js
      1ms node_modules/next/dist/shared/lib/router/utils/relativize-url.js
      1ms node_modules/next/dist/server/future/normalizers/request/next-data.js
      1ms node_modules/next/dist/server/lib/mock-request.js
    22ms node_modules/next/dist/server/serve-static.js
      20ms node_modules/next/dist/compiled/send/index.js
        1ms node_modules/next/dist/compiled/fresh/index.js
    22ms node_modules/next/dist/server/pipe-readable.js
      20ms node_modules/next/dist/server/web/spec-extension/adapters/next-request.js
        18ms node_modules/next/dist/server/web/spec-extension/request.js
          15ms node_modules/next/dist/server/web/next-url.js
            12ms node_modules/next/dist/shared/lib/router/utils/format-next-pathname-info.js
              1ms node_modules/next/dist/shared/lib/router/utils/add-path-prefix.js
            1ms node_modules/next/dist/shared/lib/i18n/detect-domain-locale.js
          2ms node_modules/next/dist/server/web/spec-extension/cookies.js
            1ms node_modules/next/dist/compiled/@edge-runtime/cookies/index.js
      1ms node_modules/next/dist/lib/detached-promise.js
    19ms node_modules/next/dist/compiled/compression/index.js
    16ms node_modules/next/dist/server/lib/dev-bundler-service.js
    4ms node_modules/next/dist/trace/index.js
      3ms node_modules/next/dist/trace/trace.js
        2ms node_modules/next/dist/trace/report/index.js
          1ms node_modules/next/dist/trace/report/to-telemetry.js
          1ms node_modules/next/dist/trace/report/to-json.js
    2ms node_modules/next/dist/server/lib/router-utils/proxy-request.js
      1ms node_modules/next/dist/server/server-route-utils.js
    1ms node_modules/next/dist/server/node-environment.js
    1ms node_modules/next/dist/shared/lib/utils.js
    1ms node_modules/next/dist/lib/find-pages-dir.js
    1ms node_modules/next/dist/server/lib/router-utils/is-postpone.js
  140ms node_modules/next/dist/server/next.js
    84ms node_modules/next/dist/server/config.js
      20ms node_modules/next/dist/shared/lib/match-remote-pattern.js
        18ms node_modules/next/dist/compiled/micromatch/index.js
      17ms node_modules/next/dist/compiled/zod/index.js
      14ms node_modules/next/dist/shared/lib/constants.js
        8ms node_modules/@swc/helpers/cjs/_interop_require_default.cjs
      3ms node_modules/next/dist/compiled/find-up/index.js
        1ms node_modules/next/dist/compiled/p-limit/index.js
      3ms node_modules/next/dist/telemetry/ci-info.js
        1ms node_modules/next/dist/compiled/ci-info/index.js
      2ms node_modules/next/dist/server/config-shared.js
        1ms node_modules/next/dist/shared/lib/image-config.js
      2ms node_modules/@next/env/dist/index.js
      2ms node_modules/next/dist/telemetry/flush-and-exit.js
      2ms node_modules/next/dist/lib/find-root.js
      1ms node_modules/next/dist/server/setup-http-agent-env.js
      1ms node_modules/next/dist/shared/lib/router/utils/path-has-prefix.js
    21ms node_modules/next/dist/server/lib/trace/tracer.js
      5ms node_modules/next/dist/compiled/@opentelemetry/api/index.js
      1ms node_modules/next/dist/server/lib/trace/constants.js
    13ms node_modules/next/dist/shared/lib/router/utils/format-url.js
    12ms node_modules/next/dist/build/output/log.js
      9ms node_modules/next/dist/lib/picocolors.js
    3ms node_modules/next/dist/server/require-hook.js
    1ms node_modules/next/dist/server/node-polyfill-crypto.js
    1ms node_modules/next/dist/lib/constants.js
    1ms node_modules/next/dist/server/lib/utils.js
  14ms node_modules/next/dist/compiled/watchpack/watchpack.js
  3ms node_modules/next/dist/compiled/debug/index.js
  1ms node_modules/next/dist/server/lib/format-hostname.js
  1ms node_modules/next/dist/server/lib/app-info-log.js
  1ms node_modules/next/dist/lib/turbopack-warning.js
```

And after the change:
```
total: 516ms
499ms node_modules/next/dist/server/lib/start-server.js
  303ms node_modules/next/dist/server/lib/router-server.js
    103ms node_modules/next/dist/server/base-server.js
      42ms node_modules/next/dist/server/future/route-matcher-providers/app-page-route-matcher-provider.js
        38ms node_modules/next/dist/server/future/normalizers/built/app/index.js
          20ms node_modules/next/dist/server/future/normalizers/built/app/app-page-normalizer.js
            18ms node_modules/next/dist/server/future/normalizers/absolute-filename-normalizer.js
              17ms node_modules/next/dist/shared/lib/page-path/absolute-path-to-page.js
            1ms node_modules/next/dist/lib/page-types.js
          17ms node_modules/next/dist/server/future/normalizers/built/app/app-bundle-path-normalizer.js
            16ms node_modules/next/dist/shared/lib/page-path/normalize-page-path.js
          1ms node_modules/next/dist/server/future/normalizers/built/app/app-pathname-normalizer.js
        1ms node_modules/next/dist/lib/is-app-page-route.js
        1ms node_modules/next/dist/server/future/route-kind.js
        1ms node_modules/next/dist/server/future/route-matcher-providers/manifest-route-matcher-provider.js
      10ms node_modules/next/dist/server/send-response.js
      8ms node_modules/next/dist/server/future/normalizers/locale-route-normalizer.js
      4ms node_modules/next/dist/server/api-utils/index.js
        2ms node_modules/next/dist/server/web/spec-extension/adapters/headers.js
          1ms node_modules/next/dist/server/web/spec-extension/adapters/reflect.js
      3ms node_modules/next/dist/server/render-result.js
        2ms node_modules/next/dist/server/stream-utils/node-web-streams-helper.js
      3ms node_modules/next/dist/server/future/route-matcher-providers/pages-api-route-matcher-provider.js
        2ms node_modules/next/dist/server/future/normalizers/built/pages/index.js
          1ms node_modules/next/dist/server/future/normalizers/built/pages/pages-bundle-path-normalizer.js
        1ms node_modules/next/dist/server/future/route-matchers/pages-api-route-matcher.js
      2ms node_modules/next/dist/server/future/route-matcher-providers/app-route-route-matcher-provider.js
        1ms node_modules/next/dist/lib/is-app-route-route.js
        1ms node_modules/next/dist/server/future/route-matchers/app-route-route-matcher.js
      2ms node_modules/next/dist/server/future/route-modules/helpers/response-handlers.js
        1ms node_modules/next/dist/server/web/spec-extension/adapters/request-cookies.js
      2ms node_modules/next/dist/server/lib/match-next-data-pathname.js
      1ms node_modules/next/dist/lib/is-edge-runtime.js
      1ms node_modules/next/dist/shared/lib/runtime-config.external.js
      1ms node_modules/next/dist/server/lib/revalidate.js
      1ms node_modules/next/dist/shared/lib/router/utils/escape-path-delimiters.js
      1ms node_modules/next/dist/server/future/route-matcher-managers/default-route-matcher-manager.js
      1ms node_modules/next/dist/server/future/route-matcher-providers/pages-route-matcher-provider.js
      1ms node_modules/next/dist/shared/lib/router/utils/get-route-from-asset-path.js
      1ms node_modules/next/dist/server/app-render/strip-flight-headers.js
      1ms node_modules/next/dist/server/future/route-modules/checks.js
      1ms node_modules/next/dist/server/lib/server-action-request-meta.js
    91ms node_modules/next/dist/server/lib/router-utils/filesystem.js
      21ms node_modules/next/dist/lib/load-custom-routes.js
        16ms node_modules/next/dist/lib/try-to-parse-path.js
          13ms node_modules/next/dist/lib/is-error.js
            1ms node_modules/next/dist/shared/lib/is-plain-object.js
          2ms node_modules/next/dist/compiled/path-to-regexp/index.js
        3ms node_modules/next/dist/lib/redirect-status.js
          1ms node_modules/next/dist/client/components/redirect-status-code.js
      16ms node_modules/next/dist/server/future/normalizers/request/prefetch-rsc.js
      12ms node_modules/next/dist/lib/metadata/get-metadata-route.js
        10ms node_modules/next/dist/server/server-utils.js
        1ms node_modules/next/dist/shared/lib/isomorphic/path.js
      9ms node_modules/next/dist/shared/lib/router/utils/route-regex.js
        1ms node_modules/next/dist/shared/lib/router/utils/remove-trailing-slash.js
      6ms node_modules/next/dist/shared/lib/router/utils/index.js
        3ms node_modules/next/dist/shared/lib/router/utils/is-dynamic.js
          2ms node_modules/next/dist/server/future/helpers/interception-routes.js
            1ms node_modules/next/dist/shared/lib/router/utils/app-paths.js
              1ms node_modules/next/dist/shared/lib/page-path/ensure-leading-slash.js
        1ms node_modules/next/dist/shared/lib/router/utils/sorted-routes.js
      5ms node_modules/next/dist/shared/lib/router/utils/middleware-route-matcher.js
        5ms node_modules/next/dist/shared/lib/router/utils/prepare-destination.js
          1ms node_modules/next/dist/shared/lib/router/utils/parse-url.js
          1ms node_modules/next/dist/client/components/app-router-headers.js
          1ms node_modules/next/dist/server/api-utils/get-cookie-parser.js
      2ms node_modules/next/dist/compiled/lru-cache/index.js
      2ms node_modules/next/dist/server/future/normalizers/request/postponed.js
        1ms node_modules/next/dist/shared/lib/page-path/denormalize-page-path.js
      1ms node_modules/next/dist/lib/file-exists.js
      1ms node_modules/next/dist/lib/recursive-readdir.js
      1ms node_modules/next/dist/shared/lib/router/utils/path-match.js
      1ms node_modules/next/dist/server/future/normalizers/request/rsc.js
    24ms node_modules/next/dist/server/pipe-readable.js
      22ms node_modules/next/dist/server/web/spec-extension/adapters/next-request.js
        20ms node_modules/next/dist/server/web/spec-extension/request.js
          17ms node_modules/next/dist/server/web/next-url.js
            13ms node_modules/next/dist/shared/lib/i18n/detect-domain-locale.js
            2ms node_modules/next/dist/shared/lib/router/utils/format-next-pathname-info.js
              1ms node_modules/next/dist/shared/lib/router/utils/add-path-suffix.js
            1ms node_modules/next/dist/shared/lib/router/utils/get-next-pathname-info.js
          3ms node_modules/next/dist/server/web/spec-extension/cookies.js
            1ms node_modules/next/dist/compiled/@edge-runtime/cookies/index.js
        1ms node_modules/next/dist/server/web/utils.js
      1ms node_modules/next/dist/lib/detached-promise.js
    22ms node_modules/next/dist/server/serve-static.js
      21ms node_modules/next/dist/compiled/send/index.js
    18ms node_modules/next/dist/server/lib/router-utils/resolve-routes.js
      11ms node_modules/next/dist/server/body-streams.js
      1ms node_modules/next/dist/server/lib/server-ipc/utils.js
      1ms node_modules/next/dist/shared/lib/router/utils/relativize-url.js
      1ms node_modules/next/dist/server/future/normalizers/request/next-data.js
      1ms node_modules/next/dist/server/lib/mock-request.js
    18ms node_modules/next/dist/compiled/compression/index.js
      1ms node_modules/next/dist/compiled/bytes/index.js
    10ms node_modules/next/dist/server/lib/dev-bundler-service.js
    4ms node_modules/next/dist/trace/index.js
      2ms node_modules/next/dist/trace/trace.js
        2ms node_modules/next/dist/trace/report/index.js
          1ms node_modules/next/dist/trace/report/to-json.js
    3ms node_modules/next/dist/server/lib/router-utils/proxy-request.js
      2ms node_modules/next/dist/server/server-route-utils.js
        1ms node_modules/next/dist/server/request-meta.js
    2ms node_modules/next/dist/shared/lib/utils.js
    1ms node_modules/next/dist/server/node-environment.js
    1ms node_modules/next/dist/lib/find-pages-dir.js
    1ms node_modules/next/dist/server/lib/router-utils/is-postpone.js
  157ms node_modules/next/dist/server/next.js
    99ms node_modules/next/dist/server/config.js
      24ms node_modules/next/dist/shared/lib/match-remote-pattern.js
        5ms node_modules/next/dist/compiled/micromatch/index.js
      17ms node_modules/next/dist/compiled/zod/index.js
      15ms node_modules/next/dist/shared/lib/constants.js
        1ms node_modules/@swc/helpers/cjs/_interop_require_default.cjs
        1ms node_modules/next/dist/shared/lib/modern-browserslist-target.js
      4ms node_modules/next/dist/compiled/find-up/index.js
        1ms node_modules/next/dist/compiled/p-limit/index.js
      4ms node_modules/next/dist/telemetry/ci-info.js
        2ms node_modules/next/dist/compiled/ci-info/index.js
      3ms node_modules/next/dist/server/config-shared.js
        1ms node_modules/next/dist/shared/lib/image-config.js
      2ms node_modules/next/dist/telemetry/flush-and-exit.js
      2ms node_modules/next/dist/lib/find-root.js
      2ms node_modules/next/dist/server/setup-http-agent-env.js
      2ms node_modules/next/dist/shared/lib/router/utils/path-has-prefix.js
        1ms node_modules/next/dist/shared/lib/router/utils/parse-path.js
      1ms node_modules/@next/env/dist/index.js
    17ms node_modules/next/dist/server/lib/trace/tracer.js
      14ms node_modules/next/dist/compiled/@opentelemetry/api/index.js
      1ms node_modules/next/dist/server/lib/trace/constants.js
    13ms node_modules/next/dist/lib/constants.js
    5ms node_modules/next/dist/shared/lib/router/utils/format-url.js
      1ms node_modules/@swc/helpers/cjs/_interop_require_wildcard.cjs
      1ms node_modules/next/dist/shared/lib/router/utils/querystring.js
    4ms node_modules/next/dist/build/output/log.js
      1ms node_modules/next/dist/lib/picocolors.js
    3ms node_modules/next/dist/server/require-hook.js
    1ms node_modules/next/dist/server/lib/utils.js
  7ms node_modules/next/dist/compiled/watchpack/watchpack.js
  3ms node_modules/next/dist/compiled/debug/index.js
  2ms node_modules/next/dist/server/lib/format-hostname.js
    1ms node_modules/next/dist/server/lib/is-ipv6.js
  1ms node_modules/next/dist/server/lib/app-info-log.js
  1ms node_modules/next/dist/lib/turbopack-warning.js
```

I would not pay much attention to absolute numbers as there will be
variance and those are single runs - but from first "require time dump"
you can estimate importing Telemetry (that might be unused) is costing
149ms / 658ms ~= 22.5% of entire time spent on importing modules -
that's pretty significant

### How?

By moving static import/require from top level to conditional code path
that actually uses it. This code path already have some modules
lazy/conditionally loaded. `packages/next/src/telemetry/storage.ts`
doesn't seem to have import side effects so at least on my first glance
it doesn't seem like moving import should cause problems?

Co-authored-by: JJ Kasper <jj@jjsweb.site>
2024-03-25 17:50:40 +00:00
Shu Ding
9677c87e8a
Improve TypeScript plugin for server boundary (#63667)
For problems like #62821, #62860 and other, the only way to improve the
DX would be relying on the type checker to ensure that Server Actions
are async functions. Inlined definitions will always be checked by SWC
(as they're always syntactically defined as functions already), but
export values are sometimes determined at the runtime.

Also added `react-dom` related methods to the disallow list for the
server layer.

Examples:


https://github.com/vercel/next.js/assets/3676859/ac0b12fa-829b-42a4-a4c6-e1c321b68a8e


https://github.com/vercel/next.js/assets/3676859/2e2e3ab8-6743-4281-9783-30bd2a82fb5c


https://github.com/vercel/next.js/assets/3676859/b61a4c0a-1ad4-4ad6-9d50-311ef3450e13



Closes NEXT-2913
2024-03-25 18:37:10 +01:00
OJ Kwon
35f93e3be3
fix(dev-overlay): align codeframe to formatIssue (#63624)
Closes PACK-2825
2024-03-25 09:55:22 -07:00
vercel-release-bot
c2e3d9ac18 v14.2.0-canary.42 2024-03-25 15:57:25 +00:00
Andrew Gadzik
f9d73cc2fa
Move Playwright to be a peerDependency of next.js (#63530) 2024-03-25 11:48:47 +01:00
Janka Uryga
f509de950b
Fix react-dom aliases for edge RSC (#63619)
Follow up to #63588, we missed edge there

Closes NEXT-2905
2024-03-25 11:37:23 +01:00
Donny/강동윤
6b6590592e
Update turbopack (#63541)
# Turbopack

* https://github.com/vercel/turbo/pull/7815 <!-- Tobias Koppers - fix
alias in getResolve -->
* https://github.com/vercel/turbo/pull/7796 <!-- Donny/강동윤 - Update
`swc_core` to `v0.90.24` -->
* https://github.com/vercel/turbo/pull/7775 <!-- Tobias Koppers - fix
single css chunks with import context -->
* https://github.com/vercel/turbo/pull/7776 <!-- Tobias Koppers - change
port of trace-server -->
* https://github.com/vercel/turbo/pull/7763 <!-- Tobias Koppers -
Tracing improvements -->
* https://github.com/vercel/turbo/pull/7813 <!-- Tobias Koppers - fix
webpack loader incorrectly calling custom_evaluate -->
* https://github.com/vercel/turbo/pull/7764 <!-- Tobias Koppers - fix
some small bugs in turbo-tasks that are required for GC -->
* https://github.com/vercel/turbo/pull/7816 <!-- Chris Olszewski -
chore: remove some unused imports -->
* https://github.com/vercel/turbo/pull/7823 <!-- OJ Kwon -
fix(sourcemap): update sourcemap, remove checker -->

### What?

Update SWC crates to
ad932f0921

### Why?

To keep in sync.

### How?



 - Closes PACK-2807
 - Closes PACK-2819

---------

Co-authored-by: Tim Neutkens <tim@timneutkens.nl>
2024-03-25 03:15:02 +00:00
vercel-release-bot
ce0120954e v14.2.0-canary.41 2024-03-24 23:23:19 +00:00
vercel-release-bot
2746990135 v14.2.0-canary.40 2024-03-23 23:21:07 +00:00
OJ Kwon
98ffe45092
fix(next-core): refine context for unsupported edge imports (#63622)
### What

Followup for the unsupported imports in edge to inject corresponding
context only.

Closes PACK-2824
2024-03-23 06:53:49 +00:00
vercel-release-bot
65d699e7d7 v14.2.0-canary.39 2024-03-22 21:20:06 +00:00
Andrew Gadzik
15b68d4c91
Enable all pages under the browser context to proxy to the test proxy (#63610)
This fixes an issue when playwright spawns a new page from the same
context (a popup window) where requests were not being proxied correctly

Co-authored-by: Shu Ding <g@shud.in>
2024-03-22 22:16:17 +01:00
OJ Kwon
07a39eed2e
Revert "Revert "feat(next-core): support unsupported module runtime error (#63491)"" (#63609)
### What

This PR reenables reverted PR #63491, with fixing unexpectedly mark
supported node.js internals as unsupported.

Tried to add test cases for the supported case but hitting
https://vercel.slack.com/archives/C03EWR7LGEN/p1711128538909549, need
separate investigation.
2024-03-22 11:50:54 -07:00
Jiachi Liu
8e8a86ee8f
Add alias for react-dom react-server condition (#63588)
`react-dom` also contains a `react-server` condition that need to be
picked up in RSC bundle layer, like what we did for react. This will
ensures the server runtime smaller and you don't accidentally use the
client apis on server side.


Closes NEXT-2898

---------

Co-authored-by: Janka Uryga <lolzatu2@gmail.com>
2024-03-22 10:21:54 -07:00
vercel-release-bot
fe87d8c6f9 v14.2.0-canary.38 2024-03-22 12:39:08 +00:00
Kiko Beats
0f6a6b232a
chore: upgrade @edge-runtime/cookies (#63602) 2024-03-22 10:58:49 +00:00
Tim Neutkens
66be631d8a
Remove lodash from external packages list (#63601)
## What?

Since the work that Shu did for optimizing large barrel dependencies
marking lodash as external is no longer required.

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

-->


Closes NEXT-2899
2024-03-22 10:56:38 +00:00
Tobias Koppers
fe989a2360
the argument might be written with underscores (#63600)
### What?

You can pass `--max_old_space_size=` with underscores instead of dashes
which wasn't handled yet.

### Why?

### How?



Closes PACK-2817
2024-03-22 10:46:40 +01:00
vercel-release-bot
368e9aa9ae v14.2.0-canary.37 2024-03-21 23:51:55 +00:00
vercel-release-bot
d1248a7536 v14.2.0-canary.36 2024-03-21 23:23:03 +00:00
Jiachi Liu
053db6af8e
Remove the erroring on force-dynamic in static generation for app route (#63526)
### What
* Remove the erroring of force-dynamic is not able to use during static
generation
* Export the route segments properly in sitemap conventions

### Why

We discovered this error is showing up when users are using
force-dynamic with generating multi sitemaps.

When you have a dynamic `route /[id]/route.js` , and you have
generateSitemaps defined which is actually using `generateSitemaps`
under the hood , then you set the route to dynamic with `export dynamic
= 'force-dynamic'`.

We should keep the route still as dynamic. `generateStaticParams` is
only for generating the paths, which is static in build time. And the
`force-dynamic` is going to be applied to each generated path.

Closes NEXT-2881
2024-03-22 00:15:20 +01:00
Andrew Gadzik
4c467a2638
Improve experimental test proxy (#63567)
Followup on https://github.com/vercel/next.js/pull/52520 and
https://github.com/vercel/next.js/pull/54014

**Enhancements**
- Removes `--experimental-test-proxy` CLI argument from `next dev` and
`next start`
- Adds a new experimental config option `testProxy?: boolean`
- Instead of throwing an error, return the `originalFetch` response if
the current request context does not contain the `Next-Test-*` HTTP
headers

**Why?**
These changes allow us to write mixed Integration + E2E tests within the
same Playwright process.

```ts
// some-page.spec.ts

test.describe('/some-page', () => {
	test('some integration test', async ({ page, next }) => {
	  // by using the `next` fixture, playwright will send the `Next-Test-*` HTTP headers for 
	  // every request in this test's context.
	  next.onFetch(...);
	  
	  await page.goto(...);
	  await expect(...).toBe('some-mocked-value');
	});

	test('some e2e test', async ({ page }) => {
	  // by NOT using the `next` fixture, playwright does not send the `Next-Test-*` HTTP headers
	  await page.goto(...);
	  await expect(...).toBe('some-real-value');
	});
})
```

Now I can run `next dev` and locally develop my App Router pages AND run
my Playwright tests against instead of having to,
- run `next dev` to locally develop my change
- ctrl+c to kill server
- run `next dev --experimental-test-proxy` to locally run my integration
tests

---------

Co-authored-by: Sam Ko <sam@vercel.com>
2024-03-21 21:31:29 +00:00
Maël Nison
7de7cbf283
Upgrades enhanced-resolve (#63499)
This PR upgrades `enhanced-resolve` to `5.16.0` so as to benefit from
https://github.com/webpack/enhanced-resolve/pull/301, recently merged.

Without this diff, importing dependencies from files from external PnP
projects would fail. It's a little niche, but I'm working on a
documentation website that leverages that to allow deploying multiple
websites from the same template.

Co-authored-by: Sam Ko <sam@vercel.com>
Co-authored-by: Steven <steven@ceriously.com>
2024-03-21 15:27:15 -04:00
vercel-release-bot
04f5781c1b v14.2.0-canary.35 2024-03-21 17:49:30 +00:00
Tobias Koppers
7d95336779
Revert "feat(next-core): support unsupported module runtime error (#63491)" (#63575)
### What?

It's causing `__import_unsupported` is not defined in `instrumentation`
context
2024-03-21 18:43:58 +01:00
Steven
abe74a5211
fix: call instrumentationHook earlier for prod server (#63536)
This ensures that the instrumentation hook for Node.js will run
immediately during `next start` instead of waiting for the first request
like does it `next dev`.

However, if there is a separate instrumentation hook for Edge, that will
still be lazy evaluated and wait until the first request.

Fixes #59999 
Fixes NEXT-2738
2024-03-21 13:11:03 +00:00
OJ Kwon
976dd526ae
feat(custom-transform): middleware dynamic assert transform (#63538)
### What

This PR implements runtime warning for dynamic codes (`eval`,
`Function`...) in edge runtime. Webpack uses middleware plugin to
replace / wrap codes, in case of Turbopack we don't have equivalent, so
creating a new transform visitor and run it if the context is edge.
Since sandbox augments global fn (__next_*), transform simply wraps the
expr if it matches to the condition.

Closes PACK-2804
2024-03-21 06:12:28 +01:00
Will Binns-Smith
aeafed9405
Turbopack: Fail when module type is unhandled (#63535)
This causes Turbopack to fail and communicate when a file with an
unhandled or unregistered extension is built.

Test Plan: `TURBOPACK=1 pnpm test-dev
test/development/basic/hmr.test.ts`


Closes PACK-2803
2024-03-21 00:36:01 +00:00
vercel-release-bot
c0f9d246d1 v14.2.0-canary.34 2024-03-20 23:22:37 +00:00
Juan Settecase
e4cd547a50
feat: add support for localizations in sitemap generator (#53765)
### What?

Following up with [this
suggestion](https://github.com/vercel/next.js/discussions/53540) I went
ahead and implemented the proposal for the Next.js team to merge it if
they agree.

Things to keep in mind:
- Google has [three different
ways](https://developers.google.com/search/docs/specialty/international/localized-versions#methods-for-indicating-your-alternate-pages)
to do this. The three of them are equivalent
- Google seems to be the only search engine supporting this approach.
The rest of them should ignore it

### Why?

This is supported by
[Google](https://developers.google.com/search/docs/specialty/international/localized-versions#example_2)
to better understand the site when the same page is available in
multiple languages.

### How?

- I added a new key to the `MetadataRoute.Sitemap` type called
`alternates` which accepts just one sub key `languages` similar to the
current one in the
[Metadata](https://nextjs.org/docs/app/api-reference/functions/generate-metadata#alternates)
object
- I updated the `resolveSitemap` method to process the new key and
generate the expected sitemap
- I updated the related tests and documentation to reflect the new
syntax

---------

Co-authored-by: Jiachi Liu <inbox@huozhi.im>
2024-03-20 17:00:20 +00:00
Tobias Koppers
1c998d86da
route/middleware/instrumentation use server assets instead of client assets (#62134)
### What?

route/middleware/instrumentation use server assets
server assets use full url rewrite

### Why?

### How?

https://github.com/vercel/turbo/pull/7750

Fixes PACK-2522

fixes PACK-2645
2024-03-20 12:06:29 +01:00
vercel-release-bot
833df606b2 v14.2.0-canary.33 2024-03-19 23:22:30 +00:00
Zack Tanner
3ed46abcda
Fix interception/detail routes being triggered by router refreshes (#63263)
### What
Actions that revalidate the router state by kicking off a refetch (such
as `router.refresh()` or dev fast refresh) would incorrectly trigger an
interception route if one matched the current URL, or in the case of
already being on an intercepted route, would trigger the full detail
page instead.

### Why
Interception rewrites use the `nextUrl` header to determine if the
requested path should be rewritten to a different path. We currently
forward that header indiscriminately, which means that if you were on a
non-intercepted route and called `router.refresh()`, the UI would change
to the intercepted content instead (since it would treat it the same as
a soft-navigation).

### How
This updates various reducers to only forward the `nextUrl` header if
there's an interception route present in the tree. If there is, we want
to refresh its data, rather than the data for the underlying page. The
reverse is also true: if we were on the "full" page, and triggered a
`router.refresh()`, we won't forward `nextUrl` meaning it won't fetch
the interception data.

In order to determine if an interception route is present in the tree, I
had to add a new segment type for dynamic interception routes, as by the
time they reach the client they are stripped of their interception
marker.

**Note: There are a series of bugs related to `router.refresh` with
parallel/interception routes, such as the previous page/slot content
disappearing when triggering a refresh. This does not address all of
those cases, but I'm working through them!**

Fixes #60844
Fixes #62470
Closes NEXT-2737
2024-03-19 15:42:41 -07:00
vercel-release-bot
ad4a7bf403 v14.2.0-canary.32 2024-03-19 22:10:11 +00:00
Ethan Arrowood
d2838ce31e
Simplify createRootLayoutValidatorStream (#63484)
This PR is a follow up to #63427 and simplifies the
`createRootLayoutValidatorStream` function to check each chunk
individually instead of combining all of them into one. This should
improve performance

Closes NEXT-2868
2024-03-19 14:46:39 -07:00
JJ Kasper
d4f5368f2c
Update RSC etag generation handling (#63336)
Currently when we generate payloads in app router, the order of RSC
chunks aren't deterministic even if the content stays the same. This
means that any caches that rely on etags for detecting changes in
content aren't able to reliably cache/and avoid invalidating properly.
To avoid this we can manually sort the content before generating the
etag. Eventually this can be fixed upstream in react although that is a
bigger lift so we are doing this for now to alleviate the issue.

x-ref: [slack
thread](https://vercel.slack.com/archives/C042LHPJ1NX/p1709937748240119?thread_ts=1709856182.174879&cid=C042LHPJ1NX)

Closes NEXT-2825
2024-03-19 21:45:21 +00:00
OJ Kwon
3689c03d60
feat(next-core): support unsupported module runtime error (#63491)
### What

Implement webpack's middleware plugin equivalent for webpack, to raise
unsupported error in runtime.

PR utilizes import map alias for the edge context, to resolve into
modulereplacer internally provides a virtualsource to call runtime error
logic. Since we already have globally augmented, the virtualsource only
need to take export those into module.

Closes PACK-2789
2024-03-19 13:52:06 -07:00
JJ Kasper
b2b5ab4aff
Update tags limit handling for max items (#63486)
Continuation of https://github.com/vercel/next.js/pull/55083 this
ensures we also properly warn when the max number of tags is hit and we
must filter them out so that users are aware of this. Related
documentation is also updated to reflect this limit.

x-ref: [slack
thread](https://vercel.slack.com/archives/C04V3E1UYNQ/p1710792129356939)

Closes NEXT-2870

---------

Co-authored-by: Steven <steven@ceriously.com>
2024-03-19 12:02:35 -07:00
Zack Tanner
7d20ba17b8
Fix instant loading states after invalidating prefetch cache (#63256)
In #61573, I updated the navigation reducer to request a new prefetch
entry if it's stale. But this has the unintended consequence of making
instant loading states effectively useless after 30s (when the prefetch
would have expired). Blocking navigation and then rendering the loading
state isn't ideal - if we have some loading data in a cache node, we
should re-use it.

Now that #62346 stores loading data in the `CacheNode`, we can copy over
`loading` during a navigation.

This PR repurposes `fillCacheWithDataProperty` which wasn't being used
anywhere, to instead be a utility we can use to programmatically trigger
a lazy fetch on a particular segment path by nulling out it's data while
copying over other properties. We could have used the existing util
as-is, but ideally we only have a single spot where lazy fetching can
happen, which currently is in `LayoutRouter`.

When a stale prefetch entry is detected, rather than applying the data
to the tree, this PR will copy over the `loading` nodes and will
"delete" the data so it can be refetched.

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

-->


Closes NEXT-2806
2024-03-19 12:02:12 -07:00
Tobias Koppers
14f16c7050
update turbopack (#63475)
* https://github.com/vercel/turbo/pull/7762 <!-- Tobias Koppers - avoid
panic -->
* https://github.com/vercel/turbo/pull/7750 <!-- Tobias Koppers - fix
ASSET_PREFIX -->
* https://github.com/vercel/turbo/pull/7761 <!-- Tobias Koppers -
process source maps from webpack loaders -->
2024-03-19 15:58:19 +01:00
vercel-release-bot
7943315cce v14.2.0-canary.31 2024-03-19 14:48:23 +00:00
Sam Ko
73b4bfbc20
chore(next/font): update @capsizecss/metrics package to the latest (#63440)
## Why?

-
https://github.com/seek-oss/capsize/releases/tag/%40capsizecss%2Fmetrics%402.2.0

Closes NEXT-2854
2024-03-19 00:22:17 +00:00
Zack Tanner
15e76ead7e
Update React from 6c3b8dbfe to 14898b6a9 (#63439)
Update React from 6c3b8dbfe to 14898b6a9.

### React upstream changes

- https://github.com/facebook/react/pull/28580

Closes NEXT-2853
2024-03-19 00:18:18 +00:00
Ethan Arrowood
229cb14834
Eliminate unnecessary decode operations in node-web-streams-helpers.ts (#63427)
This PR is strictly a performance improvement. It should not change
implementation behavior in anyway.

This PR replaces `decoder.decode()` operations by operating with the
encoded `Uint8Array` instances directly. I added some utility functions
to make things a bit easier to understand.

Ideally, this change also maintains a fair amount of code readability. 

Will measure estimate performance improvement shortly.

Closes NEXT-2848
2024-03-18 23:23:35 +00:00
vercel-release-bot
1439503b3b v14.2.0-canary.30 2024-03-18 23:21:43 +00:00
Will Binns-Smith
1f5d3179ac
Turbopack HMR: Reload when recovering from server-side errors (#63434)
Test Plan: `TURBOPACK=1 pnpm test-dev
test/development/basic/gssp-ssr-change-reloading/test/index.test.ts


Closes PACK-2767
2024-03-18 14:57:24 -07:00
OJ Kwon
e12535c706
build(cargo): bump up turbopack (#63429)
### What

fix test/development/acceptance-app/app-hmr-changes.test.ts.

Closes PACK-2765
2024-03-18 21:11:37 +00:00
Ethan Arrowood
b39a4d5971
fix x-forwarded-port header (#63303)
Follow up to https://github.com/vercel/next.js/issues/61133 that will
rely on `x-forwarded-proto` value if it exists in order to default the
`x-forwarded-port` value.

Closes NEXT-2820
2024-03-18 20:45:33 +00:00
OJ Kwon
4064c64024
fix(next-core): carry over original segment config to metadata route (#63419)
### What

Fixes to honor metadata route's segment config - turbopack replaces it
into route handler, then parsed segment config so original segment
config was ignored always.

Closes PACK-2762
2024-03-18 13:26:04 -07:00
vercel-release-bot
57da10beea v14.2.0-canary.29 2024-03-18 19:47:03 +00:00
OJ Kwon
2cd58bb091
build(package): pin typescript-eslint/parser for supported node.js (#63424)
### What

https://github.com/typescript-eslint/typescript-eslint/pull/8671
introduces a change to enforce node.js >= 18.18.0. This is technically
breaking changes, and affects us as we support 18.17.0 still
(https://github.com/vercel/next.js/blob/canary/package.json#L254).

As a workaround, pin dep version to avoid 7.3.0 - later when we lift our
engines, can remove those.

Closes PACK-2763
2024-03-18 15:43:34 -04:00
Karl Horky
51b878f5a3
Switch to postcss.config.mjs, add type (#63380)
<!-- 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?

Now that @phanect added support for ESM PostCSS config files in PR
#63109 (original issue #34448), PostCSS can use ESM config by default.

It needs to use an `.mjs` extension by default because `create-next-app`
scaffolds CommonJS apps by default.

This will also work with ESM projects which have added `"type":
"module"` in their `package.json`

### Why?

1. To convert one more file to ESM
2. To use the modern format
3. To follow other similar migrations that have taken place in the
Next.js codebase (eg. `next.config.mjs`)

### How?

- Change file extensions from `.cjs` to `.mjs` (change similar to PR
#58380)
- Change module format from CommonJS to ESM
- Add type for the config, for users who enable `checkJs: true` in
`tsconfig.json`

Co-authored-by: Sam Ko <sam@vercel.com>
2024-03-18 16:57:55 +00:00
Tim Neutkens
dd7b05897a
Add Bun lockfile to project root resolving heuristic (#63112)
## What?

Got a report from @juliusmarminge that running examples in the
[uploadthing monorepo](https://github.com/pingdotgg/uploadthing) would
result in resolving errors with Turbopack.
Turns out the monorepo root couldn't be resolved and the reason for that
is that they are using `bun install` as the package manager, which we
didn't account for in the `findRootLockFile` logic. This PR adds
`bun.lockb` to the existing list that already check npm/pnpm/yarn.

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

-->


Closes NEXT-2766
2024-03-18 17:44:18 +01:00
Jiachi Liu
e1a7de0d04
feat(error-overlay): handle script under html hydration error (#63403)
script tag cannot be placed under html directly, users reported a case
in #51242 that having `<Script>` under html will cause hydration error,
this will display the React hydration error related warning of bad usage
for it.

You will see this warning in dev overlay instead of displaying nothing
```
In HTML, <script> cannot be a child of <html>.
This will cause a hydration error.
```

Added two other react warnings detection patterns  as well
* `Warning: In HTML, text nodes cannot be a child of <%s>.\nThis will
cause a hydration error.',`
* `Warning: In HTML, whitespace text nodes cann...`

But tested they're not generating hydration errors, only warnings in
console, so we don't need to have tests for them.

Closes NEXT-2835
2024-03-18 11:40:01 +01:00
vercel-release-bot
8b9e18503c v14.2.0-canary.28 2024-03-18 10:01:02 +00:00
Shu Ding
391925808b
Code refactor (#63391)
Two small changes. There's no need to check `payload === undefined` as
it will always be a string. At the other place we can reuse the global
`textEncoder` instance.

Closes NEXT-2830
2024-03-18 10:34:30 +01:00
Tim Neutkens
6380b81bff
Ensure all metadata files have missing default export errors in Turbopack (#63399)
## What?

Fixes the `"app dir - metadata dynamic routes should error if the
default export of dynamic image is missing",` test. The check was
missing in the output code for 2 metadata variations.

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

-->


Closes NEXT-2832
2024-03-18 10:30:45 +01:00
Tobias Koppers
46a5882223
New CSS chunking algorithm (#63157)
### What?

This fixes more CSS ordering issues with production and webpack dev.

* CSS Modules must not be side effect free as side effect free modules
are per definition order independent which is not true for CSS
* fix order of iterating module references
* disable splitChunks for CSS
* special chunking for CSS with loose and strict mode
* more test cases

Closes PACK-2709
2024-03-18 10:29:13 +01:00
Oliver Lassen
af5b31c238
bug: Fields truncated when submitting form using Server Actions (#59877)
When using Server Actions with a form the fields are getting truncated
at 1MB because of `busboy`'s default `fieldSize` limit of 1MB.

This PR tries to solve https://github.com/vercel/next.js/issues/59277
however there is a mismatch about `fieldSize` and `bodySize`. I have
tried creating a PR for `busboy`
https://github.com/mscdex/busboy/pull/351 to allow configuring a max
size for the entire body.

### TODO:

- [ ] Figure out if this is acceptable
- [ ] Throw error when `bodySizeLimit` is hit.

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

-->

Fixes #59277, closes #61462.

---------

Co-authored-by: Shu Ding <g@shud.in>
2024-03-18 09:08:29 +00:00
Shu Ding
107cfbfec7
Use correct protocol and hostname for internal redirections in Server Actions (#63389)
Currently, we always fallback to https as the protocol for redirection
requests inside Server Actions even for the local server host, which can
be `0.0.0.0` and result in SSL errors.

Closes #63114, partially resolves
https://github.com/vercel/next.js/issues/62903#issuecomment-1984179180.

Closes NEXT-2829
2024-03-18 10:01:45 +01:00
vercel-release-bot
8d5e9178f9 v14.2.0-canary.27 2024-03-17 23:23:04 +00:00
vercel-release-bot
f1a999ee73 v14.2.0-canary.26 2024-03-16 22:31:13 +00:00
Tobias Koppers
76c43b7d6a
fix transform of files ending with d (#63367)
### What?

fixed `"use client"` in files ending with `d`...

### Why?

### How?


Closes PACK-2753
2024-03-16 23:27:02 +01:00