Commit graph

11225 commits

Author SHA1 Message Date
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
Will Binns-Smith
6829d7df62
Disable trace uploads with NEXT_TRACE_UPLOAD_DISABLE (#61101)
While traces are never uploaded without an explicit opt-in, this option
prevents them from being sent even when one is provided.


Closes PACK-2289
2024-01-24 13:30:48 -08:00
Leah
21c2f85805
fix(turbopack): custom page extensions for _app (#60789)
### What?
The import alias had no way to resolve the page extensions and we
already have them resolved in the `PagesStructure`, so with this PR we
use the already resolved paths.

Closes PACK-2085
Fixes #59264
2024-01-24 22:15:21 +01:00
Leah
ae12b30464
chore: update turbopack (#61090)
### Turbopack Updates

* https://github.com/vercel/turbo/pull/7091 <!-- Tobias Koppers - lock
reqwest to 0.11.17 due to build issues -->
* https://github.com/vercel/turbo/pull/7080 <!-- Tobias Koppers - reduce
work and tasks during module analysis -->
* https://github.com/vercel/turbo/pull/7093 <!-- Leah - fix: don't
escape base path in ecmascript runtime to allow for URLs -->

Closes PACK-2282
Fixes #60891 via https://github.com/vercel/turbo/pull/7093
2024-01-24 20:44:42 +00:00
Leah
17cc6437c9
fix: emotion import source should be enabled in SSR contexts (#61099)
### What?

Due to probably a confusing argument name the correct import source for
emotion wasn't used.

Closes PACK-2084
Fixes #59269
2024-01-24 20:19:55 +01:00
Leah
10ca4346f2
fix(turbopack): use correct layout for 404 page (#61032)
### What?

This fixes 2 issues with app 404 pages.
1. The root layout in a group was previously ignored when hitting the
404 page.
2. The default app 404 page was missing the correct path for dev
`/not-found` so it would fall back to the pages 404 page.

Closes PACK-2241
Fixes #60688
2024-01-24 20:07:06 +01:00
Jiachi Liu
b08fb216bf
Fix instrument bundling as client components (#60984)
### What

When users're using nextjs server API that break the build, and error
with incorrect client components usage.
Instrument should be treated as server components or server-only build
target, instead of being treated as client components.

### How

We added a new layer `instrument` for instrument hook bundling, and
apply it with the rsc server webpack loaders

Fixes #57563
Closes NEXT-2181
Closes NEXT-1994
2024-01-24 20:02:53 +01:00
Shu Ding
3db8e9b035
Improve the Server Actions SWC transform (#61001)
This PR improves the Server Actions SWC transform to make it able to
handle nested Action declarations (check
`fixture/server-actions/server/28/input.js` for more details).

It is also a simplification of that transform's internal states and
methods, with the removal of an extra AST pass
(`stmts.visit_mut_with(&mut ClosureActionReplacer {
replaced_action_proxies: &self.replaced_action_proxies, })`). The
generated code is also smaller in some cases. So overall I'd expect the
compilation and runtime performance to improve as well.

## Details

With this change, we're now using `self.declared_idents` and
`self.names` to track closure arguments. `declared_idents` keeps the
identifiers **declared** in the current closure and above. `names` keeps
identifiers **appeared** in the current closure and above. In an example
of the following cursor:

```ts
let x

async function foo() {
  "use server"
  let y

  async function bar() {
    "use server"
    let z
    console.log(x, y, z)
  }

  // <- cursor
}
```

`declared_idents` would be `y` (`x` isn't in a closure), and `names`
would be `x, y, z`. By manipulating these two states we're able to track
closure closed-up variables recursively.

Closes NEXT-2189
2024-01-24 10:33:22 -08:00
Zack Tanner
db468e399b
ppr: ensure the router state tree is provided for interception routes (#61059)
### What?
Interception routes on dynamic paths don't currently work when PPR is
turned on, and instead trigger an MPA navigation to the full route.

### Why?
Route interception relies on the `Next-Flight-Router-State` header to
extract the dynamic params necessary to convert something like
`[locale]`, which would correspond with a URL of `/en`, to something
like `["locale", "en", "d"]`. (See [this
function](fbfd7b5f81/packages/next/src/server/app-render/app-render.tsx (L129-L137))
for more info). When PPR is turned on, we currently ignore this request
header and don't provide it to the functions that render the component
tree.

Without the flight router state, this function bails out and instead
will leave the segment key as `[locale]`. When the client router goes to
diff the current tree on the client with the response from the server,
it will detect a mismatch between the current segment and the incoming
segment, and trigger an MPA navigation in [this
block](fbfd7b5f81/packages/next/src/client/components/router-reducer/reducers/navigate-reducer.ts (L414-L416)).

### How?
This special-cases interception routes to not strip this header.

Closes NEXT-2215
2024-01-24 10:20:47 -08:00
Jiachi Liu
5883a9a3a4
Fix sitemap generateSitemaps support for string id (#61088)
### What

Fixes the string id that broken when sitemap is optimized to static
route.

### Why

When sitemap is optimized to static route in production, the route
argument is changed from `[[...__metadata_id__]]` to
`[__metadata_id__]`, so the type of it is also changed from array to
string that should reflect in the loader code.

Fixes #60894 
Closes NEXT-2154
2024-01-24 16:52:52 +01:00
Jiachi Liu
905c0e7b0c
Fix version checker not displaying when version newer than npm (#61075)
Fixes flaky test of version checker display when local version is
greater than latest canary, but not published yet

Closes NEXT-2216
2024-01-24 14:59:43 +01:00
vercel-release-bot
0e1aa71616 v14.1.1-canary.9 2024-01-24 10:27:13 +00:00
Donny/강동윤
014b212388
Update swc_core to v0.87.28 (#60876)
# Turbopack

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

---

### What?

Update swc crates

### Why?

Required for #57718.
`styled-jsx` crate now has a hook to transform CSS code using a
Rust-side API

### How?

Fixes #57718



Closes PACK-2256
2024-01-24 08:05:05 +00:00
Donny/강동윤
ccf491dc71
chore: Update terser to v5.27.0 (#61068)
### What?

Update terser to the latest version.

### Why?

We need
c677e28526
which adds supports for class static blocks.

### How?

Closes PACK-2285
Fixes #60837
2024-01-24 08:42:08 +01:00
Jiachi Liu
9de7705c99
Enable next.js version checker in turbopack (#61034)
### What

We've had the Next.js version checker in dev overlay of webpack mode.
But it was missing for turbopack. Add it in turbopack mode and also give
a small marker `"(turbo)"` to highlight turbopack mode.

Screenshot

<img width="576" alt="image"
src="https://github.com/vercel/next.js/assets/4800338/1bb1500c-fd92-43bd-a60a-ddc7cd63ce6f">


Closes NEXT-2196
Closes NEXT-2106
2024-01-24 06:37:18 +01:00
Josh Story
b5772b859a
Dynamic APIs (#60645)
formalizes the concept of dynamic APIs inside Next to allow for varying
semantics beyond just staticGenerationBailout.

### Dynamic APIs

#### `markCurrentScopeAsDynamic`
useful to bail out of default caching semantics but does not imply a
Request specific data source was read. critically, this semantic is
ignored if you are inside a cache scope

#### `trackDynamicDataAccessed`
Must be called before reading any data source that is derived from
Request specific data. Currently this is `cookies()`, `headers()`, and
`searchParams`. This kind of data access inside a cache scope is
forbidden (it always should have been, but now it will error).

#### `trackDynamicFetch`
This one is unideal but the complexity of patch-fetch's current
implementation necessitates it for now. Essentially it will postpone if
we are prerendering. Long term this should be eliminated with a refactor
of patch fetch.


### Other Improvements
Also removes the `staticGenerationBailout` implementation as it has been
replaced with more specific logic in the places it was previously being
used.

One area that has also been enhanced is the proxy for app-route modules.
Previously we proxied the Request every time however when we are doing
non-static generation executions we generally don't want the overhead of
wrapping the request. In the refactor here I also improved the runtime
performance by using static proxy handlers and I believe I also fixed a
few bugs related to `clone` and `url`

In general there has been a bit of refactoring to clarify how we should
handle various render/execution states and a reduction in implicit side
effects for proper execution.

Another callout to notice is that app-route modules do not attempt a
static generation if they are force-dynamic regardless of the PPR
setting. Previously the PPR setting would opt them into this code path
which is not necessary because PPR itself does not work for routes, only
pages.

Closes NEXT-2099
2024-01-23 16:06:12 -08:00
Willi#m ⬣
78c9793a53
fix useSelectedLayoutSegment's support for parallel routes (#60912)
fixes NEXT-2173
Fixes #59968

### TODOs

- [x] recreate [repro](https://github.com/williamli/nextjs-NEXT-2173) 
- [x] patch `useSelectedLayoutSegment` to support parallel routes (see
"What")
- [x] check `useSelectedLayoutSegments` to see if it is affected
- [x] add test cases
- [x] finalise PR description

### What?

`useSelectedLayoutSegment` does not return the name of the active state
of parallel route slots.

#### Expected Behaviour

According to
https://nextjs.org/docs/app/building-your-application/routing/parallel-routes#useselectedlayoutsegments

> When a user navigates to app/@auth/login (or /login in the URL bar),
loginSegments will be equal to the string "login".

👉🏽 We should update the docs to explain `null` and __DEFAULT__ result as
well.

According to the [API reference for
useSelectedLayoutSegment](https://nextjs.org/docs/app/api-reference/functions/use-selected-layout-segment#returns):

> useSelectedLayoutSegment returns a string of the active segment or
null if one doesn't exist.

> For example, given the Layouts and URLs below, the returned segment
would be:

> <img width="881" alt="CleanShot 2024-01-20 at 14 50 52@2x"
src="https://github.com/vercel/next.js/assets/179761/bfaa34c8-3139-4ec3-bd70-4346c682e36b">


#### Current Behaviour

Currently a string "children" is returned for everything inside a
parallel route with active state and `__DEFAULT__` is returned if there
is no active state for the parallel route (since the `default.tsx` is
loaded). ~`null` is returned when the `default.tsx` is not loaded
(possibly caused by another bug, see test case 5).~

#### Reproduction

[GitHub Repo](https://github.com/williamli/nextjs-NEXT-2173) is created
based on the example provided in [Next.js docs for using
`useSelectedLayoutSegment` with Parallel
Routes](https://nextjs.org/docs/app/building-your-application/routing/parallel-routes#useselectedlayoutsegments).

#### Test Cases

1. If you visit https://next-2173.vercel.app/, you get loginSegments:
__DEFAULT__ (hard navigation) or children (soft navigation after
returning from a visit to /login)
2. If you soft nav to (/app/@auth/login and /app/@nav/login)
https://next-2173.vercel.app/login, you get
    1. loginSegment: `children` (expected value should be `login`)
    2. navSegment: `children` (expected value should be `login`)
3. If you soft nav to (/app/@auth/reset)
https://next-2173.vercel.app/reset, you get
    1. loginSegments: `children` (expected value should be `reset`)
    2. navSegment: `children` (expected value should be `login`)
4. If you soft nav to (/app/@auth/reset/withEmail)
https://next-2173.vercel.app/reset/withEmail, you get
    1. loginSegments: `children` (expected value should be `withEmail`)
    2. navSegment: `children` (expected value should be `login`)
5. ~If you hard nav to (/app/@auth/reset/withEmail)
https://next-2173.vercel.app/reset/withEmail, you get an unexpected
result due to possibly another bug:~
* ~navSegment is `null` on the deployed (Vercel) version, the navSlot is
*not* loaded~
* ~navSegment is `__DEFAULT__` on local dev, the navSlot loads
`/app/@nav/default.tsx`.~


### Why?

In `packages/next/src/client/components/navigation.ts`,
`getSelectedLayoutSegmentPath` is called and returns the correct
segmentPath for parallel routes (even though there is a TODO comment
indicating this function needs to be updated to handle parallel routes)
but `useSelectedLayoutSegment` failed to return the correct segment when
a parallelRouteKey is provided.

### How?

`useSelectedLayoutSegment` is updated to return
selectedLayoutSegments[0] for non parallel routes (original logic), but
it will return the last segments for parallel routes (or null if nothing
is active).

```
return parallelRouteKey === 'children'
    ? selectedLayoutSegments[0]
    : selectedLayoutSegments[selectedLayoutSegments.length-1] ?? null
```

---------

Co-authored-by: Zack Tanner <zacktanner@gmail.com>
2024-01-23 15:53:45 -08:00
vercel-release-bot
b2b654dba7 v14.1.1-canary.8 2024-01-23 23:23:10 +00:00
Steven
6c611fe9a8
fix(image): warn when animated image is missing unoptimized prop (#61045)
This PR adds a warning when attempting to optimize an animated image.

```jsx
<Image src="/image.gif" />
```

The warning looks like the following:

```
The requested resource "/image.gif" is an animated image so it will not be optimized. Consider adding the "unoptimized" property to the <Image>.
```

To remove the warning, add the `unoptimized` prop.

```jsx
<Image src="/image.gif" unoptimized />
```

We don't attempt to optimized animated images because it can be very
slow (30+ seconds) and sometimes deoptimizeds (the output is larger than
the input) so its best to serve the animated image as-is.

Closes NEXT-2199
2024-01-23 17:31:33 -05:00
Willi#m ⬣
71335a9912
fix parallel route top-level catch-all normalization logic to support nested explicit (non-catchall) slot routes (#60776)
Fix NEXT-2165

### What?

Addresses the limitation of #60240, where a dummy `default` file is
required in parallel route child slot to prevent errors in dev server
rendering (`TypeError: Cannot read properties of undefined (reading
'clientModules')`) as well as errors in build and deploy (`Error:
ENOENT: no such file or directory, lstat
‘/vercel/path0/.next/server/app/parallel-route/[section]/@part/[partSlug]/page_client-reference-manifest.js’`)

Without the `default.tsx`, builds and deployments will fail with:

<img width="956" alt="CleanShot 2024-01-18 at 02 12 36@2x"
src="https://github.com/vercel/next.js/assets/179761/80ba61bd-6ec0-4b16-a393-dc9375227e19">

local dev server will also crash with:

<img width="986" alt="CleanShot 2024-01-18 at 02 13 19@2x"
src="https://github.com/vercel/next.js/assets/179761/cc500a32-b2f8-47b4-999e-e57cf5141b2f">

> TypeError: Cannot read properties of undefined (reading
'clientModules')


### Why?

Since `default.tsx` is not a compulsory when you have slot that are
specific and ends with a dynamic route segment, this PR extends support
so that it is possible mixing catch-all routes with specific
non-catchall routes without requiring an additional `default.tsx` .

This PR will allow the following test cases to pass:

```
it('should not add the catch-all route to segments that have a more specific [dynamicRoute]', () => {
    const appPaths = {
      '/': ['/page'],
      '/[[...catchAll]]': ['/[[...catchAll]]/page'],
      '/nested/[foo]/[bar]/default': [
        '/nested/[foo]/[bar]/default',
        '/nested/[foo]/[bar]/@slot0/default',
        '/nested/[foo]/[bar]/@slot2/default',
      ],
      '/nested/[foo]/[bar]': [
        '/nested/[foo]/[bar]/@slot0/page',
        '/nested/[foo]/[bar]/@slot1/page',
      ],
      '/nested/[foo]/[bar]/[baz]': [
        '/nested/[foo]/[bar]/@slot0/[baz]/page',
        '/nested/[foo]/[bar]/@slot1/[baz]/page',
      ],
      '/[locale]/nested/[foo]/[bar]/[baz]/[qux]': [
        '/[locale]/nested/[foo]/[bar]/@slot1/[baz]/[qux]/page',
      ],
    }

    const initialAppPaths = JSON.parse(JSON.stringify(appPaths))
    normalizeCatchAllRoutes(appPaths)
    expect(appPaths).toMatchObject(initialAppPaths)
  })
...
```

```it('should not add the catch-all route to segments that have a more specific [dynamicRoute]', () => {
    const appPaths = {
      '/': ['/page'],
      '/[[...catchAll]]': ['/[[...catchAll]]/page'],
      '/nested/[foo]/[bar]/default': [
        '/nested/[foo]/[bar]/default',
        '/nested/[foo]/[bar]/@slot0/default',
        '/nested/[foo]/[bar]/@slot2/default',
      ],
      '/nested/[foo]/[bar]': [
        '/nested/[foo]/[bar]/@slot0/page',
        '/nested/[foo]/[bar]/@slot1/page',
      ],
      '/nested/[foo]/[bar]/[baz]': [
        '/nested/[foo]/[bar]/@slot0/[baz]/page',
        '/nested/[foo]/[bar]/@slot1/[baz]/page',
      ],
      '/[locale]/nested/[foo]/[bar]/[baz]/[qux]': [
        '/[locale]/nested/[foo]/[bar]/@slot1/[baz]/[qux]/page',
      ],
    }
...
```

and allow parallel routes defined in this [code
repro](https://github.com/williamli/nextjs-NEXT-2165) to build.


![image](https://github.com/vercel/next.js/assets/179761/030f4fe1-3a27-41e5-bbd9-bc511f95e5d7)


### How?

`packages/next/src/build/normalize-catchall-routes.ts` is extended to
check `appPath` to see if it is:
1. the route is not a catchall
2. `isMoreSpecific` than the closest `catchAllRoute`.


where `isMoreSpecific` is defined as:

```

function isMoreSpecific(pathname: string, catchAllRoute: string): boolean {
  const pathnameDepth = pathname.split('/').length
  const catchAllRouteDepth = catchAllRoute.split('/').length - 1
  return pathnameDepth > catchAllRouteDepth
}

```

---------

Co-authored-by: Zack Tanner <zacktanner@gmail.com>
2024-01-23 22:11:13 +00:00
Tim Neutkens
59e042a9a7
Implement client_root for edge in Turbopack (#61024)
## What?

Implements https://github.com/vercel/turbo/pull/7081. Ensures image
imports in the edge runtime have the correct asset url. Previously it
would be `/assets/file.hash.png` but it should be
`/_next/static/media/file.hash.png`.

Updates the image tests to correctly compare the values in Turbopack and
the values in Webpack. Currently it only checks webpack values, causing
the tests to fail in 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-2194
2024-01-23 18:41:02 +01:00
Tobias Koppers
a7a403f498
update turbopack (#61015)
* https://github.com/vercel/turbo/pull/7067 <!-- Tobias Koppers - fix a
hanging issue with strongly consistent reads -->
* https://github.com/vercel/turbo/pull/7068 <!-- Tobias Koppers - add
lazy_remove_children feature flag -->
* https://github.com/vercel/turbo/pull/7073 <!-- OJ Kwon -
fix(ecmascript): collect recoverable error after parse -->

---------

Co-authored-by: Tim Neutkens <tim@timneutkens.nl>
2024-01-23 14:35:17 +01:00
vercel-release-bot
fc7a28a0dd v14.1.1-canary.7 2024-01-23 11:04:26 +00:00
Tobias Koppers
3a7fea4034
Revert "refactor(analysis): rust based page-static-info, deprecate js parse interface in next-swc" (#61021)
Reverts vercel/next.js#59300

Breaks `app/page.mdx` files

Closes PACK-2279
2024-01-23 12:00:36 +01:00
Tobias Koppers
30fe0b8322
avoid output of webpack stats (#61023)
### What?

`ANALYZE=1` is set in CI, but this shouldn't emit stats.

### Why?

It sometimes causes the `lint` step to fail as prettier checks these
stats files too


Closes PACK-2280
2024-01-23 11:53:19 +01:00
Delba de Oliveira
142584cb59
docs: Address community feedback (#60960)
Closes: 

- https://github.com/vercel/next.js/issues/60953
- https://github.com/vercel/next.js/issues/60755

---------

Co-authored-by: Lee Robinson <me@leerob.io>
2024-01-22 19:19:34 -06:00
Zack Tanner
cf0f090fca
disable static generation on interception routes (#61004)
### What & Why?
Interception routes depend on contextual information that are provided
via request headers. Specifically it needs to know about the
`Next-Router-State-Tree` when generating the interception route RSC
data, which isn't available at build time. This doesn't currently cause
any usage issues, but it erroneously emits static files & RSC payloads
that the client router won't be able to use and will instead fallback to
a dynamic request.

I removed some special case in an existing test since this fix also
resolves a discrepancy in behavior when PPR is turned on

### How?
This excludes interception routes from `appStaticPaths` at builds which
currently determines which pages should be statically generated.

Closes NEXT-2190
2024-01-22 16:33:39 -08:00
vercel-release-bot
bb2aaf74e8 v14.1.1-canary.6 2024-01-22 22:46:28 +00:00
OJ Kwon
9d5f62eb4a
refactor(analysis): rust based page-static-info, deprecate js parse interface in next-swc (#59300)
### Description

This PR refactors existing `analysis/get-static-page-info`, moves over
most of parse / ast visiting logic into next-swc's rust codebase. By
having this, turbopack can reuse same logic to extract info for the
analysis. Also as a side effect, this removes JS side parse which is
known to be inefficient due to serialization / deserialization.

The entrypoint `getPageStaticInfo` is still in the existing
`get-page-static-info`, only for extracting / visiting logic is moved.
There are some JS specific context to postprocess extracted information
which would require additional effort to move into.


Closes PACK-2088
2024-01-22 14:42:28 -08:00
Leah
f5dab7ce7d
chore: update turbopack (#60980)
### Turbopack Updates

* https://github.com/vercel/turbo/pull/6923 <!-- Tobias Koppers - Bottom
up tracing and some tracing improvements -->
* https://github.com/vercel/turbo/pull/7028 <!-- Leah - fix: add missing
layer ident modifier to asset with inner assets -->

Closes PACK-2270
2024-01-22 17:03:22 +01:00
Jiachi Liu
92265ccbe9
Fix next phase for next build (#60969)
In both dev server and production build we both use `getStartServerInfo`
to log the basic info but for prod build we should always respect to use
"build" phase

Fixes #57927 
Closes NEXT-2179
2024-01-22 15:37:04 +01:00
Tim Neutkens
0f044d0ea8
Use more precompiled deps in react-dev-overlay (#60959)
## What?

Follow-up to #60932, adds all other precompiled dependencies.

<!-- 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-2178
2024-01-22 13:53:42 +01:00
Tim Neutkens
4125069840
Use precompiled source-map in overlay middleware (#60932)
## What?

Since #60889 is failing tests I'm narrowing the changes into some
separate PRs that can be landed independently.

This PR adds source-map@0.8.0-beta.0` to the precompiled dependencies.

<!-- 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-2177
2024-01-22 10:04:34 +01:00
Tim Neutkens
4d2ef951dc
Error overlay refactors (#60886)
## What?

Some small refactors to the click handler in the error overlay.

Also removes `export` for a function that is only used in the module.

<!-- 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-2169
2024-01-22 10:01:16 +01:00
vercel-release-bot
e5e33d4d21 v14.1.1-canary.5 2024-01-21 23:22:29 +00:00
vercel-release-bot
48533617d1 v14.1.1-canary.4 2024-01-20 23:23:00 +00:00
Will Binns-Smith
498f342b35
Turbopack: always log HMR rebuild times (#60908)
This removes the need for `NEXT_HMR_TIMING` to do this.


Closes PACK-2264

Co-authored-by: JJ Kasper <jj@jjsweb.site>
2024-01-19 17:07:22 -08:00
vercel-release-bot
5c0e1419ef v14.1.1-canary.3 2024-01-19 23:39:47 +00:00
Will Binns-Smith
7b9e711ed5
Report HMR latency as trace spans for Turbopack (#60799)
This:
- Makes makes reporting hmr changes more accurate by emitting an
explicit start event and lowering the aggregation period for reporting
completed turbo tasks
- Parameterizes the aggregation period, allowing JS subscribers to
request different intervals, such as for the next-rs-api test
- Aligns path pattern with webpack by normalizing its layer names
- Fixes a bug in `drainAndGetNext` where the stream never could drain
past the first item
- Sends `client-hmr-latency` spans from Turbopack in both page and app
router pages


Closes PACK-2252

---------

Co-authored-by: Tobias Koppers <tobias.koppers@googlemail.com>
2024-01-19 15:34:17 -08:00
vercel-release-bot
f6da5a0fe2 v14.1.1-canary.2 2024-01-19 23:21:34 +00:00
Sukka
53a0a0fb87
chore: replace micromatch w/ picomatch (#60699)
The PR continues from #58038 aiming to reduce the installation size
further, and **improve performance in doing so**.

Most of `micromatch`'s APIs are essentially wrappers/alias of
`picomatch`, supplemented with additional features facilitated by a
transitive dependency `braces`. However, Next.js doesn't use those
"extra features". Switching from `micromatch` to `picomatch` can avoid
introducing the transitive dependency `braces`.

The PR also improves some globs' performance by hoisting.

- `micromatch.makeRe` is just an alias of `picomatch.makeRe`
-
90dc0cd3e1/index.js (L387C30-L387C30)
- `micromatch.isMatch(str, patterns, options)` equals
`picomatch(patterns, options)(str)`
-
90dc0cd3e1/index.js (L123)
- `micromatch.matcher` is just an alias of `picomatch`
-
90dc0cd3e1/index.js (L104C1-L104C40)

---------

Co-authored-by: Sam Ko <sam@vercel.com>
2024-01-19 19:56:16 +00:00
Dima Voytenko
35422800fa
Telemetry: createComponentTree span (#60857)
This span is meant to be a parent for all "resolve segment modules"
spans.
2024-01-19 10:40:08 -08:00
Balázs Orbán
dc109bf6c9
chore: indicate staleness more prominently in next info output (#60376)
### What?

Improve the `next info` output.

<details>
<summary>Before:
</summary>
<img
src="https://github.com/vercel/next.js/assets/18369201/735da72f-6746-42a0-838d-e10db78b2db3">
</details>

<details>
<summary>After:
</summary>
<img
src="https://github.com/vercel/next.js/assets/18369201/d72c0027-71d9-494c-bb98-dd0fed99c8d9">
</details>

### Why?

People have been ignoring the ask to check `next@canary` before opening
a new issue, which results in triaging overhead. This PR inlines the
warning into `next info` that would make it an extra effort to remove
the warning without reading the message, hopefully leading to not
ignoring the message anymore.

### How?

Reusing the same logic from the version staleness indicator from Error
Overlay.

[Slack
thread](https://vercel.slack.com/archives/C03KAR5DCKC/p1704364764719949)
2024-01-19 18:36:19 +01:00
Damien Simonin Feugas
821849261d
Deprecation warning for config.analyticsId (#60677)
###  🧐 What's in there?

`config.analyticsId` is a rarely-used mechanism, initially intended to
Next.js users hosting their application themselves and willing to report
Core Web Vitals to Vercel Speed Insights.

This platform specific mechanism can be replaced with the built-in
[`useReportWebVitals`](https://nextjs.org/docs/app/api-reference/functions/use-report-web-vitals).

### 🧪 How to test?

1. make a new Next.js app
1. define env variable `VERCEL_ANALYTICS_ID` to a dummy value
1. start your application in dev mode:
   ```shell
⚠ config.analyticsId is deprecated and will be removed in next major
version. Read more:
https://nextjs.org/docs/messages/deprecated-analyticsid
   
      ▲ Next.js 14.0.5-canary.58
      - Local:        http://localhost:3000
    ✓ Ready in 917ms
   ```
1. build your application:
   ```shell
      ▲ Next.js 14.0.5-canary.58
   
      Creating an optimized production build ...
    ✓ Compiled successfully
      Linting and checking validity of types  .
⚠ The Next.js plugin was not detected in your ESLint configuration. See
https://nextjs.org/docs/basic-features/eslint#migrating-existing-config
    ✓ Linting and checking validity of types
    ✓ Collecting page data
    ✓ Generating static pages (4/4)
⚠ `config.analyticsId` is deprecated and will be removed in next major
version. Read more:
https://nextjs.org/docs/messages/deprecated-analyticsid
    ```
1. remove the env variable, add a `next.config.js` file with a dummy
`analyticsId` variable:
   ```js
   module.exports = { analyticsId: "UA-12345678-9" };
   ```
1. start your application in dev mode: it'll issue the same warning.
1. build your application: it'll issue the same warning.

---------

Co-authored-by: Tim Neutkens <tim@timneutkens.nl>
2024-01-19 14:45:05 +01:00
vercel-release-bot
0fc29480fc v14.1.1-canary.1 2024-01-19 06:02:07 +00:00
JJ Kasper
bde427a7d7
Optimize build trace ignores (#60859)
It seems that when tracing build dependencies our server tracing was
analyzing all server chunks un-necessarily and when a very large
dependency like `ace-builds` is creating large chunks it can slow down
builds drastically so this ensures we eagerly apply our shared ignores
to avoid this over tracing.

Build times before [with provided
repro](https://github.com/MartinXPN/next-slow-build-reproduction):

```sh
▲ Next.js 14.1.0

   Creating an optimized production build ...
 ✓ Compiled successfully
 ✓ Linting and checking validity of types
 ✓ Collecting page data
 ✓ Generating static pages (5/5)
 ✓ Collecting build traces
 ✓ Finalizing page optimization

  Done in 437.29s.
```

Build times after [with provided
repro](https://github.com/MartinXPN/next-slow-build-reproduction):

```sh
▲ Next.js 14.1.1-canary.0

   Creating an optimized production build ...
 ✓ Compiled successfully
 ✓ Linting and checking validity of types
 ✓ Collecting page data
 ✓ Generating static pages (5/5)
 ✓ Collecting build traces
 ✓ Finalizing page optimization

  Done in 42.38s.
```


Closes: https://github.com/vercel/next.js/issues/58759
Closes NEXT-2161
2024-01-18 21:58:05 -08:00
Jesse Koldewijn
3734ae8890
fix: added @sentry/profiling-node to sep list to prevent build/bundle breakage (#60855)
Issue: https://github.com/vercel/next.js/issues/60853

### What?
Added `@sentry/profiling-node` to the server-external-package object so
that sentry users who want to use this package don't have to manually
add this package in the experimental nextjs config entry.

### Why?
Package bundling will fail as shown in the following issue if not added
to this exclude list.
https://github.com/getsentry/profiling-node/issues/170

---

Fixes #60853
2024-01-19 05:16:03 +00:00
vercel-release-bot
fcfa45cd8e v14.1.1-canary.0 2024-01-18 23:23:12 +00:00
JJ Kasper
75f73fe93d
Update build worker warning to use debug (#60847)
Since we are enabling `webpackBuildWorker` by default now we should move
this warning to debug since it can be confusing without additional
context.

x-ref: [slack
thread](https://vercel.slack.com/archives/C04KC8A53T7/p1705612748627769?thread_ts=1705599489.811039&cid=C04KC8A53T7)

Closes NEXT-2158
2024-01-18 14:35:13 -08:00
vercel-release-bot
16e7a5bd93 v14.1.0 2024-01-18 21:41:02 +00:00
vercel-release-bot
1b255a6c5b v14.0.5-canary.68 2024-01-18 20:14:53 +00:00
Jiachi Liu
02c2f11ec9
Enable missing suspense bailout by default (#60840)
`experimental.missingSuspenseWithCSRBailout` should be enabled by
default to help users to disciver unwrapped suspense boundaries.

Add more notes in the error doc about deprecation and temporary
workaround to disable it.

Closes NEXT-2157

---------

Co-authored-by: JJ Kasper <jj@jjsweb.site>
2024-01-18 21:11:22 +01:00
vercel-release-bot
2096dfa687 v14.0.5-canary.67 2024-01-18 17:48:11 +00:00
Jiachi Liu
b8d8e6e7cc
dx: warn the deprecated cache configs are used (#60836)
Follow up for #57953 for DX, give better warnings

x-ref:
https://github.com/vercel/next.js/pull/60828#discussion_r1457736645

Closes NEXT-2156
2024-01-18 18:38:29 +01:00
Jiachi Liu
c192f4ec2f
turbopack: rename custom cache handler configs (#60828)
Follow up for #57953 for turbopack side

Closes NEXT-2153
2024-01-18 18:10:10 +01:00
Steven
2227ae5f34
Revert "Fix: Throw an error for empty array return in generateStaticParams with output:export" (#60831)
Reverts vercel/next.js#57053 per this comment:
https://github.com/vercel/next.js/pull/57053#issuecomment-1892747474

Instead of erroring, we should warn (and only in dev mode). That can be
added in a future PR.

Closes NEXT-2155
2024-01-18 18:02:07 +01:00
Jiachi Liu
b7f5107544
Fix: respect init.cache if fetch input is request instance (#60821)
When there’s a request input instance and init object present the same
time, we should respect init as preferred

Closes NEXT-2149
2024-01-18 17:54:36 +01:00
JJ Kasper
752c15e798
Add metrics names for unstable_cache (#60802)
This ensures we add params for `unstable_cache` so it can be identified
the same was as fetches instead of being unlabeled.

Closes NEXT-2143
2024-01-18 17:49:35 +01:00
JJ Kasper
e733853cf5
Ensure request specific caches for revalidate are reset (#60810)
This ensures our in memory cache leveraged for the `fetch-cache`
interface is reset per-request instead of using an arbitrary timeout so
that we are always pulling the revalidate state from upstream correctly
on new requests.

Before:
https://vercel-revalidate-3zi8wpexo-vtest314-ijjk-testing.vercel.app/
After:
https://vercel-revalidate-70y5a8dbh-vtest314-ijjk-testing.vercel.app/

Closes: https://github.com/vercel/next.js/issues/60680

Closes NEXT-2144
2024-01-18 16:43:55 +00:00
Leah
c2473471e2
feat: support custom image loaders in turbopack (#60736)
### What?
We were missing the alias (and config field) for custom image loaders.

Closes PACK-2190
Fixes #60097
2024-01-18 16:23:06 +00:00
Steven
cb71d80879
chore(deps): update browserslist and caniuse-lite (#60827)
Closes #57872
Closes NEXT-2152
2024-01-18 16:14:38 +00:00
Jiachi Liu
7472cefb42
Remove the warning for build worker when custom webpack present (#60820)
Drop the warning of build worker due to the common usage of custom
webpack

Closes NEXT-2148
2024-01-18 15:06:08 +00:00
Balázs Orbán
b14c1eb991
fix(ts): auto-complete next/headers (#60817)
### What?

Add support for auto-importing `headers()` and `cookies()`

### Why?

Improve the auto-import experience in IDEs like VScode

### How?

Re-export the `next/headers` type references

Closes NEXT-2146
2024-01-18 15:01:22 +01:00
vercel-release-bot
8179e7008e v14.0.5-canary.66 2024-01-18 12:52:28 +00:00
Jiachi Liu
e0399ca6dc
Support next/og usage in ESM nextjs app (#60818)
### What 

Follow up for #59852 , now you can use `next/og` if your nextjs app is
marked as ESM with `"type": "module"` in package.json.

### How

It's a bug in external handling, we shouldn't ESM import error for local
requests. Previously you'll see the below error but the
og import shouldn't be errored as it's not external package

```
Module not found: ESM packages (/.../app/opengraph-image.js) need to be imported. Use 'import' to reference the package instead
 https://nextjs.org/docs/messages/import-esm-externals
```


Closes NEXT-2147
2024-01-18 13:44:50 +01:00
Tim Neutkens
299d145303
Use snapshots for component-stack tests (#60768)
### What?

Follow-up to #60579 and #60750. Checking `startsWith` is not enough
because it hides the rest of the stack. Changed the test to check the
snapshot for Turbopack and webpack.

Fixes a bug where the stack lines showed `http (NaN:NaN)` as the source
lines.

Added support for source lines that don't have a open in editor.

<!-- 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-2128
2024-01-18 13:44:03 +01:00
Willi#m ⬣
c5bdc5c54f
add missing function call to normalize-catchall-routes test case (#60777)
### Fixed a Test Case

- Tests fixed:
`packages/next/src/build/normalize-catchall-routes.test.ts`, the
function call `normalizeCatchAllRoutes(appPaths)` was removed by
accident in this [merged commit
](efebba80a7 (diff-e3c0d3c6e15d8b035a3252a1ada2b04d5dd33010885fed8f6d689f75aa80bff5))
rendering the test case pointless

REF NEXT-1984
2024-01-18 00:33:54 -08:00
Dima Voytenko
9e8e44e530
Dev Server: Preserve globals overwrites in the initialization hook (#60796)
The original dev server implementation records globals in the server
constructor and thus overwrites the values initialized in the
instrumentation hook. This is a major delta from the `next start` where
the instrumentation values are preserved.

Fixes: https://github.com/vercel/next.js/issues/47596
Fixes: https://github.com/vercel/next.js/issues/53407
2024-01-17 16:32:54 -08:00
Shu Ding
fd59a007e1
Fix Server Actions compiler bug (#60794)
This PR fixes the issue where an inline Server Action gets exported. As
this isn't the designed use case for inline Server Actions (they're
supposed to be defined and used inside another closure, such as
components), we are not handling the export cases currently:

```ts
export async function action() {
  "use server"
  ...
}

<form action={action}/>
```

...which gets compiled into:

```ts
export async function action() {} // No-op function

<form action={...actionReference...}/>
```

Note that everything works inside this module until you `import` that
action and use it in another module.

To tackle that, this PR changes how that works as described in
`server/27/output.js`.

Closes NEXT-2140
2024-01-18 01:29:07 +01:00
Steven
4b50313fd9
feat: stabilize unstable_getImgProps() => getImageProps() (#60739)
This PR renames `unstable_getImgProps` to `getImageProps()` (originally
introduced in PR #51205).

Most feedback [after
announcing](https://twitter.com/leeerob/status/1674250190432116736)
looks positive so it seems like we can safely stabilize this API now.
Its unlikely to change.

I also added documentation with example usage.

Closes NEXT-2120
Fixes https://github.com/vercel/next.js/issues/56009
2024-01-17 18:28:49 -05:00
vercel-release-bot
70fc4028eb v14.0.5-canary.65 2024-01-17 23:23:34 +00:00
Lee Robinson
16dcebe792
Stabilize custom cache handlers and changing memory size. (#57953)
This PR stabilizes the previously introduced experimental config options
for providing a custom cache handler (for both ISR as well as the Data
Cache) and for disabling or configuring the in-memory cache size. The
example usage would be as follows:

```js
// next.config.js
module.exports = {
  cacheHandler: require.resolve('./cache-handler.js'),
  cacheMaxMemorySize: 0 // disable default in-memory caching
}
```

This PR also updates the documentation to better reflect how to use the
custom cache handler when self-hosting. Further information will be
added in a following PR that also includes a full example of a custom
cache handler that implements `revalidateTag` as well as passing in
custom cache tags. The API reference docs have been updated here, as
well as a version history added.

I also noticed that we currently have two duplicated versions of the ISR
docs in the Pages Router docs: both for rendering and for data fetching.
Data Fetching is the correct location for this page. There were no other
references to the rendering version in the docs, so that must have been
an accident. I'll need to a get a redirect going for that regardless.

Tests have been updated for `cacheHandler` and I added a new test for
`cacheMaxMemorySize`.

---------

Co-authored-by: Jiachi Liu <inbox@huozhi.im>
2024-01-17 23:42:52 +01:00
JJ Kasper
8e216ecb8d
Fix locale domain public files check (#60749)
This ensures we properly handle serving public files when routing via a
locale domain and adds regression tests for this case.

Closes: https://github.com/vercel/next.js/issues/54765
Closes: https://github.com/vercel/next.js/pull/59773
Closes: https://github.com/vercel/next.js/pull/55137
Closes NEXT-2123
2024-01-17 13:41:16 -08:00
vercel-release-bot
8d4e5be736 v14.0.5-canary.64 2024-01-17 17:59:57 +00:00
Tobias Koppers
861b472b12
fix layout segment key to match up with manifest (#60783)
### What?

When webpack loaders are applied on a page file and it's renamed with
the `as` key, layout segment key no longer matches. This fixes that

### Why?

### How?

Closes NEXT-
Fixes #

-->


Closes PACK-2251
2024-01-17 17:11:50 +00:00
vercel-release-bot
a211566655 v14.0.5-canary.63 2024-01-17 15:14:46 +00:00
Tobias Koppers
b24ba17cc7
apply page transforms only on pages (#60779)
### What?

apply page transforms only on pages as intended

### Why?

Before they were applied on all files


Closes PACK-2250
2024-01-17 16:11:09 +01:00
Tim Neutkens
4548fed1cf
Skip postcss config location resolving in node_modules (#60697)
## What?

Skip postcss config resolving in node_modules for Turbopack. This
matches current Next.js on webpack closer as that only resolves the
postcss config from the project root. The additional feature Turbopack
has is that it can find a postcss config relative to the css being
compiled. This is useful for e.g. reducing the amount of overhead
certain postcss plugins that only have to run against a single file take
(i.e. Tailwindcss).


Depends on github.com/vercel/turbo/pull/7012 landing first.

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

---------

Co-authored-by: Tobias Koppers <tobias.koppers@googlemail.com>
2024-01-17 13:54:17 +00:00
vercel-release-bot
c583528116 v14.0.5-canary.62 2024-01-17 11:37:23 +00:00
Wyatt Johnson
dda1870501
Reapply "feat(app-router): introduce experimental.missingSuspenseWithCSRBailout flag" (#60508) (#60751)
This reapplies the `experimental.missingSuspenseWithCSRBailout` option
to bail out during build if there was a missing suspense boundary when
using something that bails out to client side rendering (like
`useSearchParams()`). See #57642

Closes [NEXT-1770](https://linear.app/vercel/issue/NEXT-1770)
2024-01-17 12:33:45 +01:00
vercel-release-bot
7f3d9099c2 v14.0.5-canary.61 2024-01-17 10:16:12 +00:00
OJ Kwon
5956ff76b5
feat(next-core): port remaining next.js custom transforms (#60498)
<!-- 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?



-->

This PR ports over all of the remaining custom transforms for next-swc
into turbopack, and apply it into client / server rules accordingly.

Closes PACK-2225
2024-01-17 10:32:58 +01:00
Tobias Koppers
16d009ef1b
separate chunking per layout parts (#60569)
### What?

* creates a separate chunk group for client components per layout
segment (before it was per page)

### Why?

This fixes a bug with css loading on client transitions as next.js
assumes that the chunk group for the unchanged layout segments are
already loaded (fixes PACK-2163)


Closes PACK-2232
2024-01-17 08:18:59 +00:00
Tobias Koppers
4597ff35da
allow to pass available chunk items when creating a chunk group (#60554)
### What?

api changes for https://github.com/vercel/turbo/pull/6988

### Turbopack Changes

* https://github.com/vercel/turbo/pull/6886 <!-- Tobias Koppers -
improve nesting of tracing for invalidations -->
* https://github.com/vercel/turbo/pull/6866 <!-- Tobias Koppers - trace
memory allocations and show in tracing -->
* https://github.com/vercel/turbo/pull/6988 <!-- Tobias Koppers - allow
to pass available chunk items when creating a chunk group -->
* https://github.com/vercel/turbo/pull/7013 <!-- Leah - fix: make CSS
reloading work on firefox -->
* https://github.com/vercel/turbo/pull/7004 <!-- Tobias Koppers -
improve error message when no config is exported from postcss.config.js
-->




Closes PACK-2231
2024-01-17 08:58:02 +01:00
Dima Voytenko
0c1741c456
Telemetry code load (#60594)
The following spans are either added or displayed by default:

* `NextNodeServer.findPageComponents` - page components
resolution/require
* `NextNodeServer.getLayoutOrPageModule` - load modules (webpack or
turbopack)
2024-01-16 17:08:35 -08:00
Changwan Jun
b805180f15
chore: typo, responseCookes to responseCookies (#60654)
I found a typo in the code and fixed it.

Co-authored-by: JJ Kasper <jj@jjsweb.site>
2024-01-17 00:34:42 +00:00
Dima Voytenko
f604df1ca1
Telemetry: allow disabling of fetch tracing (#60588)
This would allow different apps to setup fetch instrumentation similar
to `@opentelemetry/instrumentation-http` and
`@opentelemetry/instrumentation-fetch` without duplicating fetch spans
and avoiding confusion with context propagation.
2024-01-16 16:14:22 -08:00
vercel-release-bot
7341149c21 v14.0.5-canary.60 2024-01-16 23:22:30 +00:00
JJ Kasper
780594f7b6
Fix recursive ignoring case in build traces (#60740)
This ensures when a dependency has a recursive require our should ignore
handling doesn't accidentally loop back and forth.

x-ref: https://github.com/lovell/sharp/issues/3944

Closes NEXT-2121
2024-01-16 14:11:17 -08:00
Shu Ding
2072f864fc
Fix client reference keys of barrel-optimized files (#60685)
As Barrel Optimization might split one file into multiple different
modules, i.e. when you import different values from it, the target file
might be transformed differently, we can no longer rely on the file path
as the identifier of the client reference.

This fix adds a suffix (`'@' + this._module.matchResource`) to the
identifier so it looks like
`/filepath/file.js@__barrel_optimize__?names=Foo`.

Here's also a quick diagram to explain:


![CleanShot-2024-01-16-QzlxzMKy@2x](https://github.com/vercel/next.js/assets/3676859/99f25975-b965-4ae0-91f2-269a6a0d7458)

Closes #59804.
Closes NEXT-2108.

---------

Co-authored-by: Jiachi Liu <inbox@huozhi.im>
2024-01-16 20:06:22 +01:00
Steven
6a3608f739
chore(eslint-plugin-next): upgrade glob dependency (#60732)
- Closes #60651 

Closes NEXT-2118
2024-01-16 11:02:28 -08:00
OJ Kwon
8627e7c8c0
refactor(next-swc): remove unused crashreporter (#60593)
<!-- 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?

This code path has not been used for some time and it is clear we won't
use this as-is. Better to get rid of them and reintroduce depends on the
needs.


Closes PACK-2235
2024-01-16 11:01:47 -08:00
Braden Kelley
d08b3ffa50
graceful shutdown (#60059)
- Both the standalone server and the `startServer` function it calls
attempt to stop the server on `SIGINT` and `SIGTERM` in different ways.
This lets `server.js` yield to `startServer`
- The cleanup function in `startServer` was not waiting for the server
to close before calling `process.exit`. This lets it wait for any
in-flight requests to finish processing before exiting the process
- Sends `SIGKILL` to the child process in `next dev`, which should have
the same effect of immediately shutting down the server on `SIGTERM` or
`SIGINT`

fixes: #53661
refs: #59551

------

Previously #59551 attempted to fix #53661, but had broken some tests in
the process. It looks like the final commit was also missing an intended
change to `utils.ts`. This should fix those issues as well as introduce
a new set of tests for the graceful shutdown feature.

In the last PR I was squashing and force-pushing updates along the way
but it made it difficult to track the changes. This time I'm pushing
quite a few commits to make it easier to track the changes and refactors
I've made, with the idea that this should be squashed before being
merged.

<!-- 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-01-16 18:25:49 +01:00
Jiachi Liu
dc394483b8
Fix hmr updates with rebuilding for build errors (#60676)
### What

Sometimes the display of the error overlay is not consistent even when
you fixed the error

Example:
* You have a client page, and you add metadata export, Next.js will
error that it's not allowed in client component.
* You fix it, but the error overlay is not disappeared. Or you fix it,
then introduce it again, then fix it again, the error overlay is still
there.

### How

We're checking if the HMR webpack hash is changed to decide if we're
going to do a hot update in `BUILT` and `SYNC` event, but we update the
hash at the very beginning of the event handler. `isUpdateAvailable()`
will return `false` in the later calls but the hash has already changed
before. So we check if they change before applying hot updates, and then
use it later with `isUpdateAvailable()` to determine if necessary to
process a new hot update

Closes NEXT-2107

---------

Co-authored-by: Tim Neutkens <tim@timneutkens.nl>
2024-01-16 12:31:28 +01:00
vercel-release-bot
ef1b66a518 v14.0.5-canary.59 2024-01-15 23:22:30 +00:00
Tobias Koppers
710ead0fb5
fix breakpoints on reload (#60507)
### What?

Only apply Safari workaround for safari

### Why?

The workaround breaks breakpoints. See comment


Closes PACK-2227
2024-01-15 09:17:40 +01:00
Tobias Koppers
f8f58f8149
remove next build turbopack version (#60655)
### What?

removes to old next build turbopack version. It will be implemented in a
different way.

### Why?

We want to use next.rs api for that.


Closes PACK-2239
2024-01-15 09:17:28 +01:00
Jiachi Liu
28e892d9f1
chore: remove unused export (#60647)
Closes NEXT-2100
2024-01-15 00:45:22 +01:00
vercel-release-bot
10a217ec7b v14.0.5-canary.58 2024-01-14 23:23:03 +00:00
Jiachi Liu
bfd10b365a
Add cache reason for using fetch with noStore (#60630)
When you're using `noStore()` with `fetch` it's currently saying "auto
cache" in cache missed reason, adding "noStore call" here to show it's
caused by using with `unstable_noStore`

```
 GET /no-store 200 in 4069ms
  │ GET https://next-data-api-endpoint.vercel.app/api/random?another-no-cache 200 in 257ms (cache: SKIP)
  │  │  Cache missed reason: (noStore call)
```

Closes NEXT-2097
2024-01-14 22:04:28 +01:00
vercel-release-bot
7b7aa99539 v14.0.5-canary.57 2024-01-14 17:24:21 +00:00
Andrew Clark
dc697245ae
Update React from f1039be4a to 60a927d04 (#60619)
Includes a fix for useOptimistic.

React upstream changes:

- https://github.com/facebook/react/pull/27936
- https://github.com/facebook/react/pull/27924
- https://github.com/facebook/react/pull/27930
- https://github.com/facebook/react/pull/27923
- https://github.com/facebook/react/pull/27922
- https://github.com/facebook/react/pull/27917
- https://github.com/facebook/react/pull/27916
- https://github.com/facebook/react/pull/27918
- https://github.com/facebook/react/pull/27919
- https://github.com/facebook/react/pull/27914
- https://github.com/facebook/react/pull/27911
- https://github.com/facebook/react/pull/27909
- https://github.com/facebook/react/pull/27907
- https://github.com/facebook/react/pull/27906
- https://github.com/facebook/react/pull/27905

<!-- 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-2096
2024-01-13 23:37:08 -08:00
vercel-release-bot
2bc242535a v14.0.5-canary.56 2024-01-13 23:22:46 +00:00
vercel-release-bot
f6c4c2768b v14.0.5-canary.55 2024-01-12 23:22:06 +00:00
JJ Kasper
9294ab2fb0
Ensure client filter with basePath is correct (#60580)
Follow-up to https://github.com/vercel/next.js/pull/60542 this adds
regression tests for `basePath` with the client router filter to ensure
we hard navigate to the correct URL when going from pages -> app.


x-ref: https://github.com/vercel/next.js/issues/47486
Closes NEXT-2086
2024-01-12 20:55:56 +00:00
Jiachi Liu
3738e8ecc0
Fix react-refresh for transpiled packages (#60563)
### What

We're applying react-refresh to browser layer and inject ESM or CJS
helper based on file type. Some package from `trasnpilePackages` might
contain CJS browser bundle. And injecting ESM helper breaks them.
Actually they don't need to have fast refresh ability since they're in
`node_modules`.

### How
Skip react-refresh for transpiled packages as they're in node_modules
and won't change.

Fixes #56487 
Closes NEXT-2061
2024-01-12 21:44:41 +01:00
Andrew Clark
61803f818a
[PPR Nav] Fix flash of loading state during back/forward (#60578)
### Depends on

- #60577 

---

A popstate navigation reads data from the local cache. It does not issue
new network requests (unless the cache entries have been evicted). So,
when navigating with back/forward, we should not switch back to the PPR
loading state. We should render the full, cached dynamic data
immediately.

To implement this, on a popstate navigation, we update the cache to drop
the prefetch data for any segment whose dynamic data was already
received. We clone the entire cache node tree and set the `prefetchRsc`
field to `null` to prevent it from being rendered. (We can't mutate the
node in place because Cache Node is a concurrent data structure.)

Technically, what we're actually checking is whether the dynamic network
response was received. But since it's a streaming response, this does
not mean that all the dynamic data has fully streamed in. It just means
that _some_ of the dynamic data was received. But as a heuristic, we
assume that the rest dynamic data will stream in quickly, so it's still
better to skip the prefetch state.

Closes NEXT-2084
2024-01-12 14:18:54 -05:00
vercel-release-bot
3e221fb614 v14.0.5-canary.54 2024-01-12 19:15:30 +00:00
Will Binns-Smith
d98b5a5757
Tracing: attach Turbopack session value to root span (#60576)
This allows us to more accurately attribute whether a trace was created
in a Turbopack session by doing so at trace creation time rather than
trace upload time.

Test Plan: Configured next to send traces to a local server and verified
this information is attached to the top-level of the trace.


Closes PACK-2233
2024-01-12 11:11:23 -08:00
Zack Tanner
3da48113f9
propagate notFound errors past a segment's error boundary (#60567)
### What?
Throwing a `notFound()` error inside of a segment that has an error
boundary will cause it to be handled by the segment's error boundary
rather than a parent not-found boundary.

### Why?
We assume anything that hits an `ErrorBoundary` is an actual error, but
this should not be the case when the caught error is one that is handled
by Next.js.

### How?
This checks if the caught error is one that is expected to be handled
someplace else.

Closes NEXT-2080
[slack
x-ref](https://vercel.slack.com/archives/C03S8ED1DKM/p1705003189392509?thread_ts=1704868742.169129&cid=C03S8ED1DKM)
2024-01-12 16:58:45 +01:00
Jiachi Liu
8515741933
Fix logging order of build jobs (#60564)
The Next.js version should always be output first instead of other jobs
in `next build`

Closes NEXT-2078
2024-01-12 15:03:20 +01:00
Tim Neutkens
10e8f4d437
Enable windowHistorySupport by default (#60557)
## What?

Enables `experimental.windowHistorySupport` by default. It has been in
experimental for quite a while now and has been successfully dogfooded
in vercel.com as well.

<!-- 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-2076
Closes NEXT-1773
2024-01-12 14:18:43 +01:00
JJ Kasper
68cecd6a3a
Update default error rate for client filter (#60542)
This updates our default error rate to be much more precise and reduce
false positives by increasing the default size of the client filter we
generate. We can afford to increase the default size as it compresses
extremely well and gives us more accurate navigations. This carries over
the failing test case from https://github.com/vercel/next.js/pull/59293
which showed one case of false positive in a smaller filter.

Closes: https://github.com/vercel/next.js/issues/47486

Closes NEXT-2070

---------

Co-authored-by: Cris Vergara <cris.vergara@bookofthemonth.com>
2024-01-11 17:51:53 -08:00
vercel-release-bot
9fd25b4be2 v14.0.5-canary.53 2024-01-11 23:22:41 +00:00
Steven
4466ba436b
chore(examples): use default prettier for examples/templates (#60530)
## Description
This PR ensures that the default prettier config is used for examples
and templates.

This config is compatible with `prettier@3` as well (upgrading prettier
is bigger change that can be a future PR).

## Changes
- Updated `.prettierrc.json` in root with `"trailingComma": "es5"` (will
be needed upgrading to prettier@3)
- Added `examples/.prettierrc.json` with default config (this will
change every example)
- Added `packages/create-next-app/templates/.prettierrc.json` with
default config (this will change every template)

## Related

- Fixes #54402
- Closes #54409
2024-01-11 16:01:44 -07:00
Jiachi Liu
98b99e408b
Fix global-error for nested routes (#60539)
## What

This fixes when the deep nested routes throws a client side error, it
can still be caught by the `global-error.js`

## How

We should always resolve global-error from root app directory instead of
current route's layout. Also fixed a bad test before where the
gloabl-error.js is not located correctly


Fixes #53756
Closes NEXT-1760
2024-01-11 23:28:17 +01:00
Jiachi Liu
9b7a5c0bbf
Handle non server action post requests safely (#60526)
When sending post requests but it's not server action, skip logging
warning or calling non-existed server action. Instead we only log the
warning like missnig headers for server actions when it's a server
action and call the action handler when it's decoded as a function

Fixes #58152 
Closes NEXT-1761
2024-01-11 21:03:43 +01:00
Leah
a1d0259ea0
chore(turbopack): check for unsupported next config options instead of supported ones (#58781)
### Why?

We have more supported options than unsupported ones.
Also new options added to next.js now should always be supported by
turbopack.


Closes PACK-2023
2024-01-11 18:46:01 +00:00
Will Binns-Smith
553aeaec0f
Turbopack hmr: record forwarded client spans (#60500)
This forwards spans created in the hmr client to the server-side tracer.

Test Plan: Loaded a page and verified navigation-to-hydration span is
recorded.


Closes PACK-2226
2024-01-11 10:09:26 -08:00
Tobias Koppers
8d129534da
add retry logic to loadClientReferenceManifest (#56518)
### What?

This fixes a race condition where loadClientReferenceManifest reads an
empty file. All other manifest already have retries, this adds it for
the client reference manifest too for consistency.


Closes WEB-1727

---------

Co-authored-by: Tim Neutkens <tim@timneutkens.nl>
2024-01-11 16:25:05 +01:00
Sukka
b8b104506d
refactor(cna): make create-next-app even smaller and faster (#58030)
The PR further reduces the `create-next-app` installation size by
another 80 KiB:

- Replace the callback version of Node.js built-in `dns` API usage with
`dns/promise` + async/await
- Replace `got` w/ `fetch` since Next.js and `create-next-app` now
target Node.js 18.17.0+
- Download and extract the tar.gz file in the memory (without creating
temporary files). This improves the performance.
- Some other minor refinements.

Following these changes, the size of `dist/index.js` is now 536 KiB.
2024-01-11 09:40:29 -05:00
Takashi Sato
e6e6609674
Remove unused target: es5 from tsconfig.json in create-next-app (#60521)
fixes #58640

When there is no tsconfig.json, `npm run dev` generates `tsconfig.json`,
which has no `target` option.
But create-next-app generates `tsconfig.json` with `"target": "es5"`

Related to: #44567
Related to: #14390
2024-01-11 14:35:17 +00:00
vercel-release-bot
d8691f5c06 v14.0.5-canary.52 2024-01-11 10:36:34 +00:00
Tobias Koppers
9cb0387681
Revert "feat(app-router): introduce experimental.missingSuspenseWithCSRBailout flag" (#60508)
Reverts vercel/next.js#57642

Closes PACK-2228
2024-01-11 11:32:40 +01:00
vercel-release-bot
120dc65bfd v14.0.5-canary.51 2024-01-11 10:13:33 +00:00
Colton Ehrman
a65ea447d8
fix: redirect logic missing basePath in App Render (#60184)
### What?

Fixes #58570 

### How?

Include the **basePath** to the **fetchUrl** to ensure the relative URL
matches the app when deployed under a **basePath**.

### Tested?

I have added an **e2e** test with a basic custom server & server action
redirect.

This test was confirmed to **catch** the bug when running it without the
fix in place. When running it you will get the failed result.

```
 FAIL  test/e2e/app-dir/app-basepath-custom-server/index.test.ts (12.293 s)
  custom-app-render
    ✕ redirects properly when server action handler uses `redirect` (1661 ms)

  ● custom-app-render › redirects properly when server action handler uses `redirect`

    expect(received).not.toEqual(expected) // deep equality

    Expected: not ["/base/another", 200]

      45 |       // if broken, this will include a 200 from the /base/another indicating a full page redirect
      46 |       responses.forEach((res) => {
    > 47 |         expect(res).not.toEqual(['/base/another', 200])
         |                         ^
      48 |       })
      49 |     })
      50 |   }

      at toEqual (e2e/app-dir/app-basepath-custom-server/index.test.ts:47:25)
          at Array.forEach (<anonymous>)
      at Object.forEach (e2e/app-dir/app-basepath-custom-server/index.test.ts:46:17)

Test Suites: 1 failed, 1 total
Tests:       1 failed, 1 total
Snapshots:   0 total
Time:        12.321 s, estimated 22 s
Ran all test suites matching /test\/e2e\/app-dir\/app-basepath-custom-server/i.
 ELIFECYCLE  Command failed with exit code 1.
 ELIFECYCLE  Command failed with exit code 1.
 ELIFECYCLE  Command failed with exit code 1.
```

### Notes

Not sure if there are any edge cases where the `fetchUrl` is now broken
in other use cases where there is no **basePath**, I assume the string
would be empty `""` and result in the same URL as before, but not sure?

### Disclosure

~I am not that familiar with the Next.js code base and this is my first
PR. I was struggling to find out how to grab the **basePath** from
`next.config.js`, but then noticed the **assetPrefix** inside the
function matched, so decided to use that for minimal change. I don't
know if there are any caveats with this approach, but could consider
switching to pull directly from the config file, if that's possible?~

**Update:** Figured out where the **basePath** came from and switched
it.

---------

Co-authored-by: Colton Ehrman <cehrman@paypal.com>
Co-authored-by: Tim Neutkens <tim@timneutkens.nl>
2024-01-11 10:08:29 +00:00
Tobias Koppers
f45a15b621
move custom allocator flag and add rustls-tls comment (#60128)
### What?

enable the custom allocator flag to enable mialloc.
allow to configure custom allocator on napi level.

### Why?

It's faster and we had it enabled before.
It was disable before as `next-core` is used with no default features in
workspace

Native Build: https://github.com/vercel/next.js/actions/runs/7388725004


Closes PACK-2185

---------

Co-authored-by: OJ Kwon <1210596+kwonoj@users.noreply.github.com>
2024-01-11 09:07:56 +01:00
mknichel
ca5bc989d1
Add experimental options for more parallelization in webpack builds (#60177)
This PR introduces 2 experimental options for doing more work in the
webpack build in parallel instead of in serial. These options may
improve the performance of builds at the cost of more memory.

`parallelServerAndEdgeCompiles`: This option kicks off the builds for
both `server` and `edge-server` at the same time instead of waiting for
each to complete before the next one. In applications that have many
server and edge functions, this can increase performance by doing that
work in parallel. This can be used with `next build` or `next
experimental-compile`.

`parallelServerBuildTraces`: This option starts the server build traces
as soon as the server compile completes and runs it in the background
while the other compilations are happening. With this option enabled,
some unnecessary work may be done since ordinarily the client
compilation provides information that can reduce the amount of tracing
necessary. However, since it is in parallel with the other work, it may
still result in a faster build in total at the cost of more memory. This
option is already the default when using `next experimental-compile` but
can now be used when `next build` is used also.

---------

Co-authored-by: Delba de Oliveira <32464864+delbaoliveira@users.noreply.github.com>
Co-authored-by: JJ Kasper <jj@jjsweb.site>
2024-01-10 17:11:33 -08:00
Zack Tanner
a29bf3373f
filter default segments from prerender manifest (#60499)
### What
`/default` segments were considered valid page outputs to handle
catch-all route normalization (see #60240) but they shouldn't leak into
the prerender manifest. This filters them out at build time.

Closes NEXT-2053
2024-01-10 16:49:03 -08:00
vercel-release-bot
bbf78c7c64 v14.0.5-canary.50 2024-01-10 23:22:15 +00:00
Jiachi Liu
e4bd06beed
Group small chunks in shared js section of output (#60479)
In the output shared js chunks section we're showing all shared chunks
atm, some of them might be too small (few bytes) due to code split. e.g.
in the below example, main-app is only `218B`, we're going to group all
the chunks below 10KB together into one item line

#### Before

```
+ First Load JS shared by all            81.9 kB
  ├ chunks/381-ffe155bc1c63f064.js       26.7 kB
  ├ chunks/8766613a-1f3d501627fe8359.js  53.3 kB
  ├ chunks/main-app-80d2c0fe59f30ae2.js  218 B
  └ chunks/webpack-e6edcd8ebd35b832.js   1.68 kB
```

#### After 
```
+ First Load JS shared by all            83.7 kB
  ├ chunks/4921c021-73266f862a05e4e2.js  53.3 kB
  ├ chunks/596-73310d23ef824244.js       28.6 kB
  └ other shared chunks (total)          1.83 kB
```

Closes NEXT-2046
Closes NEXT-1970
2024-01-11 00:12:04 +01:00
Zack Tanner
d6c754f332
parallel routes: fix client reference manifest grouping for catch-all segments (#60482)
### What?
When using catch-all routes in conjunction with parallel routes, and
when importing a client component (`"use client"`), the build would fail
with the following error:

> Could not find the module "PathToClientComponent" in the React Client
Manifest. This is probably a bug in the React Server Components bundler.

### Why?
`flight-manifest-plugin` generates manifests for each page entry. The
`clientModules` portion of this manifest is used by React to load the
appropriate client module. When React attempts to render a component
tree and detects a module that it cannot find, it will throw this error.
To illustrate why it isn't in the tree, consider the following example:

```
app
  page.tsx
  layout.tsx
  @slot
    [...catchAll]
      page.tsx
```

```tsx
// app/layout.tsx
export default function Layout({children, slot}) {
  return <>{children} {slot}</>
}
```
```tsx
// app/@slot/[...catchAll]/page.tsx
import Link from 'next/link'
export default function Page() {
  return <Link href="/">Test</Link>
}
```

When visiting `/`, we'd expect both the catch-all `@slot` and the root
page to render. At build time, we'll generate a client reference
manifest for `/` and `/[...catchAll]` since both are page components.
However, the `@slot` imports a client component. When we attempt to load
the client reference manifest for `/`, it will ignore the catch-all
slot's manifest, resulting in the error.

### How?
The `entryNameToGroupName` function seems to already exist to handle
this scenario for other cases. For example,
`app/(group)/@named/foo/page` needs to know about any manifests
associated with `app/foo`. This updates the code to apply similar
handling to catchAll segments. When applying this change to the example
mentioned earlier, it will properly merge the manifests for both
`app/@slot/[...catchAll]/page.tsx` and `app/page.tsx` because both will
be part of the `/` group.

Closes NEXT-1908
Fixes #59747
Fixes #59510
2024-01-10 14:14:19 -08:00
JJ Kasper
b16187213e
Use next.config.mjs for CNA templates (#60494)
As `.mjs` support for `next.config` is stable now we can swap our
default to use it instead.

Closes NEXT-2052
2024-01-10 14:04:57 -08:00
Alexander Savelyev
ac325dfd0b
Fix intercepted segments with basepath (#60485)
### Fixing a bug

### What?
When basePath is added, intercepted routes stop working correctly.

### Why?

For them, basePath was not added at all.

### How?

Added basePath to the rewrites for intercepted routes.

Fixes #52624, #58268
2024-01-10 13:18:00 -08:00
vercel-release-bot
21dbfecf84 v14.0.5-canary.49 2024-01-10 18:23:43 +00:00
Leah
ee6cc6d9c2
feat(turbopack): support named client references properly (#59578)
### What?
Makes sure `import * as mod from 'client-mod'` works properly by
actually adding the exports to the emitted module.

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

### Turbopack Updates

* https://github.com/vercel/turbo/pull/6965 <!-- Tobias Koppers -
recycle trace buffers -->
* https://github.com/vercel/turbo/pull/6974 <!-- Chris Olszewski -
feat(lockfiles): support Yarn 4 patches -->
* https://github.com/vercel/turbo/pull/6787 <!-- Leah -
feat(turbopack-ecmascript): support named client references -->


Closes PACK-2110
2024-01-10 18:14:36 +00:00
vercel-release-bot
6d11c1a363 v14.0.5-canary.48 2024-01-10 17:49:05 +00:00
Tobias Koppers
990d0a9ab8
update turbopack (#60478)
* https://github.com/vercel/turbo/pull/6978 <!-- Tobias Koppers - fix
aggregation of outdated children and collectibles -->
* https://github.com/vercel/turbo/pull/6968 <!-- Tobias Koppers - fix
glob matching of alternatives -->
* https://github.com/vercel/turbo/pull/6922 <!-- Tobias Koppers - avoid
using a write lock for root info -->
2024-01-10 17:45:29 +00:00
vercel-release-bot
43474e0e91 v14.0.5-canary.47 2024-01-10 15:48:27 +00:00
Tobias Koppers
45370e8ce8
update turbopack (#60208)
* https://github.com/vercel/turbo/pull/6720 <!-- Tobias Koppers - fix
weird local name, add tests -->
* https://github.com/vercel/turbo/pull/6832 <!-- Leah -
fix(turbopack-ecmascript): make sure async module wrapper is always
generated -->
* ~https://github.com/vercel/turbo/pull/6885~ <!-- Tobias Koppers - fix
aggregation of outdated children and collectibles -->
* ~https://github.com/vercel/turbo/pull/6839 <!-- Tobias Koppers - fix
glob matching of alternatives -->~
* https://github.com/vercel/turbo/pull/6884 <!-- Donny/강동윤 - Update
`swc_core` to `v0.87.16` -->
* https://github.com/vercel/turbo/pull/6964 <!-- Tobias Koppers - Reduce
calls, tasks and duplicate work -->
2024-01-10 11:14:46 +01:00
Jimmy Lai
c52cb5ad83
feat(app): add experimental.missingSuspenseWithCSRBailout (#57642)
### What?

This PR adds a new flag called
`experimental.missingSuspenseWithCSRBailout`.

### Why?

Via this PR we can break a build when calling `useSearchParams` without
wrapping it in a suspense boundary.

If no suspense boundaries are present, Next.js must avoid doing SSR and
defer the entire page's rendering to the client. This is not a great
default. Instead, we will now break the build so that you are forced to
add a boundary.

### How?

Add an experimental flag. If a `BailoutToCSRError` error is thrown and
this flag is enabled, the build should fail and log an error, instead of
showing a warning and bail the entire page to client-side rendering.

Closes NEXT-1770

---------

Co-authored-by: Balázs Orbán <info@balazsorban.com>
Co-authored-by: Wyatt Johnson <accounts+github@wyattjoh.ca>
2024-01-10 00:26:24 +01:00
vercel-release-bot
8aced5bc64 v14.0.5-canary.46 2024-01-09 23:22:17 +00:00
Jiachi Liu
08e24a8f4c
Display original failed fetch trace (#60274)
### What

Show the original fetch error trace in the dev error overlay, which can
show which line of the fetch call is failing.

#### After

![image](https://github.com/vercel/next.js/assets/4800338/cebc8d03-58a7-4574-a1bb-896c7f396674)

#### Before

![image](https://github.com/vercel/next.js/assets/4800338/5cc71ad9-c71e-44d0-aef2-5b0d5a00da36)

### Why

This helps a lot for unclear fetch failures that you only see an error
on your screen and you don't have idea where it's coming from

### How

Fixed the async task error that swallowed by tracer, it should always
throw in tracing after the metrics are traced.

Closes NEXT-1362
Fixes #59153
Fixes #49896
2024-01-09 23:38:37 +01:00
Alexander Savelyev
51bda321f0
Fix custom cache handler importing on windows (#60312)
### Fixing a bug

### What?
Custom cache handler doesn't work on Windows

### Why?

It broke in a recent fix, when adding ESM support - #59863. The problem
is not new - dynamic imports consider an absolute path in Windows as a
protocol:

`ERR! Error [ERR_UNSUPPORTED_ESM_URL_SCHEME]: Only URLs with a scheme
in: file, data are supported by the default ESM loader. On Windows,
absolute paths must be valid file:// URLs. Received protocol 'C:'`

### How?

As a solution, it is necessary to explicitly indicate that it is indeed
an absolute path, for example by adding a / at the beginning, but the
most reliable way is to use pathToFileURL.

Since the logic is repeated in 4 places - I created a common function.

Fixes #58509

---------

Co-authored-by: JJ Kasper <jj@jjsweb.site>
2024-01-09 14:16:47 -08:00
OJ Kwon
46370d816b
refactor(next/core): reorganize next.js custom transforms for next-swc/turbopack (#60400)
<!-- 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?

This PR refactors organization for the rust side packages to build
`next-swc`.

### Why?

We had some historical legacy around package structures, have ambiguous
name for `core` / `next-core`. One contains swc transform visitor for
the next.js, and the other one is new for turbopack's core next.js
features. In addition to that, there was a package dependency chain
prevents to use `core` in the turobpack / next-swc both, so each time
porting a transformer into turbopack it requires to extract new
dependency to be imported in the both place.

PR touches its organization - while PR is large to touch various files,
the crux is summarized at
2cedd06ea5
:

1. `core` becomes `next-custom-transforms`, also this becomes an
agnostic pkg can be imported in turbopack / wasm / next-swc
2. simplify dependency chain to import next-custom-transforms, organized
as below

```mermaid
flowchart TD
    C(next-custom-transforms) --> A(napi)
    C(next-custom-transforms) --> B(wasm)
    D(next-core) --> A(napi)
    E(next-build) --> A(napi)
    F(next-api) --> A(napi)
    C(next-custom-transforms) --> D
    D(next-core) --> F(next-api)
    D(next-core) --> E(next-build)
```

`impl CustomTransformer` for the each transform still lives in
`next-core`, so turbopack specific dependency is isolated under
`next-core/build/api`.


Closes PACK-2201
Closes PACK-2202

---------

Co-authored-by: hrmny <8845940+ForsakenHarmony@users.noreply.github.com>
2024-01-09 12:23:47 -08:00
Wyatt Johnson
7018a65de4
Missing Postpone Detection Fix (#59891)
### What?

Previously, if an error such as the client side rendering bailout (not
to be confused with the static rendering bailout which PPR supercedes)
occurs during render, and the `postpone` function was invoked during the
original render, then the `staticGenerationStore` would incorrectly
report that the render did call `postpone`, because the value is not
reset on the render for the error page.

### How?

Returning no error when the standard render is used and returning the
error when the error render was used ensures that we don't warn about
missing postpone data when a client side rendering bailout occurs.

### Looking Ahead

A refactor of the `AsyncLocalStorage` should be done such that the
stores are:

1. Returned by the calling function so we aren't reaching into store
properties at different parts
2. Reorganizing the stores so that they're tied to the invocation
lifetime, not the entire request lifetime, so that operations (like
postpone) should only be available during renders that support postpone,
not all renders during a request.

Closes NEXT-1927
2024-01-09 13:03:17 -07:00
Josh Story
84aeded02f
Refactor unstable_cache implementation (#60403)
The original motivation of this PR is to get `unstable_cache` into a
state where I can more easily change the implementation of postpone to
be more akin to "dynamic rendering APIs". the existing approach made
typing the staticGenerationStore in a way I wanted to for the planned
changes would have been hard to implement with the current approach. At
the same time this was an opportunity to make the implementation more
efficient and easier to reason about.

reorganizes unstable_cache to improve performance and potentially fix
latent bugs related to nest cache calls

In the original implementation there are repeated defined checks for the
store and relatively complex logic around gathering the cache entry. In
my refactor I fork the implementation based on whether we have a store
or not. Loosely this translates to whether the cache call is for App
Router vs Pages Router however due to a quirk in how we scope inner
cache calls there is an existing and unchanged case where a Pages Router
cached callback runs with a "fake" store that is used to scope some
cache values to prevent inner caching when one cached function calls
another. It should be noted that this fake store technique means that
inner cache calls inside Pages Router will hit the App Router pathway in
unstable cache. This is not great but it is the current behavior and
while I have made some changes that might fix some bugs changing this
felt like a much bigger lift to do in a primarily refactor PR.

This "fake" store can be replaced by a different async store for Pages
Router which we can use to scope the inner environment to not be cached
eventually though it may make more sense to just generalize the
staticGenerationStore into a kind of RenderStore and have it run for
Pages Router too.

I moved as much computation that can be done in the closure around the
cached function out of the cached function and I narrowed the scope of
the run call to make it clear that we really only need to scope the
callback.

I removed function allocations per invocation

I probably fixed a bug in how the revalidate property was refined on the
static generation store. Previously it would be possible to go from
number to false and back again but this doesn't make sense as false is
more like INFINITY in terms of refining to shorter values. This PR
updates this logic to be apparently

Closes NEXT-2028
2024-01-09 08:56:27 -08:00
Jiachi Liu
2e29c7b10e
Fix missing source code display for some jsx errors (#60390)
There're some cases that error frames file is still conating
"webpack-internal" for server component and also the webpack layer info
such as `(rsc)` so that the source file is not properly recovered

### After


![image](https://github.com/vercel/next.js/assets/4800338/78ba137d-62f0-4c5b-b502-c3500b8b79db)


### Before

![image](https://github.com/vercel/next.js/assets/4800338/bd585c7c-2264-4f30-9deb-5fec004be19f)


Closes NEXT-2020
Closes NEXT-1996
2024-01-09 16:30:25 +01:00
Zack Tanner
1481b2649f
Fix TypeError when using params in RootLayout with parallel routes (#60401)
### What?
When accessing `params` on a `RootLayout`, while also using parallel
routes, two potential errors would occur:
- A `Warning: React.createElement: type is invalid` error when
attempting to render a `NotFound` component that doesn't exist
- A `TypeError: Cannot read properties of undefined` error when
attempting to access params in the root layout.

### Why?
`createComponentTree` will render a duplicate `RootLayout` (to ensure
the `notFound()` fallback in unmatched parallel slots have a
`NotFoundBoundary` to catch them) but it currently doesn't ensure a
`NotFound` component exists nor does it forward `params` to the layout.

### How?
This forwards the params to the `RootLayout` and doesn't render a
`NotFoundComponent` if one doesn't exist. This replaces a few `any`
types with more sound types that would have helped catch these mistakes.
There's still a lot more typing that needs to be done (left a comment
below with some additional details) but I opted to make the minimal
changes related to this issue.

Longer term we should remove this duplicate `RootLayout` (see #60220)
which will require special UI to show unmatched slots (similar to the
error overlay, but less harsh)

Closes NEXT-1909
Fixes #59711
2024-01-09 07:06:24 -08:00
Jiachi Liu
14b6ae2e70
Change color of output bundle size (#60385)
When you have a gaint code base of next.js app, the output client side
loaded js bundle size could be large since most of them are functional,
it might not make sense to display yellow or red color to warn you that
your bundle is too large since they conatin the basic functionality.

We display the previous colored ones with opinionless bold white color
to highlight them

![image](https://github.com/vercel/next.js/assets/4800338/34814f2f-ff83-48b4-bad8-989031eff49e)

Closes NEXT-2017
Closes NEXT-2015
2024-01-09 15:05:41 +01:00
Will Binns-Smith
fe9d74d411
HMR development stats: include updatedModules for App Router and Turbopack changes (#59785)
This includes the list of changed modules in the `client-hmr-latency`
event for changes in app router pages as well as when using Turbopack.

For Turbopack, this list is derived from the data structure included in
the `turbopack-message` event. Each of these is originally a module id,
which includes additional context information. For analytics purposes
this is removed (and could maybe surfaced in the future once the webpack
data is also normalized).


Closes PACK-2167
2024-01-08 16:41:36 -08:00
Agustín Tornielli
447b416f4d
Fix: HMR in multi-zone handling 🌱 (#59471)
### What?
When running a
[multi-zone](https://github.com/vercel/next.js/tree/canary/examples/with-zones)
app in dev, guest app pages would infinitely reload if you change the
basePath of the host app to the default one (omit basePath settings in
next.config.js) (empty string `""` as per Next.js docs).

### Why?
The HMR upgrade request would fail and get caught into a retry loop. In
the multi-zone case, they fail because the upgrade request would be sent
again for a request that had already been upgraded. This resulted in a
"server.handleUpgrade() was called more than once with the same socket"
error, causing the upgrade request to fail.

Every time a retry occurred, the page would trigger a full refresh since
certain HMR errors cause the browser to reload.

### How?
This ensures the upgrade handler only responds to requests that match
the configured basePath (considering when there is no basePath). Default
basePath for Next.js applications it's an empty string `""`.
 
Ref: https://nextjs.org/docs/app/api-reference/next-config-js/basePath

Other fixes & updates related to the bug:
- Updated test apps to avoid having issues regarding client & server
mismatch for dates
- Added default use case in e2e tests, where you have a default Next.js
application where the basePath it's the default one and a guest app that
it's being routed by the main one through Next.js rewrites.

Closes NEXT-1797
Fixes #59161
Fixes #56615
Fixes #54454

---------

Co-authored-by: Zack Tanner <zacktanner@gmail.com>
2024-01-08 23:55:41 +00:00
vercel-release-bot
7e53e08d17 v14.0.5-canary.45 2024-01-08 23:22:49 +00:00
Sukka
0aa0179246
refactor(dev-overlay): remove chalk (#60317)
Per @styfle suggestion, #58038 has been split into multiple PRs for
easier review.

- Remove `chalk` inside `@next/react-dev-overlay`
- `@next/react-dev-overlay` is bundled with Next.js. The usage of
`chalk` inside `@next/react-dev-overlay` was not removed in
https://github.com/vercel/next.js/pull/55992, thus the `chalk` is still
being shipped.

---------

Co-authored-by: JJ Kasper <jj@jjsweb.site>
2024-01-08 21:55:17 +00:00
Sukka
3894bad8eb
chore(precompile): re-add watchpack to the precompile (#60309)
Per @styfle suggestion, #58038 has been split into multiple PRs for
easier review.

- Re-add precompile `watchpack`
- Next.js has stopped bundling the `watchpack` since
https://github.com/vercel/next.js/pull/50792. Currently, `watchpack` is
a direct dependency of Next.js. The PR adds the pre-compile back.

Co-authored-by: Steven <steven@ceriously.com>
2024-01-08 13:45:19 -05:00
Jiachi Liu
817a2402b2
refactor: simplify the call in lib.picocolors (#60386)
Simplify the conditional formatter call in `lib/picocolors`

Closes NEXT-2018

---------

Co-authored-by: Steven <steven@ceriously.com>
2024-01-08 18:15:18 +00:00
Sukka
94b8af2258
chore(precompile): remove obsolete precompiled assets (#60316)
Per @styfle suggestion, #58038 has been split into multiple PRs for
easier review.

- Remove `find-cache-dir`
- The usage of `find-cache-dir` was removed **4 years ago**
(https://github.com/vercel/next.js/pull/7013) but the dist and the build
script were never removed.
- Remove `@segment/ajv-human-errors`
- The usage of `@segment/ajv-human-errors` was removed in
https://github.com/vercel/next.js/pull/56383 by me. Though the build
script was also removed in that PR, the dist never got removed.
2024-01-08 13:00:49 -05:00
vercel-release-bot
864b4f71d1 v14.0.5-canary.44 2024-01-08 15:46:50 +00:00
Sukka
2a2a9c70d5
chore(font): enable minification (#60319)
Per @styfle suggestion, #58038 has been split into multiple PRs for
easier review.

- Enable minification of `@next/font`
- Currently, the `@next/font` is built separately (without minification)
and then copied to the `dist` folder of the Next.js.
2024-01-08 09:55:01 -05:00
Jiachi Liu
3db878629e
Fix dynamic sitemap detection (#60356)
### What

Fix bad detection of dynamic route of sitemap metadata route, the swc
AST check should process when the text are detected. But prevuious if
there's text with `generateSitemap` such as comment but not the actual
export it will fail.

### How
Add both checks on metadata loader side and detection helper side

* Only call `generateSitemaps` helper when the export existed
* Fix the helper detection logic (major part of this PR)

Fixes #59698
Closes #60344
Closes NEXT-2007
2024-01-08 14:11:00 +01:00
Tim Neutkens
7dbb66f390
Simplify if condition (#60250)
## What?

Makes it easier to reason about this condition.

<!-- 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-1992
2024-01-08 11:31:17 +01:00
Andrew Clark
5e7106141f
Update React from 0cdfef19b to f1039be4a (#60368)
### React upstream changes

- https://github.com/facebook/react/pull/27888
- https://github.com/facebook/react/pull/27870
- https://github.com/facebook/react/pull/27871
- https://github.com/facebook/react/pull/27850
- https://github.com/facebook/react/pull/27839
- https://github.com/facebook/react/pull/27842
- https://github.com/facebook/react/pull/27841
- https://github.com/facebook/react/pull/27840
- https://github.com/facebook/react/pull/27761
- https://github.com/facebook/react/pull/27831
- https://github.com/facebook/react/pull/27801

Closes NEXT-2012
2024-01-07 21:13:41 -08:00
vercel-release-bot
cfb75b77ea v14.0.5-canary.43 2024-01-07 23:22:24 +00:00
Lee Robinson
a5ae1a6653
docs: Add docs for next dev --experimental-https (#60357) 2024-01-07 11:32:27 -06:00
Christopher Krogh
f6c5e2f879
Bump webpack-bundle-analyzer (#58442)
https://github.com/webpack-contrib/webpack-bundle-analyzer/pull/624 was
merged and released in 4.10.0 and I'd like to leverage this change in
`@next/bundle-analyzer`
2024-01-07 13:29:35 +01:00
vercel-release-bot
9d8015ded3 v14.0.5-canary.42 2024-01-06 23:21:58 +00:00
Zack Tanner
efebba80a7
parallel routes: fix @children slots (#60288)
### What?
Our
[docs](https://nextjs.org/docs/app/building-your-application/routing/parallel-routes#convention)
point out that `app/page.js` is equivalent to `app/@children/page.js`,
however in practice this is not the case, and causes type errors when
using `@children` slots as well as incorrect behavior when matching
catch-all routes.

### Why?
- When typechecking, `@children` slots would be added to the typeguard
file for the associated layout, resulting in duplicate identifiers for
the `children` prop
- When determining where to insert catchall slots, the `hasMatchedSlots`
check wasn't considering that the `@children` slot corresponds with the
page component, so matching another page would clobber the previous one.

### How?
- Filters out the `@children` slot when collecting slots for
typechecking
- Filters out the `@children` slot when running the `hasMatchedSlots`
function in the catch-all normalizer

Closes NEXT-1984
2024-01-06 07:24:44 -08:00
Alexander Savelyev
826955b3c3
micro fix of the cache limit check (#60249)
### Fixing a bug

I'm sorry, I have no idea how I managed to delete this, as I just copied
the code.

However, I had to figure out why the tests passed. When I test the
running application locally, it works as expected.

So, when a route is first used in a running production application in a
test, `ctx.fetchCache` is `undefined`. Therefore, the error rule does
not trigger on the first request, and the cache is successfully written.
This may result in artifacts in FetchCache in Vercel and possibly in
other parts of the code.

```ts
if (
  ctx.fetchCache && // <- Undefined on first request
  // we don't show this error/warning when a custom cache handler is being used
  // as it might not have this limit
  !this.hasCustomCacheHandler &&
  JSON.stringify(data).length > 2 * 1024 * 1024
) {
  if (this.dev) {
    throw new Error(`fetch for over 2MB of data can not be cached`)
  }
  return
}
```

I'm 95% sure that this is a bug and it shouldn't work like this. I'll
look into this later and if there is an error, I'll put it into a task
and try to figure it out later.

Unfortunately, the
[test](7e028fb6d8/test/e2e/app-dir/app-static/app-static.test.ts (L3080))
from [previous PR](https://github.com/vercel/next.js/pull/59976) is not
working yet, although it is correct from my point of view. I think it
should be kept and the problem above should be fixed.

Co-authored-by: JJ Kasper <jj@jjsweb.site>
2024-01-06 01:46:49 +00:00
vercel-release-bot
a2288cb273 v14.0.5-canary.41 2024-01-05 23:22:10 +00:00
Zack Tanner
90f95399dd
fix catch-all route normalization for default parallel routes (#60240)
### What?
When relying on a `default` route as a fallback, greedier catch-all
segments in the application hierarchy would take precedence, causing
unexpected errors/matching behavior.

### Why?
When performing parallel route catch-all normalization, we push
potential catch-all matches to paths without considering that a path
might instead be matched by a `default` page. Because of this, the
catch-all take precedence and the app will not try and load the default.

For example, given this structure:

```
{
  "/": ["/page"],
  "/[[...catchAll]]": ["/[[...catchAll]]/page"],
  "/nested/[foo]/[bar]": ["/nested/[foo]/[bar]/@slot/page"],
  "/nested/[foo]/[bar]/[baz]": ["/nested/[foo]/[bar]/@slot/[baz]/page"],
}
```

(Where there's a `/nested/[foo]/[bar]/default.tsx`)

The route normalization logic would produce:

```
{
  "/": ["/page"],
  "/[[...catchAll]]": ["/[[...catchAll]]/page"],
  "/nested/[foo]/[bar]": [
    "/nested/[foo]/[bar]/@slot/page",
    "/[[...catchAll]]/page",
  ],
  "/nested/[foo]/[bar]/[baz]": [
    "/nested/[foo]/[bar]/@slot/[baz]/page",
    "/[[...catchAll]]/page",
  ],
}
```
This means that when building the `LoaderTree`, it won't ever try to
find the default for that segment. **This solution operates under the
assumption that if you defined a `default` at a particular layout
segment, you intend for that to render in place of a greedier
catch-all.** (Let me know if this is an incorrect assumption)

### How?
We can't safely normalize catch-all parallel routes without having
context about where the `default` segments are, so this updates
`appPaths` to be inclusive of default segments and then filters them
when doing anything relating to build/export to maintain existing
behavior. We use this information to check if an existing default exists
at the same segment level that we'd push the catch-all to. If one
exists, we don't push the catch-all. Otherwise we proceed as normal.

Closes NEXT-1987
2024-01-05 14:20:45 -08:00
Tim Neutkens
66e565d1ea
Move buildId logic to getBuildId (#60132)
## What?

Small refactor to allow moving this logic 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-1949
2024-01-05 16:58:39 +01:00
vercel-release-bot
00f36befb4 v14.0.5-canary.40 2024-01-05 15:17:35 +00:00
OJ Kwon
f641d9ccfc
feat(next-core): apply rsc transform in turbopack (#59629)
### What?

Turbopack does not apply same transform for the react server components,
which makes missing lot of compilation error validation and custom
comments. PR refactors transform to be used in next-swc / turbopack
both, then apply it into turbopack.

There are still some of test cases are not passing, might need further
digging for the transform condition.


Closes PACK-2155

---------

Co-authored-by: Tim Neutkens <tim@timneutkens.nl>
2024-01-05 16:14:06 +01:00
Hamir Mahal
f60c609bdb
style: enforce prop immutability in new next app (#58845)
- fixes #58844

Co-authored-by: Steven <steven@ceriously.com>
2024-01-05 09:55:27 -05:00
Tim Neutkens
ae09d7e6c3
Add writeImagesManifest (#60209)
## What?

Moves images-manifest.json related code to a separate function `writeImagesManifest`

<!-- 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-1979
2024-01-05 09:51:49 +01:00
Andrew Clark
8ae1167c53
[PPR Nav] Fix: Page data should always be applied (#60242)
This fixes a case in the PPR navigations implementation where page data
was not being applied.

During a navigation, we compare the route trees of the old and new pages
to determine which layouts are shared. If the segment keys of two
layouts are the same, they are reused.

However, the server doesn't bother to assign segment keys to the leaf
segments (which we refer to as "page" segments) because they are never
part of a shared layout. It assigns all of them a special constant
(`__PAGE__`).

In the PPR implementation, I overlooked this and compared the segment
keys of all segments, including pages, not just shared layouts. So if
the only thing that changed during a navigation was the page data, and
not any parent layout, the client would fail to apply the navigation.

The fix is to add a special case for page segments before comparing
nested layouts. I also moved an existing special case for default pages,
since those are also leaf segments and are conceptually similar.
2024-01-04 18:33:43 -05:00
vercel-release-bot
da2e56ae97 v14.0.5-canary.39 2024-01-04 23:22:34 +00:00
Alexander Savelyev
269020a028
Disable 2mb limit for custom incrementalCacheHandler (#59976)
### Fixing a bug

### What?

Disable 2MB limit for custom incrementalCacheHandler

### Why?

The limit is necessary because `FetchCache` has a 2MB limit, but it
seems there was a miscommunication regarding the key coincidence, where
`fetchCache` is a flag indicating that the method is called from fetch,
rather than indicating that the `FetchCache` Provider is currently being
used.

We do not use Vercel, and as I understand it, we do not have the
opportunity to use this functionality.

In any case, it is more important for us to increase the limits, and in
some cases, using a file storage is even preferable.

### How?

I have created a flag that determines whether the use of `FetchCache` is
possible at least in theory - if no custom provider is passed, and
additionally configured it so that it is not an implementation of
`FetchCache` as a protection against special individuals (*like me :)*).

If everything is fine, I will write proper tests.

Also, I would like to recommend making `FileSystemCache` public (_i.e.
support it as public functionality_) so that it can be imported and
extended or simply used to fix only it.

Fixes #48324 (partially)

---------

Co-authored-by: JJ Kasper <jj@jjsweb.site>
2024-01-04 15:12:43 -08:00
Steven
a7be8eac47
fix: add node-web-audio-api to server-external-packages.json (#60243)
This package contains native `.node` files that cannot be bundled

Closes NEXT-1974
2024-01-04 22:36:59 +00:00
Tim Neutkens
335ff1cea9
Remove NEXT_TURBO_FILTER_PAGES internal variable (#60217)
## What?

This is currently unused and we'll want to cover it in a different way
when we start working on Turbopack builds.

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

---------

Co-authored-by: JJ Kasper <jj@jjsweb.site>
2024-01-04 21:08:09 +00:00
Tim Neutkens
406a861c3d
Ensure appPathsManifest variable is inside if block (#60210)
## What?

I noticed that this variable is only used to write the manifest to disk so it doesn't have to be kept around in the function scope.

<!-- 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-1980
2024-01-04 19:02:57 +01:00
k-taro56
91dba7d125
Fix: Throw an error for empty array return in generateStaticParams with output:export (#57053)
Fixes #57038

# What?
Added an error message when `generateStaticParams` returns an empty
array with `output:export`.

# Why?
To provide developers with clear feedback when `generateStaticParams` is
not used correctly.

# How?
Modified the condition checks around the use of `generateStaticParams`
to include a check for an empty array and added a corresponding error
message.

---------

Co-authored-by: Steven <steven@ceriously.com>
2024-01-04 11:45:02 -05:00
Zack Tanner
aa48b65f9a
log a dev warning when a missing parallel slot results in a 404 (#60186)
### What & Why?
When visiting a route that attempts to render a slot with no page & no default, the fallback behavior is to trigger a 404. However this can lead to a confusing development experience for complex parallel routing cases as you might not realize a default is missing, or which slot is causing the error.

Previous issues where this caused confusion:
- https://github.com/vercel/next.js/issues/51805
- https://github.com/vercel/next.js/issues/49569


### How?
This is a dev-only modification to track parallel slots that are using the default fallback (aka missing). When the `NotFoundBoundary` is triggered in development mode, this will log a warning about why it 404ed, along with a list of slot(s) that were determined to be missing.

![CleanShot 2024-01-03 at 14 34 30@2x](https://github.com/vercel/next.js/assets/1939140/1a00ea49-24b6-4ba0-9bac-8773c7e10a75)

### Future
We should eventually lift this into some sort of dev-only UI to help catch it when not monitoring the browser console (similar to the error overlay). However, this will require some design thought and isn't necessary for the first iteration.

Closes NEXT-1798
2024-01-04 07:56:20 -08:00
Donny/강동윤
1216422454
fix: Mark file as ESM if it has an export from auto-cjs pass (#60216)
### What?

Improve `auto-cjs` pass to consider `export` statements.

### Why?

The previous code caused some problems.

### How?

Fixes #60197


Closes PACK-2195

---------

Co-authored-by: Jiachi Liu <inbox@huozhi.im>
2024-01-04 16:24:27 +01:00
Tim Neutkens
3fd3d5d4b5
Add writeFullyStaticExport (#60200)
## What?

Moves the code for `output: 'export'` to a separate function.

<!-- 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-1976
2024-01-04 15:53:37 +01:00
Michał Dudak
6f9df4a0ac
Allow undefined environment variables in config (#58247)
<!-- 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 #

-->

This PR loosens the config schema to allow undefined environment
variables (for cases where they are defined only on certain
environments). Both the Zod schema and TS interface were updated.

Fixes #57755

---------

Co-authored-by: Tim Neutkens <tim@timneutkens.nl>
2024-01-04 15:52:49 +01:00
Hichem Fantar
5fde19b6d9
fix responsiveness in starter templates (#60140)
Fixes #60139
2024-01-04 14:28:10 +00:00
Tim Neutkens
2916042fca
Change server actions cache default to no-store (#60170)
## What?


Currently there is a bug in Server Actions when you `fetch` as it uses
the same defaults (caching when not specified) as rendering, this causes
some issues as you want to read your writes in Server Actions.

This change adds the `no-store` default for Server Actions, you can
still override it by specifying `cache: 'force-cache'` for example, but
it defaults to `cache: 'no-store'`.

Fixes NEXT-1926

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

## For Contributors

### Improving Documentation

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

### Adding or Updating Examples

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

### Fixing a bug

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

### Adding a feature

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


## For Maintainers

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

### What?

### Why?

### How?

Closes NEXT-
Fixes #

-->

---------

Co-authored-by: Zack Tanner <zacktanner@gmail.com>
2024-01-04 14:01:50 +01:00
Tobias Koppers
5117cc6ea9
Improve consistency of issues and diagnostics for napi calls (#60198)
### What?

get value, issues and diagnostics in a single strongly consistent call

### Why?

Before issues and diagnostics where not received strongly consistent,
which could result in stale data.

### How?



Closes PACK-2194
2024-01-04 13:06:45 +01:00
vercel-release-bot
bc69a382f6 v14.0.5-canary.38 2024-01-04 12:05:43 +00:00
Jiachi Liu
84c572175a
Upgrade @vercel/og (#60205)
Upgrade `@vercel/og` to `0.6.2` for wasm oversize problem
2024-01-04 13:02:40 +01:00
Tim Neutkens
bcbaf8c854
Always write FunctionsConfigManifest (#60163)
## What?

Noticed there was a specific guard to avoid writing this manifest when
there was no custom config, but for consistency in the output it's
better to always write it.
Also added a type for this manifest.

<!-- 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-1960
2024-01-04 11:26:17 +01:00
Tim Neutkens
48355fdc25
Add writeStandaloneDirectory (#60162)
## What?

Moves the creation of the `standalone` directory when using `output:
'standalone'` into a separate function. Also added a type for
`RequiredServerFilesManifest` as it was missing.

<!-- 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-1959
2024-01-04 11:23:30 +01:00
Tim Neutkens
09af522f8b
Add writePrerenderManifest (#60158)
## What?

Ensures the duplicated code in the if/else branch just uses a function
so that the logic is shared.

<!-- 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-1958
2024-01-04 11:21:23 +01:00
Tim Neutkens
5aaeb85170
Add writeManifest (#60138)
## What?

Follow-up to `readManifest` this adds `writeManifest`.

<!-- 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-1955
2024-01-04 11:11:53 +01:00
vercel-release-bot
25d7e3d89e v14.0.5-canary.37 2024-01-04 10:04:54 +00:00
pacexy
a2f4ca52e4
fix: cache next font during development to avoid FOUC (#60175)
In fact, this is an issue that has been solved in #52033, but it seems
#52492 introduced it again.

> During development, for fonts created via next/font the file path is
already containing the hash so we can always have them cached. This
fixes the problem of fonts causing FOUC in HMR.

Fixes #50782

---------

Co-authored-by: Tim Neutkens <tim@timneutkens.nl>
2024-01-04 08:54:23 +00:00
vercel-release-bot
36a1ec62c4 v14.0.5-canary.36 2024-01-03 23:23:02 +00:00
Anthony Shew
5a10d2566b
Getting rid of a few TypeScript anys. (#60017)
Had some spare time and was trying to get more familiar with the
codebase.

Added a few types to `create-next-app` here. Nothing fancy!

---------

Co-authored-by: Steven <steven@ceriously.com>
2024-01-03 16:22:29 -05:00
Josh Story
f9697190ab
Refactor: Separate RSC renderer from SSR wrapping component (#59676)
This commit updates some of the code organization in app-render in
preparation for supporting dynamic RSC repsonses on top of static SSR
responses for PPR. The main change to notice is the separation of
creating the server component renderer which initiates the RSC render
and executes in the RSC layer with the consuming component which lives
in the SSR layer. By organizing the code this way we can later only call
the server render in certain cases, omitting the SSR render entirely.

This is different than just using the generaetFlight pathway because
that pathway serves client navs and does not actually render the same
output that the intial render does.

Closes NEXT-1889
2024-01-03 12:14:26 -08:00
JJ Kasper
6bde3e5082
Fix invalid comment (#60182)
Noticed this comment conflicts with actual behavior so fixing for
posterity.

Closes NEXT-1972
2024-01-03 19:56:02 +00:00
Zane Bauman
37a09891f3
fix: <Script> with beforeInteractive strategy ignores additional attributes in App Router (#59779)
### What?

Currently, `next/script` in the App Router does not behave as the docs
describe in the [Additional
Attributes](https://nextjs.org/docs/app/building-your-application/optimizing/scripts#additional-attributes)
section – it does not pass on all additional attributes when
`strategy="beforeInteractive"`
([#49830](https://github.com/vercel/next.js/issues/49830)).

### Why?

The props from the `<Script>` component were not passed on to the
underlying script loader (`self.__next_s`).

### How?

I've added the missing props to the object that is `push`ed to
`self.__next_s`.

NEXT-1304
Fixes #49830
2024-01-03 20:48:55 +01:00
Steven
df16698a8c
chore: bump @vercel/nft@0.26.1 (#60172)
https://github.com/vercel/nft/releases/tag/0.26.2
https://github.com/vercel/nft/releases/tag/0.26.1
https://github.com/vercel/nft/releases/tag/0.25.0

Closes NEXT-1962
2024-01-03 14:14:43 -05:00
Tim Neutkens
4e9a3ba300
Refactor to unify writeFile, readFile, and add readManifest (#60137)
## What?

Consolidates similar function calls, sets up `readManifest` and the
foundation for `writeManifest` 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-1954
2024-01-03 18:59:35 +01:00
Tim Neutkens
b6c7183b06
Move cacheDir logic to getCacheDir (#60133)
## What?

Similar to #60132 but for `cacheDir`, allows moving it to a separate
place 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-1950
2024-01-03 16:40:55 +01:00
Jiachi Liu
c42c7cd001
Fix emitting ESM swc helpers for 3rd parties CJS libs in bundle (#60169)
Previously in #58967 we set all the module type as `'es6'` to let swc
parse app router code as ESM and output as ESM due to the incorrect
detection of CJS module by auto-cjs plugin, but this is not accurate
when the external library bundle is CJS. The problem is when swc
compiling modern syntax for example private properties in CJS bundle but
emitted the swc helpers with ESM imports.

We had a auto-cjs swc plugin to determine if the file is using CJS or
not, @kdy1 fixed the bug of it so now we can use the default module
type, and let the plugin to determine its module type, to make sure
we're emitting the right helpers.

Closes NEXT-1942
Based on #60118
2024-01-03 16:04:08 +01:00
Jiachi Liu
7818c2d736
Allow using ESM pkg with custom incremental cache (#59863)
Use dynamic import instead of require to load the incremental cache
handled, so when using ESM it will still work.

Updated the tests and merged them into new test suite, include 3 cases
of custom cache definition:
- CJS with `module.exports`
- CJS with `exports.default` with ESM mark
- ESM with `export default`

Closes NEXT-1924
Fixes #58509
2024-01-03 14:22:50 +01:00
Jiachi Liu
a1d2d91076
Fix start build log being overwritten by logs from page (#60122)
The start line of build logging `Creating an optimized production build
...` was logged by spinner, and when all build is finished we stop that
spinner. But the problem is all the logs from a page such as warnings
will be also leaded by it since they interrupted the spinner.

We changed the spinner to a one-line log now that will make the warning
logs more clear and let the page-level build logs print without messed
with app-level build logs.

#### After

```
   ▲ Next.js 14.0.5-canary.34

   Creating an optimized production build ...
 ⚠ Next.js can't recognize the exported `runtime` field in "/Users/huozhi/workspace/next.js/test/e2e/app-dir/app-edge/app/expo
rt/inherit/page.tsx" as it was not assigned to a string literal.
The default runtime will be used instead.
 ⚠ Next.js can't recognize the exported `preferredRegion` field in "/Users/huozhi/workspace/next.js/test/e2e/app-dir/app-edge/
app/export/inherit/page.tsx" as it was not assigned to a string literal or an array of string literals.
The default runtime will be used instead.
```

#### Before

```
   ▲ Next.js 14.0.5-canary.34

   Creating an optimized production build  ... ⚠ Next.js can't recognize the exported `runtime` field in "/Users/huozhi/worksp
ace/next.js/test/e2e/app-dir/app-edge/app/export/inherit/page.tsx" as it was not assigned to a string literal.
The default runtime will be used instead.
 ⚠ Next.js can't recognize the exported `preferredRegion` field in "/Users/huozhi/workspace/next.js/test/e2e/app-dir/app-edge/
app/export/inherit/page.tsx" as it was not assigned to a string literal or an array of string literals.
The default runtime will be used instead.
   Creating an optimized production build  ... ⚠ Next.js can't recognize the exported `runtime` field in "/Users/huozhi/worksp
ace/next.js/test/e2e/app-dir/app-edge/app/export/inherit/page.tsx" as it was not assigned to a string literal.
The default runtime will be used instead.
 ⚠ Next.js can't recognize the exported `preferredRegion` field in "/Users/huozhi/workspace/next.js/test/e2e/app-dir/app-edge/
app/export/inherit/page.tsx" as it was not assigned to a string literal or an array of string literals.
The default runtime will be used instead.
```   

Closes NEXT-1939
Closes NEXT-1947
2024-01-03 14:07:58 +01:00
Zack Tanner
d52d36d3b3
gracefully handle client router segment mismatches (#60141)
### What?
Next.js throws a hard `SEGMENT MISMATCH` error when the reducers were
unable to apply the a patch to the router tree from the server response.

### How?
Rather than crashing the router, this will treat segment mismatches as a
MPA navigation, to restore the client router into a working state.

### Test Plan
If there are specific scenarios where Next.js throws this error, it
should most likely be fixed in Next and not in user-land. Since it's not
currently obvious what scenarios will trigger this error, this PR serves
to recover from a mismatch more gracefully and provides some debug
information rather than crashing the application. As such, there's no
easy way to create an E2E test for this and I've instead opted for a
simple unit test.

Closes NEXT-1878
[slack
x-ref](https://vercel.slack.com/archives/C017QMYC5FB/p1704214439768469)
[slack
x-ref](https://vercel.slack.com/archives/C03KAR5DCKC/p1702565978694519)

---------

Co-authored-by: JJ Kasper <jj@jjsweb.site>
2024-01-03 03:49:55 +00:00
Arnab Sen
5d5f58560f
chore: align webpack config node version (#59862)
Aligning Node version to currently supported version

Co-authored-by: JJ Kasper <jj@jjsweb.site>
2024-01-02 16:51:32 -08:00
vercel-release-bot
4e1cd94a3a v14.0.5-canary.35 2024-01-02 23:21:51 +00:00
Aleksandr Kondrashov
d3151279e7
Filter out duplicate paths in build output (#59858)
<!-- Thanks for opening a PR! Your contribution is much appreciated.
To make sure your PR is handled as smoothly as possible we request that
you follow the checklist sections below.
Choose the right checklist for the change(s) that you're making:

## For Contributors

### Improving Documentation

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

### Adding or Updating Examples

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

### Fixing a bug

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

### Adding a feature

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


## For Maintainers

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

### What?

### Why?

### How?

Closes NEXT-
Fixes #

-->
Fixes #59775
Closes NEXT-1907
The build output includes a [normalized
path](b3ad907d2b/packages/next/src/shared/lib/router/utils/app-paths.ts (L23))
that disregards groups and parallel segments, potentially causing
different routes to share the same normalized path. To address this,
I've implemented a check ensuring that the path is added to the
resulting array only once.

---------

Co-authored-by: Zack Tanner <zacktanner@gmail.com>
2024-01-02 19:18:45 +00:00
lijianan
9ce18c4d5f
chore: update Copyright time from 2023 to 2024 (#60071)
<!-- 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-01-02 11:06:02 -08:00
Donny/강동윤
145a0c0797
fix: Fix wrong cjs detection of auto-cjs pass (#60118)
### What?

Make `auto-cjs` pass consider shadowing of `module`, so it can ignore
`module.exports = foo` in nested scopes.

### Why?

It's problematic for many tasks

### How?

Closes PACK-2074
2024-01-02 16:59:09 +01:00
Tim Neutkens
5f6cd8f649
Fix path issues on linux machines when build created on windows (#60116)
Copy of #58398 with `normalizePathSep` applied. Unfortunately the branch
wasn't editable, I'm guessing because it was opened on an organization
instead of an individual.

Fixes #58244
Closes #58398

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

---------

Co-authored-by: keyur2582 <52085601+keyur2582@users.noreply.github.com>
2024-01-02 16:55:23 +01:00
Tim Neutkens
f1bc538629
Always call createPagesMapping for root paths (#60107)
## What?

Always call `createPagesMapping` as it already handles the case when
there are no paths.

Also introduces `PAGE_TYPES` to have a single source of truth for these
types and where they're used. As you can see this replaces a ton of
hardcoded `'app'`, `'pages'`, and `'root'` references.

<!-- 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-1935
2024-01-02 15:20:05 +01:00
Tim Neutkens
e5aa95ca8d
Add MappedPages type (#60106)
## What?

All of these separately defined types are referring to the same type
that is passed through to the functions so I've unified them into a
single type.

<!-- 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-1934
2024-01-02 15:00:23 +01:00
Tim Neutkens
4425cde49d
Remove extra duplicate pages warning (#60113)
## What?

While working on some other refactors I noticed that this check for
duplicate routes is incorrect.
Upon further investigation with @feedthejim we noticed that this check
can be removed altogether as it's already being checked correctly in the
route matcher.

I've moved the test to use `createNextDescribe` and removed the check
for build because it's a dev-only warning.

<!-- 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-1941
2024-01-02 14:55:55 +01:00