Commit graph

11499 commits

Author SHA1 Message Date
Tobias Koppers
405933a0ea
update turbopack (#62884)
* https://github.com/vercel/turbo/pull/7622 <!-- Tobias Koppers - don't
apply alternatives if there is an exports field -->
2024-03-05 15:57:50 +00:00
Tobias Koppers
1d8b70411f
apply some transforms on foreign code too (#62827)
### What?

some transforms need to be applied on node_modules code too to work
correctly

### Why?

### How?


Closes PACK-2651
2024-03-05 16:03:35 +01:00
Thomas Danecker
6f5e0f3694
Don't emit crossorigin attributes for output: "export" by default (#61211)
In other output modes, link and script tags do not contain a crossorigin
attribute by default.

When using output: "export", it should also follow the other output
modes, to avoid unnecessary CORS issues, especially when hosting the
assets on a different domain (i.e. a CDN).

fixes #61210

Co-authored-by: Steven <steven@ceriously.com>
2024-03-05 14:33:37 +00:00
Almaz
473ef817a7
Update readme of @next/bundle-analyzer package (#62804)
Set actual information about output of bundle analyzer.

---------

Co-authored-by: JJ Kasper <jj@jjsweb.site>
2024-03-05 05:18:22 +00:00
Shu Ding
135642b9df
Remove extra logic of Server Reference check for registering twice (#62486)
This isn't necessary as it has been landed in React already:
https://github.com/facebook/react/pull/28343.

Closes NEXT-2586
2024-03-05 03:42:46 +00:00
vercel-release-bot
07e5b60a03 v14.2.0-canary.0 2024-03-05 01:09:36 +00:00
Jacob Hummer
392507b023
fix "setBlocking is not a function" errors on StackBlitz (#62843)
To reproduce:
- go to https://next.new/
- run `next build`
- it breaks

```sh
~/projects/nextjs-pdjpmx
❯ npm install && npx next dev

added 328 packages in 6s

116 packages are looking for funding
  run `npm fund` for details
   ▲ Next.js 14.1.0
   - Local:        http://localhost:3000

   Downloading swc package @next/swc-wasm-nodejs...
 ✓ Ready in 5.7s
 ○ Compiling / ...
 ✓ Compiled / in 9.2s (510 modules)
 ✓ Compiled in 483ms (240 modules)
^C


~/projects/nextjs-pdjpmx 27s
❯ npx next build
   ▲ Next.js 14.1.0

   Creating an optimized production build ...

> Build error occurred
TypeError: process.stdout._handle.setBlocking is not a function
    at loadBindings (file:///home/projects/nextjs-pdjpmx/node_modules/next/dist/build/swc/index.js:231:32)
    at getBaseWebpackConfig (file:///home/projects/nextjs-pdjpmx/node_modules/next/dist/build/webpack-config.js:333:37)
    at eval (file:///home/projects/nextjs-pdjpmx/node_modules/next/dist/build/webpack-build/impl.js:140:40)
    at async Span.traceAsyncFn (file:///home/projects/nextjs-pdjpmx/node_modules/next/dist/trace/trace.js:151:20)
    at async webpackBuildImpl (file:///home/projects/nextjs-pdjpmx/node_modules/next/dist/build/webpack-build/impl.js:133:21)
    at async Object.workerMain (file:///home/projects/nextjs-pdjpmx/node_modules/next/dist/build/webpack-build/impl.js:313:20) {
  type: 'TypeError'
}
```

fixes #61848 

<!-- 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-03-05 01:06:21 +00:00
JJ Kasper
eeb2369a5d
Update to latest version (#62850)
Updates our version to match the last backport for canaries.

Closes NEXT-2699
2024-03-04 16:04:21 -08:00
Jiwon Choi
882aa6d13c
fix(next-lint): do not pass absolute path to distDir (#62797)
This PR reverts part of #61877 passing an absolute path to the distDir
value when running `next lint`.

Fixes #62796

Co-authored-by: Sam Ko <sam@vercel.com>
2024-03-04 23:56:35 +00:00
vercel-release-bot
a1c9c3b9d4 v14.1.2-canary.7 2024-03-04 23:22:19 +00:00
Zack Tanner
9ac6c4abb2
remove reducer unit tests (#62766)
These tests were added back when the router would suspend in reducers,
primarily to test that things were working as expected during concurrent
rendering. Now that we don't suspend in reducers, most of these tests
aren't actually adding much value, and instead introduce friction
anytime we want to change the router state since they're currently
relying on snapshotting.

Before removing these tests, I verified that we have a corresponding e2e
test that covers the expected behaviors more explicitly. Specifically:

- `test/e2e/app-dir/actions` (server actions) 
- `test/e2e/app-dir/navigation` (navigation tests & router.refresh)
- `test/e2e/app-dir/app-client-cache` and
`test/e2e/app-dir/app-prefetch` (prefetch & router cache behavior)
- `test/e2e/app-dir/router-autoscroll` (navigation auto-scrolling
behavior)

<!-- 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-2669
2024-03-04 14:42:00 -08:00
vercel-release-bot
91a84b3ee2 v14.1.2-canary.6 2024-03-04 21:47:40 +00:00
OJ Kwon
655227f4e1
Revert "refactor(analysis): rust based page-static-info, deprecate js parse interface in next-swc" (#62838)
Reverts vercel/next.js#61832

Closes PACK-2654
2024-03-04 21:43:56 +00:00
JJ Kasper
5717b9a14d
Revert "Add experimental config for navigation raf test (#62668)" (#62834)
Reverting this experimental flag as it should not be used and we are
going to investigate experimenting with this further upstream so that it
can be done properly.

This reverts commit 2bdcaa0fda.

x-ref: https://github.com/vercel/next.js/pull/62668



Closes NEXT-2689
2024-03-04 12:39:41 -08:00
OJ Kwon
6e89226615
fix(next-core): throw on invalid metadata handler (#62829)
### What

Align with original route loader, explicitly throw on invalid handler
import.

This does not fixes test currently - other failures on the specific test
need to be solved.

Closes PACK-2652
2024-03-04 11:48:50 -08:00
Shu Ding
7b2b982343
fix: Add stricter check for "use server" exports (#62821)
As mentioned in the new-added error messages, and the [linked
resources](https://react.dev/reference/react/use-server#:~:text=Because%20the%20underlying%20network%20calls%20are%20always%20asynchronous%2C%20%27use%20server%27%20can%20only%20be%20used%20on%20async%20functions.):

> Because the underlying network calls are always asynchronous, 'use
server' can only be used on async functions.
> https://react.dev/reference/react/use-server

It's a requirement that only async functions are allowed to be exported
and annotated with `'use server'`. Currently, we already have compiler
check so this will already error:

```js
'use server'

export function foo () {} // missing async
```

However, since exported values can be very dynamic the compiler can't
catch all mistakes like that. We also have a runtime check for all
exports in a `'use server'` function, but it only covers `typeof value
=== 'function'`.

This PR adds a stricter check for "use server" annotated values to also
make sure they're async functions (`value.constructor.name ===
'AsyncFunction'`).

That said, there are still cases like synchronously returning a promise
to make a function "async", but it's still very different by definition.
For example:

```js
const f = async () => { throw 1; return 1 }
const g = () => { throw 1; return Promise.resolve(1) }
```

Where `g()` can be synchronously caught (`try { g() } catch {}`) but
`f()` can't even if they have the same types. If we allow `g` to be a
Server Action, this behavior is no longer always true but depending on
where it's called (server or client).

Closes #62727.
2024-03-04 18:50:19 +01:00
vercel-release-bot
b80d388032 v14.1.2-canary.5 2024-03-04 16:11:11 +00:00
OJ Kwon
372c74b620
refactor(analysis): rust based page-static-info, deprecate js parse interface in next-swc (#61832)
Reenabling https://github.com/vercel/next.js/pull/59300 with fixes for
the unsupported inputs.

Closes [PACK-2088](https://linear.app/vercel/issue/PACK-2088)

---------

Co-authored-by: Tim Neutkens <tim@timneutkens.nl>
2024-03-04 08:07:36 -08:00
vercel-release-bot
330b04ff55 v14.1.2-canary.4 2024-03-04 12:29:28 +00:00
Tobias Koppers
92eecbfdff
Turbopack: sass support (#62717)
### What?

* upgrades turbopack for `getResolve` in webpack loaders
* add missing resolve-url-loader to turbopack for full sass support

Closes PACK-2634
2024-03-04 11:56:55 +00:00
OJ Kwon
e9862a80f8
build(cargo): update turbopack (#62744)
### What

* https://github.com/vercel/turbo/pull/7544 <!-- Tobias Koppers -
extract a turbopack-resolve crate -->
* https://github.com/vercel/turbo/pull/7547 <!-- Tobias Koppers - only
register once -->
* https://github.com/vercel/turbo/pull/7447 <!-- Leah - fix(turbopack):
catch invalid source map paths -->
* https://github.com/vercel/turbo/pull/7503 <!-- Leah -
fix(turbopack-node): don't bundle postcss config -->
* https://github.com/vercel/turbo/pull/7445 <!-- Tobias Koppers - allow
to set a name on the virtual file system -->
* https://github.com/vercel/turbo/pull/7552 <!-- Tobias Koppers - add
default_files, prefer_relative and fully_specified resolve options -->
* https://github.com/vercel/turbo/pull/7560 <!-- Tobias Koppers - remove
unused code -->
* https://github.com/vercel/turbo/pull/7562 <!-- Tobias Koppers - add
getResolve to webpack loader context -->
* https://github.com/vercel/turbo/pull/7564 <!-- Tobias Koppers - fix
serde deserialization -->
* https://github.com/vercel/turbo/pull/7566 <!-- Tobias Koppers - Revert
"add getResolve to webpack loader context" -->
* https://github.com/vercel/turbo/pull/7565 <!-- Tobias Koppers - Ignore
circular aliasing with alias field -->
* https://github.com/vercel/turbo/pull/7320 <!-- OJ Kwon -
feat(turbo-tasks-fetch): allow specifying a proxy -->
* https://github.com/vercel/turbo/pull/7573 <!-- OJ Kwon - Revert
"Remove mopa dependency in turbo-tasks" -->
* https://github.com/vercel/turbo/pull/7526 <!-- Alexander Lyon - Handle
logging story better on daemon -->

Closes PACK-2639

---------

Co-authored-by: Tobias Koppers <tobias.koppers@googlemail.com>
2024-03-04 11:33:21 +01:00
vercel-release-bot
9fb18e6739 v14.1.2-canary.3 2024-03-03 23:21:56 +00:00
vercel-release-bot
f2d4d04ff8 v14.1.2-canary.2 2024-03-02 23:21:32 +00:00
Will Binns-Smith
be87132327
Turbopack: Trace server app render errors through source maps (#62611)
Previously, errors shown in the error overlay, these stir were left
untraced through source maps.

Test Plan: `TURBOPACK=1 pnpm test-dev
test/development/app-render-error-log/app-render-error-log.test.ts`

Closes PACK-2608
2024-03-01 16:31:02 -08:00
vercel-release-bot
d70a554032 v14.1.2-canary.1 2024-03-01 23:17:20 +00:00
Sam Ko
47f73cd8ec
refactor(cli): refactor cli to commander (#61877)
## Description
Refactor the [Next.js
CLI](https://nextjs.org/docs/app/api-reference/next-cli) to use
[commander](https://github.com/tj/commander.js) instead of
[arg](https://github.com/vercel/arg).

## Why?
- Auto-generated, properly formatted help command + output. With `arg`,
much of the help commands were manually added via a single
`console.log`, causing deviations over time.
- Ergonomic, ease of adding new subcommands and rules

## Breaking Changes
- Update the experimental `next experimental-compile` and `next
experimental-generate` build commands in favor of `next build
--experimental-build-mode=compile/generate`

---------

Co-authored-by: JJ Kasper <jj@jjsweb.site>
2024-03-01 23:12:47 +00:00
vercel-release-bot
2f7721a632 v14.1.2-canary.0 2024-03-01 21:49:46 +00:00
Zack Tanner
9529a874bd
Add a flag to disable MergeCssChunksPlugin (#62746)
This is currently on by default, but this adds a flag to allow disabling
it if it causes issues with your application's CSS.

Closes NEXT-2664
2024-03-01 21:44:28 +00:00
JJ Kasper
8562680f23
Update version from backport (#62745)
Ensures new canaries start from correct version as we did a backport for
`v14.1.1`

Closes NEXT-2663
2024-03-01 21:35:18 +00:00
Max Leiter
6ffbdc5db1
Route static render error message: remove duplicate word (#62738)
### What?
Removes an extra word from an error message

### Why?
It bothered me 

### How?
I opened it in VS Code and removed it

Co-authored-by: JJ Kasper <jj@jjsweb.site>
2024-03-01 21:35:15 +00:00
Jiachi Liu
4d4b45ec2c
fix dev overlay pseudo html collapsing (#62728)
Dev overlay should show the full stack trace after clicking the
uncollase button to display the full component stack

Closes NEXT-2658
2024-03-01 19:13:57 +01:00
Tim Neutkens
8034042215
Add compiler error for conflicting App Router and Pages Router in Turbopack (#62531)
## What?

Working on fixing `test/e2e/conflicting-app-page-error`, this adds a
compiler error for the case where App Router routes conflict with Pages
Router routes. It's not 1:1 the same error as in webpack because in the
webpack version we hijacked the App Router resolving logic to assume
there's a certain set of paths, where Turbopack has the full route to
route tree resolving implementation which doesn't assume there's a
single page that can be resolved.

The tests are updated to reflect this change.


<!-- 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-2592
2024-03-01 17:39:39 +01:00
Tim Neutkens
d12693e779
Handle top level errors coming from Turbopack entrypoints subscription (#62528)
## What?

Adds handling for issues that are emitted during the entrypoints
subscription, before the changes in this PR any issue (i.e. compiler
errors) that was emitted during the collection of which entrypoints
exist in the application were ignored.

<!-- 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-2591
2024-03-01 14:47:41 +01:00
Balázs Orbán
7593039b4c
fix(error-overlay): improve a11y, minor refactors (#62723)
### What?

- Use `button` instead of `span` to allow keyboard navigation
- match tabindex with other items in the overlay to include it in the
natural focus sequence
- the style is kept, but we might need a better contrasting icon for the
dark background
- use same file conventions with existing files
  - match file casing
  - move icons to the `icons` folder
- Improve PseudoHtml internal docs
  - use code guards ``` for code snippets
- drop the `any` type (long-term, we really should disallow `any` types)

Closes NEXT-2657
2024-03-01 14:40:46 +01:00
Tobias Koppers
744d9f464e
Turbopack: remove node_modules error filter (#62586)
### What?

This isn't needed

### Why?

### How?


Closes PACK-2604
2024-03-01 10:26:08 +01:00
Vercel Release Bot
35aab7eee3
Update font data (#62704)
This auto-generated PR updates font data with latest available

---------

Co-authored-by: JJ Kasper <jj@jjsweb.site>
2024-03-01 01:17:52 +00:00
JJ Kasper
dc41d9c644
Add param to debug PPR skeleton in dev (#62703)
This adds an experimental query `__nextppronly` to allow debugging PPR
skeletons in development to avoid having to do numerous builds to be
able to debug this experience.

x-ref: [slack
thread](https://vercel.slack.com/archives/C05KYT5S9FF/p1709151588583179?thread_ts=1708474869.960689&cid=C05KYT5S9FF)
2024-02-29 16:30:56 -08:00
Jiachi Liu
7d8a923f8d
chore: remove unused helper (#62701)
This code is removed in #62585 , remove it and related imports

Closes NEXT-2652

Co-authored-by: JJ Kasper <jj@jjsweb.site>
2024-02-29 23:41:52 +00:00
vercel-release-bot
c77454a02a v14.1.1-canary.82 2024-02-29 23:21:48 +00:00
JJ Kasper
41564fd5d1
Fix lint check (#62702)
x-ref:
https://github.com/vercel/next.js/actions/runs/8103553122/job/22149048179

Closes NEXT-2653
2024-02-29 15:16:16 -08:00
Jiachi Liu
ce422240e3
feat: display text diff for text mismatch hydration errors (#62684)
### What

Keep improving the hydration erros. Currently we divide the hydration
mismatch types into two categories, html tag mismatch and text mismatch.
We're displaying the mismatched text content between server and client
here since we have it in the component stack and warnings.

We've already made some improvements in #62590 , here we carry on
improving the highlited text into red and bold that is much easier for
you to spot on.

This updated a few long snapshots that we could collapse and show only
the text content difference instead of all the component stack.

### Screenshots

(Dark and light modes)

#### Mismatch html tags
<img width="360"
src="https://github.com/vercel/next.js/assets/4800338/f721b374-69cc-4600-a09d-bef87e885fab"><img
width="360"
src="https://github.com/vercel/next.js/assets/4800338/1abf2572-2be8-4359-a652-8ba39aaccfd3">


#### Mismatch text content
<img width="360"
src="https://github.com/vercel/next.js/assets/4800338/7f0d2215-8bc0-4fba-9c92-6c44efa29531"><img
width="360"
src="https://github.com/vercel/next.js/assets/4800338/656d1e1a-3157-4bcf-a239-74bb81fcb4c4">


#### Large content mismatch

### Why

I was intended to bring a html diff between server and client html
content but turns out the diff result could be giant and not ideal due
to few reasons. So we switched to the path of leveraging component stack
and mismatch contents.
React reordering the tags after hydration. For instance the `script` or
`link` tags could be hoist by React Float, so the lines of html is are
to preserved. so the diff is hard to be super accurate unless your
mismatch is small. If you're mismatch a component with rich html
content, it could be a pretty large diff.

Another case is if you have a bad nesting html like `<p> ...<span>...
<p>my text</p> ...</span>... <p>` where there're many span in between,
the final different could also be hudge as browser will close the first
`<p>` tag and the rest content will go into the diff. Hence we're going
with the component and text content diff.


Closes NEXT-2645
2024-02-29 23:36:38 +01:00
Jiachi Liu
28c2832405
Update precompiled for mini-css-extract-plugin (#62699)
Update precompiled related to below dependencies upgrades 

x-ref: https://github.com/vercel/next.js/pull/62698
x-ref: https://github.com/vercel/next.js/pull/62644

Closes NEXT-2649

Co-authored-by: JJ Kasper <jj@jjsweb.site>
2024-02-29 22:36:23 +00:00
neomad1337
c6e865bf6f
Upgrade mini-css-extract-plugin (#62698)
## For Contributors

### What?
This PR upgrades the mini-css-extract-plugin dependency

### Why?
In this
[version](https://github.com/webpack-contrib/mini-css-extract-plugin/releases/tag/v2.4.4),
the bug related to content hash is fixed. This bug causes different
hashes of CSS chunks in the webpack chunk.

### How?

Closes
[NEXT-1146](https://linear.app/vercel/issue/NEXT-1146/hashes-are-different-between-multiple-servers-with-generatebuildid)
Fixes #49230

Co-authored-by: Madiyar Turkenov <tagwriter@mail.ru>
Co-authored-by: Sam Ko <sam@vercel.com>
2024-02-29 21:20:50 +00:00
OJ Kwon
ecec67d3f5
refactor(next-swc): remove unused features (#62696)
### What

Remove unused features for the turbopack.

Closes PACK-2628
2024-02-29 11:14:16 -08:00
Jan Nicklas
56c8792698
add native css nesting support (#62644)
today ~83% of all browsers support css nesting:
https://caniuse.com/css-nesting

![CSS Nesting Browser
Support](https://github.com/css-modules/postcss-modules-local-by-default/assets/4113649/141f8dce-a8bd-4df4-b2bd-210252189711)
https://caniuse.com/css-nesting  
https://developer.mozilla.org/en-US/docs/Web/CSS/Nesting_selector

therefore this pr upgrades postcss-modules-local-by-default which fixes
a bug in
https://github.com/css-modules/postcss-modules-local-by-default/pull/64)

-  `.foo { &:hover { a_value: some-value; } }` is pure
-  `.foo { html &:hover { a_value: some-value; } }` is pure
-  `.foo { &:global(.bar) { a_value: some-value; } }` is pure
-  `:global(.foo) { &:hover { a_value: some-value; } }` is **not** pure


upgrading the package will allow using css nestings with or **without**
postcss compilation

it fixes the following error:

```
CssSyntaxError: postcss-modules-local-by-default: <css input>:1:8: Selector "&:hover" is not pure (pure selectors must contain at least one local class or id)
```

Fixes #55053
Fixes #33734
Fixes #10475

Co-authored-by: Sam Ko <sam@vercel.com>
2024-02-29 18:13:10 +00:00
Leah
a34bfcdd11
perf: don't emit issues via websocket for now (#59024) 2024-02-29 17:32:35 +00:00
Leah
9f72146dd7
fix(turbopack): don't emit issues for deleted pages (#62012)
### What?

We now keep track of all client assets emitted for each route in
`ClientAssetMapper` and remove all issues associated with them when a
route get deleted.

Fixes #61384  
Closes PACK-2487
2024-02-29 16:55:49 +00:00
vercel-release-bot
603b3771ce v14.1.1-canary.81 2024-02-29 16:38:01 +00:00
JJ Kasper
01b9603edc
Revert "Ensure dynamic routes dont match _next/static unexpectedly" (#62691)
Reverting temporarily to allow investigation into separate issue
eliminating this as also an issue.

Reverts vercel/next.js#62559
2024-02-29 08:34:11 -08:00
Tobias Koppers
5b204be07d
Turbopack: remove unused code (#62690)
### What?

No longer used with nexturbo


Closes PACK-2624
2024-02-29 16:32:39 +00:00
JJ Kasper
2bdcaa0fda
Add experimental config for navigation raf test (#62668)
This adds a new experimental config for testing. 

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

Closes NEXT-2644
2024-02-29 08:30:09 -08:00
Tim Neutkens
c262e6118f
Consistently use /_not-found for not found page in App Router (#62679)
## What?

#62528 caused test/e2e/app-dir/not-found/conflict-route to fail
compilation in Turbopack, this compiler error was previously already
reported by Turbopack but Next.js didn't show it, which #62528 resolved.

This PR changes the handling for the not-found handling to be consistent
between development and build, which ensures that the "special" page no
longer conflicts with app/not-found/page.js.

Closes NEXT-2617


Note: this is a reworked iteration of
https://github.com/vercel/next.js/pull/62585 which wasn't sufficient.

<!-- 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-02-29 14:47:31 +00:00
Balázs Orbán
9ae437f4b1
fix(navigation): allow useSelectedLayoutSegment(s) in Pages Router (#62584)
### What?

Do not fail when `useSelectedLayoutSegment` or
`useSelectedLayoutSegments` APIs are called in the Pages Router.

### Why?

This makes migration easier and creates consistency with our other App
Router-specific APIs that inherit the same behavior.

### How?

Similar to #47490, we return `null` if there is no Layout context
(indicating being in Pages Router)

Types are also overridden in the navigation compact module declaration
which kicks in during start to correct the types if we detect a `pages/`
directory.

Note to reviewer: #47490 didn't add a test, so I added one top-level,
let me know if you have a better suggestion for placing.

Closes NEXT-2506
Fixes #61464
2024-02-29 13:14:52 +00:00
vercel-release-bot
f0461abff0 v14.1.1-canary.80 2024-02-28 23:23:19 +00:00
vercel-release-bot
6a7a0da737 v14.1.1-canary.79 2024-02-28 22:42:21 +00:00
栗原和也
2baf4f74e4
fix: Enable SearchParams to be displayed after redirect in Server Action (#62582)
### What?
Fixes https://github.com/vercel/next.js/issues/62525
Closes NEXT-2620

Since codes below do not consider searchParams, `redirect` in server
action removes all searchParams passed from client side.

93e4bb823c (diff-c809d50461027cdba7c092e564818b1172133d337abc5c513f829c94c8483dc6R186)

So I just add conditional branch for searchParams.

---

lint, prettier was applied.
Also I have done tests by commands below. and it was all passed.

```
pnpm testonly --testPathPattern "integration" -t "redirect"
```

---------

Co-authored-by: Zack Tanner <zacktanner@gmail.com>
2024-02-28 14:37:39 -08:00
OJ Kwon
c5299239d3
feat(next-swc): lightningcss binding (#62604)
### What

This PR enables lightningcss features in next-swc. Currently this is for
the native build targets only, for the wasm there are some unknown build
error prevents to enable this.

Closes PACK-2607
2024-02-28 21:45:02 +00:00
OJ Kwon
acdf052e88
build(cargo): remove unused features (#62616)
### What?

It doesn't look like we are using these dependencies, remove from cargo
manifests.

Deploy CI confirms all native builds are passing:
https://github.com/vercel/next.js/actions/runs/8074472383


Closes PACK-2609
2024-02-28 09:13:54 -08:00
Jiachi Liu
7525633427
DX: display highlited pesudo html when bad nesting html error occurred (#62590)
### What

When you have bad nesting html in your React code, React wil raise
hydration error since the browser html parser might parse it to sth else
different comparing to server html on client. Previously we're display
only the warning in the error description in dev overlay.

Now we introduced another format of displaying pesudo html that
representing your code, with highlighting the html tag that causes the
error. Since React might gives you the whole component stack of React
tree, so we also introduced a way that can collapse the error.

#### Example


https://github.com/vercel/next.js/assets/4800338/622122d6-4d2e-4c8e-95e8-4864343e478b

### Why
The reason we added this is that even we show the html diff, it could
super large due to React ordering the html on client, so the mismatch
might be a lot. The idea here is similar to what you saw when you passed
down a bad event handler into server component, we displayed a pesudo
html as it could hit your mind faster than just seeing the warning. The
best way is to display the source code, but before we can show the
source, getting component stack display as pseudo html instead of here
could be more helpful.



### After vs Before

<img width="400"
src="https://github.com/vercel/next.js/assets/4800338/714119ad-ff23-46a9-bc5a-5601eb390e71">
<img width="400"
src="https://github.com/vercel/next.js/assets/4800338/575f95fa-889e-4cee-ad19-9c2fea06519a">



Closes NEXT-2621
2024-02-28 16:14:48 +01:00
Remo Vetere
3790099997
Fix Router Error Events in Shallow Routing by Skipping cancelHandler Creation (#61771)
### Problem

We've identified a bug within Next.js's pages router when utilizing the
shallow routing API, specifically when invoking `router.push` with the
`{ shallow: true }` option, like so:
 
```javascript
router.push('/?counter=10', undefined, { shallow: true });
```

Shallow routing is designed to update the URL without running data
fetching methods such as getServerSideProps, getStaticProps, or
getInitialProps. However, a side effect of this process is that it skips
the clean-up of the cancelHandler. This leads to router error events
being fired erroneously, causing confusion and potential stability
issues, as the system behaves as if an error occurred when, in fact,
none did.
 
### Solution

This PR addresses the issue by modifying the shallow routing logic to
also skip the creation of the cancelHandler. Given that shallow routing
operations are synchronous and do not involve data fetching or other
asynchronous tasks that might need to be canceled, the cancelHandler is
unnecessary in this context.

fixes #61772

---------

Co-authored-by: Shu Ding <g@shud.in>
2024-02-28 05:39:31 -08:00
vercel-release-bot
6b6575ce48 v14.1.1-canary.78 2024-02-28 12:09:02 +00:00
Tim Neutkens
b55a023b49
Refactor flight-manifest-plugin to use compilation.entrypoints directly (#62636)
## What?

Currently flight-manifest-plugin relies on looping over all webpack
chunk groups and trying to infer the entrypoint name from them, which
can be brittle in cases where the chunk group doesn't match exactly with
the entrypoint, which happens for the `_not-found` entrypoint for
example.

This PR changes the implementation to use `compilation.entrypoints`
directly. `compilation.entrypoints` is a `Map` where the key is the
entrypoint name and the value is the entrypoint chunk group, exactly
what this logic was looking for in the current implementation.

<!-- 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-2637
2024-02-28 12:48:25 +01:00
Abhinay Pandey
f38dc18861
Fix: generateSitemaps in production giving 404 (#62212)
### What?
generateSitemaps function returns a 404 for /sitemap/[id].xml in
production

### Why?
While finding the correct sitemap partition from the array, we check the
param against the id. Which works in dev because id and param are both
without trailing .xml. But it fails in production as param has a
trailing .xml (/sitemap/[id] works in production because it falls back
to dynamic loading and param and id are both without .xml)

### How?
If we are in production environment, check the id with a trailing .xml
because that's whats returned from generateStaticParams, an array of
__metadata_id__ with trailing .xml

Fixes #61969

---------

Co-authored-by: Jiachi Liu <inbox@huozhi.im>
2024-02-28 12:43:07 +01:00
JJ Kasper
eaa7606de1
Fix instrumentation with only pages (#62622)
This ensures we properly transpile `instrumentation.ts` when only
`pages` is being used as previously we were relying on the `app`
specific loaders which aren't configured when an `app` directory isn't
present. We regressed on this in
https://github.com/vercel/next.js/pull/60984 as it was working as
expected prior to this commit

x-ref: [slack
thread](https://vercel.slack.com/archives/C011GK1JUBA/p1709075846401649?thread_ts=1706643408.233909&cid=C011GK1JUBA)

Closes NEXT-2632
2024-02-28 11:38:39 +01:00
Donny/강동윤
9408f35b11
Update Turbopack (#62632)
### What?

* https://github.com/vercel/turbo/pull/7520 <!-- Leah - fix(turbopack):
restore `require.resolve` functionality -->
* https://github.com/vercel/turbo/pull/7504 <!-- Donny/강동윤 -
fix(turbopack): Enable CSS parsing option for legacy nesting syntax -->
* https://github.com/vercel/turbo/pull/7528 <!-- Tobias Koppers - add
test case for ?: -->
* https://github.com/vercel/turbo/pull/7518 <!-- Donny/강동윤 - Update
`swc_core` to `v0.90.12` -->
* https://github.com/vercel/turbo/pull/7535 <!-- Donny/강동윤 -
fix(turbopack): Fix ordering of `IssueStage`s -->
* https://github.com/vercel/turbo/pull/7406 <!-- Leah -
fix(turbopack-core): don't resolve exports field in folders -->
* https://github.com/vercel/turbo/pull/7537 <!-- Donny/강동윤 -
feat(turbopack): Add `JsValue::TypeOf` -->
* https://github.com/vercel/turbo/pull/7527 <!-- Tobias Koppers -
implement handling for alias field resolving in more cases -->
* https://github.com/vercel/turbo/pull/7539 <!-- Tobias Koppers - add
external require back to edge runtime -->

### Why?

To keep in sync

### How?

---------

Co-authored-by: Tobias Koppers <tobias.koppers@googlemail.com>
2024-02-28 08:43:29 +00:00
Donny/강동윤
cea5366ce0
fix(next-swc): Provide tokio context required for WASM plugins (#62441)
### What?

Run transforms with the tokio context so Wasmer works properly.

### Why?

To allow invoking Wasm plugins. `wasmer` had a breaking change.

### How?



Closes PACK-2587
Closes #62081

---------

Co-authored-by: hrmny <8845940+ForsakenHarmony@users.noreply.github.com>
2024-02-28 11:28:00 +09:00
JJ Kasper
26de5ca269
Migrate locale redirect handling to router-server (#62606)
This moves the locale redirect handling out of `base-server` as it
shouldn't be handled here and should be at the routing level. This
avoids the duplicate handling with middleware that causes the incorrect
detection/infinite looping. Test case from separate PR was carried over
to prevent regression.

Fixes: https://github.com/vercel/next.js/issues/55648
Closes: https://github.com/vercel/next.js/pull/62435
Closes: NEXT-2627
Closes: NEXT-2628

---------

Co-authored-by: Nourman Hajar <nourmanhajar@gmail.com>
Co-authored-by: samcx <sam@vercel.com>
2024-02-27 16:37:11 -08:00
Jiachi Liu
69d1edf6d0
Fix metadata json manifest convention (#62615)
### What

Change from processing the file with `next-metatdata-route-loader`
directly into passing the file as loader query, and leave an empty
resource file for it. This will resolve the error that users were seeing
with `manifest.json` convention.

```
Import trace for requested module:
../../../../packages/next/dist/build/webpack/loaders/next-metadata-route-loader.js?page=%2Fmanifest.jso
n%2Froute&isDynamic=0!./app/manifest.json?__next_metadata_route__
getStaticAssetRouteCode page /manifest.json/route this.resourcePath /Users/huozhi/workspace/next.js/tes
t/e2e/app-dir/metadata-json-manifest/app/manifest.json
```

### Why

I looked at the loader process that the final resource processed by
webpack is `json!next-metadata-route-loader...`, which means the builtin
json loader processing json file after the metadata route loader. I
didn't get chance to solve the ordering issue, so I changed the
resourcePath to empty "", and pass the file path as query into the
loader to avoid json-loader processing it after transpilation.


Fixes #59923

Closes NEXT-2630
Closes NEXT-2439
2024-02-28 00:55:27 +01:00
vercel-release-bot
b0fcd44e13 v14.1.1-canary.77 2024-02-27 23:20:54 +00:00
JJ Kasper
e1e6a073fa
Ensure dynamic routes dont match _next/static unexpectedly (#62559)
This ensures our dynamic routes that have the same specificity as
`_next/static/:path*` don't get matched unexpectedly when the
`_next/static` asset doesn't exist. We were holding off on making this
change explicit due to compatibility concerns but these are no longer a
concern and the unexpected matching is more of a concern.

Closes: CSM-11
Fixes: https://github.com/vercel/next.js/issues/19270

Closes NEXT-2613
2024-02-27 15:01:16 -08:00
Jiachi Liu
29876c6f4f
Fix redirect under suspense boundary with basePath (#62597)
### What

Fixes `redirect()` call under suspense boundary, redirect url should
include the `basePath` in the url.

### Why

`redirect()` under suspense boundaries will go through server html
insertion, which is being used every time by suspense boundary resolved,
new errors will triggered from SSR streaming. It was missing before.

Fixes NEXT-2615
Fixes #62407
2024-02-27 23:45:24 +01:00
Balázs Orbán
c441245932
fix(build-output): show stack during CSR bailout warning (#62594)
### What?

We should treat the warning for CSR bailout the same as the hard-error,
and show the stack trace for either case.

### Why?

It might be useful to track down the source of this warning.

### How?

We have the stack info already, but we only showed it during the error
logging. We should show it for warnings too.

This is similar to #61200

Closes NEXT-2624
2024-02-27 21:13:55 +01:00
Zack Tanner
195537e48c
refactor createInfinitePromise to be re-used unresolveable thenable (#62595)
We currently use an infinite promise to indefinitely suspend while
waiting for something else to happen (new data from a server response,
or an MPA navigation finally resolving).

We don't need to create a new promise every time we do this, and instead
can leverage a shared "thenable" that will never actually resolve. The
primary motivation for this is that `use` shouldn't be called with a new
promise value between renders as described in the
[RFC](https://github.com/acdlite/rfcs/blob/first-class-promises/text/0000-first-class-support-for-promises.md).

<!-- 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-2625
2024-02-27 12:06:37 -08:00
Donny/강동윤
523b7f8601
feat(turbopack): Sort issues (#62566)
### What?

Sort issues emitted by turbopack.


### Why?

Make it deterministic and testable


### How?

Closes PACK-2440

turbopack counterpart: https://github.com/vercel/turbo/pull/7519

---------

Co-authored-by: Tobias Koppers <tobias.koppers@googlemail.com>
2024-02-27 19:07:32 +00:00
Zach Bloomquist
f72debcf48
fix: improve error when starting next without building (#62404)
Addresses #57066

Currently, a user running `next start` on an un-built Next.js project
receives a confusing uncaught error before the process just ends:

```
   ▲ Next.js 14.1.0
   - Local:        http://localhost:3000

[Error: ENOENT: no such file or directory, open '/home/flotwig/src/project/.next/BUILD_ID'] {
  errno: -2,
  code: 'ENOENT',
  syscall: 'open',
  path: '/home/flotwig/src/project/.next/BUILD_ID'
}
```

In my case, I ran into this because I had not worked with Next.js for a
while, and I forgot that `next dev` was used for local development, not
`next start`. I believe many of the confused users in #57066 are making
a similar mistake and not realizing it, due to the error message.

This PR catches an `ENOENT` when reading `BUILD_ID` and suggests that
the user `next build` or `next dev` to remove this friction point:

```
   ▲ Next.js 14.1.1-canary.69
   - Local:        http://localhost:3000

Error: Could not find a production build in the '.next' directory. Try building your app with 'next build' before starting the production server. https://nextjs.org/docs/messages/production-start-no-build-id
    at setupFsCheck (/home/flotwig/src/next.js/packages/next/src/server/lib/router-utils/filesystem.ts:157:13)
    at initialize (/home/flotwig/src/next.js/packages/next/src/server/lib/router-server.ts:90:21)
    at Server.<anonymous> (/home/flotwig/src/next.js/packages/next/src/server/lib/start-server.ts:295:28)
```

A few things probably need to be resolved before this PR can merge, I
would appreciate any input from Next.js maintainers.

- [x] Is this the best place to catch this? I am not familiar with the
Next.js codebase, so I just caught this in the most obvious way.
- [x] Can the error message be improved?
- [x] Add a test for the error in `test/development`

---------

Co-authored-by: JJ Kasper <jj@jjsweb.site>
2024-02-27 10:34:22 -08:00
vercel-release-bot
036a4f60fc v14.1.1-canary.76 2024-02-27 18:20:06 +00:00
Zack Tanner
48bad4e894
fix router crash on revalidate + popstate (#62383)
### What
When the popstate action is fired (as is the case in a browser back
button), if the page you're going back to has missing cache node data,
the router will crash.

### Why
Almost all router actions will suspend at the app-router level with the
exception of `ACTION_RESTORE`. This was to address an issue where
suspending in the router would add enough delay for browser scroll
restoration behavior not to work.

As a result, when going back to the page with missing data, app-router
wouldn't suspend but layout-router would suspend on the missing data
while triggering a lazy fetch. We trigger a server-patch with the
applied lazy data, but when React replays the render, it will replay the
branch without the cache node data applied. This results in the router
getting caught in a loop of suspending, applying the cache node,
replaying the branch without the cache node, and eventually crashing due
to an error thrown by React to prevent re-suspending indefinitely.

### How
This adds a property to the cache node to signal if the lazy data has
been resolved. If it has been, we won't call the server patch action
again.

Fixes #61336
Closes NEXT-2438
2024-02-27 10:15:36 -08:00
vercel-release-bot
36dde3c37e v14.1.1-canary.75 2024-02-27 17:21:46 +00:00
Shu Ding
8f7a6ca7d2
Improve redirection handling (#62561)
Currently to redirect to another RSC route of the same app, we initiate
another request to that route. This PR changes that request to directly
use the internal hostname of the current server handler, rather than
relying on other headers.

Closes NEXT-2614
2024-02-27 09:17:50 -08:00
Balázs Orbán
18200a849b
Revert "fix(build-output): show stack during CSR bailout warning" (#62592)
Closes NEXT-2623
2024-02-27 16:56:41 +01:00
Balázs Orbán
629cb14855 fix(build-output): show stack during CSR bailout warning 2024-02-27 16:44:36 +01:00
vercel-release-bot
eb6867fdad v14.1.1-canary.74 2024-02-26 23:22:03 +00:00
nhducit
0fe68736ce
Fix typo in the GTM URL (#62436)
<!-- 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 #

-->
TODO: update description

Co-authored-by: JJ Kasper <jj@jjsweb.site>
2024-02-26 18:21:12 +00:00
Shu Ding
4f46fab088
Improve TS plugin options (#62438)
The `experimental-edge` config is no longer needed:


![CleanShot-2024-02-23-xxccX9gb@2x](https://github.com/vercel/next.js/assets/3676859/8a75143d-630e-4eae-a323-a78fd11e83ce)

This PR:


![CleanShot-2024-02-23-EmCglptd@2x](https://github.com/vercel/next.js/assets/3676859/0cacd221-1c4a-4b30-afde-19eb9b4883de)


Closes NEXT-2580
2024-02-26 18:02:50 +00:00
Jiachi Liu
87015acead
Upgrade vendored react (#62549)
### React upstream changes

- https://github.com/facebook/react/pull/28438
- https://github.com/facebook/react/pull/28436
- https://github.com/facebook/react/pull/25954
- https://github.com/facebook/react/pull/28434
- https://github.com/facebook/react/pull/28433
- https://github.com/facebook/react/pull/28432
- https://github.com/facebook/react/pull/28415
- https://github.com/facebook/react/pull/27903
- https://github.com/facebook/react/pull/28430
- https://github.com/facebook/react/pull/28424
- https://github.com/facebook/react/pull/28400
- https://github.com/facebook/react/pull/28422
- https://github.com/facebook/react/pull/28423
- https://github.com/facebook/react/pull/28412
- https://github.com/facebook/react/pull/28418
- https://github.com/facebook/react/pull/28421
- https://github.com/facebook/react/pull/28417
- https://github.com/facebook/react/pull/28399
- https://github.com/facebook/react/pull/28408
- https://github.com/facebook/react/pull/28350
- https://github.com/facebook/react/pull/28387
- https://github.com/facebook/react/pull/28403
- https://github.com/facebook/react/pull/28384
- https://github.com/facebook/react/pull/28409
- https://github.com/facebook/react/pull/28398
- https://github.com/facebook/react/pull/28405
- https://github.com/facebook/react/pull/28328
- https://github.com/facebook/react/pull/28402
- https://github.com/facebook/react/pull/28386
- https://github.com/facebook/react/pull/28388
- https://github.com/facebook/react/pull/28379
- https://github.com/facebook/react/pull/28383
- https://github.com/facebook/react/pull/28390
- https://github.com/facebook/react/pull/28389
- https://github.com/facebook/react/pull/28382
- https://github.com/facebook/react/pull/28348



Closes NEXT-2600
2024-02-26 18:53:56 +01:00
Natt Nguyen ツ
e60cb36d54
chore: update non-interactive snippet in README.md (#62493)
Updated the code snippet in the `README.md` to reflect information on
the documentation website.

Reference:
https://nextjs.org/docs/app/api-reference/create-next-app#non-interactive

Co-authored-by: Sam Ko <sam@vercel.com>
2024-02-26 17:13:38 +00:00
Jiachi Liu
c1980ce7b9
Display only one hydration error when there's few in error overlay (#62448)
## What & Why

When there's a bad nesting HTML tags occurred, we want to show the
hydration mismatch with the warning of bad nesting.

Multiple hydration errors emitted from `onRecoverableError` as react is
trying re-render on client, and few more errors could throw from
different places. But for alert the issue, we only need to know one
hydration mismatch error instead of


### After
Show the toast with error number first and only show one hydration error
when you open
<img width="200"
src="https://github.com/vercel/next.js/assets/4800338/b57e73b9-60a6-4f09-9b71-e052121666f2"><img
width="500"
src="https://github.com/vercel/next.js/assets/4800338/9d409422-d513-4da0-ad6c-002c1ba7c497">

### Before

Mutiple hydration errors are displayed
<img width="200"
src="https://github.com/vercel/next.js/assets/4800338/8d6696a8-30de-496f-a9c4-bafb7d1f1d4c"><img
width="500"
src="https://github.com/vercel/next.js/assets/4800338/bc72bea9-85be-4bb2-b007-b88e655ade4e">


Closes NEXT-2315
2024-02-26 18:02:07 +01:00
Dima Voytenko
fb14590b4a
OTEL: Ensure that RSC:1 requests get the next.route attr (#62464) 2024-02-26 08:39:12 -08:00
Tim Neutkens
bbf6dfac61
Add IssueKey type (#62526)
## What?

Ensures there's a stricter type for the issues map.

<!-- 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-2590
2024-02-26 14:21:21 +01:00
Jiachi Liu
c221fc4508
Create react server condition alias for next/navigation api (#62456)
### What

Introduce a `react-server` export condition of `next/navigation`, which
only take effects in RSC layer. And it will only contain `notFound` and
`redirect` related APIs, which can be shared in both server components
and client components environment. This export excludes those APIs
working with React context which are only working in client components.

### Why

We fixed an issue bad alias for react-server condition of react itself
in
https://github.com/vercel/next.js/pull/61522/files#diff-ecb951c8d26893f6d1e4425a873b399d52346ef63eb90fba79d980cef2fabe8cL35
, this was a good fix. But we found that if you're using edge runtime
with `next/navigation` it will error with bundling that you're attempted
to import some client component hooks such as `useContext` from react.

So we introduced a `react-server` version of `next/navigation` that
doesn't interoplate with any client hooks, can we'll bundle that one
instead of original `next/navigation` when you're using it in server
components or app routes.

Closes NEXT-2583
Closes NEXT-2519
Fixes #62187
2024-02-26 13:35:44 +01:00
Balázs Orbán
0fec89c0df
feat(error-overlay): hide Node.js internals (#62532)
### What?

Hide frames that start with `node:internal`.

### Why?

These are usually unactionable anyway. 

### How?

Filter these lines the same way we filtered `stringify <anonymous>` in
#62325

Closes NEXT-2593
2024-02-26 13:29:54 +01:00
vercel-release-bot
0fcb946eca v14.1.1-canary.73 2024-02-26 10:40:07 +00:00
Tobias Koppers
110fc47f7c
add plugin to avoid too many css requests (#62530)
### What?

Reduces the number of css chunks per entrypoint by merging chunks.

### Why?

In larger application the total CSS deduplication approach falls short
in a sense of it's causing way too many separate chunks, which results
in way to many requests. That affects page load performance.


Closes PACK-2598
2024-02-26 11:36:46 +01:00
Tobias Koppers
d9b2a4baea
update turbopack (#62523)
* https://github.com/vercel/turbo/pull/7437 <!-- Tobias Koppers - report
relative start/end and fix start time for events -->
* https://github.com/vercel/turbo/pull/7446 <!-- Tobias Koppers - allow
to aggregate all spans -->
* https://github.com/vercel/turbo/pull/6651 <!-- max -
fix(postcss_configs): support for resolve `postcss.config.json` file -->
* https://github.com/vercel/turbo/pull/7448 <!-- Leah - chore: remove
"rust" npm package -->
* https://github.com/vercel/turbo/pull/7436 <!-- Leah -
refactor(turbo-tasks-fs): move file watching into separate file -->
* https://github.com/vercel/turbo/pull/7396 <!-- Donny/강동윤 -
feat(turbopack): Apply critical ES lint rules -->
* https://github.com/vercel/turbo/pull/7421 <!-- Donny/강동윤 -
fix(turbopack): Use different title for non-parsing issues -->
* https://github.com/vercel/turbo/pull/7501 <!-- Tobias Koppers -
Tracing: Report progress on initial read -->
* https://github.com/vercel/turbo/pull/7508 <!-- Donny/강동윤 -
fix(turbopack): Fix CSS Modules of turbopack in swc mode -->
* https://github.com/vercel/turbo/pull/7424 <!-- Donny/강동윤 -
fix(turbopack): Analyze for-of stmts to allow using `sharp` -->
* https://github.com/vercel/turbo/pull/7510 <!-- Tobias Koppers - dedupe
primary_modules to avoid deduping in chunking, reduce memory usage -->
* https://github.com/vercel/turbo/pull/7509 <!-- Tobias Koppers - split
graph_node_to_referenced_nodes into cacheable and non-cacheable parts
-->
* https://github.com/vercel/turbo/pull/7516 <!-- Tobias Koppers - fix
ignore in package.json -->
* https://github.com/vercel/turbo/pull/7500 <!-- Tobias Koppers - add
span count to trace-server -->
* https://github.com/vercel/turbo/pull/7507 <!-- Donny/강동윤 -
fix(turbopack): Fix CSS module purity validator -->
2024-02-26 11:19:31 +01:00
Tim Neutkens
4ebeace3d2
Rename currentIssues to currentEntryIssues (#62524)
## What?

Renaming this as a follow-up PR is going to introduce top-level errors.

<!-- 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-2589
2024-02-26 10:43:17 +01:00
vercel-release-bot
bef716ad03 v14.1.1-canary.72 2024-02-24 23:22:11 +00:00
Jiachi Liu
aa914eea73
[turbopack] update edge alias (#62461)
Use public api alias for turbopack edge runtime, aligning with webpack

Closes NEXT-2584
2024-02-24 01:25:16 +01:00
vercel-release-bot
8166c15973 v14.1.1-canary.71 2024-02-23 22:55:51 +00:00
Dima Voytenko
00f300a020
Telemetry: ensure the ClientComponentLoad metric is only reported when available (#62459) 2024-02-23 14:51:13 -08:00
Leah
dcf8f04135
fix(turbopack): deal with eventual consistency in get_directory_tree (#62444)
### What?

The file watcher might invalidate the (moved / deleted) directory before
the parent task can mark it as no longer needed.

Closes PACK-2588
2024-02-23 17:12:53 +01:00
Ryo H
ae524fb244
Fixed typo. (#62440)
### What?

I fixed the typo from `occured` to `occurred`.

Co-authored-by: Ryo H <49798519+ryobs@users.noreply.github.com>
2024-02-23 14:58:41 +01:00
Tobias Koppers
1d2225eab7
Turbopack: reduce memory usage (#62432)
### What?

Avoid cloning a bit

### Why?

less allocations and memory usage

### How?


Closes PACK-2584
2024-02-23 13:04:06 +01:00
Jiachi Liu
e5d604f33b
Upgrade vendored react (#62326)
### React upstream changes

- https://github.com/facebook/react/pull/28333
- https://github.com/facebook/react/pull/28334
- https://github.com/facebook/react/pull/28378
- https://github.com/facebook/react/pull/28377
- https://github.com/facebook/react/pull/28376
- https://github.com/facebook/react/pull/28338
- https://github.com/facebook/react/pull/28331
- https://github.com/facebook/react/pull/28336
- https://github.com/facebook/react/pull/28320
- https://github.com/facebook/react/pull/28317
- https://github.com/facebook/react/pull/28375
- https://github.com/facebook/react/pull/28367
- https://github.com/facebook/react/pull/28380
- https://github.com/facebook/react/pull/28368
- https://github.com/facebook/react/pull/28343
- https://github.com/facebook/react/pull/28355
- https://github.com/facebook/react/pull/28374
- https://github.com/facebook/react/pull/28362
- https://github.com/facebook/react/pull/28344
- https://github.com/facebook/react/pull/28339
- https://github.com/facebook/react/pull/28353
- https://github.com/facebook/react/pull/28346
- https://github.com/facebook/react/pull/25790
- https://github.com/facebook/react/pull/28352
- https://github.com/facebook/react/pull/28326
- https://github.com/facebook/react/pull/27688
- https://github.com/facebook/react/pull/28329
- https://github.com/facebook/react/pull/28332
- https://github.com/facebook/react/pull/28340
- https://github.com/facebook/react/pull/28327
- https://github.com/facebook/react/pull/28325
- https://github.com/facebook/react/pull/28324
- https://github.com/facebook/react/pull/28309
- https://github.com/facebook/react/pull/28310
- https://github.com/facebook/react/pull/28307
- https://github.com/facebook/react/pull/28306
- https://github.com/facebook/react/pull/28315
- https://github.com/facebook/react/pull/28318
- https://github.com/facebook/react/pull/28226
- https://github.com/facebook/react/pull/28308
- https://github.com/facebook/react/pull/27563
- https://github.com/facebook/react/pull/28297
- https://github.com/facebook/react/pull/28286
- https://github.com/facebook/react/pull/28284
- https://github.com/facebook/react/pull/28275
- https://github.com/facebook/react/pull/28145
- https://github.com/facebook/react/pull/28301
- https://github.com/facebook/react/pull/28224
- https://github.com/facebook/react/pull/28152
- https://github.com/facebook/react/pull/28296
- https://github.com/facebook/react/pull/28294
- https://github.com/facebook/react/pull/28279
- https://github.com/facebook/react/pull/28273
- https://github.com/facebook/react/pull/28269
- https://github.com/facebook/react/pull/28376
- https://github.com/facebook/react/pull/28338
- https://github.com/facebook/react/pull/28331
- https://github.com/facebook/react/pull/28336
- https://github.com/facebook/react/pull/28320
- https://github.com/facebook/react/pull/28317
- https://github.com/facebook/react/pull/28375
- https://github.com/facebook/react/pull/28367
- https://github.com/facebook/react/pull/28380
- https://github.com/facebook/react/pull/28368
- https://github.com/facebook/react/pull/28343
- https://github.com/facebook/react/pull/28355
- https://github.com/facebook/react/pull/28374
- https://github.com/facebook/react/pull/28362
- https://github.com/facebook/react/pull/28344
- https://github.com/facebook/react/pull/28339
- https://github.com/facebook/react/pull/28353
- https://github.com/facebook/react/pull/28346
- https://github.com/facebook/react/pull/25790
- https://github.com/facebook/react/pull/28352
- https://github.com/facebook/react/pull/28326
- https://github.com/facebook/react/pull/27688
- https://github.com/facebook/react/pull/28329
- https://github.com/facebook/react/pull/28332
- https://github.com/facebook/react/pull/28340
- https://github.com/facebook/react/pull/28327
- https://github.com/facebook/react/pull/28325
- https://github.com/facebook/react/pull/28324
- https://github.com/facebook/react/pull/28309
- https://github.com/facebook/react/pull/28310
- https://github.com/facebook/react/pull/28307
- https://github.com/facebook/react/pull/28306
- https://github.com/facebook/react/pull/28315
- https://github.com/facebook/react/pull/28318
- https://github.com/facebook/react/pull/28226
- https://github.com/facebook/react/pull/28308
- https://github.com/facebook/react/pull/27563
- https://github.com/facebook/react/pull/28297
- https://github.com/facebook/react/pull/28286
- https://github.com/facebook/react/pull/28284
- https://github.com/facebook/react/pull/28275
- https://github.com/facebook/react/pull/28145
- https://github.com/facebook/react/pull/28301
- https://github.com/facebook/react/pull/28224
- https://github.com/facebook/react/pull/28152
- https://github.com/facebook/react/pull/28296
- https://github.com/facebook/react/pull/28294
- https://github.com/facebook/react/pull/28279
- https://github.com/facebook/react/pull/28273
- https://github.com/facebook/react/pull/28269

Closes NEXT-2542


Disable ppr test for strict mode for now, @acdlite will check it and
we'll sync again
2024-02-23 12:46:58 +01:00
Shu Ding
b0c6b00643
Fix module-level Server Action creation with closure-closed values (#62437)
With Server Actions, a module-level encryption can happen when you do:

```js
function wrapAction(value) {
  return async function () {
    'use server'
    console.log(value)
  }
}

const action = wrapAction('some-module-level-encryption-value')
```

...as that action will be created when requiring this module, and it
contains an encrypted argument from its closure (`value`). This
currently throws an error during build:

```
Error: Missing manifest for Server Actions. This is a bug in Next.js
    at d (/Users/shu/Documents/git/next.js/test/e2e/app-dir/actions/.next/server/chunks/1772.js:1:15202)
    at f (/Users/shu/Documents/git/next.js/test/e2e/app-dir/actions/.next/server/chunks/1772.js:1:16917)
    at 714 (/Users/shu/Documents/git/next.js/test/e2e/app-dir/actions/.next/server/app/encryption/page.js:1:2806)
    at t (/Users/shu/Documents/git/next.js/test/e2e/app-dir/actions/.next/server/webpack-runtime.js:1:127)
    at 7940 (/Users/shu/Documents/git/next.js/test/e2e/app-dir/actions/.next/server/app/encryption/page.js:1:941)
    at t (/Users/shu/Documents/git/next.js/test/e2e/app-dir/actions/.next/server/webpack-runtime.js:1:127)
    at r (/Users/shu/Documents/git/next.js/test/e2e/app-dir/actions/.next/server/app/encryption/page.js:1:4529)
    at /Users/shu/Documents/git/next.js/test/e2e/app-dir/actions/.next/server/app/encryption/page.js:1:4572
    at t.X (/Users/shu/Documents/git/next.js/test/e2e/app-dir/actions/.next/server/webpack-runtime.js:1:1181)
    at /Users/shu/Documents/git/next.js/test/e2e/app-dir/actions/.next/server/app/encryption/page.js:1:4542
```

Because during module require phase, the encryption logic can't run as
it doesn't have Server/Client references available yet (which are set
during the rendering phase).

Since both references are global singletons to the server and are
already loaded early, this fix makes sure that they're registered via
`setReferenceManifestsSingleton` before requiring the module.

Closes NEXT-2579
2024-02-23 12:00:24 +01:00
Ethan Arrowood
f520111c9f
update configSchema.ts with experimental#useEarlyImport (#62408)
Follow up to #61168 that adds the `useEarlyImport` to `experimental`
config section.

Closes NEXT-2573
2024-02-23 02:19:01 +00:00
JJ Kasper
dfaa9efb5d
Simplify node/edge server chunking some (#62424)
This continues https://github.com/vercel/next.js/pull/62336 and ensures
we chunk fully but removes the cache groups as that introduces some
un-necessary duplication. With this configuration we ensure we split
chunks of all types which fixes the OOM/cache size issue and also avoids
overall chunk size increase.

Closes NEXT-2577
2024-02-22 17:45:02 -08:00
Will Binns-Smith
749e3c4e85
Turbopack react-refresh: perform full reload on runtime error (#62359)
Previously, runtime errors would not be recovered from. Like the webpack
implementation, this addresses the issue by performing a full page
reload when recovering from a runtime error.

Test Plan: `test/development/acceptance-app/error-recovery.test.ts --
Error recovery app default stuck error`


Closes PACK-2569
2024-02-22 17:15:36 -08:00
Dima Voytenko
2451af931c
OTEL: Add top span for middleware (#62421)
Without this, any spans added by the middleware implementation would be
orphaned and create extra traces.
2024-02-23 01:08:29 +00:00
vercel-release-bot
1aaa40c781 v14.1.1-canary.70 2024-02-22 23:23:39 +00:00
Sam Ko
e64dbaa3eb
chore(cli): add clarifying comment (#62418)
## Changes

- Add clarifying comment around why we're `process.exit(1)` at the end
of `runLintCheck`
- Related → https://github.com/vercel/next.js/pull/62378

Closes NEXT-2576
2024-02-22 22:23:32 +00:00
Tim Neutkens
dae8756b86
Correctly pass prependData and additionalData to sass-loader for Turbopack (#62397)
## What?

Ensures that `prependData` and `additionalData` are passed as loader
options instead of as part of `sassOptions`, mirrors webpack behavior.

Covers two cases that currently fail in #62321.

<!-- 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-2571
2024-02-22 18:42:25 +01:00
Zack Tanner
93eb32d96a
Remove default fallback behavior when route group is missing a default (#62370)
This test case was added in #59752, but this doesn't seem like the
correct behavior.

The original PR was intended to be smart about resolving `/default.tsx`
to a route group default (e.g. `/(foo)/default.tsx`) when one wasn't
specified. But since the route group is creating a new hierarchy in the
tree and defines its own layout, if the route group layout doesn't
specify a default, then the not found behavior seems correct.

To fix unexpected not-found behavior in this case, you should specify a
default at the same level as the layout where the missing slot(s) might
be rendered.

Closes NEXT-2565
2024-02-22 16:13:50 +01:00
Sam Ko
905ee8ed8d
fix(next-lint): fix next lint not throwing exit 1 on error (#62378)
## Changes

The error on
3e92d8a41d/packages/next/src/lib/eslint/runLintCheck.ts (L117)
runs to the `try` in here →
3e92d8a41d/packages/next/src/cli/next-lint.ts (L191)
instead of throwing in the `catch`, so we add a last `else` statement to
`process.exit(1)`.

Closes NEXT-2567
2024-02-22 11:40:19 +01:00
Tobias Koppers
f27e76e0a2
Turbopack: resolve endpoints to avoid extra nesting in tracing (#62317)
### Why?

Allows to correctly aggregate different endpoints in tracing

Closes PACK-2559
2024-02-22 08:22:24 +00:00
Tobias Koppers
4545f3e7f1
scope issues from subscriptions to the websocket connection (#62344)
### What?

* scope issues from subscriptions to the websocket connection
* close subscriptions when closing the websocket connection

### Why?

* subscriptions on one page should not affect other pages

### How?



Closes PACK-2567
2024-02-22 08:55:31 +01:00
Donny/강동윤
8d6c1a6d40
fix(next-swc): Fix span for invalid 'use server' directives (#62259)
### What?

Highlight only `'use server'`, instead of the whole function body.

### Why?

Other statements of the body is not related to the error.


### How?

x-ref:
https://vercel.slack.com/archives/C04CAN8CGCE/p1708353068632249?thread_ts=1708351927.544179&cid=C04CAN8CGCE

Closes PACK-2538
2024-02-22 08:51:45 +01:00
JJ Kasper
3e92d8a41d
Add experimental flag for early exit on prerender error (#62367)
This adds an experimental flag to allow exiting during prerendering when
the first path errors instead of waiting until all prerendering is
finished to then fail the build.

x-ref: [slack
thread](https://vercel.slack.com/archives/C0676QZBWKS/p1708559793380989)
Closes: NEXT-2561

Closes NEXT-2563
2024-02-22 01:47:43 +00:00
vercel-release-bot
aafb329c6d v14.1.1-canary.69 2024-02-21 23:22:02 +00:00
JJ Kasper
40bc285d21
Update data cache max size error (#62348)
Makes the error message more specific to Next.js and provides specific
size that exceeded the limit.

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

Closes NEXT-2559
2024-02-21 22:03:20 +00:00
vercel-release-bot
5dd895db83 v14.1.1-canary.68 2024-02-21 21:46:16 +00:00
Tobias Koppers
46521db5c4
Turbopack: limit build concurrency, show progress bar (#62319)
### What?

Run 10 concurrent Turbopack compilation jobs instead of all of them
show a progress spinner

### Why?

* In future this allows to reclaim memory for finished jobs
* It looks nicer in tracing


Closes PACK-2561
2024-02-21 20:55:37 +00:00
Tobias Koppers
8421a97154
output filesystem without watching (#62340)
### What?

Use an output filesystem without watching to allow external changes to
output files


Closes PACK-2566
2024-02-21 20:53:50 +00:00
Tobias Koppers
e7ff4c02e5
avoid loading the page loader chunk on initial page load (#62269)
### What?

* unnecessary request
* removes a race condition with script loading



Closes PACK-2544
2024-02-21 21:49:49 +01:00
Jiachi Liu
5f635de51f
Revert "Ensure webpack build worker defaults on" (#62342)
Reverts vercel/next.js#62214

Enabling build worker by default breaks some mdx rendering pages with
`next build`
x-ref: https://vercel.slack.com/archives/C04DUD7EB1B/p1708543258307169
2024-02-21 12:00:18 -08:00
JJ Kasper
f994d409c2
Revert "Revert "Update split chunk handling for edge/node" (#62313)" (#62336)
This re-lands the chunking optimization with fix for the split chunks
config to ensure we aren't generating duplicate chunks from not chunking
`all` together.

Tested various configs against our repro case here:

https://vercel.com/vercel/vercel-site/2D5Xirs9Vr1M29WHAuNawgjvgE4G
https://vercel.com/vercel/vercel-site/B2aez1NNCyVvoUBTSMFy8npBKK3j

Closes NEXT-2552
closes: https://github.com/vercel/next.js/issues/51298
x-ref: https://github.com/vercel/next.js/pull/62313
2024-02-21 11:40:29 -08:00
Sébastien Vanvelthem
cd6dacd59f
eslint-config-next: allow typescript eslint v7 (#62137)
### What?

Allow [typescript-eslint
v7](https://typescript-eslint.io/blog/announcing-typescript-eslint-v7)
support

### Why?

Allow compatibility with typescript eslint v7, pave the way to support
eslint flat config and possibly typescript 5.4

### How?

Add a v7 to the allowed versions in eslint-config-next dependencies and
regenerate the lock with pnpm install. Be aware that some eslint peer
dev deps have been updated in the process. See the lock

Tested with pnpm build && ppm lint

## Close

- Closes https://github.com/vercel/next.js/issues/62138
2024-02-21 14:01:43 -05:00
Balázs Orbán
a1b20470c6
feat(error-overlay): hide <unknown>/stringify methods in <anonymous> file from stack (#62325)
### What?

Clean up the error overlay:

<details>
<summary><b>Before:</b></summary>
<img
src="https://github.com/vercel/next.js/assets/18369201/22c3ab2c-8445-4c25-8554-a5ab51100af4"/>
</details>

<details>
<summary><b>After:</b></summary>
<img
src="https://github.com/vercel/next.js/assets/18369201/403c30fc-8b27-4529-838c-47d9cbe52381"/></details>


I also simplified the current code as it was likely using `useMemo` a
bit eagerly.

### Why?

This is an unactionable line by the user, no value in showing it in the
overlay.

### How?

Filter out the frame before rendering it in the overlay.

This answers [this
question](https://github.com/vercel/next.js/pull/62206#issuecomment-1956636486)
too, since the module grouping is local. Now that `<anonymous>` is
filtered out, the two Next.js groups are now merged into one, further
cleaning up the stack.

Closes NEXT-2505
2024-02-21 16:58:22 +01:00
Tobias Koppers
79cb2b2256
Revert "Turbopack: reduce tasks needed for emitting" (#62324)
Reverts vercel/next.js#62291

Closes PACK-2563
2024-02-21 15:29:03 +01:00
Balázs Orbán
2a9a7a2cbe
fix(error-overlay): correct module grouping, hide useless frames (#62206)
### What?

While working on hiding useless frames, I also noticed that we regressed
on #44137, meaning it was totally ignored. I haven't tracked down at
which point this happened but made it work again in the same PR.

This should significantly clear up the shown error stack in the error
overlay:

<details>
<summary><b>Before:</b></summary>
<img
src="https://github.com/vercel/next.js/assets/18369201/1833abfe-7c0b-4a34-bad8-735799f1cf42"/>
<img
src="https://github.com/vercel/next.js/assets/18369201/70ecc124-1241-4df9-adfe-7f0c8f47d6d3"/>
</details>


<details>
<summary><b>After:</b></summary>
<img
src="https://github.com/vercel/next.js/assets/18369201/d0395320-c52c-47a0-a281-f7721410f4da"/>
</details>

### Why?

Some frames in the error stack are useless/unactionable to the user and
make it harder to parse the error. This PR filters out some of them, to
make the stack more readable.

### How?

The stack traces are run through a `.filter()` before being displayed.


Closes NEXT-2505
Closes NEXT-2522
2024-02-21 13:07:40 +00:00
Tobias Koppers
7d448236a2
Turbopack: add SSR category to tracing (#62318)
### Why?

Show correct type of processing in tracing


Closes PACK-2560
2024-02-21 13:42:41 +01:00
Tobias Koppers
bf196f5e5a
Turbopack: reduce tasks needed for emitting (#62291)
### What?

* reduce tasks needed for emitting
* add user level tracing


Closes PACK-2552
2024-02-21 13:36:57 +01:00
vercel-release-bot
063c286416 v14.1.1-canary.67 2024-02-21 11:00:29 +00:00
JJ Kasper
fc0f94f8c0
Revert "Update split chunk handling for edge/node" (#62313)
We have a reproduction of OOMs still occurring with this chunking so
going to revert while we investigate further

x-ref:
https://github.com/vercel/next.js/issues/51298#issuecomment-1953004425

Reverts vercel/next.js#62205

Closes NEXT-2548
2024-02-21 11:57:08 +01:00
Ethan Arrowood
eea4e6079f
Fix draft mode invariant (#62121)
### What?

In today's implementation, requests that don't end in `.rsc` are getting
the data request query. We need to remove this toggle to prevent them
from 500'ing.

### Why?

The invariant triggered was:


212553958c/packages/next/src/server/base-server.ts (L2838-L2842)

Crawling up the code, the conditional:


212553958c/packages/next/src/server/base-server.ts (L2815)

must be `true`.

The variable `isDataReq` is set here:


212553958c/packages/next/src/server/base-server.ts (L1833-L1839)

This conditional expression is a bit complex, but it simplifies down to:
- `isDataReq` is `true` when (TODO)
- `isDataReq` is `false` when (TODO)

### How?

Closes NEXT-2341
Fixes #61377

Tested manually by:
- Building and packaging this branch locally
- Deploying tarball and then depending on it as the Next.js version for
an example app similar to the one reported by #61377
- Inspecting console for 500 errors.

---------

Co-authored-by: JJ Kasper <jj@jjsweb.site>
Co-authored-by: Zack Tanner <zacktanner@gmail.com>
2024-02-21 08:34:22 +00:00
vercel-release-bot
79b7cb5f07 v14.1.1-canary.66 2024-02-21 06:09:07 +00:00
Sam Ko
745b1b59b2
fix(next-font): update capsize css so fallbacks are updated with the … (#62309)
## Description
We need to manually update the `@capsizecss/metrics` every time it
updates so we get the latest fallback fonts.

## Changes
- https://github.com/vercel/next.js/issues/47115

Closes NEXT-2547
2024-02-20 22:04:56 -08:00
OJ Kwon
6f87054c76
fix(next-core): properly normalize app route for _ (#62307)
### What

This PR amends turbopack's behavior to handle some cases of normalized
path (`%5F` starting path), mainly fixes entry lookup works against
original path without normalization, also bends the output path of
client reference manifest matchs to what next.js expects.

Closes PACK-2553
2024-02-20 21:11:40 -08:00
Javi Velasco
2f9d718695
Fix perf spans (#62306)
- Remove a not-needed `performance.measure()` call.
- Fixes reporting client component loading span to happen on headers
flush.
- Simplifies measures by using `performance.now()`


Closes NEXT-2546
2024-02-21 01:06:50 +00:00
vercel-release-bot
ad992d4576 v14.1.1-canary.65 2024-02-20 23:21:37 +00:00
vercel-release-bot
51e231b0b1 v14.1.1-canary.64 2024-02-20 21:39:22 +00:00
JJ Kasper
6feb803f78
Add otel span for client component loading (#62296)
This adds a new span to allow tracking the sum of all client component
loading times for a specific request along with the count of items
loaded.

Closes NEXT-2540

---------

Co-authored-by: Zack Tanner <zacktanner@gmail.com>
2024-02-20 13:27:16 -08:00
Jiachi Liu
f4ac92d320
Add flag for early import app router modules (#61168)
Closes NEXT-2236

---------

Co-authored-by: Ethan Arrowood <ethan@arrowood.dev>
Co-authored-by: JJ Kasper <jj@jjsweb.site>
2024-02-20 12:29:30 -08:00
Dima Voytenko
662472370e
Allow fetch to propagate arbitrary init options (#62168)
Co-authored-by: JJ Kasper <jj@jjsweb.site>
2024-02-20 18:31:06 +00:00
Tobias Koppers
6d3ede147d
update turbopack (#62285)
* https://github.com/vercel/turbo/pull/7430 <!-- Tobias Koppers -
disable manifest chunks by default -->
* https://github.com/vercel/turbo/pull/7431 <!-- Donny/강동윤 -
fix(turbopack): Fix `pure` lint for CSS Modules in lightningcss mode -->
2024-02-20 19:13:00 +01:00
OJ Kwon
dd4b52e77e
fix(next-core): fix aliased free var for edge runtime (#62289)
### What?

Matches global free var alias to what webpack does (to the native
instead of polyfill)


Closes PACK-2550
2024-02-20 10:11:34 -08:00
Zack Tanner
d371f648d2
Renew prefetch cache entry after update from server (#61573)
### What
When a prefetch cache entry becomes "stale", it'll remain stale until
eventually it gets evicted. However during that stale window, the cache
is never revalidated, and so instant navigations stop working and data
is fetched from origin every navigation.

### Why
The `lastUsedTime` entry on the prefetch cache is currently only updated
after the first read. Once it becomes stale, `applyFlightData`'s
recursive functions will see that there is no longer a reusable prefetch
cache entry, and will trigger a lazy fetch of the new data on every
subsequent navigation.

### How
This updates prefetch cache handling to always ensure we’re using a
fresh or reusable prefetch cache entry. This means that stale prefetch
entries will be refreshed on a navigation event. As a result of this,
I’ve had to disable one of our tests that relies on this stale cache
behavior. It’s not ideal that we’re blocked on the loading boundary when
fetching child segment data—ideally we can refactor this to cache the
loading component in the CacheNode and copy it over on navigations,
similar to how ‘head’ is handled. I’ll work on this in a separate PR.

Note: The new client cache test for this is disabled in PPR for the same
reason as the other tests: auto prefetching with PPR navigations is
currently loading fresh data rather than reusing the prefetch cache.


Fixes #58969
Fixes #58723
Closes NEXT-1904
2024-02-20 09:07:18 -08:00
Tobias Koppers
73322aa3d8
Verify correctness of externals (#62235)
### What?

* Verify correctness of externals
* error when packages can't be made external

### Why?

* Resolving to incorrect externals might lead to runtime errors
* Give users hints how to fix these issues

### How?


Closes PACK-2535

---------

Co-authored-by: Tim Neutkens <tim@timneutkens.nl>
2024-02-20 16:38:31 +00:00
vercel-release-bot
d894fac0e1 v14.1.1-canary.63 2024-02-20 16:18:08 +00:00
Jiachi Liu
d7d636adf5
Tree shake the unused exports in direct relative imported client component module (#62238)
### What & Why

This PR helps fixes a long time tree-shaking issue that if you're import
some identifiers from client components, the whole client component is
being included in the client chunk. Because we're using import eager
mode in webpack to include all the client component modules that make
sure they're present in SSR entry and browser entry when they're
transformed to client reference on RSC layer.

But the way we collect client components is a bit "aggressive" where
contains some spaces to optimize.

### How

We change the collected client components from simpliy collecting it
resolved module request, into collecting both the imported identifiers
(by server components) and the module request. And when we inserted the
used client components imports into the SSR and Client entry, leverage
webpack magic comments `"webpackExports"` to only contain the used
exports in the bundle. Thank you webpack for this nice feature : )

Along the way we also fixed an issue that when you only used default
export, the `default` export itself should also be proxied when the
bundle is in ESM.

#### Notice

There's a limitation yet that it can't work with barrel file, if you
have a shared component `index.js` to re-export the changes several
client components there and you only partially import few from
`index.js` it won't work. For the cases that the node_modules package
contain a barrel file importing multiple client components, please use
[optimizePackageImports](https://nextjs.org/docs/app/api-reference/next-config-js/optimizePackageImports)
config for now. We'll have follow up optimizations

### Testing Result

If we compare the `react-aria-components` the reproduction from #60246,
you'll see the result being optimized a lot:

#### After vs Before

134KB being tree-shaked out 🤯 
```
Route (app)                              Size     First Load JS
┌ ○ /                                    324 B           127 kB
├ ○ /_not-found                          872 B          86.5 kB
└ ○ /other-page                          174 B           127 kB
```

```
Route (app)                              Size     First Load JS
┌ ○ /                                    325 B           261 kB
├ ○ /_not-found                          870 B          86.5 kB
└ ○ /other-page                          176 B           261 kB
```

Fixes #60246
Related report: https://github.com/adobe/react-spectrum/issues/5639
Closes NEXT-2527
phase 1 of NEXT-1799

---------

Co-authored-by: Shu Ding <g@shud.in>
2024-02-20 17:07:25 +01:00
Kuzey Kose
09c0065c3d
fix(create-next-app): add --no-import-alias for non-interactive (#62035)
### What?

The [create-next-app
documentation](https://nextjs.org/docs/app/api-reference/create-next-app#non-interactive)
under API reference says that;

> Further, you can negate default options by prefixing them with --no-
(e.g., --no-eslint).

When I tried to use --no-import-alias, I thought that it would
automatically use the default alias (@/*), but it does not.

### Why?

Each option has --no prefix control but import-alias has no --no prefix
control to give default value to program.

In an [Interactive](https://nextjs.org/#interactive) approach, the user
can select a prompt; `Would you like to customize the default import
alias (@/*)? No / Yes.` If the user selects no, then the default alias
is applied with @/*.

### How?

Implementing a condition solve the problem for general purpose. If
arguments includes `--no-import-alias` then the importAlias section
automatically apply the default value.

---------

Co-authored-by: JJ Kasper <jj@jjsweb.site>
Co-authored-by: Steven <steven@ceriously.com>
2024-02-20 10:23:04 -05:00