Commit graph

11542 commits

Author SHA1 Message Date
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
Leah
a97725f5f6
fix(turbopack): print missing slots in debug message (#62280)
### What?

The console message was added in
https://github.com/vercel/next.js/pull/60186, but Turbopack outputs
fully resolved paths.


Closes PACK-2548
2024-02-20 16:22:15 +01:00
Balázs Orbán
ac1c14b8ce
feat(cli): show available memory/CPU cores in next info (#62249)
### What?

Adds a new line to the `next info` output:

```diff
Operating System:
  Platform: linux
  Arch: x64
  Version: #18~22.04.1-Ubuntu SMP PREEMPT_DYNAMIC Wed Feb  7 11:40:03 UTC 2
+ Available memory (MB): 31795
+ Available CPU cores: 16
Binaries:
  Node: 18.18.2
  npm: 9.8.1
  Yarn: N/A
  pnpm: 8.15.1
Relevant Packages:
  next: 14.1.1-canary.61 // Latest available version is detected (14.1.1-canary.61).
  eslint-config-next: 14.1.1-canary.61
  react: 18.2.0
  react-dom: 18.2.0
  typescript: 5.2.2
Next.js Config:
  output: N/A
```

### Why?

This can help in debugging

### How?

Using [`os.totalmem()`](https://nodejs.org/api/os.html#ostotalmem) and
[`os.cpus()`](https://nodejs.org/api/os.html#oscpus)

Closes NEXT-2529
[Slack
thread](https://vercel.slack.com/archives/C046HAU4H7F/p1708359702870269?thread_ts=1708355509.771049&cid=C046HAU4H7F)
2024-02-20 11:46:51 +01:00
Donny/강동윤
2d8462eaf4
Update turbopack (#62263)
### What?


* https://github.com/vercel/turbo/pull/7416 <!-- Donny/강동윤 - Update
`swc_core` to `v0.90.10` -->


### Why?

To keep in sync

### How?



Closes PACK-2540
2024-02-20 08:26:39 +01:00
JJ Kasper
9c44024139
Add test log prefix for otel (#62258) 2024-02-19 21:19:49 -08:00
Jiwon Choi
b63196f0fe
fix(next): terser-webpack-plugin path in taskfile.js is missing 'src' (#62229)
### Why?

While developing https://github.com/vercel/next.js/pull/57656, using
`webpack`(which runs `bundle5.js`) gives me the following error:

```
Error: Cannot find module 'next/dist/build/webpack/plugins/terser-webpack-plugin'
Require stack:
- .../node_modules/next/dist/compiled/webpack/bundle5.js
```

### What?

The path to
[terser-webpack-plugin](https://github.com/vercel/next.js/blob/canary/packages/next/src/build/webpack/plugins/terser-webpack-plugin/src/index.ts)
seems to be modified, but the `taskfile.js` for building `bundle5.js`
hasn't been updated since https://github.com/vercel/next.js/pull/29168.

### How?

- Added `src` after the `terser-webpack-plugin` path in `taskfile.js`
- Run `pnpm ncc-compiled` (not sure if this is the right command to
run), built `bundle5.js` only.

---------

Co-authored-by: JJ Kasper <jj@jjsweb.site>
2024-02-19 16:17:13 -08:00
vercel-release-bot
321e4d0f2e v14.1.1-canary.62 2024-02-19 23:21:18 +00:00
JJ Kasper
1a102fb273
Fix type error in build.ts (#62253)
Fixes:
https://github.com/vercel/next.js/actions/runs/7964464677/job/21742122219

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

Closes NEXT-2530
2024-02-19 12:09:21 -08:00
Adrian Hartanto
92fdcc75d4
update: allow providing stale-while-revalidate delta (#61330)
<!-- 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: https://github.com/vercel/next.js/pull/52251
Closes: https://github.com/vercel/next.js/issues/51823

### Adding a feature

Added `stale-while-revalidate` delta amount to indicate that the cache
could reuse a stale response while it revalidates,
[reference](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Cache-Control).
It's also already supported by
[CloudFront](https://aws.amazon.com/about-aws/whats-new/2023/05/amazon-cloudfront-stale-while-revalidate-stale-if-error-cache-control-directives/).

---------

Co-authored-by: JJ Kasper <jj@jjsweb.site>
2024-02-19 11:51:13 -08:00
Tim Neutkens
544444b9da
Ensure handleRouteType does not throw in production builds (#62234)
## What?

Ensures the build can finish before issues are reported with Turbopack.

<!-- 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-2525
2024-02-19 20:39:33 +01:00
Leah
ecb4d7484e
refactor(turbopack): resolve routes by page name instead of pathname (#61778)
### Why?

We currently use `page` and `pathname` in different places for file
system paths (manifests can be in a different folder to the js entry),
this PR makes more things just use `page` directly instead of going
through `pathname`.

This PR also adds an entry key (similar to the webpack version) uniquely
identifying all entry points (and assets).


Closes PACK-2432
2024-02-19 15:13:39 +00:00
Leah
6926688a1e
refactor(turbopack): wrap manifest loading in helper class (#62118)
### What?

All the manifest loading logic now lives in the
`TurbopackManifestLoader` class.
We have to pass way fewer arguments around to the functions now.

I've also cleaned up / restructured the arguments of the bigger
functions in `turbopack-utils.ts` and gave some functions better names.


Closes PACK-2520
2024-02-19 14:27:09 +00:00
Balázs Orbán
971843d019
fix: clarify Dynamic API calls in wrong context (#62143)
### What?

An unactionable error is thrown when `headers()`, `cookies()` or other
Dynamic API functions are called outside the render/request context.
This PR clarifies what the user can do to fix the problem.

### Why?

The current error is  hard to understand

> Error: Invariant: `cookies` expects to have requestAsyncStorage, none
available.

### How?

I am adding a dedicated error page and rephrasing the error message.

Closes NEXT-2509
2024-02-19 13:41:14 +01:00
Leah
031cf70092
fix(turbopack): catchall route matching (#62114)
This PR adds catch-all matching support to Turbopack. This allows you to
have catch-all parallel slots.

Closes NEXT-2038
Closes PACK-2518

Fixes #59502

---------

Co-authored-by: Zack Tanner <zacktanner@gmail.com>
2024-02-19 10:44:53 +01:00
Tobias Koppers
8250a8419a
add turbo.resolveExtensions to allow to customize extensions (#62004)
### What?

* add `turbo.resolveExtensions` to allow to customize extensions in
Turbopack

fixes PACK-2335
Fixes https://github.com/vercel/turbo/issues/4934
2024-02-19 09:07:09 +00:00
Tim Neutkens
7e4be1f014
Add page name to error logged in Turbopack (#62218)
## What?

Ensures you can track what page caused a compiler error.

<!-- 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-2524
2024-02-19 09:38:29 +01:00
Donny/강동윤
755e88b16b
feat: Lint invalid CSS modules (#62040)
### What?

`css-loader` seems to have a linting rule for invalid CSS Modules.
[My Turbopack PR](https://github.com/vercel/turbo/pull/7381) implements
the same rule for `swc_css` and `lightningcss`, and this PR is for
enabling related test suite and updating the jest snapshot.

### Why?

`css-loader` has a similar linting rule.

### How?

Closes PACK-2408
2024-02-19 03:10:08 +00:00
vercel-release-bot
12411e9fe0 v14.1.1-canary.61 2024-02-19 00:04:04 +00:00
JJ Kasper
8ef58bb113
Ensure webpack build worker defaults on (#62214)
As discussed almost all webpack plugins shouldn't have issues with this
being enabled by default so removing the default condition where we
disable this optimization due to custom webpack config is more
beneficial and in the rare case a custom plugin has issues it can still
be manually disabled.

Closes NEXT-2523
2024-02-18 15:41:35 -08:00
JJ Kasper
0b5f7d9b42
Update split chunk handling for edge/node (#62205)
While investigating OOMs noticed that our split chunks handling for edge
runtime isn't optimized properly causing a lot of duplicate
transpiling/minification which causes exponential memory/cache usage.

On a minimal app before this change the memory usage and cache size were
over `2GB`s after this change they are under `200MB`.

**Before**

![CleanShot 2024-02-17 at 16 08
46@2x](https://github.com/vercel/next.js/assets/22380829/5286e5fb-5e48-4296-a6be-d2ed1455eb95)


**After**

![CleanShot 2024-02-18 at 08 58
51@2x](https://github.com/vercel/next.js/assets/22380829/f813a185-51a7-40e0-b44b-e1ab95649194)



Closes NEXT-2521
2024-02-18 15:27:40 -08:00
vercel-release-bot
7bf825741d v14.1.1-canary.60 2024-02-18 23:21:18 +00:00
Vercel Release Bot
160bb99b06
Update font data (#62173)
This auto-generated PR updates font data with latest available

Co-authored-by: JJ Kasper <jj@jjsweb.site>
2024-02-17 23:49:35 +00:00
vercel-release-bot
c62053f30b v14.1.1-canary.59 2024-02-17 23:20:55 +00:00
suu3
e56275974c
docs: updated link in JSDoc for the shallow property in link.tsx (#62181)
<!-- 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 #

-->

Hi there.
I discovered that the JSDoc link in the shallow property of link.tsx was
not updated and I updated it.
2024-02-18 00:07:56 +01:00
Akbarshokh Sobirov
4fa08dea8c
Fix sendGAEvent function (for real?) (#62192)
The recently merged PR - https://github.com/vercel/next.js/pull/62065,
doesn't seem to fix the issue. As per the comment this seems to be
related to `dataLayer` that does not like working with Arrays, but works
with [arguments
object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/arguments).
Also, when using window.gtag(...) an Arguments() is pushed instead of
Array().

Fixes #61703
2024-02-17 20:00:04 +00:00
vercel-release-bot
da616e56d2 v14.1.1-canary.58 2024-02-16 23:21:11 +00:00
Tobias Koppers
8ee776dd17
add support for esmExternals in pages (#61983)
### What?

* add support for esmExternals in pages
* fix default of esmExternals to true
* fix serverComponentExternalPackages support
* add test case

fixes PACK-2311
fixes PACK-1916

Fixes https://github.com/vercel/turbo/issues/4544
2024-02-16 23:09:45 +00:00
Will Ashe
e71046b610
Fix sendGAEvent function (#62065)
Previous implementation of `sendGAEvent` was pushing arguments to
`dataLayer` via rest parameter syntax, resulting in an actual array,
which GA doesn't seem to process correctly (resulting in the event not
showing up in GA reports). This PR refactors it to a vanilla JS function
passing data via the `arguments` array-like object, which is able to be
processed correctly and results in the event showing up as expected.

fixes [61703](https://github.com/vercel/next.js/issues/61703)

Co-authored-by: JJ Kasper <jj@jjsweb.site>
2024-02-16 18:56:19 +00:00
OJ Kwon
2e138532fa
docs(next-api): trying to document project_update_info_subscribe (#61962)
### What?

Closes PACK-2469

Trying to add some description to the one of the public interface.

---------

Co-authored-by: Tobias Koppers <tobias.koppers@googlemail.com>
2024-02-16 17:31:00 +00:00
Jiachi Liu
cbdd1d2654
Fix handling subpath for server components externals (#62150)
Follow up of #61986 where we didn't handle the subpath externals very
well, found by @sokra

Closes NEXT-2517
2024-02-16 17:24:12 +01:00
vercel-release-bot
646a3d99db v14.1.1-canary.57 2024-02-16 15:27:46 +00:00
Tim Neutkens
212553958c
Fix issue with ComponentMod being read in Turbopack (#62141)
## What?

Fixes an issue where trying to build an edge runtime page with
generateStaticParams fails to read `ComponentMod`. Discussed with @sokra
and found that changing it to `import()` resolves the problem.

<!-- 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-2514
2024-02-16 16:06:38 +01:00
Tim Neutkens
96599a1b1d
Show build errors from Turbopack (#62139)
## What?

Ensures that when errors happen during compilation they are shown and
the build exits because it can't continue.

<!-- 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-2513
2024-02-16 13:55:28 +01:00
Jiachi Liu
dd24033caf
DX: hide the webpack info prefix for module paths (#62101)
### What

Hide the module file path webpack prefix for better visualization.
There're few types of webpack module prefixes 

- `wepack://`
- `wepack:///`
- `webpack://_N_E`
- `webpack-internal:///`

We're stripping them from the module path

### After vs Before
<img width="320"
src="https://github.com/vercel/next.js/assets/4800338/a9f5ae61-4fbf-42d7-b3e0-9bed1c7babb4">
<img width="420"
src="https://github.com/vercel/next.js/assets/4800338/ed6e120a-7c1c-4c31-be5d-9a1726d4e20c">


Closes NEXT-1966
Closes NEXT-1983
Closes NEXT-2504
2024-02-16 11:33:34 +01:00
Remco Haszing
d407a016c0
Fix @next/mdx types (#57580)
It’s not possible to combine `export =` type definitions with ESM-style
exports. To export types for a module that uses `module.exports =`, one
needs to use a namespace.

Also `Options` is now imported from `@mdx-js/loader`. The imports need
to come from a direct dependency or peer dependency. Also
`@mdx-js/loader` is more accurate here, because the options are passed
into `@mdx-js/loader`.

---------

Co-authored-by: JJ Kasper <jj@jjsweb.site>
2024-02-15 20:54:43 -08:00
Dima Voytenko
b4db808822
OpenTelemetry: trace API routes in page router (#62120)
Co-authored-by: JJ Kasper <jj@jjsweb.site>
2024-02-16 03:45:59 +00:00
Erfan
b2e5c014e5
Add polyfill for Object.hasOwn (#60437)
`Object.hasOwn` should be in list of default polyfills. It's a widely
used feature of ES2022

---------

Co-authored-by: JJ Kasper <jj@jjsweb.site>
2024-02-16 01:32:05 +00:00
Will Binns-Smith
60b60683bd
Update to turbopack-240215.5 (#62119)
Includes:
- https://github.com/vercel/turbo/pull/7401

This makes “conversion to class component” Turbopack tests pass.
2024-02-16 00:52:29 +00:00
Jiachi Liu
3c4ec650b3
Should not warn metadataBase missing if only absolute urls are present (#61898)
### What

* Narrow down the metadata base warnings only when there's any relative
urls need to be resolved, if there's only absolute urls present, no need
to resolve and we don't warn.
* Polish the error message, updated from "metadata.metadataBase is not
set ..." to "metadataBase property in metadata export is not set ..."

### Why

It will be confusing if we're still show metadataBase warning when
there's no need to set one, since the social image cards only have
absolute urls

Closes NEXT-2426
2024-02-16 00:29:55 +01:00
vercel-release-bot
994fdd71ea v14.1.1-canary.56 2024-02-15 23:22:35 +00:00
Shu Ding
d19d802671
Improve the Server Actions SWC transform (part 2) (#62052)
This fills the last piece in the puzzle and it's based on #61001. In
#61001 we covered the case of nested Server Action definition in a non
"use server" file. And this PR extends that to a "use server" file so
exported values are automatically handled just like before, but any
other definitions including nested ones will be hoisted and marked
correctly now.

```ts
'use server'

let a, f

export async function action0(b, c, ...g) { // <- Handled like before.
  return async function action1(d) {        // <- Renamed, marked and hoisted.
    'use server'
    let f
    console.log(...window, { window })
    console.log(a, b, action2)

    async function action2(e) {             // <- Renamed, marked and hoisted.
      'use server'
      console.log(a, c, d, e, f, g)
    }

    return [
      action2,
      async function action3(e) {           // <- Renamed, marked and hoisted.
        'use server'
        action2(e)
        console.log(a, c, d, e)
      },
    ]
  }
}
```

Closes NEXT-2491
2024-02-15 23:41:52 +01:00
Tim Neutkens
afd22c0251
Consolidate NextMode checks (#62106)
## What?

Consolidating the checks for NextMode so that it's easier to find where
it's implemented.

<!-- 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-2508
2024-02-15 14:19:44 -08:00
Jiachi Liu
dc71a5721b
Fix trailing slash for canonical url (#62109)
### What

We should respect the `trailingSlash` config for metadata canonical url,
this PR is adding the handling for strip or keep the trailing slash for
canonical url. Passing down trailingSlash config to metadata resolving
to decide how we handle it.

### Why

The tricky one was `/` pathname, when visiting the origin directly, that
it will always have at least `/` in the URL instance. But for the
default `origin`, it shouldn't show the `/` if the `trailingSlash`
config is `false`. Also it should show trailing slash for all pathnames
if that config is enabled.

BTW there's a `__NEXT_TRAILING_SLASH` env but since we're using the
fixed nextjs runtime module, so this can't be dynamically replaced in
the metadata resolving modules. So we didn't use it

Fixes #54070 
Closes NEXT-2424
2024-02-15 18:57:15 +01:00
Steven
e61497f18d
fix: add zeromq to server-external-packages.json (#62105)
The package [`zeromq`](https://unpkg.com/browse/zeromq@6.0.0-beta.19/)
contains native `.node` files that cannot be bundled (similar to
https://github.com/vercel/next.js/pull/60243)

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

Closes NEXT-2507
2024-02-15 17:00:23 +00:00
Tim Neutkens
2b177d654d
Implement Vc<NextMode> (#62099)
## What?

Ensures that `NextMode` is passed through based on the project setting
instead of hardcoding it to development in various places in the
Turbopack integration.

<!-- 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-2503
2024-02-15 17:26:35 +01:00
OJ Kwon
00633f1774
docs(turbopack): move docs to separate (#62069)
### What

For better organization, extracting docs into separate location.

Closes PACK-2494
2024-02-15 08:05:48 -08:00
Tobias Koppers
e1787bb719
Turbopack: add support for dynamic requests in require() and import() (#62092)
### What?

see https://github.com/vercel/turbo/pull/7398

### Turbopack Changes

* https://github.com/vercel/turbo/pull/7367 <!-- Tobias Koppers - add
custom_extensions to resolve options context -->
* https://github.com/vercel/turbo/pull/7398 <!-- Tobias Koppers - add
support for dynamic requests in require() and import() -->


Closes PACK-2513
2024-02-15 15:31:28 +00:00
vercel-release-bot
25809e83d1 v14.1.1-canary.55 2024-02-15 14:59:22 +00:00
Zack Tanner
5309c30c7d
make router restore action resilient to a missing tree (#62098)
### What
Following an anchor link to a hash param, and then attempting to use
`history.pushState` or `history.replaceState`, would result in an MPA
navigation to the targeted URL.

### Why
In #61822, a guard was added to prevent calling `ACTION_RESTORE` with a
missing tree, to match other call-sites where we do the same. This was
to prevent the app from crashing in the case where app router internals
weren't available in the history state. The original assumption was that
this is a rare / unlikely edge case. However the above scenario is a
very probable case where this can happen, and triggering an MPA
navigation isn't ideal.

### How
This updates `ACTION_RESTORE` to be resilient to an undefined router
state tree. When this happens, we'll still trigger the restore action to
sync params, but use the existing flight router state.

Closes NEXT-2502
2024-02-15 14:10:29 +00:00
Tim Neutkens
079fe5432f
Remove unused app-turbopack files (#62087)
## What?

Noticed this file was being `require`ed but doesn't actually hold
anything relevant as the flag it adds was removed already.

Also found that in the next-core crate there were files that are no
longer needed as it uses Next.js directly now. That fixes a bug when
running with `NextMode::Build` as well, as it couldn't resolve some of
these unused files.

<!-- 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-2500
2024-02-15 13:50:35 +01:00
Tim Neutkens
b3cd381d76
Add dev option to Turbopack createProject() (#62083)
## What?

Adds the `dev` option to switch between development and production
output flags for Turbopack.
Note: This only adds the option, the `false` value (production) doesn't
work yet.

<!-- 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-2499
2024-02-15 13:50:08 +01:00
Balázs Orbán
9648475045
chore: hide version info parse error (#62084)
### What?

Currently, if the network call to the
`https://registry.npmjs.org/-/package/next/dist-tags` endpoint fails,
the error is still logged to the terminal.

### Why?

This might be unnecessary as it is likely unactionable and only creates
noise for the user.

### How?

Drop the logging of the error if it's network-related, but log as before
otherwise.
I.e: any other error should still show up:


![image](https://github.com/vercel/next.js/assets/18369201/1e01fe35-aed9-418c-8e0e-f4ee34624eb5)

I also re-enabled some related tests that were skipped.

Closes NEXT-2393

[Slack
thread](https://vercel.slack.com/archives/C03KAR5DCKC/p1707326242303969)
2024-02-15 13:16:17 +01:00
Tobias Koppers
9572dfd80c
update turbopack (#62080)
* https://github.com/vercel/turbo/pull/7347 <!-- Tobias Koppers - avoid
resolving recursive main field -->
* https://github.com/vercel/turbo/pull/7349 <!-- Tobias Koppers - dedupe
resolving independent on reference type -->
* https://github.com/vercel/turbo/pull/7391 <!-- OJ Kwon -
feat(tasks-fs): allow to skip subpath invalidation -->
2024-02-15 12:41:26 +01:00
Tim Neutkens
e1a2d13277
Ensure Turbopack writes font optimization manifest (#62079)
## What?

Even though we don't support the legacy font optimization (what came
before `next/font`) the manifest is read during builds, so we have to
write an empty version of it.

<!-- 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-2498
2024-02-15 11:11:45 +00:00
Tim Neutkens
bf5ddd4c25
More hot-reloader-turbopack refactors (#62055)
## What?

Follow-up to #61993

More code moved to be used for builds in the future.

<!-- 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-2492
2024-02-15 08:53:36 +01:00
OJ Kwon
9d4954998d
fix(next-core): apply image-loader alias to the remaining context (#62070)
### What?

Fix custom image loader not being reflected in some contexts and running
the default image loader when next.config.js is present. For Webpack,
this alias is specified in `createWebpackAlias`
(8d28d5954e/packages/next/src/build/create-compiler-aliases.ts (L22))
and this setting seems to be context-agnostic in base
(8d28d5954e/packages/next/src/build/webpack-config.ts (L649)).

Closes PACK-2509
2024-02-14 20:21:16 -08:00
vercel-release-bot
aca5336449 v14.1.1-canary.54 2024-02-14 23:22:56 +00:00
JJ Kasper
df2e09f095
Fix output: export with custom distDir (#62064)
This ensures we don't normalize the `distDir` in the webpack config in
dev mode as it won't be moved to the right location like it is during
build.

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

Closes NEXT-2495
2024-02-14 21:23:10 +00:00
OJ Kwon
d857636851
docs(turbopack): revise links (#62062)
### What?

Minor update to additional links.

PACK-2493
2024-02-14 13:18:19 -08:00
Jiachi Liu
cfedc529c7
Fix extra swc optimizer applied to node_modules in browser layer (#62051)
### What

Disable swc transform optimizer for node_modules in browser layer of app
router bundles

Fixes #61858
Fixes #60644 
Fixes #60920
Fixes #61740
Closes NEXT-2418

### Why

In browser there could be not only one runtime, it could have both js
worker and browser. In js worker the `typeof window` is not as same as
in browser, so disabling the swc optimizer which will replace the code.
Leave the condition as it as.
2024-02-14 21:58:39 +01:00
Phil Z
9559e440f4
Add puppeteer-core to server-external-packages.json (#62063)
<!-- 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 #

-->

Adding `puppeteer-core` after discussion about a customer issue:
https://vercel.slack.com/archives/C0676QZBWKS/p1707940401705889
2024-02-14 12:52:23 -08:00
vercel-release-bot
ea65cb6541 v14.1.1-canary.53 2024-02-14 19:15:51 +00:00
Leah
60f0837b67
refactor(tests): make chain more "correct" (#51728)
### Why?

I really dislike the way `.chain` works right now, it shouldn't mutate
the `BrowserInterface`, this PR changes it so it's just a pure chain
without weird side effects.

One example with the current version (before this PR):
```
const el = browser.elementByCss('#version-2')
await el.text()
// throws
await el.text()
```

### Additional Changes

- removes selenium (which is completely unused)
- updates playwright
- makes the playwright tracing not error all the time
2024-02-14 20:14:24 +01:00
Leah
f336bd6ada
fix(turbopack): react-dom/server in rsc context (#61165)
### What?
Probably not the right solution, next.js disables the `react-server`
import condition in there somehow I think

### Why?

Resend uses `@react-email/render` which uses `renderToString` from
`react-dom/server`.
Unfortunately importing `react-dom/server` with the `react-server`
import condition leads to a broken bundle (which seems like a bug in
react?).

Closes PACK-2243
Fixes #57936
2024-02-14 20:14:10 +01:00
Zack Tanner
fffa4c3d9b
fix navigation applying stale data when triggered from global not found (#62033)
### What
When a global not found page is rendered, and when the not-found page or
containing layout has a link with `prefetch: auto` back to the root
page, the router would update the URL but not correctly swap out the
not-found component with the page component.

### Why
With auto prefetching (which is the default when `prefetch` is left
unspecified on a link), the router will perform a partial prefetch on
dynamic pages. This means it'll fetch the flight data _without_ React
nodes and store it in the prefetch cache. On navigation, this is used to
determine where we already have cached React nodes and where we need to
trigger a lazy fetch to get new data. However, global not found pages
are peculiar in that they will always contain a data path like: `['', {
children: ['__PAGE__', {}] }]` since they are inserted at the root. This
means that if there's also a page component that corresponds with the
same path, the router will incorrectly think it already has cache node
data for it.

### How
During SSR when the `asNotFound` flag signals to the renderer that the
component we're rendering is matching the global not-found page, we
modify the segment key to be something unique so the data path won't
collide with a top-level page.

In
[fc01c8e](fc01c8e7f7)
I added handling only on the server to modify the segment key. This
still fixes the issue, but at the cost of triggering an MPA navigation
on the client because it's treated as a root layout change

In
[69d5687](69d5687765)
I added client handling to not treat this special segment key as a root
layout change, and to signal to the router it needs to refetch the data.
This ensures we don't do an MPA navigation.

Fixes #61956
Closes NEXT-2481

---------

Co-authored-by: JJ Kasper <jj@jjsweb.site>
2024-02-14 10:46:31 -08:00
OJ Kwon
56d35ede8e
fix(custom-transform): allow to assert empty program for rsc (#61922)
### What?
Turbopack uses `parse_as_prorgram`, and in case of empty file it returns
script instead of module so none of visitor runs for the rsc module.

This PR attempts to workaround, however need double clarification if
upstream swc behavior is desired.

Closes PACK-2460
2024-02-14 09:14:32 -08:00
OJ Kwon
65dc55a5eb
docs(turbopack): conslidate existing links (#62034)
### What?

This PR improves turbopack documentation, mostly collects existing
documents into a single place.

Also, adds a support to render mermaid diagram.

Closes PACK-2488
2024-02-14 09:12:33 -08:00
Florian Lopez Plaza
7ba4a0d53d
FIX [#58788]: Fixed useParams hook undesired re-renders and updated it to use PathParamsContext in the app router. (#60708)
Moved app-dir path params parsing logic from `useParams` to `AppRouter`.
This allows for the use of `PathParamsContext` in the `useParams` hook
for both pages and app routers. In addition, this allows for memoization
of the layout tree which fixes undesired re-renders of the `useParams`
hook.

Fixes [#58788](https://github.com/vercel/next.js/issues/58788)
Closes NEXT-2434

---------

Co-authored-by: Zack Tanner <zacktanner@gmail.com>
2024-02-14 16:52:44 +00:00
Jiachi Liu
07c652a120
Fix server components externals on SSR layer (#61986)
### What

Fix the externals resolving for server rendering layer for app router.
For SSR requests, if it's next externals, we resolved and return early,
if we didn't resolve, keep going through the following externals
resolving

### Why

Previously on app router's SSR bundling layer, we didn't go through the
following requests when seeing an server external package, it will keep
bundling even it's in server components external packages.

A bug found in #61983 

Closes NEXT-2473
2024-02-14 16:25:57 +01:00
Jonas-PFX
7744cc91be
fix: handle multiple x-forwarded-proto headers (#58824)
### What?
This PR changes how protocol is determined.
A change was recently made (in [PR
57815](1caa58087a (diff-c49c4767e6ed8627e6e1b8f96b141ee13246153f5e9142e1da03450c8e81e96fR1744)))
that did not take into account cases where there are multiple
`x-forwarded-proto` headers. In such cases, the protocol becomes e.g
"https, https".

### Why?
An error will occur in parseUrl on line 1616, since its not a valid url
(e.g. `https, https://localhost:3000`).

### How?
Reverted part of the changes in [PR
57815](https://github.com/vercel/next.js/pull/57815).

Fixes #58764 and fixes #59031

Closes NEXT-2437

---------

Co-authored-by: Balázs Orbán <info@balazsorban.com>
2024-02-14 14:47:26 +01:00
Shu Ding
45b18bb77e
Rename internal utility naming for clarification (#62048)
`createActionProxy` isn't the accurate name here - the function doesn't
return anything new but only mark the value as registered. And also, it
might not be a proxy (which is implementation detail) and might not be
used for Server Actions only. `registerServerReference` is a better name
here.

There's no functionality change in this PR, only a few renames.

Closes NEXT-2490
2024-02-14 14:09:27 +01:00
Leah
0c21654845
merge pages and app overlays (#60899)
### What

Merges the package into the internal overlay.


### Detailed Changes

* Move `@next/react-dev-overlay` into next package and rename the import
paths.
* Fix the `getErrorSource` symbol issue, use `Symbol.for()` instead of
`Symbol`
* Extra `getErrorSource` into single lib as it's being used in a lot of
places, this will keep the same bundle size

Closes PACK-2261
Closes NEXT-1977

---------

Co-authored-by: Jiachi Liu <inbox@huozhi.im>
2024-02-14 11:28:13 +01:00
Donny/강동윤
24f9812e36
build: Update swc_core to v0.90.8 (#61976)
### What?

Update swc crates one more time.

### Why?

To apply https://github.com/swc-project/plugins/pull/267

### How?

Fixes #61788

Closes PACK-2446
Closes PACK-2476
2024-02-14 07:09:57 +00:00
OJ Kwon
39deaa5976
refactor(next-core): do not reexport turbopack_binding (#62018)
### What

Minor correction to the imports, turbopack_binding should not be
reexported.


Closes PACK-2490
2024-02-13 16:53:37 -08:00
Steven
17fd7a5ce6
fix: bump @vercel/nft@0.26.4 (#62019)
- Release https://github.com/vercel/nft/releases/tag/0.26.4
- Fixes https://github.com/vercel/next.js/issues/61844

Fixes NEXT-2485
2024-02-13 18:53:01 -05:00
vercel-release-bot
9e918dec8b v14.1.1-canary.52 2024-02-13 23:21:40 +00:00
JJ Kasper
49b4331e26
Reduce memory/cache overhead from over loader processing (#62005)
In `v14.0.2-canary.1` users started noticing more memory errors
especially with many edge runtime configured pages. After investigation
it seems this can be related to the additional transpiling we configured
in https://github.com/vercel/next.js/pull/59569 and
https://github.com/vercel/next.js/pull/57784

To help alleviate this we are updating the default swc loader to have an
additional check to see if no special features such as `next/font`,
`next/dynamic`, or `use server/client` directives are present and then
no-oping in the loader to avoid additional overhead for a majority of
modules.

For monitoring regressions our `stats-app` has been updated with
repeated edge-ssr routes to hopefully help us keep an eye on memory or
cache size issues.

x-ref: NEXT-2430
x-ref: NEXT-2395
x-ref: NEXT-2299
x-ref: NEXT-2324
x-ref: NEXT-2373

Closes NEXT-2479
2024-02-13 22:40:19 +00:00
OJ Kwon
8b4005e792
docs(turbopack): reduce documentation size (#62016)
### What

next_core unexpectedly reexports everything, makes documentation size
too large.

Closes PACK-2480
2024-02-13 14:36:11 -08:00
OJ Kwon
2567b35acd
fix(next-core): correct error message (#62011)
<!-- 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 PACK-2486
2024-02-13 13:37:02 -08:00
OJ Kwon
1dc3c01030
docs(turbopack): build more docs (#61977)
### What

This PR changes setup for the turbopack documentation.

Long story in short, we want to 2 types of documentation: one for high
level description (archtecture, etcs) and another for the api doc.
rustdoc / cargo doc unfortunately doesn't support to integrate both
easily.

PR adds mdbook setup to workaround those - instead of using rustdoc's
index as entrypoint, mdbook becomes an entrypoint to rustdoc. This
allows to host plain text document, and also able to access full rustdoc
pages.


preview: https://turbopack-rust-docs-b6qta4xdq.vercel.sh/
rustdoc:
https://turbopack-rust-docs-b6qta4xdq.vercel.sh/rustdoc/index.html


Closes PACK-2475
Closes PACK-2468
2024-02-13 12:17:25 -08:00
Tobias Koppers
292ebad893
log fast refresh in app dir (#61441)
### What?

log fast refresh timing in app dir

### Why?

We have a similar log line in pages


Closes PACK-2336
2024-02-13 09:06:44 -08:00
Tim Neutkens
0a58a0d07f
Remove leftover server addr references (#61997)
## What?

Follow-up to #61932 to remove serverAddr references from the JS code
too.

<!-- 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-2477
2024-02-13 17:36:41 +01:00
Zack Tanner
4e03b85cee
seed prefetch cache with initial page (#61535)
### What
When navigating back to a page that you had already loaded, it currently
results in a prefetch cache miss and will re-trigger any data
fetching/loading despite it being available.

### Why
When creating the initial router state, the prefetch cache is
initialized to an empty map.

### How
This uses the `initialTree` passed from the server to seed the cache for
that route with flight data.

Closes NEXT-2001
2024-02-13 15:42:53 +00:00
Zack Tanner
b9861fd2cd
only prefix prefetch cache entries if they vary based on Next-URL (#61235)
### What
Prefetches to pages within a shared layout would frequently cache miss
despite having the data available. This causes the "instant navigation"
behavior (with the 30s/5min TTL) to not be effective on these pages.

### Why
In #59861, `nextUrl` was added as a prefetch cache key prefix to ensure
multiple interception routes that correspond to the same URL wouldn't
clash in the prefetch cache. However this causes a problem in the case
where you're navigating between sub-pages. To illustrate the issue,
consider the case where you load `/foo`. This will populate the prefetch
cache with an entry of `{foo: <PrefetchCacheNode}`. Navigating to
`/foo/bar`, with a link that prefetches back to `/foo`, will now result
in a new cache node: `{foo: <PrefetchCacheNode>, /foo/bar%/foo:
<PrefetchCacheNode>}` (where `Next-URL` is `/foo/bar`). Now we have a
cache entry for the full data, as well as a cache entry for a partial
prefetch up to the nearest loading boundary. Now when we navigate back
to `/foo`, the router will see that it's missing data, and need to
lazy-fetch the data triggering the loading boundary.

This was especially noticeable in the case where you have a route group
with it's own loading.js file because it creates a level of hierarchy in
the React tree, and suspending on the data fetch would result in the
group's loading boundary to be triggered. In the non-route group
scenario, there's still a bug here but it would stall on the data fetch
rather than triggering a boundary.

### How
In #61794 we conditionally send `Next-URL` as part of the `Vary` header
if we detect it could be intercepted. We use this information when
creating the prefetch entry to prefix it, in case it corresponds with an
intercepted route.

Closes NEXT-2193
2024-02-13 15:03:37 +00:00
Tim Neutkens
dc886090bc
Use destructured object for #61993 (#61996)
## What?

Applies the suggestion to use an object for the parameter from #61993.

<!-- 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-2475
2024-02-13 16:02:09 +01:00
Tim Neutkens
f4f0293895
More hot-reloader-turbopack refactors (#61993)
## What?

Follow-up to #61940. Splitting out additional logic so that it can be
used for builds later.

<!-- 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-2474
2024-02-13 15:29:22 +01:00
Tobias Koppers
310c9beead
Turbopack: remove server addr (#61932)
### What?

remove server_addr option

### Why?

We no longer need the server addr for bundling.


Closes PACK-2462
2024-02-13 13:12:30 +00:00
Donny/강동윤
42872bf423
Update swc_core to v0.90.7 and update turbopack (#61662)
# Turbopack changes

* https://github.com/vercel/turbo/pull/7342 <!-- OJ Kwon - docs(turbopack): build, deploy rustdocs -->
* https://github.com/vercel/turbo/pull/7356 <!-- OJ Kwon - ci(workflow): remove doc deploy -->
* https://github.com/vercel/turbo/pull/7272 <!-- Donny/강동윤 - build: Update `swc_core` to `v0.90.7` -->


### What?

Update swc crates

### Why?

- To apply https://github.com/swc-project/swc/pull/8532 and other bugfixes

### How?

 - Closes PACK-2389
 - Closes PACK-2446
 - Closes #61788
2024-02-13 04:20:16 +00:00
Zack Tanner
a4f46bc157
Fix empty white page with parallel routes + loading boundaries (#61597)
### What
When navigating to a page that uses a loading boundary + parallel route,
an empty white screen would be displayed rather than the loading state /
final state

### Why
With parallel routes, the RSC data is an array of data paths, each
corresponding with one of the parallel segments rendered on the page.

During the navigation event, when we iterate over this data, we call
`applyFlightData` with this data path & an empty cache node.
`applyFlightData` checks to see if the flight data contains cache nodes
("seed data"). If it doesn't, then that means it has no work to do, and
it bails out. Pre-PPR and in the case of having a `loading.js` file,
`walkTreeWithFlightRouterState` doesn't return any seed data, just
router state. This means that `applyFlightData` will not have any work
to do on the new cache node, and leaves it untouched.

Once `applyFlightData` is finished, but while still in the flight data
path loop, we reassign `currentCache` to the empty cache object we
created prior to `applyFlightData`. But since that cache node has
remained empty, the next iteration of the loop is going to be inspecting
a now empty cache, rather than the actual "current" cache. Now there's
no existing cache to copy into the new cache. The app now doesn't know
about any cache nodes.

### How
It doesn't seem like we should be re-assigning `currentCache` to the new
cache. In the context of a navigation, it seems more accurate to always
assume `currentCache` is the cache _now_, since it won't actually be
applied to the state until the action has finished (`mutable.cache` is
currently taking care of this).

Closes NEXT-2223
Fixes #61080
2024-02-12 16:30:52 -08:00
Josh Story
ff7c5c2ba3
Support resuming a complete HTML prerender that has dynamic flight data (#60865)
followup to: https://github.com/vercel/next.js/pull/60645

### Background

When prerendering the determination of whether a prerender is fully
static or partially static should not be directly related to whether
there is a postponed state or not. When rendering RSC it is possible to
postpone because a dynamic API was used but then on the client (SSR) the
postpone is never encountered. This can happen when a server component
is passed to a client component and the client component conditionally
renders the server component.

Today if this happens the entire output would be considered static when
in fact the flight data encoded into the page and used for bootstrapping
the client router contains dynamic holes. Today this is blocked by an
error that incorrectly assumes that this case means the user caught the
postpone in the client layer but as shown above this may not be the
case.

### Implementation

A more capable model is to think of the outcome of a prerender as having
3 possible states
1. Dynamic HTML: The HTML produces by the prerender has dynamic holes.
we save the static prelude but expect to resume the render later to
complete the HTML. This means we will resume the RSC part of the render
as well
2. Dynamic Data: The HTML is completely static but the RSC data encoded
into the page is dynamic. We don't want to resume the render but we do
need to produce new inlined RSC data during a Request.
3. Static: The HTML is completely static and so is the RSC data encoded
into the page. We save the entire HTML output and there will be no
dynamic continuation when this route is visited.

Really 1 & 3 are the same as today (Partially static & Fully Static
respectively) but case 2 which today errors in a confusing way is now
supported.

In addition implementing the Dynamic Data case the old warning about
catching postpones is removed. The reason we don't want this is that
catching postpones is potentially a valid way to do optimistic UI. We
probably want a first-party API for it at some point (and maybe we'll
add the warning back in once we do) but imagine you do something dynamic
like look up a user but during prerender you want to render as if the
user is logged out. you could call `getUser()` in a try catch and render
fallback UI if it throws. In this case we'd detect a dynamic API was
used but we wouldn't have a corresponding postpone state which would put
us in the Dynamic Data case (2).

Another item to note is that we can produce a fully static result even
if there is a postponed state because users may call postpone themselves
even if they are not calling dynamic APIs like headers or cookies. When
this happens we don't want to statically capture a page with postponed
boundaries in it. Instead we immediately resume the render and abort it
with a postponed abort signal. This will cause the boundaries to
immediately enter client render mode which should speed up recovery on
the client.

#### Technical Note

Another note about the implementation is that you'll see that regardless
of which case we are in, if there is a postponed state but we consider
the page to be Dynamic Data meaning we want to serialize all the HTML
and NOT do a resume in the dynamic continuation then we immediately
resume the render with and already aborted AbortSignal. The purpose here
is to mark any boundaries which have dynamic holes as being
client-rendered.

As a general rule if the render produces a postponed state we must do
one of the following
1. save the postponed state and ensure there is a dynamic continuation
that calls resume
2. immediately resume the render and save the concatenated output and
ensure the dynamic continuation does NOT call resume.

or said another way, every postponed state must be resumed (even if it
didn't come from Next's dynamic APIs)

#### Perf considerations

This PR modifies a few key areas to improve perf.

Reduces quantity of *Stream instances where possible as these add
significant overhead
Reduces extra closures to lower allocations and keep functions in
monomorphic form where possible


Closes NEXT-2164
2024-02-12 15:59:13 -08:00
vercel-release-bot
e3fa949d77 v14.1.1-canary.51 2024-02-12 23:21:34 +00:00
OJ Kwon
b04c70335d
ci(workflow): deploy rustdocs for turbopack (#61958)
### What

We'd like to deploy generated rustdocs from turbopack & related packages
(next-swc), setting up a CI workflow to automate those.

Since we need next.js side packages to build docs, this CI sets up
things in this repo.

Closes PACK-2375.
2024-02-12 15:14:36 -08:00
vercel-release-bot
4107f609a7 v14.1.1-canary.50 2024-02-12 18:45:11 +00:00
OJ Kwon
d7f1e4552a
build(cargo): update turbopack for filewatcher fix (#61955)
<!-- Thanks for opening a PR! Your contribution is much appreciated.
To make sure your PR is handled as smoothly as possible we request that
you follow the checklist sections below.
Choose the right checklist for the change(s) that you're making:

## For Contributors

### Improving Documentation

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

### Adding or Updating Examples

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

### Fixing a bug

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

### Adding a feature

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


## For Maintainers

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

### What?

### Why?

### How?

Closes NEXT-
Fixes #

-->

### What

* https://github.com/vercel/turbo/pull/7340 <!-- OJ Kwon -
feat(tasks-fs): bump up notify, fix empty file watch -->

Bump up turbopack PR to fix hmr issues.

Closes PACK-2466
2024-02-12 10:41:39 -08:00
vercel-release-bot
6a049eaf0c v14.1.1-canary.49 2024-02-12 18:11:59 +00:00
OJ Kwon
63f160e8b3
build(cargo): bump up turbopack to latest (#61952)
### What?

Bump up turbopack to latest. This is to cut off turbopack **before**
including filewatcher changes, so we can easily bisect & revert if
watcher have regressions.
2024-02-12 10:08:40 -08:00
Steven
9cf2a3273d
fix(next/image): improve warning when fill and sizes="100vw" (#61949)
Previously, this error was confusing because it made it sound like the
`sizes` prop was missing. This was because the default value of `sizes`
is `100vw` so the previous code couldn't tell the different between
implicit vs explicit `100vw`.

This PR changes the code to read the input value from the `sizes` prop
and prints a better warning.


Fixes NEXT-2441
2024-02-12 17:32:39 +00:00
Tim Neutkens
8ce6365f52
More hot-reloader-turbopack refactors (#61940)
## What?

Follow-up to #61929. More refactors to move the logic out of
`createHotReloaderTurbopack` so that these functions can be used for
builds later too.

<!-- 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-2440
2024-02-12 16:57:29 +01:00
Tim Neutkens
94c0152f67
hot-reloader-turbopack refactors (#61929)
## What?

Follow-up to #61917. Splitting out more code from the development
handling so that it can be used for builds too in a later PR.

<!-- 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-2429
2024-02-12 12:17:47 +00:00
Tim Neutkens
cc1d40f741
Move turbopack helpers (#61917)
## What?

Refactors the Turbopack dev bundler creation to a separate file, similar
to hot-reloader-webpack.

<!-- 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-2427
2024-02-12 09:03:51 +01:00
vercel-release-bot
5437fdaa15 v14.1.1-canary.48 2024-02-11 23:22:10 +00:00
vercel-release-bot
03b652a955 v14.1.1-canary.47 2024-02-10 23:21:27 +00:00
vercel-release-bot
194311d8c9 v14.1.1-canary.46 2024-02-09 21:49:06 +00:00
Josh Story
0525ec3c47
Update app-index to only ever construct the initial data response once (#61869)
There was a bug where if the root hydrates and then an update happens
the intitial server data response can be replaced by one that is
completely empty and will never resolve. This can lead to a frozen
hydration that blocks interactivity. This udpate makes it so it is
impossible for the initial data response to ever be created more than
once.

Making a regression test is tricky because this relies on subtle timing
of hydration, updates, and when the inline chunks arrive in the stream.
The original implementation is just not safe in that it violates the
rules of react and the new one is self-evidently unable to produce a
similar situation so as long as our existing test suite passes that must
be sufficient absent a good alternative to making a specific regression
test

Closes NEXT-2420
2024-02-09 13:44:51 -08:00
Zack Tanner
3e3c012726
provide interception rewrites to edge runtime (#61414)
In #61794, the routes manifest is used to find the interception route rewrites in `next-server` and computed on the fly in `next-dev-server` based on `appPaths`.

The edge runtime doesn't have access to the routes manifest nor a full list of app paths. This writes an entry for the edge runtime to make the interception routes readable, and adds plumbing to return them in the `getInterceptionRouteRewrites` handling in `web-server`. This is what we use to signal to the server whether to return ‘Next-URL’ in the Vary for RSC requests. 

This piggybacks on the existing interception routes test but adds an edge runtime case.

Closes NEXT-2304
2024-02-09 10:30:58 -08:00
Zack Tanner
12bfa97e48
conditionally send Next-URL in Vary response (#61794)
To ensure that we properly cache data for routes that change based on `Next-URL` (which is used for route interception), this adjusts how we set the `Vary` header to conditionally include `Next-URL`. 

The `Next-URL` request header only impacts the response for routes that are intercepted. When we detect that path we're handling could be intercepted, we add `Next-URL` to the vary. This signals in #61235 to prefix these cache entries with `nextUrl` if the response might vary based on it. 

Closes NEXT-2398
2024-02-09 09:57:23 -08:00
Tobias Koppers
5c74ed9258
update turbopack (#61187)
### What?

* https://github.com/vercel/turbo/pull/7302 <!-- Tobias Koppers -
support exporting undefined -->
* https://github.com/vercel/turbo/pull/7303 <!-- Tobias Koppers -
improve HMR performance -->
* https://github.com/vercel/turbo/pull/7306 <!-- OJ Kwon - ci(test): add
wasi target check for the supported packages -->
* https://github.com/vercel/turbo/pull/7308 <!-- OJ Kwon - build(cargo):
apply formatting -->
* https://github.com/vercel/turbo/pull/7117 <!-- Tobias Koppers - track
RequestKey during resolving and avoid duplicate keys -->



Closes PACK-2299
2024-02-09 18:57:15 +01:00
vercel-release-bot
f8343210dd v14.1.1-canary.45 2024-02-09 09:18:47 +00:00
Zack Tanner
f1655147b4
Update React from 2bc7d336a to ba5e6a832 (#61837)
Updates React from 2bc7d336a to ba5e6a832.

### React upstream changes

- https://github.com/facebook/react/pull/28283
- https://github.com/facebook/react/pull/28280
- https://github.com/facebook/react/pull/28079
- https://github.com/facebook/react/pull/28233
- https://github.com/facebook/react/pull/28276
- https://github.com/facebook/react/pull/28272
- https://github.com/facebook/react/pull/28265
- https://github.com/facebook/react/pull/28259
- https://github.com/facebook/react/pull/28153
- https://github.com/facebook/react/pull/28246
- https://github.com/facebook/react/pull/28218
- https://github.com/facebook/react/pull/28263
- https://github.com/facebook/react/pull/28257
- https://github.com/facebook/react/pull/28261
- https://github.com/facebook/react/pull/28262
- https://github.com/facebook/react/pull/28260
- https://github.com/facebook/react/pull/28258
- https://github.com/facebook/react/pull/27864
- https://github.com/facebook/react/pull/28254
- https://github.com/facebook/react/pull/28219
- https://github.com/facebook/react/pull/28248
- https://github.com/facebook/react/pull/28216
- https://github.com/facebook/react/pull/28249
- https://github.com/facebook/react/pull/28241
- https://github.com/facebook/react/pull/28243
- https://github.com/facebook/react/pull/28253
- https://github.com/facebook/react/pull/28256
- https://github.com/facebook/react/pull/28236
- https://github.com/facebook/react/pull/28237
- https://github.com/facebook/react/pull/28242
- https://github.com/facebook/react/pull/28251
- https://github.com/facebook/react/pull/28252

Closes NEXT-2411
2024-02-09 10:13:45 +01:00
Alexander Savelyev
e8a8221415
fix:(next/image) handle remotePatterns with a dot in the pathname (#60488)
### Fixing a bug

### What?
Fix remotePatterns when all paths and/or domains are allowed.

### Why?

micromatch creates a very strange regex for all paths -
`/^(?:(?!\.)(?:(?:(?!(?:^|[\\/])\.).)*?)[\\/]?)$/`. That is, paths
cannot start with a dot or contain a slash followed by a dot.

Interestingly, here are some valid paths:

- /a/a.a/6a00d8341c4fbe53ef02c8d3a82122200d-600wi
- ////a/a.a/6a00d8341c4fbe53ef02c8d3a82122200d-600wi
- ///:?%;№%/a/a.a/6a00d8341c4fbe53ef02c8d3a82122200d-600wi.\/
- /:./6a00d8341c4fbe53ef02c8d3a82122200d-600wi.\/

And here are some invalid ones:

- /.a/6a00d8341c4fbe53ef02c8d3a82122200d-600wi
- /a/.a/6a00d8341c4fbe53ef02c8d3a82122200d-600wi
- ./a/6a00d8341c4fbe53ef02c8d3a82122200d-600wi

I don't think this check makes any sense.

### How?

If the user allows all (`**`) - it means any path or domain will be
considered valid.

- Fixes #60483
- Fixes #58139
- Fixes #46903

---------

Co-authored-by: Steven <steven@ceriously.com>
2024-02-08 18:21:29 -05:00
Steven
698fcbb8d1
fix: babel usage with next/image (#61835)
### Why

The `process/browser` lib was imported and being transformed, but
`process.browser = true` turns to `true = true` that causes the
compilation error, we need to exclude them from certain compilation
layers

### What

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

Closes NEXT-2410
Closes NEXT-2328

---------

Co-authored-by: Jiachi Liu <inbox@huozhi.im>
2024-02-08 18:16:30 -05:00
Zack Tanner
6f74618486
Guard against restoring router state with missing data (#61822)
Unclear when this can happen currently (hence missing a test), but this adds a safeguard to `applyUrlFromHistoryPushReplace` to ensure that we don't potentially call `ACTION_RESTORE` with data that might be missing from `window.history.state`. 

This is consistent with other spots where we're reading this internal flag from state.

The function that calls `applyUrlFromHistoryPushReplace` first calls `copyNextJsInternalHistoryState` to copy over `__PRIVATE_NEXTJS_INTERNALS_TREE` into the data argument of `pushState`/`replaceState`.  But technically it does so with the possibility that `__PRIVATE_NEXTJS_INTERNALS_TREE` is undefined. Since that's the case, this is more typesafe. 

Closes NEXT-2406
2024-02-08 09:28:23 -08:00
Donny/강동윤
e838f268ec
feat: Allow specifying useLightningcss for styled-jsx (#61359)
### What?

Add `styledJsx` option to the schema.

### Why?

This is required to test `lightningcss` against internal apps.

### How?



Closes PACK-2316
2024-02-08 17:05:29 +01:00
Jiachi Liu
c2a132b5a4
DX: fix error overlay flash (#61813)
### What

Skipping module build error and module not found error in
`onUnhandledError` handler from pages router dev overlay, to avoid the
build error being caught twice by error overlay in both unhandled error
and build error type. The unhandled error is slightly eariler than build
error, which causes the flash. We skipped it to avoid display same
duplicated errors.

### Why

This change fixes a flashing UX on error overlay when build error
occurred, it will go from a white background with red text to a source
panel with actual code where triggered build error, such as synatx
error. I recodered two videos to show them properly. Since it happens
too fast, hard to address them with test, more like fixing a minor
frustration in the UI.


### After

https://github.com/vercel/next.js/assets/4800338/59dcde0f-3ac7-419f-ba5c-c28c9d5a7205

### Before

https://github.com/vercel/next.js/assets/4800338/e64e8855-2c5f-43a5-948c-8137cad538a1



Closes NEXT-2403
Closes NEXT-2145
2024-02-08 16:54:01 +01:00
vercel-release-bot
0114c2cb24 v14.1.1-canary.44 2024-02-08 12:22:09 +00:00
Jimmy Lai
feb27ad621
Revert "feat(next/image)!: remove squoosh in favor of sharp as optional dep" (#61810)
Reverts vercel/next.js#61696

Closes NEXT-2401
2024-02-08 11:00:34 +00:00
Tim Neutkens
b3878423c4
Increase Rust stack size (#61809)
## What?

Follow-up to #61781. That change doesn't apply so the packages we tested
still crashed the process. This ensures the environment variable is set
if it's not already set.

<!-- 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-2400
2024-02-08 10:59:50 +01:00
Will Binns-Smith
50ef635c0c
Fall back loading chunks for sourcemap tracing (#61790)
This implements falling back to try multiple locations loading chunks
for sourcemap tracing.

Unfortunately, when RSC replays server errors on the client, it does not
carry over the [0] symbol used to annotate server frames. Instead,
errors are recreated by React and only include the message and stack.

This allows more tests to pass, as we are able to correctly trace stack
frames by loading the appropriate server chunk.

Closes PACK-2442
2024-02-08 09:05:08 +01:00
OJ Kwon
775e898603
feat(next-core): build time client|server-only assertion (#61732)
### What

This PR injects a build-time error for the turbopack if
`client|server-only` is imported in incorrect context. The basic idea is
using resolve plugin, so in resolve time if matching context (which
alises erroneous import), raise a build time error.

Unfortunately this won't fix all of the tests in `invalid-imports`, due
to

1. resolveplugin does not have way to trace import from transformed, so
not able to detect `styled-jsx` from using `<styled..` tags
2. webpack (in our implementation) and turbopack's resolveplugin have
different order of transform / module trace chain, so enabling resolve
plugin in some context raises build error instead of runtime error in
rsc-build-error.

Closes PACK-2397
2024-02-08 09:04:43 +01:00
Donny/강동윤
c662d57342
fix(next-swc): Detect exports.foo from cjs_finder (#61795)
### What?

Patch cjs finder to detect `exports.foo` (instead of module.exports)

### Why?

This causes an issue for `react.production.min.js`.

x-ref: https://vercel.slack.com/archives/C02HY34AKME/p1707343215879979

### How?

Closes PACK-2443
2024-02-08 11:28:33 +09:00
Tyler Sebastian
70b78c2945
Skip client-side data-fetching after ssr error (#51377)
Fixes: #47978

When an error occurs in getInitialProps, the error page's
getInitialProps is run server-side and returned in `__NEXT_DATA__`.
Following, there's no need to re-run `getInitialProps` client-side on
the hydrate pass.

---------

Co-authored-by: JJ Kasper <jj@jjsweb.site>
2024-02-07 17:24:26 -08:00
Zack Tanner
7c38a667aa
consolidate prefetch utils & separate build util (#61789)
In preparation for the refactor of cache utils in subsequent PRs, this PR moves the one-off prefetch cache utils into a shared `prefetch-cache-utils` file, and also relocates the `buildCustomRoute` util into an isolated lib so that it can be imported into base-server (in a future PR).

This PR does not make any changes to these functions.

Closes NEXT-2394
2024-02-07 16:22:35 -08:00
Jiachi Liu
ed3ee38108
Fix attempted import error for react (#61791)
### What

Exclude precompiled react packages from browser layer loaders coverage.

### Why

Since we're transpiling all the browser layer code now after #59569,
then SWC will also compile react. But when it compiles
`react.production.min.js` it gives me with the code and ESM helper
inserted

```js
import { _ as _type_of } from "@swc/helpers/_/_type_of"; // This is not correct
var l = Symbol.for("react.element"), n = Symbol.for("react.portal"), p = Symbol.for("react.fragment"), q = Sym
bol.for("react.strict_mode"), r = Symbol.for("react.profiler"), t = Symbol.for("react.provider"), u = Symbol.f
```

This makes bundler think it's a ESM package but actually it's CJS, which
converts the module into `{ default: .., __esModule }` instead of the
original react module.

When you're using `React.useEffect` or other API through namespace
import (`import * as React from 'react'`), this will break the module
exports check in bundling as the property doesn't directly attached to
the module now. This PR disabled the transform for precompiled react
packages now and will see the deeper issue in next-swc side later.

Fixes #60890
Fixes #61185

Closes NEXT-2362
2024-02-08 00:57:43 +01:00
Balázs Orbán
53fd5ac0e5
fix(ts): match MiddlewareConfig with documentation (#61718)
### What?

Fix the user-facing `MiddlewareConfig` interface.

~While in the codebase, I also made the incoming config object type a
bit more strict by converting from `any` to `unknown`.~ Reverted, as we
do a config assertion already in a [different
place](https://github.com/vercel/next.js/blob/canary/packages/next-swc/crates/next-custom-transforms/src/transforms/page_config.rs/#L171-L180).

### Why?

The interface we previously exposed was the one we used internally,
_after_ we did some parsing on the config object, which is different
from what the user is expected to pass.

### How?

I separated the internal type to its own `MiddlewareConfigParsed`
interface.

Closes NEXT-2375
Fixes #61705

Ref: #61576
2024-02-07 23:32:03 +00:00
vercel-release-bot
d04cfb68a4 v14.1.1-canary.43 2024-02-07 23:21:21 +00:00
OJ Kwon
13af19a562
build(cargo): add deps for the wasi (#61784)
<!-- 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



### Why?

### How?

Closes NEXT-
Fixes #

-->

### What?

minor config update to the deps to include tokio for the wasi target.


Closes PACK-2435
2024-02-07 10:44:30 -08:00
Tobias Koppers
9d67a9f2d8
partially fix css duplication in app dir (#61198)
### What?

depends on https://github.com/facebook/react/pull/28108

* fixes CSS Ordering issues due to CSS duplication in production mode
* The issues still happen in dev mode
* Highlights broken CSS Ordering for more dev cases, e. g. CSS in client
components


Closes PACK-2300
2024-02-07 17:08:48 +01:00
vercel-release-bot
fa4d1a501c v14.1.1-canary.42 2024-02-07 08:48:27 +00:00
JJ Kasper
56cf916714
Add experimental touchstart flag for testing (#61747)
Adds an experimental flag to allow us to validate `touchstart` handling

x-ref: [slack
thread](https://vercel.slack.com/archives/C03S8ED1DKM/p1707269419316909?thread_ts=1707256828.309319&cid=C03S8ED1DKM)

Closes NEXT-2384
2024-02-07 09:45:20 +01:00
Tobias Koppers
86c46edce7
source map fixes (#61723)
### What?

* show guessed original file for generate code
* avoid internal cast
* add get_source_map method
* hide turbopack runtime stack lines
* hide unmapped stack lines


Closes PACK-2400

Before:


![image](https://github.com/vercel/next.js/assets/1365881/29f24f59-7c77-4496-92de-efcc72d28ad5)

After:


![image](https://github.com/vercel/next.js/assets/1365881/ca07e9f9-71ea-440d-97a2-c2c731ab3899)

and expanded:


![image](https://github.com/vercel/next.js/assets/1365881/1f73e632-890d-4681-8f21-ef502c676aae)

### Other Turbopack changes


* https://github.com/vercel/turbo/pull/4235 <!-- Leah -
chore(turborepo-lib): use compile error for feature validation -->
* https://github.com/vercel/turbo/pull/7285 <!-- Tobias Koppers -
resolve source maps that are attached in source code -->
* https://github.com/vercel/turbo/pull/7301 <!-- Donny/강동윤 -
fix(turbopack): Reverse order of css chunks to fix css module issues -->
* https://github.com/vercel/turbo/pull/7286 <!-- Tobias Koppers - guess
original source for generated code -->
2024-02-07 08:58:08 +01:00
vercel-release-bot
b77373e283 v14.1.1-canary.41 2024-02-07 06:48:49 +00:00
OJ Kwon
f437ebb2c1
feat(next-core): expand matching js extensions for the rules (#61745)
### What?

fixes unexpected use client build warning in some applications.

We've consolidated all the ecmaplugins into custom rules. It behaves
different for the ecma inputs, while plugin runs any ecmascript inputs
rules only runs with matching target. The culprit module in question was
published as `.mjs`, so the necessary transform didn't ran.

Closes PACK-2419
2024-02-06 17:05:32 -08:00
Ahmed Abdelbaset
36a70667b2
fix jsDoc of notFound (#61692)
In #61649 the paragraph `"This function allows you to redirect the user
to another URL. It can be used in..."` describing `notFound` was copied
as is from the `redirect` jsDoc

---------

Co-authored-by: JJ Kasper <jj@jjsweb.site>
2024-02-06 15:56:21 -08:00
vercel-release-bot
b61a709068 v14.1.1-canary.40 2024-02-06 23:21:25 +00:00
vercel-release-bot
f07c2bd559 v14.1.1-canary.39 2024-02-06 23:19:27 +00:00
itz-Me-Pj
98232c8c73
Fix: Error Fetching _devpagesmanifest.json #17274 (#60349)
Closes NEXT-
Fixes #17274 Error Fetching _devpagesmanfest.json

---------

Co-authored-by: JJ Kasper <jj@jjsweb.site>
2024-02-06 15:15:39 -08:00
Will Binns-Smith
0060de1c49
Reapply "Turbopack: convert between locations correctly (#61477)" (#61733) (#61735)
This reverts commit a32d654c73.


Closes PACK-2421
2024-02-06 14:24:30 -08:00
Eddie Jaoude
ad15817f03
docs: fix example code missing comma (#59012)
<!-- 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?

Code example in docs was invalid

### Why?

Missing comma, causing command `npm run dev` to break.

### How?

Closes NEXT-
Fixes #

-->

---------

Co-authored-by: Sam Ko <sam@vercel.com>
2024-02-06 21:59:44 +00:00
Ahmed Abdelbaset
0a796d66f3
Fix duplicate line in README (#61691)
#48717 duplicated the /learn course link in README.md
2024-02-06 20:45:14 +00:00
Will Binns-Smith
a32d654c73
Revert "Turbopack: convert between locations correctly (#61477)" (#61733)
This reverts commit b19585f7fa.


Closes PACK-2420
2024-02-06 20:33:49 +01:00
Wyatt Johnson
252d9cf453
Navigation Signals in PPR (#60450)
### What

This adds support for navigation signals like `notFound()` and
`redirect(url)` when Partial Prerendering has been enabled.

### Why

Navigation API's like `notFound()` and `redirect(url)` throw errors in
order to interrupt the rendering of components. When a page both invokes
API's that cause the render to be marked as dynamic (like
`unstable_noStore()`) and also a navigation API, these errors may race
to the end. In the case where the navigation error does not beat out the
error emitted by dynamic API's will still trigger the detection warning
that's present to warn you about situations where you may have
accidentally caught the error.

### How

This resolves this issue by explicitly checking for navigation signals
(errors) thrown during the render, and not displaying the "caught
dynamic API" error and console warning.

Closes NEXT-2037
2024-02-06 12:25:50 -07:00
vercel-release-bot
300cf76c83 v14.1.1-canary.38 2024-02-06 19:24:56 +00:00
Steven
07c4ec052e
feat(next/image)!: remove squoosh in favor of sharp as optional dep (#61696)
## History

Previously, we added support for `squoosh` because it was a wasm
implementation that "just worked" on all platforms when running `next
dev` for the first time. However, it was slow so we always recommended
manually installing `sharp` for production use cases running `next
build` and `next start`.

Now that [`sharp` supports
webassembly](https://sharp.pixelplumbing.com/install#webassembly), we no
longer need to maintain `squoosh`, so it can be removed. We also don't
need to make the user install sharp manually because it can be installed
under `optionalDependencies`. I left it optional in case there was some
platform that still needed to manually install the wasm variant with
`npm install --cpu=wasm32 sharp` such as codesandbox/stackblitz (I don't
believe sharp has any fallback built in yet).

Since we can guarantee `sharp`, we can also remove `get-orientation` dep
and upgrade `image-size` dep.

I also moved an [existing `sharp`
test](https://github.com/vercel/next.js/pull/56674) into its own fixture
since it was unrelated to image optimization.

## Related Issues
- Fixes https://github.com/vercel/next.js/issues/41417
- Closes https://github.com/vercel/next.js/pull/54670
- Related https://github.com/vercel/next.js/issues/54708
- Related https://github.com/vercel/next.js/issues/44804
- Related https://github.com/vercel/next.js/issues/48820
2024-02-06 14:17:07 -05:00
Will Binns-Smith
b19585f7fa
Turbopack: convert between locations correctly (#61477)
- parsed stack traces (and error stack locations in js) have 1-based
lines and 1-based columns
- source map tokens have 0-based lines and 0-based columns
- babel code frames use 1-based lines and 0-based columns

This was not always respected. This preserves the 1-based lines and
columns in anything called a stack frame, 0-based lines and columns for
source map apis, and converts to babel’s format as needed.


Closes PACK-2341

---------

Co-authored-by: Tobias Koppers <tobias.koppers@googlemail.com>
2024-02-06 11:09:48 -08:00
OJ Kwon
9cadae5eef
feat(next-swc): support wasm32-* build target (#61586)
<!-- 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

### How?

Closes NEXT-
Fixes #

-->

### What?

This PR introduces a ground work to generate wasm bindings package from
our napi bindings. This doesn't actually replace anything yet, however
aim to establish our napi bindings package can be built against wasm32
target.

### Why?

We currently have two bindings package to generate native / wasm target
support, one for napi and one other for wasm. Recently napi-rs started
to support to generate bindings for the wasm directly - which means we
can get rid of the wasm-pack based bindings code entirely and maintain a
single bindings code only.

This'll makes our `next-swc` simpler as well, since the invocation to
the bindings now becomes identical we don't have to additional wasm
specific logics to invoke functions (i.e transform, transformsync..).
Also napi generates wasi-supported wasm bindings, provides few more
features to the current wasm bindings.

#### Good
- Async napi binding fn works transparently (`transform`, `minify`...)
- (Experimental) thread supports depends on node.js runtime
- Wasi support: i.e it can even read filesystem directly!

#### Things to consider
- node.js's wasi support is experimental yet
- napi-rs's wasm support is in beta yet, specifically `packaging`
generated wasm output.

Due to `things to consider` reasons, this PR does not replace existing
wasm target yet. We should be able to plan out things later.

**What happens to the turbopack api in napi bindings?**

Simply put, this **does not support turbopack in wasm**. Build works by
disabling turbopack (more notably, underlying dependency doesn't support
wasm) features. It is something to explore separately.


Closes PACK-2367


There is a branch at https://github.com/vercel/next.js/pull/61586 shows
quick demo for importing, running sync / async / read external files.
2024-02-06 10:15:13 -08:00
Julius Marminge
6d07c00dee
fix: allow some recursion for middleware subrequests (#60615)
This alters the behavior of the subrequest check to allow for 5
recursive calls to match Vercel production, ref [Slack
thread](https://pinglabsworkspace.slack.com/archives/C052S77L05C/p1694729495655489).

> [!NOTE]
> Currently limited by fetches having to forward the subrequest header
for each request which isn't ideal. Need some assistant on how to access
the request in the module context fetch override.
> No forwarding: 
![CleanShot 2024-02-05 at 22 52
10@2x](https://github.com/vercel/next.js/assets/51714798/8ae79f00-f987-4919-946c-d8363d540cef)
> With forwarding: 
![CleanShot 2024-02-05 at 22 51
31@2x](https://github.com/vercel/next.js/assets/51714798/32bd4072-9373-4cb0-ab05-f862a818e0d7)

---------

Co-authored-by: JJ Kasper <jj@jjsweb.site>
2024-02-06 18:00:29 +00:00
OJ Kwon
e652a6f652
feat(transforms): enable rsc transforms for the remaining contexts (#61231)
### What?

This PR wraps up supporting rsc transforms (mostly for the assertion) in
Turbopack. PR contains a few changes to support it, including:

- adjust / expand transform rules for the corresponding contexts
- fix file name / node_modules check
- extract visitors for the assertion / transforms

This change enables most of the rsc-build* tests and some more other
tests. The only failing tests in the rsc-build-errors is due to
Turbopack not triggering hmr with empty file.

Closes PACK-2303
2024-02-06 09:15:07 -08:00
vercel-release-bot
59bf406d0a v14.1.1-canary.37 2024-02-06 17:07:44 +00:00
Jiachi Liu
4aa5e9cad2
Fix next/server api alias for ESM pkg (#61721)
### What & Why

We have a modularize imports config for `next/server` before, which will
transform the `next/server` imports to directly import from the actual
file, for instance: `import { NextRequest } from 'next/server'` will
become `import { NextRequest } from
'next/dist/server/web/exports/next-request'`, where the NextRequest is
exported as default export. This is fine in most case until you're using
a ESM pkg, then it will be resolved as `{ default: NextRequest }`
according to the spec. Since it's a ESM import to a CJS module in
`next/dist`.

Since we already have the ESM alias introduced in #59852 , this can
handle the case more properly.

### How

Remove the modularize imports config for `next/server`, use the ESM api
alias instead.

Migrate the cjs optimizer tests from middleware to a separate endpoint
`/cjs/server`. As now ESM imports for next/server are not going to get
tree-shaken in dev, but since we don't have image response there it's
still fine.

Closes NEXT-2376
Closes NEXT-2374
2024-02-06 16:59:24 +00:00
Zack Tanner
a19b3bc6fb
fix navigation issue when dynamic param casing changes (#61726)
### What
When navigating to a page with dynamic params using a certain casing,
and then following a link to another page using _different_ casing for
the same param, the router would get stuck in an infinite suspense
cycle.

### Why
On the client we normalize cache keys by lowercasing the values for
dynamic segments. However the RSC data for each segment wouldn't have
this same casing logic applied. This is causing the router to not
recognize that there is already RSC data available for that segment,
resulting in an infinite suspense cycle.

### How
The `toLowerCase()` logic shouldn't be needed here. Technically we could
leave this in place and update `matchSegment` to also apply the
lowercase logic, but currently there are too many utility functions that
parse segments to comfortably make that change. I confirmed that the bug
related to why we lowercased these router cache keys is no longer
present after making this change.

Fixes #61722
Closes NEXT-2377
2024-02-06 08:59:18 -08:00
Balázs Orbán
df74a02fe3
fix(ts): ReadonlyURLSearchParams should extend URLSearchParams (#61419)
### What?

Let the developer check the instance of `ReadonlyURLSearchParams` to
match against `URLSearchParams`

### Why?

`useSearchParams()`'s return type is `ReadonlyURLSearchParams` which
implements all the methods of `URLSearchParams`, therefore its type
should be extended from `URLSearchParams` as well. Deprecated methods
are also implemented to throw an error, so no runtime behavior is being
changed

### How?

Mark the unavailable methods as `@deprecated` which will visually mark
them in IDEs:


![image](https://github.com/vercel/next.js/assets/18369201/f3de2858-14ac-4021-981d-b0267610faa7)

This is similar how `ReadonlyHeaders` extends `Headers`, added in:
#49075

[Slack
thread](https://vercel.slack.com/archives/C03KAR5DCKC/p1706628877916779)

Closes NEXT-2305
2024-02-06 16:15:38 +01:00
Zack Tanner
da842e167a
fix loading issue when navigating to page with async metadata (#61687)
### What
Client-side transitioning to a page that triggered a loading boundary
with async metadata would cause the transition to stall, potentially
getting stuck in a refetch loop.

### Why
In layout-router, we trigger a "lazy fetch" when we encounter a segment
that we don't have cache nodes for. This calls out to the server and
suspends until the data fetch is resolved, and applied to the router
tree. However after suspending but before updating the client router, we
set `childNode.lazyData` to null. When we unsuspend from the server
patch action, `childNode.rsc` might still be missing and clearing
`lazyData` means we've blown away the reference to the fetch we already
had pending, triggering a refetch loop.

### How
This removes the logic that mutates the cache node in render, as this is
not concurrent safe, and doesn't appear to be needed for anything.

Fixes #61117
Closes NEXT-2361

---------

Co-authored-by: Jiachi Liu <inbox@huozhi.im>
2024-02-06 07:10:53 -08:00
Leah
f910e2bdcd
chore: update turbopack (#61682)
### Turbopack Updates

* https://github.com/vercel/turbo/pull/7240 <!-- OJ Kwon -
refactor(turbopack): remove deprecated options -->
* https://github.com/vercel/turbo/pull/7241 <!-- Will Binns-Smith -
Turbopack: Fix Next.js in cross-bundler benchmarks -->
* https://github.com/vercel/turbo/pull/7274 <!-- Leah - fix(turbopack):
support reloading typescript tailwind config -->

Fixes #61607
2024-02-06 14:40:15 +01:00
Jiachi Liu
92e4a4b78c
Associate server error digest with browser logged one (#61592)
### What

#### Core
This PR respect the error's digest when recieves new error occurred from
server side, and it will be logged into client on production with the
same `digest` property.
If we discover the original RSC error in SSR error handler, retrieve the
original error

#### Tests

* Move the errors related tests from `test/e2e/app-dir/app` to a
separate test suite `test/e2e/app-dir/errors`
* Add a new test case for logging the original RSC error
* Add a new test case for logging the original Server Action error


### Why

This will help associate the `digest` property of the errors logged from
client with the actual generated server errors. Previously they're
different as we might re-compute the digest proper in handler that react
server renderer thinks it's a new error, which causes we have 2
different errors logged on server side, and 1 logged on client side. The
one on client side can associate to the server errors but it's from
react renderer which is not the original error.

Closes NEXT-2094
Fixes #60684
2024-02-06 13:39:12 +01:00
Tobias Koppers
89fcf68c6a
decode magic identifiers (#61658)
### What?

* decode magic identifiers when printing compile errors to the console
* Error Overlay
  * decode magic identifiers in the error message
  * decode magic identifiers in source frame
  * decode magic identifiers in call stack


![image](https://github.com/vercel/next.js/assets/1365881/836ba497-84dd-4958-8341-4207fc6d860f)

![image](https://github.com/vercel/next.js/assets/1365881/f03d5c9e-0b2f-4699-b7c3-56c38b0eba51)

![image](https://github.com/vercel/next.js/assets/1365881/49a65991-92d8-47b4-863c-961536d98d13)


### Why?

### How?

PACK-2008


Closes PACK-2387
2024-02-06 10:19:07 +00:00
Leah
933c98651c
fix(turbopack): read preload option for google fonts (#61679)
### What?

I forgot to check the `preload` option when implementing it and just
looked at the `subsets`.

This also fixes duplicate preload tags by adding them to a set in the
default `_document.tsx`



Closes PACK-2392
2024-02-06 08:30:12 +01:00
Josh Story
23955574ae
Update React from 60a927d04 to 2bc7d336a (#61522)
Updates React from 60a927d04 to 2bc7d336a

Also updates aliases for `react.shared-subset` to `react.react-server`

### React upstream changes

- https://github.com/facebook/react/pull/28250
- https://github.com/facebook/react/pull/28225
- https://github.com/facebook/react/pull/28123
- https://github.com/facebook/react/pull/28240
- https://github.com/facebook/react/pull/28239
- https://github.com/facebook/react/pull/28245
- https://github.com/facebook/react/pull/28244
- https://github.com/facebook/react/pull/28238
- https://github.com/facebook/react/pull/28235
- https://github.com/facebook/react/pull/28221
- https://github.com/facebook/react/pull/28215
- https://github.com/facebook/react/pull/28214
- https://github.com/facebook/react/pull/28213
- https://github.com/facebook/react/pull/28212
- https://github.com/facebook/react/pull/28211
- https://github.com/facebook/react/pull/28247
- https://github.com/facebook/react/pull/28210
- https://github.com/facebook/react/pull/28186
- https://github.com/facebook/react/pull/28232
- https://github.com/facebook/react/pull/28169
- https://github.com/facebook/react/pull/28177
- https://github.com/facebook/react/pull/28170
- https://github.com/facebook/react/pull/28168
- https://github.com/facebook/react/pull/28122
- https://github.com/facebook/react/pull/27982
- https://github.com/facebook/react/pull/28217
- https://github.com/facebook/react/pull/28223
- https://github.com/facebook/react/pull/28208
- https://github.com/facebook/react/pull/28209
- https://github.com/facebook/react/pull/28200
- https://github.com/facebook/react/pull/28199
- https://github.com/facebook/react/pull/28198
- https://github.com/facebook/react/pull/28197
- https://github.com/facebook/react/pull/28196
- https://github.com/facebook/react/pull/28194
- https://github.com/facebook/react/pull/28192
- https://github.com/facebook/react/pull/28191
- https://github.com/facebook/react/pull/28182
- https://github.com/facebook/react/pull/28181
- https://github.com/facebook/react/pull/28180
- https://github.com/facebook/react/pull/28178
- https://github.com/facebook/react/pull/28201
- https://github.com/facebook/react/pull/28176
- https://github.com/facebook/react/pull/28162
- https://github.com/facebook/react/pull/28131
- https://github.com/facebook/react/pull/28190
- https://github.com/facebook/react/pull/28172
- https://github.com/facebook/react/pull/28171
- https://github.com/facebook/react/pull/28173
- https://github.com/facebook/react/pull/28174
- https://github.com/facebook/react/pull/28175
- https://github.com/facebook/react/pull/28136
- https://github.com/facebook/react/pull/28135
- https://github.com/facebook/react/pull/28134
- https://github.com/facebook/react/pull/28133
- https://github.com/facebook/react/pull/28132
- https://github.com/facebook/react/pull/28130
- https://github.com/facebook/react/pull/28202
- https://github.com/facebook/react/pull/28102
- https://github.com/facebook/react/pull/28161
- https://github.com/facebook/react/pull/28193
- https://github.com/facebook/react/pull/28195
- https://github.com/facebook/react/pull/28189
- https://github.com/facebook/react/pull/28160
- https://github.com/facebook/react/pull/28096
- https://github.com/facebook/react/pull/28183
- https://github.com/facebook/react/pull/28125
- https://github.com/facebook/react/pull/28157
- https://github.com/facebook/react/pull/28115
- https://github.com/facebook/react/pull/28124
- https://github.com/facebook/react/pull/28163
- https://github.com/facebook/react/pull/28164
- https://github.com/facebook/react/pull/28150
- https://github.com/facebook/react/pull/28159
- https://github.com/facebook/react/pull/28069
- https://github.com/facebook/react/pull/28110
- https://github.com/facebook/react/pull/28148
- https://github.com/facebook/react/pull/28116
- https://github.com/facebook/react/pull/28099
- https://github.com/facebook/react/pull/28100
- https://github.com/facebook/react/pull/28147
- https://github.com/facebook/react/pull/28128
- https://github.com/facebook/react/pull/28126
- https://github.com/facebook/react/pull/28139
- https://github.com/facebook/react/pull/28140
- https://github.com/facebook/react/pull/28141
- https://github.com/facebook/react/pull/28142
- https://github.com/facebook/react/pull/28113
- https://github.com/facebook/react/pull/28129
- https://github.com/facebook/react/pull/28114
- https://github.com/facebook/react/pull/28053
- https://github.com/facebook/react/pull/28091
- https://github.com/facebook/react/pull/28087
- https://github.com/facebook/react/pull/28112
- https://github.com/facebook/react/pull/28086
- https://github.com/facebook/react/pull/28101
- https://github.com/facebook/react/pull/28106
- https://github.com/facebook/react/pull/28117
- https://github.com/facebook/react/pull/28118
- https://github.com/facebook/react/pull/28105
- https://github.com/facebook/react/pull/27883
- https://github.com/facebook/react/pull/28111
- https://github.com/facebook/react/pull/28095
- https://github.com/facebook/react/pull/28108
- https://github.com/facebook/react/pull/28090
- https://github.com/facebook/react/pull/28089
- https://github.com/facebook/react/pull/28076
- https://github.com/facebook/react/pull/28074
- https://github.com/facebook/react/pull/28103
- https://github.com/facebook/react/pull/28098
- https://github.com/facebook/react/pull/28097
- https://github.com/facebook/react/pull/28068
- https://github.com/facebook/react/pull/28093
- https://github.com/facebook/react/pull/28094
- https://github.com/facebook/react/pull/28073
- https://github.com/facebook/react/pull/28084
- https://github.com/facebook/react/pull/28063
- https://github.com/facebook/react/pull/28085
- https://github.com/facebook/react/pull/28083
- https://github.com/facebook/react/pull/28065
- https://github.com/facebook/react/pull/28061
- https://github.com/facebook/react/pull/28077
- https://github.com/facebook/react/pull/28075
- https://github.com/facebook/react/pull/28078
- https://github.com/facebook/react/pull/28050
- https://github.com/facebook/react/pull/28011
- https://github.com/facebook/react/pull/28055
- https://github.com/facebook/react/pull/28066
- https://github.com/facebook/react/pull/28067
- https://github.com/facebook/react/pull/28010
- https://github.com/facebook/react/pull/27993
- https://github.com/facebook/react/pull/28052
- https://github.com/facebook/react/pull/28060
- https://github.com/facebook/react/pull/28059
- https://github.com/facebook/react/pull/28034
- https://github.com/facebook/react/pull/28033
- https://github.com/facebook/react/pull/28004
- https://github.com/facebook/react/pull/28051
- https://github.com/facebook/react/pull/28012
- https://github.com/facebook/react/pull/28001
- https://github.com/facebook/react/pull/28002
- https://github.com/facebook/react/pull/27995
- https://github.com/facebook/react/pull/28006
- https://github.com/facebook/react/pull/28005
- https://github.com/facebook/react/pull/28007
- https://github.com/facebook/react/pull/28008
- https://github.com/facebook/react/pull/28009
- https://github.com/facebook/react/pull/28000
- https://github.com/facebook/react/pull/28003
- https://github.com/facebook/react/pull/27997
- https://github.com/facebook/react/pull/27240
- https://github.com/facebook/react/pull/27977
- https://github.com/facebook/react/pull/27940
- https://github.com/facebook/react/pull/27939
- https://github.com/facebook/react/pull/28090
- https://github.com/facebook/react/pull/28089
- https://github.com/facebook/react/pull/28076
- https://github.com/facebook/react/pull/28074
- https://github.com/facebook/react/pull/28103
- https://github.com/facebook/react/pull/28098
- https://github.com/facebook/react/pull/28097
- https://github.com/facebook/react/pull/28068
- https://github.com/facebook/react/pull/28093
- https://github.com/facebook/react/pull/28094
- https://github.com/facebook/react/pull/28073
- https://github.com/facebook/react/pull/28084
- https://github.com/facebook/react/pull/28063
- https://github.com/facebook/react/pull/28085
- https://github.com/facebook/react/pull/28083
- https://github.com/facebook/react/pull/28065
- https://github.com/facebook/react/pull/28061
- https://github.com/facebook/react/pull/28077
- https://github.com/facebook/react/pull/28075
- https://github.com/facebook/react/pull/28078
- https://github.com/facebook/react/pull/28050
- https://github.com/facebook/react/pull/28011
- https://github.com/facebook/react/pull/28055
- https://github.com/facebook/react/pull/28066
- https://github.com/facebook/react/pull/28067
- https://github.com/facebook/react/pull/28010
- https://github.com/facebook/react/pull/27993
- https://github.com/facebook/react/pull/28052
- https://github.com/facebook/react/pull/28060
- https://github.com/facebook/react/pull/28059
- https://github.com/facebook/react/pull/28034
- https://github.com/facebook/react/pull/28033
- https://github.com/facebook/react/pull/28004
- https://github.com/facebook/react/pull/28051
- https://github.com/facebook/react/pull/28012
- https://github.com/facebook/react/pull/28001
- https://github.com/facebook/react/pull/28002
- https://github.com/facebook/react/pull/27995
- https://github.com/facebook/react/pull/28006
- https://github.com/facebook/react/pull/28005
- https://github.com/facebook/react/pull/28007
- https://github.com/facebook/react/pull/28008
- https://github.com/facebook/react/pull/28009
- https://github.com/facebook/react/pull/28000
- https://github.com/facebook/react/pull/28003
- https://github.com/facebook/react/pull/27997
- https://github.com/facebook/react/pull/27240
- https://github.com/facebook/react/pull/27977
- https://github.com/facebook/react/pull/27940
- https://github.com/facebook/react/pull/27939

Closes NEXT-2331
2024-02-05 18:22:27 -08:00
Jiwon Choi
4c5384351c
fix(next-eslint): .eslintrc.json not being created by next lint on App Router (#55104)
This PR fixes `.eslintrc.json` not being created after the user runs
`next lint` and selects an option of `Strict` or `Base`.
The reason is that the lint check was looking for `pages` and
`src/pages` only. Added `app` and `src/app` to be checked also.

Fixes: #55094
Fixes: #55102

---------

Co-authored-by: JJ Kasper <jj@jjsweb.site>
2024-02-05 15:47:18 -08:00
Allan Guigal
4ba1f06380
fix: status code to avoid navigation with empty props (#60968)
### What?
Currently, when a middleware is active and the path results in a 404,
the server responds with a 200 status code to data requests. We propose
a change to ensure that a 404 status code is returned in these
situations, as expected, solving production issues for the navigation
router.

### Why?
The client data requests (identified with `_next/data` path &
`x-nextjs-data` header) get answered the status code 200. The code below
is executed when there is a version skew for the data requests (e.g
prefetch in production).


4125069840/packages/next/src/server/lib/router-server.ts (L217-L227)

The version skew consists in the client side version identified with the
buildId in `__NEXT_DATA__ ` tag to be obsolete compared to the server
version (`BUILD_ID` file).

In the case of prefetching, this leads to the code above being executed,
therefore the `prefetch-reducer.ts` handles the response as valid and
sets it in its cache. Which ultimately triggers a navigation with empty
prop, resulting in erroneous behaviours reported in issues and in our
production websites:

4125069840/packages/next/src/client/components/router-reducer/reducers/prefetch-reducer.ts (L54-L74)

By switching the response to a 404, we trigger this code in the fetch
(`fetchServerResponse`). This change prompts a hard navigation
(mpaNavigation), effectively refreshing the client version and
resynching it with the server version.

4125069840/packages/next/src/client/components/router-reducer/fetch-server-response.ts (L125-L134)

### How?
We simply update the status code to 404 here:

4125069840/packages/next/src/server/lib/router-server.ts (L223)

Closes: https://github.com/vercel/next.js/pull/60785
Closes: https://github.com/vercel/next.js/issues/59295
Fixes: https://github.com/vercel/next.js/issues/47516

---------

Co-authored-by: JJ Kasper <jj@jjsweb.site>
2024-02-05 15:34:23 -08:00
vercel-release-bot
bdd0dd2d50 v14.1.1-canary.36 2024-02-05 23:22:30 +00:00
Aly Ahmed
19c2e197ea
fix setAssetPrefix when running on NextCustomServer (#61676)
### What?

Fixes `setAssetPrefix` when running on a custom server using next()
function

### Why?

Looks like when we run next custom server, there are 2 instances created
to handle this case

* main server in `/server/next.ts`
* and Render server `./server/lib/render-server.ts`

The issue mainly happens when calling `setAssetPrefix` it will update
only the main server and not render server

``` javascript
  const next = require('next')
  const app = next({ });
    app.setAssetPrefix('my-fancy-cdn/static');
    app.render(); // render server is used instead of the main server
```

### How?

when calling `setAssetPrefix` on the main server also update the render
server with the same information.

Fixes: #59940
Fixes: #51223 
Fixes: #61383

### Related Resources

#53523  #49805


c9c6ff6d77/docs/03-pages/01-building-your-application/06-configuring/10-custom-server.mdx

---------

Co-authored-by: JJ Kasper <jj@jjsweb.site>
2024-02-05 14:09:29 -08:00
OJ Kwon
a4d33d4acd
fix(next-core): adjust server alias for the context (#61690)
### What

This PR attempts to adjust import map to `server-only` / `client-only`
close to the existing webpack configs, makes to pass more tests.

Closes PACK-2396
2024-02-05 14:05:37 -08:00
Balázs Orbán
bb7577aa44
feat(ts): add JSDoc comments for public APIs (#61649)
### What?

This PR adds JSDoc comments to the most common public APIs to improve
the DX in IDEs like VSCode.

### Why?

Currently, we provide no information on some of the most used APIs in
IDEs, which makes it harder than it needs to be to look up the extra
information.

<details>
<summary><b>Before:</b></summary>
<img
src="https://github.com/vercel/next.js/assets/18369201/8b6092e8-8f9b-49da-a3df-b07a59982069"
width="640"/>
</details>

<details>
<summary><b>After:</b></summary>
<img
src="https://github.com/vercel/next.js/assets/18369201/30216f76-414a-43b0-9aa6-2fdd742ab3fe"
width="640"/>
</details>

### How?

Using JSDoc comments, I added a basic description to most public APIs
that link back to the current docs for more details. The description is
kept minimal to avoid out-of-sync documentation.

Note: In the future, the flow could be reversed here, and our API
Reference docs could actually be generated from a single source of
truth, the source code itself. However, this will require more work by
re-organizing our public API submodules in a single directory, (related
#61525), so the API docs are easy to maintain even without a deeper
knowledge of the codebase.

Note: These comments should also be extended to
methods/properties/arguments in these public APIs in the future.

Closes NEXT-2357

[Slack
thread](https://vercel.slack.com/archives/C03KAR5DCKC/p1706735292633029)
2024-02-05 20:31:59 +00:00
vercel-release-bot
b1f6b8246e v14.1.1-canary.35 2024-02-05 19:38:59 +00:00
Balázs Orbán
645be74efd
feat(cna): remove autoprefixer from default templates (#55725)
### What?

Removing `autoprefixer` from the default Tailwind CSS templates. (It can
be installed afterward)

### Why?

After some investigation by @timneutkens, `autoprefixer` seems to
introduce some compilation overhead

### How?

Removing `autoprefixer` from the auto-installed dependency list, it
would be up to the developer to install this plugin if they need it.

[Slack
thread](https://vercel.slack.com/archives/C04DUD7EB1B/p1695288906722539)
2024-02-05 14:22:47 -05:00
JJ Kasper
2ad058d356
Revert "build: upgrade edge-runtime" (#61686)
See here for additional context
https://github.com/vercel/edge-runtime/pull/795 but TLDR is due to a bug
in the `npmcli` we aren't able to publish Next.js releases after this
package was upgraded.

We can re-land the upgrade after that PR is landed/published. 

Reverts vercel/next.js#61030

Closes NEXT-2367
2024-02-05 19:18:08 +00:00
Balázs Orbán
492b4157f3
feat(ts): expose MiddlewareConfig interface (#61576)
### What?

Expose the `MiddlewareConfig` interface.

### Why?

You can now `import type { MiddlewareConfig } from "next/server"` to
type the `config` object in your `middleware.ts` file.

Now you an type the entire file for example like so:
```ts
// middleware.ts
import type { NextMiddleware, MiddlewareConfig } from "next/server"

export const middleware: NextMiddleware = async (req) => {
  //...
}

export const config: MiddlewareConfig = {
  //...
}
```

### How?

Re-exported the interface from its current location via
`server/web/types`, to colocate it with `NextMidldeware`.

I wonder if we could somehow type this file automatically, but it might
be dependent on https://github.com/microsoft/TypeScript/issues/38511

Closes NEXT-2308

[Slack
thread](https://vercel.slack.com/archives/C03S9JCH2Q5/p1706287433026409?thread_ts=1706058855.423019&cid=C03S9JCH2Q5),
[Slack
thread](https://vercel.slack.com/archives/C03KAR5DCKC/p1706659724141899)
2024-02-05 11:15:58 -08:00
vercel-release-bot
d1fa2876e8 v14.1.1-canary.34 2024-02-05 17:25:07 +00:00
Donny/강동윤
8a11319efb
chore: Update @swc/helpers to v0.5.5 (#61659)
### What?

Update `@swc/helpers` to `v0.5.5`.

### Why?

- To apply https://github.com/swc-project/swc/pull/8574. This fixes a bug in helper, which can prevent useful operation while testing with `@next/jest`.

(https://github.com/swc-project/swc/pull/8097 is also included, but it's not used by next.js)

### How?



Closes PACK-2388
2024-02-05 19:22:32 +09:00
Tobias Koppers
2ac1468540
avoid processing client components and server actions in route handlers (#60985)
### What?

app api routes doesn't need to handle client components and server
actions


Closes PACK-2271
2024-02-05 09:57:14 +01:00
Sam Ko
47c74dc454
chore: update README.md (#61650)
## Description

On [second thought](https://github.com/vercel/next.js/pull/48717), the
previous heading size of (`##`) looks better.

Closes NEXT-2358
2024-02-04 18:54:54 -08:00
Ishaan
d245079177
Update README.md (#48717)
## Improving Documentation

### The following changes have been made to the official repository's
**Readme.md**:

- Shortened link text across the readme.
- Added additional descriptions for more details.
- Added bold text to highlight emphasis on important topics
- Changed heading sizes to indicate first headings (h1) for each section
instead of second headings (h2) which was previously being used
- Merged _'Who is using Next.js?'_ section with _'Getting Started'_
section for a more professional, cleaner look.

### The following changes have been made to the repository's
**Contribution docs**:

- Fixed two typos in the docs

---------

Co-authored-by: Sam Ko <sam@vercel.com>
Co-authored-by: Delba de Oliveira <32464864+delbaoliveira@users.noreply.github.com>
2024-02-04 18:47:51 -08:00
vercel-release-bot
5d2e79b61f v14.1.1-canary.33 2024-02-05 01:29:47 +00:00
OMikkel
6d5cacad6e
Encode revalidateTag value fixes #61390 (#61392)
fixes #61390

### What?

Added encodeURIComponent to encode revalidateTag value beforing
appending it to the url.

### Why?

If a tag contains special characters the tag wont be revalidated because
the special characters arent encoded.
By encoding the tag any special characters can be used.
Check out issue #61390 for further explanation

I believe this is the reason why users report the revalidateTag as
unreliable. They might be using special characters in their tags to make
sure they are unique, but when deployed to vercel and the fetch cache is
used revalidateTag fail to revalidate them.

### How?

By encoding revalidateTag with encodeURIcomponent the tag can contain
special characters.

Closes NEXT-
Fixes #61390

---------

Co-authored-by: JJ Kasper <jj@jjsweb.site>
2024-02-05 00:17:46 +00:00
vercel-release-bot
498d29413b v14.1.1-canary.32 2024-02-04 23:21:04 +00:00
Wojciech Maj
f7fcd2b773
Fix @react-pdf/renderer not working in RSC (#61317)
<!-- 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?

Fixes @react-pdf/renderer not working in RSC.

### Why?

Next.js RSC version of React does not include features necessary for
@react-pdf/renderer to work.

### How?

Adding @react-pdf/renderer to serverComponentsExternalPackages by
default.

Fixes #61313

Co-authored-by: JJ Kasper <jj@jjsweb.site>
2024-02-04 21:30:47 +00:00
vercel-release-bot
db24fc0c3f v14.1.1-canary.31 2024-02-04 20:10:43 +00:00
Zack Tanner
49020b7179
Remove unused mockedRes in resolveRoutes (#61635)
While looking into a bugfix in `resolveRoutes`, I noticed this mocked
req/res handler wasn't being used for anything anymore.


Closes NEXT-2342
2024-02-04 11:07:31 -08:00
Vercel Release Bot
a949bab3bc
Update font data (#61621)
This auto-generated PR updates font data with latest available
2024-02-04 00:20:28 +00:00
vercel-release-bot
bedfeac4e3 v14.1.1-canary.30 2024-02-03 23:21:46 +00:00
Leah
cb77a9c586
feat(turbopack): serve google fonts locally and allow preloading them (#61596)
### What?

Adds support for preloading google fonts.

Closes PACK-2351
2024-02-03 21:34:36 +01:00
Leah
1f8a5a2ed6
feat(turbopack): only preload fonts that opt in (#61591)
### What?

Adds another `ImportMappingReplacement` for the font file in order to
add markers to the filename.
The markers are used to generate the `next-font-manifest.json` (and also
in next.js code).

Closes PACK-2352
2024-02-03 19:53:21 +01:00
vercel-release-bot
aa66300f75 v14.1.1-canary.29 2024-02-02 23:21:11 +00:00
Zack Tanner
a67d247d94
ensure server action errors notify rejection handlers (#61588)
### What
When attaching a rejection listener to a server action promise, in the case of network errors, the rejection handler would be skipped and it'd throw an error that crashes the application.

### Why
When we refactored these reducers to no longer suspend, it caused the rejection handling logic we have to no longer make sense. In this case we're working with a native promise that won't have a `status` property, so we'd re-throw the error and not call `reject`. 

### How
This removes the special status handling logic and makes the rejection handler always call `reject` with the error. This will either be handled by user code or let the error bubble to an error boundary. 

I also cleaned up some mutable code that is no longer needed now that these reducers aren't replayed. 

Closes NEXT-1715
Closes NEXT-2323
Fixes #58638
2024-02-02 14:36:39 -08:00
OJ Kwon
fc22d287ba
refactor(next-core): consolidate custom ecma transform rules (#61481)
This PR consolidates how we inject specific, custom ecma transforms for
the each context.

Previously we had 2 different way to apply custom transforms via
ecmatransform plugin / custom rules, but it could create some conflict
in order as well as can be confusing between how it gets created. PR
uses new moduleruleeffect instead, consolidates all of the references
into single way.

Closes PACK-2342
2024-02-02 12:58:33 -08:00
OJ Kwon
b95e45a511
build(cargo): bump up turbopack (#61590)
* https://github.com/vercel/turbo/pull/7213 <!-- OJ Kwon -
feat(turbopack): extend ecmatransform moduleeffect -->
* https://github.com/vercel/turbo/pull/7219 <!-- Leah - fix(turbopack):
encode source map urls -->
* https://github.com/vercel/turbo/pull/7220 <!-- Leah -
style(turbopack): make idents more readable -->

Closes PACK-2369
2024-02-02 12:22:42 -08:00
Tim Neutkens
9f5462ca23
Fix .env HMR for Turbopack in Edge runtime (#61565)
## What?

Fixes the `should update server components pages when env files is
changed (edge)` tests. In order for changes to the environment to apply
to edge-runtime routes we need to call `clearModuleContext`, currently
that only supports a single path being provided, but in Turobpack the
compilation is much more granular than webpack, in case of webpack we
loop through all items coming out of the compilation and invalidate them
regardless, which is not needed for Turbopack. Instead, when an
entrypoint (route) is recompiled it'll automatically only invalidate
that part. For `.env` changes that don't affect compilation, which is
what the test checks, this wouldn't be sufficient as there is no
compilation difference between changing those env vars. In the case that
you change `.env` / tsconfig/jsconfig we have to clear all module
contexts, which is what this PR implements.

<!-- 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-2337
2024-02-02 11:48:16 +01:00
Leah
2afb6379d1
feat: first pass of next/font manifest (#61424)
### What?

We need the manifest to pass a bunch of preloading tests.

Currently, this is just a dumb implementation that preloads all fonts
and always sets size-adjust to true.

Google fonts are also still requested from Google directly it seems and
therefore never preloaded.
2024-02-02 09:42:36 +01:00
Donny/강동윤
a77f8a9165
Update turbopack (#61553)
# Turbopack

* https://github.com/vercel/turbo/pull/7207 <!-- Donny/강동윤 -
feat(turbopack): Enable error recovery of lightningcss -->
* https://github.com/vercel/turbo/pull/7096 <!-- Tobias Koppers -
migrate type references to primary references -->
* https://github.com/vercel/turbo/pull/7225 <!-- Donny/강동윤 -
fix(turbopack): Fix css var issue and font issue when using
`lightningcss` -->

### What?

Update turbopack 

### Why?

To test https://github.com/vercel/turbo/pull/7225 against internal apps.


### How?



Closes PACK-2364
2024-02-02 08:27:00 +00:00
Balázs Orbán
d43a387d27
chore: update ESLint and plugins to latest (#61544)
Bumping ESLint to the newest version.

Related: #61525

Closes NEXT-2336
2024-02-01 20:06:02 -05:00
vercel-release-bot
5cd7790091 v14.1.1-canary.28 2024-02-01 23:21:30 +00:00
Steven
5ee6a07d74
fix: bump @vercel/nft@0.26.3 (#61538)
- Release notes https://github.com/vercel/nft/releases/tag/0.26.3
- Fixes https://github.com/vercel/next.js/issues/59346
- Related to https://github.com/lovell/sharp/issues/3967

Closes NEXT-2334
2024-02-01 16:46:38 -05:00
Zack Tanner
c60967328c
remove unnecessary PPR branch in non-PPR reducer (#61176)
PPR flows through the `navigateReducer_PPR` branch. This handling is vestigial from before proper PPR navigation support was added.

Closes NEXT-2244
2024-02-01 12:26:29 -08:00
Tim Neutkens
ffd5732187
Fix .env hmr for Node.js runtime in Turbopack (#61504)
## What?

Whenever `.env` related files or tsconfig/jsconfig changes there's a
call to `invalidate()`, as far as I found the only call to
`invalidate()` even, which wasn't implemented for Turbopack yet. For
`NEXT_PUBLIC_` changes normal Turbopack HMR will kick in already but
this test was checking env vars that do not affect the compiled output,
so Turbopack would not trigger a HMR as no inputs changed. Similarly
webpack doesn't either and it implements this call in a similar way.

For edge runtime there's a different bug where changes are not
propagated even when you refresh, so while this change does fix another
bug for edge runtime it doesn't solve that underlying issue where the
values don't update to begin with. I'll investigate that next.

<!-- 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-01 18:00:05 +01:00
Jiachi Liu
edb9371443
Fix experimental react support in app-route runtime (#61511)
Follow up for #61463

Basically the fix in #61463 was not correct. I added a log to see which
react is resolved in `dynmiac-rendering` module, and the got this:

The module with incorrect react version is from
`next.js/packages/next/dist/compiled/next-server/app-route.runtime.prod.js`
which resolves `react` as `./dist/compiled/react/index.js` even
experimental react should pop in here.

Then I found the app-route runtime doesn't have check for the react exp
env, then I added there to make it aligned with app-page runtime


Closes NEXT-2327
Closes NEXT-2294
2024-02-01 17:13:28 +01:00
Kiko Beats
461aa5108e
build: upgrade edge-runtime (#61030)
It exposes `performance` constructor

Closes #60433 
Closes NEXT-2195
2024-02-01 13:10:12 +01:00
Vercel Release Bot
2e3b88dcf1
Update font data (#61479)
This auto-generated PR updates font data with latest available

Co-authored-by: JJ Kasper <jj@jjsweb.site>
2024-02-01 01:12:13 +00:00
vercel-release-bot
a35f689c5b v14.1.1-canary.27 2024-01-31 23:21:57 +00:00
Jiachi Liu
be37d3eaab
Fix build worker callback arg missing correct page path (#61347)
### What

The `arg` in the worker callback is alwasy `any`, when we access the
page path the argument could be in different form as the arg types are
different.

This PR align the argument type to object for `isPageStatic`,
`getDefinedNamedExports`, `hasCustomGetInitialProps` methods in static
worker. So they can share the similar shape of type of argument when
accessing `page` path. This will avoid the case that logged `page` in
the warning is `undefined`

Import the helpers from utils instead of workers as the worker itself
don't need to contain other exports that is not used for static worker.

### Why

This PR align the callback type of callback argument type of static
worker, so that we could get the actual page path value in a type-safe
way. We have 4 methods for static worker, `exportPage`, `isPageStatic`,
`getDefinedNamedExports`, `hasCustomGetInitialProps`, which the rest of
3 methods share the same format of warnings but their argument are
different. It's easily ended up with wrong argument type, and log with a
bad page path in the warning.


Closes NEXT-2289
2024-02-01 00:04:34 +01:00
Jiachi Liu
92125f07b4
Always show version text in error overlay (#61421)
Make sure the version is always display on error overlay if possible, to
avoid that we saw it's "update to date" in screenshot but still no idea
about the version


![image](https://github.com/vercel/next.js/assets/4800338/22d932ce-6176-4cbd-be66-3db1eda259aa)


Closes NEXT-2307
2024-02-01 00:04:00 +01:00
Will Binns-Smith
c7ba7b8d8c
Turbopack: fix telemetry attributes for swc options (#61474)
Previously, this considered explicitly `false` options as true, as they
were still `Some(_)`.


Closes PACK-2340
2024-01-31 13:58:08 -08:00
Thomas Knickman
7943ef8ed8
feat(next): trace build dependencies for turborepo (#59553)
### What?

This adds a method to optionally detect disk, network, and env access
access during a build and write this to a file.

### Why?

This will be consumed by Turborepo to determine **if** a build can be
cached, and if so, **how** it should be cached.

### How?

This implements a proxy that can be selectively applied to functions to
watch their access to disk, network, and env. For Turborepo, we only
care about what can alter the build output, to achieve this, we trace
the config load, and the static page generation.

Closes
https://linear.app/vercel/issue/TURBO-1904/support-build-access-tracing-in-nextjs

Performance Testing:

Repo -
https://github.com/tknickman/nextjs-turborepo-build-trace-performance-testing

```
- - - - - - - - - - - - - - - - - Performance - - - - - - - - - - - - - - - - -
pages-single-app:
  44629.53301 ms (+/- 6313.82757 ms) from 5 iterations (223318.53692 ms total)
local-pages-single-app-with-trace:
  45684.00503 ms (+/- 6570.85083 ms) from 5 iterations (228585.01729 ms total)
local-pages-single-app-without-trace:
  45938.76231 ms (+/- 6816.13022 ms) from 5 iterations (229830.15925 ms total)
approuter-single-app:
  49517.23156 ms (+/- 7820.20687 ms) from 5 iterations (247725.16713 ms total)
local-approuter-single-app-with-trace:
  50019.98247 ms (+/- 9443.82537 ms) from 5 iterations (250224.62496 ms total)
local-approuter-single-app-without-trace:
  50124.07092 ms (+/- 9656.22047 ms) from 5 iterations (250726.35688 ms total)
local-large-pages-single-app-without-trace:
  51582.92992 ms (+/- 12179.09895 ms) from 5 iterations (258469.36942 ms total)
local-large-pages-single-app-with-trace:
  51740.25813 ms (+/- 12601.02878 ms) from 5 iterations (259329.50946 ms total)
local-xlarge-pages-single-app-with-trace:
  234111.66735 ms (+/- 74629.30509 ms) from 5 iterations (1191018.63608 ms total)
local-xlarge-pages-single-app-without-trace:
  239621.11837 ms (+/- 84629.16374 ms) from 5 iterations (1218078.41921 ms total)
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
```

<details>
<summary>Test case keys</summary>

* `local-xlarge-pages-single-app-without-trace`: this branch, built and
linked to a local project with 5000 SSG pages and trace **disabled**
* `local-xlarge-pages-single-app-with-trace`: this branch, built and
linked to a local project with 5000 SSG pages and trace **enabled**
* `local-large-pages-single-app-with-trace`: this branch, built and
linked to a local project with 100 SSG pages and trace **enabled**
* `local-large-pages-single-app-without-trace`: this branch, built and
linked to a local project with 100 SSG pages and trace **disabled**
* `local-approuter-single-app-without-trace`: this branch, built and
linked to a local default approuter starter and trace **disabled**
* `local-approuter-single-app-with-trace`: this branch, built and linked
to a local default approuter starter and trace **enabled**
* `local-pages-single-app-with-trace`: this branch, built and linked to
a local default pages starter and trace **enabled**
* `local-pages-single-app-without-trace`: this branch, built and linked
to a local default pages starter and trace **disabled**
* `approuter-single-app`: next@latest running on the default approuter
starter
* `pages-single-app`: next@latest running on the default pages starter


</details>


TODO:
- [ ] Telemetry events
2024-01-31 14:18:27 -07:00
JJ Kasper
55c3baa8b1
Replace image optimizer IPC call with request handler (#61471)
This ensures we don't do un-necessary IPC calls during image optimizing
and leverage the internal request handler for fetching internal static
images/resources.

x-ref: https://github.com/vercel/next.js/issues/58248

Closes NEXT-2318
2024-01-31 15:17:52 -05:00
vercel-release-bot
dbd9598f56 v14.1.1-canary.26 2024-01-31 18:11:07 +00:00
Jiachi Liu
cbcee50f19
Pass down __NEXT_EXPERIMENTAL_REACT env to webpack build worker explicitly (#61463)
Make sure `__NEXT_EXPERIMENTAL_REACT` env is alwasy available in webpack
build worker, like we've done for the other worker before

Closes NEXT-2294
2024-01-31 18:58:08 +01:00
Tim Neutkens
724c4462d5
Support crossOrigin in Turbopack (#61461)
## What?

Implements `crossOrigin` in the React Client Components manifest for
Turbopack. This feature was missing.

Removes the `false` value as it doesn't actually do anything, the
default is no crossorigin property.

<!-- 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-2313
2024-01-31 18:37:34 +01:00
Tobias Koppers
d6badf82b7
avoid sending issues turbopack messages to browser (#61443)
### What?

avoid sending issues turbopack messages to browser

### Why?

they trigger fake HMR events and are not used on client side anyway


Closes PACK-2338
2024-01-31 09:30:07 -08:00
Zack Tanner
871416655e
fix issues loading CSS in default slots (#61428)
### What
When using a default slot that re-exports another page, the CSS entries
(and presumably other client reference modules, like JS entries) that
correspond with the re-exported page won't be loaded, resulting in CSS
styles not being applied.

### Why
`next-app-loader` constructs the path to the default segment but special
cases the `children` slot (which is used as the page), to mark the
segment as an empty string. This is so that the parallel default file
can be loaded. However the way that `defaultPath` is constructed, it
assumes that `actualSegment` won't be an empty string, and constructs an
invalid path like so:

`app/example//default.tsx`

When we go to look up the JS/CSS entries from the client reference
manifest, the key will be incorrect and so it won't find the files for
it, resulting in this bug.

### How
This moves the `/` delimiting to be part of the creation of the
`actualSegment` variable so that we only append it when we know we
aren't setting it to be an empty string.

Fixes #52245
Fixes #49871
Closes NEXT-2309
Closes NEXT-2310
2024-01-31 07:25:38 -08:00
Chris Weber
6efe76f954
CNA: exclude ts(js)conf.json as well as .git folder (#61412)
### What?

On windows the .git/* files are read only, when the CNA "import path" script attempts to open one of the .git/* files

### Why?

attempting to open any of the .git/* files results in an error thrown by CNA and CNA exists, hence not finishing the setup of a new project

### How?

My suggested fix uses the fast-glob ignore option to exclude the .git folder, I also moved the the ts(js)config.json exclusion into the ignore (was an "if" before)

- Fixes #61411 
- Discussion https://github.com/vercel/next.js/discussions/61261
2024-01-31 09:36:31 -05:00
Jiachi Liu
fd6db76ae0
Fix next dynamic import named export from client components (#61378)
When using `next/dynamic` in server components to load a client
component with named export, we shouldn't dot into the prop name since
client component reference as it's already a valid react component type.
It would work with `default` prop but not other named exports.

Let's say `mod` is a dynamic imported module
```
mod.Button.default
```

will become the client reference key
```
mod#Button#default
```
Which means in module `mod`, get `Button` export, then `default`
property of it, which is wrong but it's a valid key in the client
reference roxy.

This PR checks if they're client module, then return itself as dynamic
imported component type for `next/dynamic` if it is one.


Fixes #61046
Closes NEXT-2229
2024-01-31 14:50:20 +01:00
Tobias Koppers
e5b514692e
fix a perf problem in VersionedContentMap (#61442)
### What?

Avoid a dependency from the emit operation to the `get_and_write`
lookup.

### Why?

This makes HMR much faster since the `get_internal` method is pretty
slow.


Closes PACK-2337
2024-01-31 11:50:00 +01:00
Donny/강동윤
fafcb5fbfe
Update turbopack (#61433)
# Turbopack

* https://github.com/vercel/turbo/pull/7167 <!-- Leah - fix: catch
import map lookup error properly in `ResolvingIssue` -->
* https://github.com/vercel/turbo/pull/7182 <!-- Donny/강동윤 - feat:
Re-enable `preset-env` mode of `styled-jsx` in turbopack -->
* https://github.com/vercel/turbo/pull/7161 <!-- Tobias Koppers - add
support for globs in sideEffects field in package.json -->
* https://github.com/vercel/turbo/pull/7184 <!-- Donny/강동윤 - chore:
Update `swc_core` to `v0.89.6` -->

### What?

Update turbopack

### Why?

To test https://github.com/vercel/turbo/pull/7182 against internal
webapps.

### How?

 - Closes #57718

Closes PACK-2334
2024-01-31 19:33:37 +09:00
Donny/강동윤
ead21691b6
chore: Update swc_core to v0.89.6 (#61426)
### What?

Update SWC crates

### Why?

To apply the latest bugfixes

### How?

Fixes #40385



Closes PACK-2332
2024-01-31 18:35:20 +09:00
vercel-release-bot
6df41fde43 v14.1.1-canary.25 2024-01-31 00:29:05 +00:00
Tobias Koppers
328673d193
fix hmr telemetry reporting (#61420)
### What?

We sometimes send events with `start: null`...


Closes PACK-2327
2024-01-31 01:18:31 +01:00
Zack Tanner
31a0edbd1b
parallel routes: fix catch-all slots being treated as optional catch-all (#61174)
### What
Catch-all parallel slots were being incorrectly matched to the root of their segment. For example, `@foo/[...catchAll]/page` as a parallel route on `/page.tsx` should not match on `/`, but it should match on `/foo`, `/bar`, ...etc

### Why
The catch-all route normalization logic doesn't treat optional catch-all routes differently from catch-all routes. The assumption was if any catch-all route was found, that it should match the path that shared its prefix.

### How
This updates the normalization logic to handle optional-catchall as it was in the original implementation. For regular catch-all, we ensure that the catch-all base path (for `/[...slug]` that'd be `/`) isn't identical to the path we'd match it to.

Fixes #60613
Closes NEXT-2243
2024-01-30 15:28:47 -08:00
vercel-release-bot
7c4d724e57 v14.1.1-canary.24 2024-01-30 23:22:57 +00:00
vercel-release-bot
1eecfc7d74 v14.1.1-canary.23 2024-01-30 19:02:50 +00:00
Will Binns-Smith
332720a3e9
Always respect NEXT_TRACE_UPLOAD_DISABLED (#61402)
Closes PACK-2326
2024-01-30 10:58:36 -08:00
vercel-release-bot
62bba1982e v14.1.1-canary.22 2024-01-30 14:37:47 +00:00
Tim Neutkens
e114229d61
Same as #61360 (#61369)
## What?

Same PR as #61360, somehow that branch could not be checked out / wasn't
available in git.

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

---------

Co-authored-by: Will Binns-Smith <wbinnssmith@gmail.com>
2024-01-30 15:13:06 +01:00
Donny/강동윤
292cd0d377
Update turbopack (#61381)
# Turbopack changes
* https://github.com/vercel/turbo/pull/7160 <!-- Will Binns-Smith - Make
`EcmascriptDevChunkContent` public to other crates -->
* https://github.com/vercel/turbo/pull/7162 <!-- Tim Neutkens - Fix
sourcemap PR compile error -->
* https://github.com/vercel/turbo/pull/7163 <!-- Donny/강동윤 - fix: Revert
`preset-env` mode of `styled-jsx` in turbopack -->


### What?

Update turbopack

### Why?

To apply https://github.com/vercel/turbo/pull/7163

### How?



Closes PACK-2323
2024-01-30 14:29:12 +01:00
vercel-release-bot
4cf64ec79d v14.1.1-canary.21 2024-01-29 23:22:19 +00:00
Leah
e4b3531377
fix(turbopack): don't parse .ts files as .tsx (#61219)
### What?

We currently parse JSX syntax in all typescript files which is wrong.

Closes PACK-2302

Turbo PR: https://github.com/vercel/turbo/pull/7121

### Turbopack Updates

* https://github.com/vercel/turbo/pull/7099 <!-- Donny/강동윤 -
fix(turbopack): Fix panic from `EcmascriptModuleFacadeModule::content`
-->
* https://github.com/vercel/turbo/pull/7121 <!-- Leah - fix(turbopack):
don't parse `.ts` files as `.tsx` -->
2024-01-29 21:13:32 +00:00
Jiachi Liu
f0ea88427c
Refine logging message of experiments (#61337)
Refining the message that uses "use with caution" instead of "use at
your own risk" as some experimental features was functionally stable but
we can't bring them as default for now and need to test as experiments

Closes NEXT-2286
2024-01-29 20:02:46 +01:00
Dima Voytenko
6eb2c2461f
Telemetry: add time-to-first-byte signal (#61238) 2024-01-29 09:36:12 -08:00
Jiachi Liu
3008af6b0e
DX: add route context to the dynamic errors (#61332)
### What 

Given user infomation when the dynamic errors are thrown, e.g. bad
`cookies` or `headers` usages. Now users can tell through the error
information to see which pathname is broken, and trace down the usage.

#### before

```
Page couldn't be rendered statically because ...
This page needs to bail out of prerendering at this point because ...
```

#### after

```
Route /cookies couldn't be rendered statically because ...
Route /server needs to bail out of prerendering at this point because ...
```

### Why

When you have multi pages in your app, such as 100+, and many page might
uses these. This is hard to trace down where exactly the error is from

Closes NEXT-2283
Cloese NEXT-2265
2024-01-29 17:35:01 +01:00
vercel-release-bot
380a491981 v14.1.1-canary.20 2024-01-29 07:16:59 +00:00
Donny/강동윤
38f229b09b
fix: Revert preset-env mode of styled-jsx in webpack mode (#61306)
### What?

Partially revert SWC update PR, to avoid a breaking change.

### Why?

x-ref: https://vercel.slack.com/archives/C03EWR7LGEN/p1706511131287999

### How?



Closes PACK-2309
2024-01-29 08:13:47 +01:00
vercel-release-bot
93fb762fc6 v14.1.1-canary.19 2024-01-29 05:29:58 +00:00
Donny/강동윤
2d9ea76af3
Update swc_core to v0.89.4 (#61285)
### What?

Update swc crates.

### Why?

To fix the build issues of vercel sites.

### How?



Closes PACK-2304
2024-01-29 02:09:44 +00:00
Danny
c34b398b14
create-next-app: update tailwind packages and new classes in page.tsx (#61065)
- Updates `tailwindcss` package
- Fixes classes order based on `eslint-plugin-tailwindcss`
- Remove/updates certain classes that now have shorthands, for example
`lg:h-auto lg:w-auto` is now `lg:size-auto`
- Removes unnecessary curly braces

Co-authored-by: Sam Ko <sam@vercel.com>
2024-01-29 02:02:58 +00:00
vercel-release-bot
98be3ba23e v14.1.1-canary.18 2024-01-28 23:21:57 +00:00
vercel-release-bot
f61b382f12 v14.1.1-canary.17 2024-01-27 23:21:15 +00:00
Jiachi Liu
54f33992c0
Fix indentation in source code of dev overlay (#61216)
This fix the bad missing indentation for the source code in dev overlay.
It was caused by a space replacement change in dev overlay before. Which
should only replace the leading multi-spaces but it was replacing other
spaces as well in the code.

#### Code

```jsx
export default async function Page() {
  await fetch('http://localhost:3004')
}
```

#### After
<img width="486" alt="image"
src="https://github.com/vercel/next.js/assets/4800338/2c0a2720-c3c8-4db2-a548-f4daabd3c5d5">


#### Before
<img width="484" alt="image"
src="https://github.com/vercel/next.js/assets/4800338/f68ceea0-cead-4e23-9db7-2acb24a14485">



Closes NEXT-2166
Closes NEXT-2257
2024-01-27 19:15:38 +01:00
Shu Ding
93e4bb823c
Fix Server Action redirection with absolute internal URL (#60798)
Closes NEXT-2141
2024-01-27 10:04:38 -08:00
Shu Ding
ecef83ac61
Fix Server Reference being double registered (#61244)
When we apply `createActionProxy` twice to the same value, it currently
errors because we can't override the ID of it.

This PR makes sure that 1) when the value already have an ID defined, we
skip setting it again; 2) all the action IDs are being tracked even for
duplicated ones.

Note that it's technically impossible to "detect" the duplication here
(via static analyzation) and only set it once. For example:

```ts
'use server'

export async function foo () {}
export const bar = a_value_we_dont_know_yet ? foo : async () => {}
```

So, the compiler will always wrap `createActionProxy` for every exported
value and assume they're different Server Actions (hence different IDs).
With this fix, if we find that it's already defined before, we just
return the defined reference as they're strictly identical so the ID
does't matter.

Closes #54655, closes #61183.

Closes NEXT-2264
2024-01-27 14:15:24 +01:00
vercel-release-bot
98795f0737 v14.1.1-canary.16 2024-01-27 10:08:59 +00:00
Donny/강동윤
7b9d90bcdc
Update swc_core to v0.89.x (#61086)
## Turbopack

* https://github.com/vercel/turbo/pull/7092 <!-- Donny/강동윤 - Update `swc_core` to `v0.89.x` -->


### What?

Update SWC crates

### Why?

To fix some issues

### How?

Fixes #59805
Fixes #56144


Closes PACK-2222
Closes PACK-2285
2024-01-27 09:43:57 +00:00
Shu Ding
b7cc5b9baa
Fix cookie merging in Server Action redirections (#61113)
This PR fixes the cookie merging logic in Server Actions. Specifically,
when users do `cookies().set(...)` or `cookies.delete(...)` with a
`redirect()` to an internal route followed. Currently, we are just
concatenating the original cookies (request cookies) and the mutated
cookies. That introduces several issues, like it can't override or
delete an existing cookie.

Closes NEXT-2221
2024-01-26 23:26:23 -08:00
Zack Tanner
771e29cb71
revert changes to process default routes at build (#61241)
Reverts changes from #61173 & #60240 (while leaving the tests that were
added).

There are too many spots where considering `/default` routes as pages
needs to be carefully considered in different runtimes, and it turns out
that it's not actually needed to handle the case that it was originally
added for. I confirmed that the test that added the case it was intended
to fix (`parallel-routes-catchall-default`, along with the unit tests in
`normalize-catchall-routes`) are still passing as expected.
2024-01-26 18:10:33 -08:00
vercel-release-bot
b81ce7256b v14.1.1-canary.15 2024-01-26 23:22:18 +00:00
Aleksandr Kondrashov
a3243e6710
Refine revalidatePath warning message (#61220)
<!-- 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 #

-->
#61159 fixed the documentation by removing incorrect information stating
that the type parameter must be set to 'page' when the path contains a
dynamic segment. This PR reflects this change in the warning message,
while confirming that the condition for the warning is already correct.
Additionally, I changed the word "affect" to "effect," assuming it was a
typo. In the documentation, I corrected myself and changed the wording
from "argument is required" to "parameter is required".
2024-01-26 22:05:04 +00:00
Zack Tanner
c9321c72c9
parallel routes: support multi-slot layouts (#61115)
### What?
When using layouts in multiple parallel route slots, only 1 of the
layouts would render.

### Why?
The `resolveParallelSegments` logic responsible for populating the
loader tree was incorrectly bailing if it found another parallel route
that matched a page component.

### How?
I did my best to update this loader code with some more comments to make
it a bit easier to reason about, and also made some slight refactors.
But the gist of the fix is just ensuring that each parallel route (that
isn't a direct match on the `children` slot) is resolved as an array, so
that when the subtree is created, it doesn't skip over the slot.

Fixes #58506
Fixes #59463

Closes NEXT-2222
2024-01-26 11:46:23 -08:00
vercel-release-bot
a655645bcb v14.1.1-canary.14 2024-01-26 16:25:21 +00:00
Steven
39afdc5f97
chore: refactor image optimization to separate external/internal urls (#61172)
This PR is refactoring only and doesn't change the logic, therefore no
tests were added.

The improvement here is readability:
- separate functions to fetch external vs internal image (in the future,
we could improve perf of internal image routing)
- types of the arguments are more specific (rather than passing in
complete NextConfig)

> Note: Its easier to review with whitespace hidden:
https://github.com/vercel/next.js/pull/61172/files?w=1
2024-01-26 08:20:20 -08:00
Jiachi Liu
c6a061a88e
Add stack trace to client rendering bailout error (#61200)
When there's `useSearchParams` hook triggers the bailout to client side
rendering, users might hard to find where it's from since it could
either from users code base or third party libraries. Adding the stack
trace for it so they could at least investigate which line is throwing
from the server bundle. Will improve it in the later future when we can
give more insights.

#### After
```
 ⨯ useSearchParams() should be wrapped in a suspense boundary at page "/". Read more: https://
nextjs.org/docs/messages/missing-suspense-with-csr-bailout
    at a (/private/var/folders/gy/kq4zjn8s0ljf9sfjyyh_nj640000gn/T/next-install-aa5f331b7f6af2
82fd9bab0f69685454d1f50dc8f3c775da23d4e5e807a970cb/.next/server/chunks/846.js:1:9912)
    at h (/private/var/folders/gy/kq4zjn8s0ljf9sfjyyh_nj640000gn/T/next-install-aa5f331b7f6af2
82fd9bab0f69685454d1f50dc8f3c775da23d4e5e807a970cb/.next/server/chunks/846.js:1:22018)
    at a (/private/var/folders/gy/kq4zjn8s0ljf9sfjyyh_nj640000gn/T/next-install-aa5f331b7f6af2
82fd9bab0f69685454d1f50dc8f3c775da23d4e5e807a970cb/.next/server/app/page.js:1:2518)
```

#### Before
```
 ⨯ useSearchParams() should be wrapped in a suspense boundary at page "/". Read more: https://
nextjs.org/docs/messages/missing-suspense-with-csr-bailout
```

Closes NEXT-2239
2024-01-26 16:32:18 +01:00
Zack Tanner
d4b520aaa0
exclude default routes from isPageStatic check (#61173)
### What & Why
Using parallel routes with edge runtime would cause a build error when
using a default segment, because edge runtime has special handling to
[read the client reference
manifests](12c9040568/packages/next/src/build/utils.ts (L1543-L1555))
for these when determining if a page is static.

### How
In a similar fashion to how we exclude static checks on reserved pages,
I added similar handling for app pages.

Fixes #60917
Closes NEXT-2241
2024-01-26 06:43:18 -08:00
vercel-release-bot
5d0b29c046 v14.1.1-canary.13 2024-01-26 10:27:31 +00:00
Jimmy Lai
883e958271
build: remove sentry from the externals list (#61194)
Context:
- on app router, we bundle all the code used both on server and client
- sentry used to be incompatible with that, however a raw require call
on production to Sentry leads to a 350ms impact on cold boots/initial
load
- it might be ok to bundle now, let's try it out


<!-- 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-2250
2024-01-26 11:24:02 +01:00
Tim Neutkens
edc658a5cc
Upgrade Turbopack (#61190)
* https://github.com/vercel/turbo/pull/7104 <!-- Will Binns-Smith -
Turbopack: use inline sourcemaps for HMR chunks -->

<!-- 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-2248
2024-01-26 10:45:25 +01:00
vercel-release-bot
6391e1d820 v14.1.1-canary.12 2024-01-26 01:57:35 +00:00
vercel-release-bot
e2ca4e2228 v14.1.1-canary.11 2024-01-25 23:22:28 +00:00
Ahmed Abdelbaset
68dd495de9
Add maxDuration to typescript plugin allowed exports (#59193)
According to
[docs](https://nextjs.org/docs/app/api-reference/file-conventions/route-segment-config#maxduration)
and
[tests](a3616d33ed/test/e2e/app-dir/with-exported-function-config/app/app-ssr-edge/page.tsx (L6C1-L6C7)).
`maxDuration` should be a valid export. currently TypeScript plugin
throws.

---------

Co-authored-by: Jiachi Liu <inbox@huozhi.im>
2024-01-25 23:57:57 +01:00
Jiachi Liu
288d14e0db
chore: upgrade webpack to 5.90.0 (#61109)
Dependency: upgrade webpack to latest to benefit from the bug fixes and
underlying improvements

Closes NEXT-2220
2024-01-25 20:18:12 +01:00
Tim Neutkens
9cc7167e1b
Fix filesystempublicroutes test for Turbopack (#61132)
## What?

`exportPathMap` didn't work when Turbopack was enabled because the
`serializeNextConfig` function mutates the original values, overriding
`exportPathMap`.

This PR changes the serialization to copy the object and mutate only the
copied object.

Also refactored the test that was checking `_next`, the better way to
test that is to have the page render something dynamically, which is
what is added in this PR.

<!-- 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-2225
2024-01-25 14:44:50 +01:00
vercel-release-bot
9da4edaf64 v14.1.1-canary.10 2024-01-24 22:02:36 +00:00
Ethan Arrowood
1fdc00c3fb
add optimizeServerReact to config-shared (#61106)
This PR adds the `optimizeServerReact` experimental flag to the shared
config and defaults it to `false`.

<!-- 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-2219
2024-01-24 14:41:09 -07:00