Commit graph

9977 commits

Author SHA1 Message Date
Wyatt Johnson
6bc9f79e48
Shared Revalidate Timings (#64370)
<!-- Thanks for opening a PR! Your contribution is much appreciated.
To make sure your PR is handled as smoothly as possible we request that
you follow the checklist sections below.
Choose the right checklist for the change(s) that you're making:

## For Contributors

### Improving Documentation

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

### Adding or Updating Examples

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

### Fixing a bug

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

### Adding a feature

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


## For Maintainers

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

### What?

### Why?

### How?

Closes NEXT-
Fixes #

-->

### What?

This creates a new `SharedRevalidateTimings` type that is safe to share
amongst different points within the framework for sharing revalidation
timings. This is a precursor to #64313 which freezes loaded manifests.

### Why?

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

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

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

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

## How

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

Fixes #64214.

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

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

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

### Why?

### How?



Closes PACK-2913

---------

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

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

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

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

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

### Why

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

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

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


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



### What?

Update SWC crates.

### Why?

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

### How?



Closes PACK-2860
2024-04-11 00:09:18 +00:00
vercel-release-bot
22754faff6 v14.2.0-canary.65 2024-04-10 23:22:42 +00:00
Jeongjin Oh
04c87ae2d7
fix: show the error message if images.loaderFile doesn't export a default function (#64036)
<!-- Thanks for opening a PR! Your contribution is much appreciated.
To make sure your PR is handled as smoothly as possible we request that
you follow the checklist sections below.
Choose the right checklist for the change(s) that you're making:

## For Contributors

### Fixing a bug

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

-->

fixes #63803 

## What I do?

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

## AS-IS / TO-BE

### AS-IS

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

### TO-BE

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

---------

Co-authored-by: Steven <steven@ceriously.com>
2024-04-10 18:11:38 +00:00
Jiachi Liu
142050ddc0
Fix css FOUC in dynamic component (#64294)
### What

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

### Why

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

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

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

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

### Other Changes Overview

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

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

Replacement for #64021 but only with production test
2024-04-10 16:16:20 +02:00
Tim Neutkens
4c128a5d6b
Ensure configuration is checked for Turbopack build (#64247)
## What?

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

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

## For Contributors

### Improving Documentation

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

### Adding or Updating Examples

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

### Fixing a bug

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

### Adding a feature

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


## For Maintainers

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

### What?

### Why?

### How?

Closes NEXT-
Fixes #

-->


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

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

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

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

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

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

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

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

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

---------

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

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

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

Fixes #61918
Fixes #63915

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

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

---------

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

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

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

Closes NEXT-3030
2024-04-09 07:26:53 +00:00
Donny/강동윤
5aa984de75
feat: Do not mangle AbortSignal to avoid breaking node-fetch (#58534)
### What?

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

### Why?

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

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

### How?


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

Closes PACK-1977
2024-04-09 09:28:03 +09:00
vercel-release-bot
c289063517 v14.2.0-canary.63 2024-04-08 23:22:35 +00:00
Jiachi Liu
530382aeea
Fix hydration error higlight when tag matched multi times (#64133)
### What

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

### Why

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

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

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

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

Thanks @JohnPhamous for reporting the issue


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

x-ref:
https://github.com/vercel/next.js/discussions/54075#discussioncomment-9031149
<!-- Thanks for opening a PR! Your contribution is much appreciated.
To make sure your PR is handled as smoothly as possible we request that
you follow the checklist sections below.
Choose the right checklist for the change(s) that you're making:

## For Contributors

### Improving Documentation

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

### Adding or Updating Examples

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

### Fixing a bug

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

### Adding a feature

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


## For Maintainers

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

### What?

### Why?

### How?

Closes NEXT-
Fixes #

-->


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

Adds support for modern configurations introduced in TS 5.4

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

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

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

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

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

---------

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

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

### Why?

To align with the default mode

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

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

---------

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

Polish the UX based on the feedbacks from @sambecker 

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

### After vs Before

#### Runtime Error


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

#### Build Error

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



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

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

---------

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

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

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

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

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

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

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


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

## For Contributors

### Improving Documentation

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

### Adding or Updating Examples

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

### Fixing a bug

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

### Adding a feature

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


## For Maintainers

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

### What?

### Why?

### How?

Closes NEXT-
Fixes #

-->


Closes NEXT-3013
2024-04-05 16:53:03 +00:00
Wyatt Johnson
bb74ece14e
Ensure static generation storage is accessed correctly (#64088)
<!-- Thanks for opening a PR! Your contribution is much appreciated.
To make sure your PR is handled as smoothly as possible we request that
you follow the checklist sections below.
Choose the right checklist for the change(s) that you're making:

## For Contributors

### Improving Documentation

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

### Adding or Updating Examples

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

### Fixing a bug

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

### Adding a feature

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


## For Maintainers

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

### What?

### Why?

### How?

Closes NEXT-
Fixes #

-->

### What?

Primarily, this is fixing the code highlighted here:


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

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

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

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

### Why?

Without this change, checks like:


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

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

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

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

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


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

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

## For Contributors

### Improving Documentation

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

### Adding or Updating Examples

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

### Fixing a bug

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

### Adding a feature

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


## For Maintainers

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

### What?

### Why?

### How?

Closes NEXT-
Fixes #

-->


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

Closes NEXT-3005
2024-04-04 14:13:13 -07:00