Commit graph

12291 commits

Author SHA1 Message Date
vercel-release-bot
8d71ac42fe v15.0.0-canary.12 2024-06-05 03:19:27 +00:00
Zack Tanner
14da561df2
fix NextRequest proxy in edge runtime (#66551)
Properties such as the native `Headers` / `Cookies` on the `NextRequest`
proxy make use of internal slots, so passing `receiver` (the proxy
object) which does not have the internal slots on it causes an issue in
the edge runtime. Instead, we want to make sure that the target is the
native object. This is similar to
https://github.com/vercel/next.js/pull/47088.

<!-- 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-06-05 03:14:41 +00:00
vercel-release-bot
02e144d376 v15.0.0-canary.11 2024-06-04 20:20:55 +00:00
Ivan Torres
abff797e92
Update dev dependecies validate npm package name (#66536)
New PR

Update DevDependecies "validate-npm-package-name" and type

PR closed: #66420

---------

Co-authored-by: torresgol10.itd <torresgol10.itd@gmail.com>
Co-authored-by: Sam Ko <sam@vercel.com>
2024-06-04 10:47:11 -07:00
Zack Tanner
855ea3af24
fix 'loading' segment not being copied into new CacheNode (#66538)
When `router.refresh` or a server action creates a new `CacheNode` tree,
we were erroneously not copying over the `loading` segment in the new
tree. This would cause the subtree to be remounted as the loading
segment switched from having a Suspense boundary to not having one.

Fixes #66029
Fixes #66499
2024-06-04 10:15:42 -07:00
Wyatt Johnson
8cb8edb686
refactor: deprecate future directory (#66432)
This removes the previous `server/future` directory and moves everything
into the `server` or `server/lib` directories. This is aimed to start to
flatten the server application structure.
2024-06-04 15:23:23 +00:00
Tobias Koppers
aacedcb417
add more tracing (#66528)
### What?

* add tracing for transforms
* add high level tracing
* add tracing for next/dynamic collection
2024-06-04 15:13:35 +00:00
Tobias Koppers
82df2a8d82
improve order of spans in tracing (#66516)
### What?

awaits generating the output before calling into emitting

### Why?

this improve the order of spans in the tracing
2024-06-04 15:12:11 +00:00
Tobias Koppers
a8221a0582
fixing next/dynamic transform for turbopack (#66527)
### What?

pass the correct prefer_esm value to the transform
2024-06-04 14:06:51 +00:00
vercel-release-bot
3ef03ff320 v15.0.0-canary.10 2024-06-04 12:05:01 +00:00
Tobias Koppers
e00f58e3ef
optimize server actions (#66523)
### What?

optimize allocations in server actions transform

In one edge case it reduces allocations from 30GB to 4.5MB and time from
760ms to 11ms.

### Why?

make it faster
2024-06-04 14:00:09 +02:00
Sebastian Silbermann
52689b5960
Fix fetch deduping in dev after reload (#66507) 2024-06-04 13:19:37 +02:00
Tobias Koppers
77e6b033c5
fix css order for some edge cases in App Dir (#66500)
### What?

* order of CSS between layout and page
* order of CSS between page and next/dynamic

### Why?

### How?

* overrides webpack CSS chunk loading to use react CSS loading to allow
them to share the order
2024-06-04 10:18:52 +02:00
Zack Tanner
ceef719459
fix missing stylesheets when parallel routes are present (#66300)
This takes the `layerAssets` property from the previous PR and actually
renders it, replacing the previous style handling. This ensures that
when multiple page segments are rendered on screen, all of their
associated CSS files are loaded. The existing `findHeadInCache` method
only ever returns a single head node, which means it’d miss stylesheets.


Fixes #59308
Fixes #63465
2024-06-03 16:35:31 -07:00
vercel-release-bot
786a703584 v15.0.0-canary.9 2024-06-03 23:23:25 +00:00
vercel-release-bot
f76563393a v15.0.0-canary.8 2024-06-03 20:42:41 +00:00
Zack Tanner
312eb61d24
add layerAssets property to FlightDataPath (#66354)
This adds a new `layerAssets` property (containing styles and script
tags) to `FlightDataPath`. Previously these were lumped in with the
`head` node, but we intentionally only ever render a single `head`, to
avoid duplicating metadata. This would mean `<AppRouter />` would only
ever render imported stylesheets for a single page in a racey way.
However, since Float handles hoisting and deduping these style tags,
we're safe to render them for each segment.

This PR introduces no change in behavior, aside from sending
`layerAssets` down from the server and storing it in the client router
cache. These nodes aren't rendered -- this is done in #66300.
2024-06-03 13:19:52 -07:00
Wyatt Johnson
be7d0c970e
fix: only generate prefetch rsc for ppr enabled routes (#66395)
This adds details for every ISR cache request if the page being
requested supports PPR. If it does, it'll attempt to load the
`.prefetch.rsc` payload instead of the `.rsc` payload. This corrects a
bug that was present in deployed environments.

This additionally refactors the `isAppPPREnabled` out of most of the
application, as it's only used to determine if we should add to the
`prefetchDataRoute` fields in the `prerender-manifest.json`. To support
loading the prefetch file or not, we pass the `isRoutePPREnabled`
through with the cache get/set operations instead.

x-slack-ref:
https://vercel.slack.com/archives/C075MSFK9ML/p1717094328986429
2024-06-03 12:55:05 -07:00
Hendrik Liebau
4f2e65ba96
Fix next/navigation type augmentation (#66489) 2024-06-03 17:53:37 +00:00
Tobias Koppers
7ea0337ad1
avoid filtering the error message (#65311)
### What?

If the error message contains a reference to `node_modules` it would
omit the error message, but actually we only want to omit the stack
frames

### Why?

### How?
2024-06-03 15:14:35 +00:00
Alexander Lyon
4849ae76c4
expose experimental option to set a memory limit for turbo (#66101)
### What?

We have a GC with rough edges, but it is worth exposing a flag to be able to try it out.

### Why?

I think it would be useful to set up a benchmark that tests the GC perf on new canary builds to make sure we are going in the right direction.

### How?

Add a new flag in the experimental settings and wire it up to the existing native bindings.

Closes PACK-3093
2024-06-03 15:03:58 +01:00
Jiachi Liu
18a7a4d204
Polish copy button state and styles (#66370)
### What
Address the feedbacks in #65921 

* Improve the a11y, using native button
* add more state, such as pending.

### Videos

#### Successful state


https://github.com/vercel/next.js/assets/4800338/2943d6dc-148d-4122-92dd-ba8578abdcf4

#### Error state


https://github.com/vercel/next.js/assets/4800338/3fa36c41-845b-4152-8b82-f15b2ebd72b2

---------

Co-authored-by: Sebastian Silbermann <sebastian.silbermann@vercel.com>
2024-06-03 15:11:32 +02:00
vercel-release-bot
12dbc8ad7e v15.0.0-canary.7 2024-06-02 23:23:04 +00:00
vercel-release-bot
5ae286ffd6 v15.0.0-canary.6 2024-06-01 23:23:16 +00:00
Zack Tanner
734fa1df62
fix: ensure route handlers properly track dynamic access (#66446)
In #60645, dynamic access tracking was refactored but we erroneously
stopped tracking dynamic access in route handlers. Request proxying, as
well as tracking segment level configs (such as `export const dynamic =
'force-dynamic'`), were only enabled during static generation. This was
an unintended breaking change that consequently caused dynamic access to
not properly bail from data cache in various circumstances.

This adds some more rigorous testing for route handlers, as this seems
to be a fairly large gap in our fetch cache testing currently.

This PR is easiest to review with [whitespace
disabled](https://github.com/vercel/next.js/pull/66446/files?w=1).
2024-06-01 15:32:50 -07:00
Jiachi Liu
34c2a05da2
Warn metadataBase missing in standalone mode or non vercel deployment (#66296)
### What

Change the metadataBase missing warning for all cases to only warn in
standalone mode or the non-vercel deployment.

### Why

In vercel deployments, previous concern was that you might not discover
you missed that metadataBase when you deploy. But now we have sth
fallback on production deployments. So we only need to warn in
non-vercel deployment.

Standalone is usually for self-hoist, we always warn users to set the
`metadataBase` to make sure the domain can be properly resolved.


[x-ref](https://vercel.slack.com/archives/C03S8ED1DKM/p1716926825853389?thread_ts=1716923373.484329&cid=C03S8ED1DKM)
2024-06-01 20:15:01 +02:00
Sebastian Silbermann
355a4acc9e
Improve JSDoc link for Metadata API (#66455) 2024-06-01 17:00:36 +00:00
Zack Tanner
d9b2d8b9cc
fix erroneous RSC calls on hash changes (#66434)
When the router encounters a `stale` cache entry, it clears the `rsc`
data so that it can be fetched in render. All navigations (even just for
hash fragments) flow through the navigation reducer, which has logic to
discard any existing cache entries when the cache is stale.

This bug has become more obvious after removing the default 30s cache,
which would previously have masked it.

This updates the existing handling that clears flight data to not do so
if only the hash changes as there would be no server changes in this
case.

<!-- 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-06-01 06:26:04 -07:00
Will Binns-Smith
b39ae62a3b
Update rust toolchain to nightly-2024-05-31 (#66428)
Depends on https://github.com/vercel/turbo/pull/8256
2024-06-01 03:37:04 +00:00
vercel-release-bot
1e63f5b336 v15.0.0-canary.5 2024-05-31 23:22:44 +00:00
vercel-release-bot
86a0c8f7b1 v15.0.0-canary.4 2024-05-31 21:57:18 +00:00
Zack Tanner
f55a064ce5
add experimental flag for retrying static generation (#66393)
Transient/recoverable errors can cause page(s) to fail. When building an
app with a lot of static pages, a single page failing to build can be
frustrating, especially if it it'll pass on a retry. This adds an
experimental `staticPageGenerationTimeout` property that can be used to
configure how many times Next.js attempts to build a particular page
before giving up.

I recommend reviewing this PR [without
whitespace](https://github.com/vercel/next.js/pull/66393/files?w=1)

<!-- 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-05-31 14:53:46 -07:00
Zack Tanner
a0155c79c5
refactor page export error tracking (#66392)
This adds a map to track failed pages (and the number of attempts, which
will be used in #66393). I removed some other variables that were being
used to track the same information.

<!-- 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-05-31 20:23:27 +00:00
Zack Tanner
c467c0a992
remove duplicate export workers (#66388)
We already have workers available when determining if a page is static,
and we expose those workers to the page export handler. We should re-use
those workers instead of creating new ones.

In practice this seems like dead code, since `setupWorkers` returns the
existing workers if a pages worker exists, and we always create a pages
worker.

<!-- 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-05-31 12:41:17 -07:00
Kevin Mårtensson
2e4884035d
chore: bump supported msw version to v2.3.0 (#66351)
### What?

This bumps the supported `msw` version when using the `playwright` test
mode. There's no need for mocking requests and responses anymore since
[they adopted](https://github.com/mswjs/msw/pull/1436) the global fetch
API in `msw`.

### Why?

Users can extend `test` from `playwright` manually and create the `msw`
fixtures, but it's better if it works out of the box with newer versions
of `msw`.

Fixes #63338.

Co-authored-by: Sam Ko <sam@vercel.com>
2024-05-31 12:18:41 -07:00
vercel-release-bot
9622d89eb9 v15.0.0-canary.3 2024-05-31 18:17:31 +00:00
Jiachi Liu
86723a6f52
Revert "Middleware RSC bundling changes" (#66422)
Revert #66052 
Revert #66294
2024-05-31 18:10:08 +00:00
Benjamin Woodruff
c0562529db
next-swc-napi: Remove "plugin" from default feature list (#66380)
Effectively a revert of https://github.com/vercel/next.js/pull/66006,
but:

- Keeps the cleanup changes from that PR.
- With https://github.com/vercel/nextpack/pull/106 removing the explicit
`--features plugin` flag, we will match behavior between cargo's
defaults and the nextpack development scripts (which we want to do for
maximizing cache reuse).

The tradeoff here is faster cold builds, at the cost of waiting longer
when you want to test with plugins.

Feedback from @kdy1 was:

> I think it's a good idea to disable plugin by default for nextpack. We
don't use it for most of daily development, but it's very large and slow
to compile

Tested by running both:

```
pnpm build-native
pnpm build-native-no-plugin
```
2024-05-30 17:03:15 -07:00
vercel-release-bot
f9bbb0c82d v15.0.0-canary.2 2024-05-30 23:22:53 +00:00
Vercel Release Bot
50ca7f874c
Update font data (#66359)
This auto-generated PR updates font data with latest available

Co-authored-by: JJ Kasper <jj@jjsweb.site>
2024-05-30 12:25:46 -07:00
yasmin p
139d577c95
Use classnames to set font family in Tailwind create-next-app templates (#66374)
Replaces inline styles in the Tailwind `create-next-app` templates with
classnames to set the font family.

Co-authored-by: Sam Ko <sam@vercel.com>
2024-05-30 10:43:36 -07:00
Wyatt Johnson
dc6d612529
fix: ensure dynamic fetches are tracked correctly (#66349)
This modifies the patched fetch implementation to better handle when
called within an `unstable_cache` callback. In these callbacks, it
should not throw an error related to dynamic access.

This replaces the verbose `trackDynamicFetch` instead with
`markCurrentScopeAsDynamic` which already has support for checking if
inside an unstable cache context. It also has been adjusted to be a
no-op when `export const dynamic = "force-static"`, further simplifying
the code within the patch fetch implementation.
2024-05-30 16:54:03 +00:00
Sebastian Silbermann
deb60c65f4
Restore optimization to ignore legacy APIs in react-dom/server (#66371) 2024-05-30 16:34:48 +02:00
notomo
278b0ba481
feat(react-dev-overlay): Open nvim with line number (#66358)
Co-authored-by: Jiachi Liu <inbox@huozhi.im>
2024-05-30 15:59:48 +02:00
Jiachi Liu
92443b6f75
Transform client reference in middleware layer (#66294)
### What

Use `next-flight-loader` to transform the client components into client
reference in middleware and instrumentation.
Add related required webpack aliases, such as alias for
`react-server-dom-webpack`

### Why

issue reported in
https://github.com/vercel/next.js/pull/65424#issuecomment-2128902585
2024-05-30 11:38:55 +02:00
Jiachi Liu
a95356a59d
feat: add copy button for runtime error (#65921)
### What

Add copy stack trace button to copy the original stacktrace in error
overlay.
It will be a dimmed red button with disallowed cursor when it's found
not able to copy.

#### Video



https://github.com/vercel/next.js/assets/4800338/c44e0bf8-f340-41ba-8ee8-4b94fdc298e1


### Why

Makes error reporting easier, users can do one-click to copy the
original text
2024-05-30 09:58:01 +02:00
vercel-release-bot
b4f32831ef v15.0.0-canary.1 2024-05-29 23:22:54 +00:00
Wyatt Johnson
b5ab9abd62
refactor: remove isRSCRequestCheck (#65587)
In preparation for the following request adapter work, this removes a
helper function for checking if a request is an RSC one, instead
preferring to use the metadata directly.

This helps readability because we know where it's coming from, and it
keeps the implementation simple.
2024-05-29 14:23:59 -07:00
vercel-release-bot
64ed7ec951 v15.0.0-canary.0 2024-05-29 15:30:18 +00:00
Sam Ko
4c48f3b580
chore(next-font): bump @capsizecss/metrics package to the latest (#66302)
## Why?

Upgrade `@capsizecss/metrics` package to the
[latest](https://github.com/seek-oss/capsize/releases/tag/%40capsizecss%2Fmetrics%403.2.0).
2024-05-28 18:13:15 -07:00
vercel-release-bot
c4f6645041 v14.3.0-canary.87 2024-05-28 23:23:34 +00:00
Jiachi Liu
25db485a00
Trigger error for stream on client when it is not finished as expected (#65798)
### What

* Error on case that readable stream controller tries to close but
stream is either errored or unfinished
* Delay the DOMContentLoaded event to avoid "Connection Closed" error


### Why

Regarding to the new error about readbale stream controller, the new
error we added here is for identifying the connection is closing before
the last bit has been received that's an error case not intentional
close. It's not a proper state for close more for erroring.


As for adding the queuing for the task of dom content loaded callback,
after investigation, I found that if the DOMLoaded execute earlier the
readable stream controller cuold close earlier on client, which lead to
the "Connection Closed." error. Hence we added a `queueMicroTask` here
to delay it after hydrate call.

x-ref: [slack
thread](https://vercel.slack.com/archives/C01A2M9R8RZ/p1715188343813489)
2024-05-28 23:42:04 +02:00
Jiachi Liu
9c993ec787
enhance: ignore nextjs version fetch error in dev overlay (#66271)
### What 

It's not helpful to see the network issue of fetching error on reading
nextjs version in dev overlay

### Why

Error case:

<img width="400"
src="https://github.com/vercel/next.js/assets/4800338/a7852d9b-1f98-4098-8498-a3b832efdbb0">

This should just be ignored, it's fine that the fetching is failed.
There're so many fetch errors code, it's easy to try-catch on fetch
instead of enumerate all the codes
2024-05-28 22:19:35 +02:00
vercel-release-bot
7dfb652ef1 v14.3.0-canary.86 2024-05-28 16:24:47 +00:00
Wyatt Johnson
b5d911c92c
[ppr] Don't mark RSC requests as /_next/data requests (#66249)
Old logic from the pages router was previously being hit during
development. This was more apparent when PPR was enabled as it was
mixing dynamic + static rendering in development which propagated to
errors. This change ensures that requests that are made with `RSC: 1`
are not marked as `/_next/data` URL's, and don't use the same logic
paths.

Previously it was a bit confusing because we used the variable
`isDataReq` in a few places that made it hard to tell what it was
referring to. In this case, the `isDataReq` is actually only used by the
pages router. This renames the `isDataReq` to `isNextDataRequest` to
make it clearer, as well as refactors to ensure that it's not used in
the paths for app routes.

Also to better represent the rendering modes the `supportsDynamicHTML`
variable was renamed to `supportsDynamicResponse`.

Fixes #66241
2024-05-28 07:53:04 -07:00
Jiachi Liu
1b36d76155
fix dev overlay version indicator style (#66278)
Fix the Build Error indicator location, it should be located on the
top-right corner. Align the padding with

### Build Error


![image](https://github.com/vercel/next.js/assets/4800338/835506a5-bf29-4f3e-ae0e-091dc9a7b386)

### Runtime Error


![image](https://github.com/vercel/next.js/assets/4800338/2a61a933-58f2-471e-9d3f-84b3954b1460)
2024-05-28 16:26:40 +02:00
Jiachi Liu
1415609870
Reland bunling webpack middleware changes (#66049) (#66052)
Revert the revert in #66049 

It was erroring in pages api with importing `react-dom/server` as this
is disallowed in app but shouldn't be in pages. It's caused by we're
validating middleware layer as server components but edge pages api is
still bundled in the same layer, where we shouldn't apply the check.

* Separate the api in api layers, and while handling middleware
warnings, checking api layer as well
* No need to check layers while handling externals in edge compiler
* Found a bug that we shouldn't check if `config.transpilePackages` is
defined then we enable `externalDir`, removed that condition. It fails
the telemetry tests case build with code change from this PR.


Add more tests for pages dir and middleware

|  | `react` condition | `react-dom/server` condition |
| ---- | ---- | ---- |
| middleware (edge) | react-server | not allowed, failed with dev/build
checks |
| pages/api edge | default condition | default condition |
| pages/api node | default condition | default condition |
2024-05-28 13:55:12 +02:00
vercel-release-bot
1c83394dd3 v14.3.0-canary.85 2024-05-27 23:23:34 +00:00
Sebastian Silbermann
d36917cd34
Bump React types to 19 rc (#66186) 2024-05-27 16:19:41 +00:00
Hendrik Liebau
6ea265f402
Fix source map loading failure for path-to-regexp (#66242) 2024-05-27 16:16:08 +00:00
Sebastian Silbermann
202243932f
Bump styled-jsx to 5.1.6 (#66185) 2024-05-27 18:05:32 +02:00
Sebastian Silbermann
2ae0572742
Bump React types to latest 18.3.x (#66181) 2024-05-27 17:16:59 +02:00
yasmin p
0f55f2ab1d
Update create-next-app template CSS (#66233)
Updates `create-next-app` template CSS:

- Declares variable font weights in `localFont` options and removes
instances of `font-synthesis: none`
- Removes Geist font variables from Tailwind config files
- Adds fallback sans typefaces to the `body` CSS

Co-authored-by: Sam Ko <sam@vercel.com>
2024-05-26 17:42:36 -07:00
akazwz
10dd336747
chore: update empty template tailwindcss config (#66173)
### What?

update update empty template tailwindcss config

### Why?

empty template tailwindcss with src dir has problem
[https://github.com/vercel/next.js/blob/canary/packages/create-next-app/templates/index.ts#L162](https://github.com/vercel/next.js/blob/canary/packages/create-next-app/templates/index.ts#L162)

### How?

Closes NEXT-
Fixes #66172

Co-authored-by: Sam Ko <sam@vercel.com>
2024-05-27 00:18:46 +00:00
Adam Bosco
b3d9098383
fix(create-next-app): Update CNA templates' .gitignore files for parity with Yarn recommendations (#65823)
### What?

Updates create-next-app's templates' `.gitignore` files for parity with
[Yarn's official
recommendations](https://v3.yarnpkg.com/getting-started/qa#which-files-should-be-gitignored),
accounting for Yarn's modern Plug-n-Play functionality.

Fixes #65586 

### Why?

New projects initialized with create-next-app presently add various
extraneous files from the Yarn cache to the initial commit. This is most
notable in the case of the Next SWC binary, which may exceed 100M in
some environments and prevent users from pushing their new projects to
free GitHub repositories without rewriting the commit history or setting
up Git LFS.

### How?

I've opted to follow the recommendations for
non-[Zero-Install](https://yarnpkg.com/features/caching#zero-installs)
configurations as Zero-Install may necessitate additional configuration
and present additional complications for unsuspecting users, so I think
it's best left up to the user to opt-in.

Contrary to the example `.gitignore`s provided by Yarn, I've excluded
the `.yarn/sdks` directory as it contains IDE-specific tooling which I
think is also best left up to the user to opt-in to including.

I have retained the current `.gitignore`'s exclusion of the `/.pnp`
directory for backwards compatibility with older versions of Yarn.
2024-05-26 17:06:24 -07:00
vercel-release-bot
6fc03e70b6 v14.3.0-canary.84 2024-05-26 23:23:17 +00:00
vercel-release-bot
4df90ac6ff v14.3.0-canary.83 2024-05-26 10:42:09 +00:00
Tim Neutkens
216ce33b5b
Implement typeof window inlining for Turbopack (#66128)
## What?

Update: Implemented a feature in Turbopack for `typeof window` inlining:
https://github.com/vercel/turbo/pull/8211. Verified the changes in that
PR + this PR fix the test 💯


Turbopack upgrade:

* https://github.com/vercel/turbo/pull/8081 <!-- Alexander Lyon - add
support for upload speed / remaining in the cache upload step -->
* https://github.com/vercel/turbo/pull/7673 <!-- Alexander Lyon -
[turbo-trace] add additional filter modes for allocs over time -->
* https://github.com/vercel/turbo/pull/8191 <!-- Will Binns-Smith -
Turbopack: Register react refresh exports in module factory -->
* https://github.com/vercel/turbo/pull/8195 <!-- Donny/강동윤 - feat:
Remove lint for `grid-template-areas`" -->
* https://github.com/vercel/turbo/pull/8207 <!-- Benjamin Woodruff -
chore: Remove unused `base16` dependency and dead `hex` wrapper function
-->
* https://github.com/vercel/turbo/pull/8185 <!-- Tim Neutkens - Update
contributing guide to mention snapshot test updating -->
* https://github.com/vercel/turbo/pull/8211 <!-- Tim Neutkens - Add
option for inlining typeof window -->
* https://github.com/vercel/turbo/pull/8214 <!-- Will Binns-Smith -
Revert "Turbopack: Register react refresh exports in module factory
(#8191)" -->

---

Previous PR description::

Implements a failing test for issue #66058.
The test only fails when using Turbopack.

While digging into that issue I found that `typeof window` replacement
is either not applied or does not cause `import()` or `require()` to be
removed. In the reproduction that approach is used to load a particular
package only in Node.js and another only in the browser.

<!-- 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-05-26 12:25:40 +02:00
vercel-release-bot
20201a11a2 v14.3.0-canary.82 2024-05-25 23:21:46 +00:00
vercel-release-bot
0f1d9e9f7b v14.3.0-canary.81 2024-05-24 23:21:57 +00:00
Loren ☺️
a0911afbe0
Clarify create-next-app question wording (#66157)
### Why?

The current wording leaves room for questions/misinterpretations like:

- What does "use `src/`" mean? Does this affect my build, like compile
`src/*.ts` to `lib/*.js`?
- Oh, I can customize import aliases to use @ for project root instead
of doing relative everywhere? I'll choose Yes!

I think the proposed wording clarifies ^

---------

Co-authored-by: Sam Ko <sam@vercel.com>
2024-05-24 16:11:30 -07:00
Wyatt Johnson
02522212c6
[ppr] Data route fix (#66190)
Fixes a typo in the logic for checking if it should add the prefetch
data doute.
2024-05-24 19:24:48 +00:00
Tim Neutkens
08b75b77b0
Handle next/navigation import in middleware (#66175)
## What?

Ensures that `next/navigation` and React is aliased in middleware in the
same way that it's aliased in Route Handlers. This matches the behavior
we have in Next.js with webpack.

Fixes #66162

<!-- 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: Hendrik Liebau <mail@hendrik-liebau.de>
2024-05-24 15:39:08 +00:00
Alexander Lyon
82a7c9c2c0
add bash script to run a benchmark (#64717) 2024-05-24 16:00:23 +01:00
Alexander Lyon
f993ea3d04
add next-build-test binary / library (#64121)
This adds a new target in the next-swc package designed as an entrypoint
for collecting memory benches. Later PRs in the stack add a script to
run the benches and finally a manual-triggered CI step
2024-05-24 15:14:39 +02:00
vercel-release-bot
dfe7fc03e2 v14.3.0-canary.80 2024-05-23 23:23:20 +00:00
Zack Tanner
94a970a78d
update typescript plugin to support experimental_ppr (#66141)
Before:
![CleanShot 2024-05-23 at 11 51
21@2x](https://github.com/vercel/next.js/assets/1939140/a8be7baf-71aa-4fa6-8400-892dc06ca7d7)


After:
![CleanShot 2024-05-23 at 12 00
59@2x](https://github.com/vercel/next.js/assets/1939140/61d6aa88-9f2d-4274-bd87-93be68bee569)


<!-- 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-05-23 19:21:11 +00:00
Benjamin Woodruff
5017a41c75
feat(turbopack): Attempt to detect and warn about slow file IO (#66057)
We'd like to warn users if they have particularly slow file IO, so that they can correct the problem themselves, and don't send us reports of poor performance.

- Feature request: https://vercel.slack.com/archives/C03KAR5DCKC/p1716051650641529
- Tweet about how Bun does this: https://x.com/jarredsumner/status/1637549427677364224
- Bun implementation: 06a9aa80c3/src/install/install.zig (L3038)

**Why 100ms?** Bun used to use 10ms, found it too noisy, and switched to 100ms.

This benchmark should run non-blocking in the background and should not meaningfully slow down server startup (even on slow disks).

## Simulated Testing

I looked around and found https://github.com/schoentoon/slowpokefs/. It hasn't been updated in 10 years, but still seems to build fine.

In a nextjs project directory, turn `.next` into an artifically slow mount point:

```
fusermount -uz .next; rm -rf .next .next.real && mkdir .next .next.real && ~/slowpokefs/slowpokefs -m 50 -M 50 --no-slow-read -F .next.real .next
```

<img width="695" alt="Screenshot 2024-05-21 at 4 14 58 PM" src="https://github.com/vercel/next.js/assets/180404/217d7692-33cf-42b7-bbf7-5a530b9e0df1">

Run `pnpm dev --turbo` and see that the warning is generated.

## "Real World" Testing

The following tests are from a linux VM using virtiofs to connect to a 5400 RPM USB 2.0 HDD with APFS:

Only the .next is on an HDD (bind mount):
Otherwise idle disk: `4.86ms 4.44ms 5.31ms`
Otherwise busy disk (copying files): `69.34ms 53.75ms 25.12ms`

The whole project directory is on the HDD (more realistic):
Otherwise idle disk: `20.29ms 35.61ms 48.12ms`
Otherwise busy disk (copying files): `131.40ms 21.71ms 87.33ms`

Most of the time the threshold was not reached, but the 131.40ms test did trigger the warning!

Fixes PACK-3087
2024-05-23 09:52:33 -07:00
vercel-release-bot
7fe4f41e13 v14.3.0-canary.79 2024-05-23 14:45:18 +00:00
Sebastian Silbermann
41a80533f9
Revert "Don't fail the build if @types/ packages appear to be missing" (#66130)
This reverts commit
637033c410.

What wasn't clear originally is that we require that required packages
have their `package.json` resolvable. So either they don't have an
`exports` field, or their `package.json` is listed in the `exports`
field. The React beta types didn't have `package.json` entry in
`exports` so we accidentally thought they weren't installed.

I published [`19.0.0-beta.2` that has `package.json` in
`exports`](13879ee571 (diff-81cc573aa0c2bd0e13f9463499747741704aabccd7474f544db710befd7bcfc4R44))
so we can restore the old behavior. It's still questionable IMO to do
all that I/O work just for a nicer error message that may contain
false-positive but that's for another time.
2024-05-23 09:01:10 -05:00
JJ Kasper
0bf384bf02
Stabilize swrDelta config (#66108)
Alternative to https://github.com/vercel/next.js/pull/65867 this
stabilizes our `swrDelta` config that allows customizing the
`stale-while-revalidate` period that is included in the `Cache-Control`
header for ISR enabled routes.

This is not a breaking change itself as no default value is provided as
is the case already.
2024-05-23 08:46:57 -05:00
Sebastian Silbermann
59ce87e522
Don't fail the build if @types/ packages appear to be missing (#66127)
Co-authored-by: Alessio Gravili <alessio@gravili.de>
2024-05-23 12:39:27 +00:00
Janka Uryga
3a1d3f847b
[unstable_after] always use 'waitUntil' from '@next/request-context' if available (#66119)
This PR changes the `getWaitUntil` logic to always check if the platform
provided a request context with a `waitUntil` implementation (via [the
`@next/request-context`
symbol](05e6b82576/packages/next/src/server/after/wait-until-builtin.ts (L12)))
, regardless of minimalMode or runtime.

Previously, we wouldn't check the context at all unless `minimalMode`
was set, and defaulted `waitUntil` to a noop otherwise. This would make
integration more difficult for providers who don't use `minimalMode`,
because they'd have no way to inject their `waitUntil` implementation.
2024-05-23 14:22:13 +02:00
Wyatt Johnson
05e6b82576
[ppr] Data route fixes (#66109)
Ensures that app routes (like the `favicon.ico` added in the test case
in this PR which is represented as an app route) do not have a prefetch
RSC also attached.
2024-05-23 10:24:00 +02:00
Wyatt Johnson
39ccec8900
[ppr] Remove canary requirement (#66112)
This removes the canary requirement for using PPR in a project, and now
enables use on stable releases.
2024-05-23 09:36:59 +02:00
vercel-release-bot
24180bda25 v14.3.0-canary.78 2024-05-23 02:39:11 +00:00
Sebastian Silbermann
e421fea1ee
Update React from 81c5ff2e04 to f994737d14 (#66093)
<details>
<summary>React upstream changes</summary>

- https://github.com/facebook/react/pull/29219
- https://github.com/facebook/react/pull/29007
- https://github.com/facebook/react/pull/29207

</details>
2024-05-22 19:34:06 -07:00
JJ Kasper
4d14e83173
[Breaking] Disable automatic fetch caching (#66004)
## Background

Previously we introduced automatic caching for `fetch` based on certain
heuristics that were a bit tricky to grasp all scenarios. The scenarios
we would automatically cache were no dynamic data access before the
fetch call e.g. `headers()` or `cookies()`, the fetch call is inside of
a dynamic page e.g. `POST` method or `export const revalidate = 0` page
and the fetch is a non-`GET` request or has `Authorization` or `Cookie`
headers, or the fetch had `cache: 'no-store' | 'no-cache'` or
`revalidate: 0`.

## New Behavior

By default fetches will no longer automatically be cached. Instead they
need to be opted-in to caching via `export const fetchCache =
'default-cache' | 'force-cache',` `next: { revalidate: false or value >
0 }` or `cache: 'force-cache' | 'default-cache'`.

When the fetch call is automatically skipping the cache it won't impact
the page level ISR cacheability although if a fetch call manually
specifies `cache: 'no-store'` or `revalidate: 0` it will still bail from
the page being statically generated as it was before.

To achieve the previous behavior of automatic fetch caching all that
needs to be added is `export const fetchCache = 'default-cache'` in the
root layout(s) of your project.
2024-05-22 19:30:28 -07:00
Wyatt Johnson
6c1c004953
fix: ensure prefetch data routes are always added when app has ppr enabled (#66102)
When PPR is enabled, we should always write the prefetch RSC routes to
ensure that the builder and FS cache can use it.
2024-05-22 19:18:58 -07:00
vercel-release-bot
74be1f68c2 v14.3.0-canary.77 2024-05-22 23:23:25 +00:00
Janka Uryga
a8e0114174
[unstable_after] fix occasional dev-mode crash in edge runtime pages (#66099)
When hot-reloading an edge runtime page, sometimes we randomly get this:
```
[InvariantError: Invariant: Cannot call onClose on a response that is already sent. This is a bug in Next.js.] {
  name: 'InvariantError'
}
```
and since `unstable_after` relies on `onClose`, no callbacks are called.

I believe this is because `web-server` [calls `res.send()` pretty early
for streaming
responses](b9817f8351/packages/next/src/server/web-server.ts (L311)),
so `res.sent` becomes `true` even though we're still streaming, and
prevents us from calling `onClose` in the streaming render. It makes
more sense to check the CloseController's `isClosed` instead -- when
that becomes `true`, we _really_ shouldn't call onClose anymore (points
to a bug), but before that it's fine.
2024-05-23 01:17:24 +02:00
JJ Kasper
0329a8f7e3
Ensure metadata routes dont skip static optimization (#66097)
Follow-up to https://github.com/vercel/next.js/pull/65825 this ensures
we don't skip the static optimization specifically for metadata routes
as this most often should be static as they aren't dynamic content and
are requested very frequently.
2024-05-22 21:53:58 +00:00
mknichel
8b360afb7b
[Memory] Add option to reduce memory usage caused by duplicate strings in webpack-sources (#66003)
This PR adds a flag to Next.js to enable Webpack options to improve
memory usage. See https://github.com/webpack/webpack-sources/pull/155
for a full description of the changes and impact on memory.

This PR adds a patch to `webpack-sources` temporarily that contains the
fixes as the real changes are iterated on to merge upstream in the
`webpack/webpack-sources` repository. After that is done, the patch will
be reverted and the latest `webpack-sources` version will be updated in
Next.js.
2024-05-22 15:30:05 -05:00
JJ Kasper
b17ca02695
Skip setting to fetch cache when not modified (#66055)
To avoid extra network hops we can compare existing cache entries we've
already fetched and see if the revalidated value matches and if it does
we can avoid sending the set request with the identical data.
2024-05-22 13:54:16 -05:00
Benjamin Woodruff
ad8d1c27ff
[turbopack] Use updated RawOutput API (#65300)
Use updated API suggested by sokra in review on #65223:

https://github.com/vercel/next.js/pull/65223#discussion_r1587157258

Depends on https://github.com/vercel/turbo/pull/8075
2024-05-22 11:10:58 -07:00
Benjamin Woodruff
4ead5fc00d
next-swc-napi: Enable "plugin" feature by default (#66006)
As noted in (https://github.com/vercel/nextpack/pull/103), by not having
this as a default feature, when running the `build-native` script it's
not able to re-use any cargo caches that might already exist from a
default build.

Because this feature impacts the swc crate, everything dependent on it
can be forced to rebuild.

By making this a default feature, the hope/theory is that the number of
different ways we potentially build our dependency graph reduces, and
cargo cache hits will improve.

## Changes

- Add `plugin` to the default set of features for `next-swc-napi`.
- Consolidate `build-native-no-plugin-woa` with
`build-native-no-plugin`. Given the lack of any other default features,
these are equivalent.
- `i686-pc-windows-msvc`: Switch to `build-native-no-plugin-release` in
CI instead of just supplying the `--release` flag. This has the benefit
of also enabling `tracing/release_max_level_info`, which might reduce
the size of or speed up these builds.
- `x86_64-apple-darwin`: Remove a redundant `--release` flag in the CI
config (no expected changes).

## Testing

I've tested this locally on Linux (`pnpm run build-native`) and
Windows-on-ARM (`pnpm run build-native-no-plugin`) by making sure things
still build. I'll also make sure CI passes.
2024-05-22 11:09:04 -07:00
Steven
c3d93b126c
chore(next/image): remove unused output parameter (#66083)
This parameter was previously used for a warning message, but we no
longer print that warning since
https://github.com/vercel/next.js/pull/63321 so now we can remove the
unused parameter.
2024-05-22 12:15:30 -05:00
Zack Tanner
5c9ea1c575
implement unstable_rethrow (#65831)
This implements an API to re-throw errors that are intended to be caught
by Next.js, so that they are not caught by your code.

RFC: https://github.com/vercel/next.js/discussions/64076

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

## For Contributors

### Improving Documentation

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

### Adding or Updating Examples

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

### Fixing a bug

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

### Adding a feature

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


## For Maintainers

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

### What?

### Why?

### How?

Closes NEXT-
Fixes #

-->

---------

Co-authored-by: JJ Kasper <jj@jjsweb.site>
Co-authored-by: Ahmed Abdelbaset <A7med3bdulBaset@gmail.com>
Co-authored-by: Janka Uryga <lolzatu2@gmail.com>
2024-05-22 07:58:36 -07:00
Sebastian Silbermann
a25e7d2fe9
Update React from 04b058868c to 81c5ff2e04 (#65869) 2024-05-22 14:46:57 +02:00
vercel-release-bot
d299bbf431 v14.3.0-canary.76 2024-05-21 23:23:05 +00:00
Will Binns-Smith
35d300e5cc
Add dedicated client entry for Turbopack builds (#65824)
Previously with Turbopack, we would attempt to establish a websocket
connection to the HMR server, even when running production builds. This
adds `next-turbopack.ts`, which includes the necessary runtime code for
Turbopack, but does not include HMR code.

Test Plan: `TURBOPACK=1 TURBOPACK_BUILD=1 pnpm next build
test/e2e/app-dir/app-middleware`

---------

Co-authored-by: Tim Neutkens <tim@timneutkens.nl>
2024-05-21 22:43:41 +00:00
vercel-release-bot
22f822ebb7 v14.3.0-canary.75 2024-05-21 21:18:04 +00:00
Zack Tanner
1f545aff05
[Breaking] disable client router cache for page segments (#66039)
This configures the default client router cache `staleTime.dynamic`
value to be `0`.

This means that:
- Navigating between pages will always fire off a network request to get
RSC data for the page segment, rather than restoring from router cache
- Loading states will remain cached for 5 minutes (or whatever
`config.experimental.staleTimes.static` is set to)
- Shared layout data will continue to remain cached due to [partial
rendering](https://nextjs.org/docs/app/building-your-application/routing/linking-and-navigating#4-partial-rendering)
- Back/forward behavior will still restore from cache to ensure the
browser can restore scroll position.

It's possible to opt-out of this, and into the previous behavior, by
setting the
[`staleTimes`](https://nextjs.org/docs/app/api-reference/next-config-js/staleTimes)
config in `next.config.js`:

```js
/** @type {import('next').NextConfig} */
const nextConfig = {
  experimental: {
    staleTimes: {
      dynamic: 30
    },
  },
}

module.exports = nextConfig
```

<!-- 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-05-21 13:54:23 -07:00
vercel-release-bot
5cba51e342 v14.3.0-canary.74 2024-05-21 19:54:31 +00:00
Tim Neutkens
413d1223d8
Upgrade lightningcss, disable grid prefixing (#65986)
## What?

Requires https://github.com/vercel/turbo/pull/8176 first.

Grid scoping in CSS Modules is disabled because Webpack CSS Modules
handling doesn't handle grid currently. This ensures moving from Webpack
to Turbopack doesn't have mismatching behavior around CSS grid.

Fixes #64509
Fixes #63758
Fixes PACK-2976

<!-- 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-05-21 19:39:46 +00:00
JJ Kasper
4818c4c32f
Revert webpack bundling layer changes for middleware/pages (#66049)
This reverts the below changes to avoid a breaking change in pages with
importing `react-dom/server` as this is disallowed in `app` but
shouldn't be in `pages`.

Revert "Bundle the installed react for middleware (#65811)"
Revert "Error in build for middleware when import client-only (#65792)"

This reverts commit fdd8f0c65f.
This reverts commit 082072ca95.

x-ref: [slack
thread](https://vercel.slack.com/archives/C03S8ED1DKM/p1716305493514869)
2024-05-21 18:31:31 +00:00
yasmin p
a38caf402b
Update create-next-app template CSS (#66043)
Updates the `create-next-app` template CSS to:
- Prevent browsers (e.g. Safari) from using synthetic bold font weights
- Move CSS variables out of global CSS / Tailwind config, to simplify
the process of wiping the default template.

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

## For Contributors

### Improving Documentation

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

### Adding or Updating Examples

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

### Fixing a bug

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

### Adding a feature

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


## For Maintainers

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

### What?

### Why?

### How?

Closes NEXT-
Fixes #

-->

Co-authored-by: JJ Kasper <jj@jjsweb.site>
2024-05-21 18:27:40 +00:00
Niaz Morshed Nayeem
03f34f2d52
Fix typo in JSDoc of ppr flag of next.config.js (#66028) 2024-05-21 16:16:36 +02:00
Jude Gao
d498f9c173
Fix router.refresh missing canonical url override (#65999)
Fixes https://github.com/vercel/next.js/issues/65970

----

The browser update happens at
10d5c278bc/packages/next/src/client/components/app-router.tsx (L685),
which sets the browser location to `canonicalUrl`. `canonicalUrl` was
correctly set at
ab03c3261f/packages/next/src/client/components/router-reducer/reducers/refresh-reducer.ts (L98),
but then mistakenly overriden at
51549d92de/packages/next/src/client/components/router-reducer/reducers/refresh-reducer.ts (L129).

This PR fixes that and includes an E2E test to prevent future
regression.

---------

Co-authored-by: JJ Kasper <jj@jjsweb.site>
Co-authored-by: Zack Tanner <1939140+ztanner@users.noreply.github.com>
2024-05-20 18:11:07 -07:00
JJ Kasper
6f9c4720f9
[Breaking] Disable automatic static generation for route handlers (#65825)
## Background

Currently route handlers will be attempted to statically generate the
same as normal pages in app router. If a route handler accessed dynamic
data such as `cookies()`, `headers()`, `req.url`, or similar we would
bail from this static generation but this didn't handle the case where
you would do data fetching via a non-fetch based library e.g. `redis` or
even using `Date.now()` or `Math.random()` so users would expect these
to be run every request like normal API endpoints but they would be
static so wouldn't be executed again after a build.


## New Behavior

As discussed this disable the default static generation handling for
route handlers as we've seen this confuse our users since in most cases
when creating a route handler you are handling dynamic workloads. This
doesn't remove the ability to static generate route handlers though as
you can still manually specify:

If you specify `export const revalidate = 1` we will still bail if
dynamic data is accessed to prevent accidental `revalidate` configuring
but this can be avoided via `force-static` being used as well.
 
```js
export const dynamic = 'force-static'
// or
export const dynamic = 'error'
// or
export const revalidate = false
// or
export const revalidate = 1 // value great than 0
// or 
export const generateStaticParams() {}
```

---------

Co-authored-by: Zack Tanner <1939140+ztanner@users.noreply.github.com>
2024-05-20 16:25:02 -07:00
vercel-release-bot
49c1e127aa v14.3.0-canary.73 2024-05-20 23:23:18 +00:00
Will Binns-Smith
4ff11d0631
Turbopack: Implement next/font/local with BeforeResolvePlugin and show custom error message (#65870)
Depends on vercel/turbo#8165

This:
- Creates and uses a `BeforeResolvePlugin` to handle requests to
`next/font/local/target.css` instead of `ImportMapping` replacers
- Returns a `ResolveResultItem::Error` which includes a custom
`StyledString` describing the missing font file

Test Plan: `TURBOPACK=1 pnpm test-dev
test/e2e/app-dir/next-font/next-font.test.ts`
2024-05-20 15:46:19 -07:00
Arindam Majumder
60ad8affd7
feat: Add option to enable Turbopack with create-next-app (#65926)
This PR addresses an issue where the `dev` script in `package.json` was
not correctly updated to use the `--turbo` option when specified. The
changes ensure that the `dev` script is set to `next dev --turbo` if the
`turbo` option is enabled.

### Changes:
1. **Function Modification**:
- Updated the `modifyPackageJson` function to include a check for the
`turbo` parameter.
- If `turbo` is true, the `dev` script in `package.json` is set to `next
dev --turbo`.
   - If `turbo` is false, the `dev` script remains `next dev`.

2. **Integration in App Creation**:
- Integrated the `modifyPackageJson` function into the app creation
process to ensure the `dev` script is correctly set based on the `turbo`
parameter.

### Testing:
- Verified that the `dev` script in `package.json` is correctly updated
to `next dev --turbo` when the `turbo` option is enabled.
- Ensured that the `dev` script remains `next dev` when the `turbo`
option is not enabled.

### Related Issues:
- Fixes #65924

### Notes:
- This change ensures that developers opting to use Turbopack for
development will have the correct script set up automatically.

---------

Signed-off-by: Arindam Majumder <arindammajumder2020@gmail.com>
Co-authored-by: Lee Robinson <me@leerob.io>
Co-authored-by: devjiwonchoi <devjiwonchoi@gmail.com>
Co-authored-by: Jiachi Liu <inbox@huozhi.im>
Co-authored-by: Sam Ko <sam@vercel.com>
2024-05-20 20:34:24 +00:00
Zack Tanner
0eedddbf89
short-circuit OPTIONS requests to pages (#65295)
Currently `OPTIONS` requests to page handlers (eg `pages/foo.tsx` or
`app/foo/page.tsx`) will respond as though it's handling a `GET`
request. There should be no reason for these routes to handle `OPTIONS`
requests as the only valid option is `GET`.

We do not need to special-case actions here because those will always be
invoked from the same origin as the canonical browser URL.

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

## For Contributors

### Improving Documentation

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

### Adding or Updating Examples

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

### Fixing a bug

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

### Adding a feature

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


## For Maintainers

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

### What?

### Why?

### How?

Closes NEXT-
Fixes #

-->


Closes NEXT-3305
2024-05-20 19:58:48 +00:00
JJ Kasper
c5a0878946
Change default of prerenderEarlyExit to true (#65830)
## Background

Historically during prerendering we have waiting until all paths have
been attempted before we exit the process and fail the build. This is
nice if you want to collect all potential errors to address them at the
same time although this has the drawback of slowing down builds if
things are timing out or if the same error is occurring across numerous
paths.

## New Behavior

This changes our default behavior to immediately exit when the first
error occurs during prerendering so that builds don't stall out from
timeout errors or from the same error occurring across numerous paths.
This will help from holding up CI or similar un-necessarily.

If users want to opt-in to the previous behavior the flag is still
present under `experimental.prerenderEarlyExit`.
2024-05-20 12:51:01 -07:00
Niaz Morshed Nayeem
e1e197a104
Add additional log to experimental ppr flag in next.config.js (#65944)
### What?

This PR adds an additional log that describes the function of the `ppr`
flag in `next.config.js`.

---------

Co-authored-by: JJ Kasper <jj@jjsweb.site>
2024-05-20 09:22:10 -07:00
Jiwon Choi
79c934aaec
fix(next): initial prefetch cache not set properly with different search params (#65977)
cc @icyJoseph @ztanner

NOTE: The canary release
[`v14.1.1-canary.51`](https://github.com/vercel/next.js/releases/tag/v14.1.1-canary.51)
and below work as expected.

### Why?

Introduced from #61535, the initial prefetch cache is set based on the
`location.pathname`.
When a page is loaded WITH the search param, the cache key does not
contain information of the search param.

The issue is when on a dynamic page reading the `searchParams` value,
the value doesn't change if navigated as:

```
/?q=foo --> /
```

The prefetch cache hits, not re-rendering, and the `searchParams` value
is not passed properly.

### How?

For the prefetch cache, add the `location.search` as well.

Since `createPrefetchCacheKey` uses
[`createHrefFromUrl`](https://github.com/vercel/next.js/blob/canary/packages/next/src/client/components/router-reducer/create-href-from-url.ts)
which includes `location.search`, I'm expecting the change won't affect
current cache key behavior.

Fixes #64170
Fixes #65030

---------

Co-authored-by: Zack Tanner <1939140+ztanner@users.noreply.github.com>
2024-05-20 15:44:03 +00:00
Niko Sams
8a429e083e
Fix revalidateTimings route for catchall index route (#65843)
fixes #65842

When setting revalidateTimings correctly use toRoute to convert `/index`
to `/`, like done for get
(https://github.com/vercel/next.js/blob/canary/packages/next/src/server/lib/incremental-cache/index.ts#L213)

See #65842 for reproduction codesandbox.

The bug also exists in 14.2.3 (and below) - before #64370

---------

Co-authored-by: JJ Kasper <jj@jjsweb.site>
2024-05-20 15:13:07 +00:00
Janka Uryga
663488cf52
unstable_after: support nested unstable_after calls (#65950)
Adds support for nested `unstable_after()`.

This pattern previously threw a "Not supported yet" error, but works
now:

```js
function MyComponent() {
  after(() => asyncWork());
  return <div>...</div>
}

async function asyncWork() {
  after(() => { /* look ma, nesting!*/ })
  // more stuff...
}
```

### Implementation notes
Switched `AfterContext` to use a proper promise queue
([`p-queue`](https://www.npmjs.com/package/p-queue)) instead of plain a
callback array to support adding more callbacks as we execute (i.e. from
nested `after`s). Used a package because I didn't want to reinvent the
wheel here.

As a nice bonus, `p-queue` lets us limit the concurrency of running
tasks if we're worried about resource consumption. **This PR doesn't do
that**, but it's very easy to add. That could be controlled via
`process.env.NEXT_AFTER_MAX_CONCURRENT_TASKS`, a next.config.js option
(`unstable_after: { maxConcurrentTasks: 5 }`), or something like that.
2024-05-20 15:09:16 +00:00
Vercel Release Bot
f95656a4ca
Update font data (#65961)
This auto-generated PR updates font data with latest available

Co-authored-by: JJ Kasper <jj@jjsweb.site>
2024-05-20 14:35:39 +00:00
Lovell Fuller
dd8ee527b8
fix(next/image): prefer sharp defaults, use mozjpeg for JPEG (#65846)
### What?

Upgrades sharp to the latest version and relies on more of its default
settings (if the default settings are unsuitable, we should consider
improving these for all users in sharp itself).

- The `sequentialRead` setting is now managed for you based on each
input image and the operations to be applied to it.

- The concurrency detection is more accurate than `os.cpus()` as it now
inspects things like CPU set/affinity as well as the memory allocator.

- The (mostly archaic) concept of chroma subsampling is not required for
AVIF output. Using full chroma should improve the quality of red/orange
edges, as well as slightly reducing file size as it allows greater use
of AV1 chroma-from-luma prediction.

In addition, this PR also enables the use of mozjpeg features such as
trellis quantisation to produce smaller file sizes. The use of `mozjpeg:
true` infers `progressive: true`. This aligns JPEG output behaviour with
the previously-used squoosh, which always used mozjpeg.

/cc @styfle
2024-05-20 09:30:09 -04:00
vercel-release-bot
14a98734e3 v14.3.0-canary.72 2024-05-20 10:35:37 +00:00
Janka Uryga
79bebe7bd3
experimental: unstable_after (#65038)
Implements `unstable_after`, which lets the user schedule work to be
executed after the response is finished.

### Implementation notes

- `unstable_after()` is a dynamic function (bypassable only with `export
dynamic = "force-static"`)
- Usable in: server components (including `generateMetadata`), actions,
route handlers, middleware
- It is meant to run its callbacks even if a response didn't complete
successfully (thrown error) or called `notFound()`/`redirect()`
- Currently gated behind a `experimental.after` feature flag, because it
touches many runtime bits (including a React monkeypatch...)
- The state for `unstable_after()` in a given request lives in
`requestAsyncStorage` (added via `RequestAsyncStorageWrapper`)

- the implementation is based around two functions that we inject via
`renderOpts`:
- `waitUntil(promise)` - keep a function invocation alive until a
promise settles. it is provided as a platform primitive in serverless
contexts, and a noop in `next start`
- for serverless (nodejs), Next.js will attempt to get `waitUntil` from
`globalThis[Symbol.for('@next/request-context')].get().waitUntil`. This
should be considered unstable for now. See
`packages/next/src/server/after/wait-until-builtin.ts` for details.
- `onClose(callback)` **[NEW]** - run something when a response is done.
basically `res.on('close', callback)`, but also implemented for Web APIs
- unfortunately, for Web, this requires some potentially expensive
tricks - see `packages/next/src/server/web/web-on-close.ts`
2024-05-20 08:49:53 +00:00
vercel-release-bot
3843166730 v14.3.0-canary.71 2024-05-18 23:21:55 +00:00
日高 凌
6a80f2b25d
Docs: Replace "twitter.com" to "x.com" (#65917)
### What?
Replace `twitter.com` links in the docs with `x.com`

### Why?
Now that Twitter (twitter.com) has officially moved to the x.com domain

### How?
- Replace the link, then click on the link to make sure there are no
problems

Closes NEXT-
Fixes #65916

---------

Co-authored-by: Sam Ko <sam@vercel.com>
2024-05-18 05:49:49 +00:00
yasmin p
c0b3f430ed
Update create-next-app template (#65803)
Updates the `create-next-app` template with a new design by @evilrabbit.

#### Updated template
![new —
light](https://github.com/vercel/next.js/assets/22132822/7abf8ac5-e2c5-4d2d-944a-53616dcae5ed)
![new —
dark](https://github.com/vercel/next.js/assets/22132822/a06a948d-6071-4a44-9c7e-9a5077866b0a)

#### Previous template
![old —
light](https://github.com/vercel/next.js/assets/22132822/49c97cdf-46ae-4d28-88c7-52fe0e9c995b)
![old —
dark](https://github.com/vercel/next.js/assets/22132822/fb028dda-a38a-443c-ad13-21886b750d7a)

<!-- 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: Sam Ko <sam@vercel.com>
2024-05-17 22:33:19 -07:00
vercel-release-bot
9c31149967 v14.3.0-canary.70 2024-05-17 23:23:12 +00:00
vercel-release-bot
48b91dcc0b v14.3.0-canary.69 2024-05-17 21:19:07 +00:00
Zack Tanner
658037358c
Revert "Fix broken HTML inlining of non UTF-8 decodable binary data f… (#65906)
…rom Flight payload (#65664)"

This reverts commit a34d909877.

This PR appears to be causing issues with PPR when deployed.
[x-ref](https://github.com/vercel/vercel/actions/runs/9133310975/job/25116552847?pr=11610)

<!-- 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-05-17 14:15:55 -07:00
Donny/강동윤
138e45cf56
Update turbopack & swc_core (#65450)
### What?

* https://github.com/vercel/turbo/pull/8101 <!-- Tobias Koppers - fix
off-by-one bug while reading heaptrack files -->
* https://github.com/vercel/turbo/pull/8130 <!-- Tobias Koppers -
refactor memory tracking -->
* https://github.com/vercel/turbo/pull/8097 <!-- Donny/강동윤 - build:
Update `swc_core` to `v0.92.5` -->

Update swc_core.


### Why?

To keep in sync and fix styled-jsx issues

### How?

Closes PACK-3042

---------

Co-authored-by: hrmny <8845940+ForsakenHarmony@users.noreply.github.com>
2024-05-17 20:15:51 +02:00
Zack Tanner
168d125710
Revert "Set default stale-while-revalidate header value to 1 year" (#65887)
This PR was run without CI. Reverting so we can reland after it passes
CI.

Reverts vercel/next.js#65867
2024-05-17 07:47:51 -07:00
Jiachi Liu
046acd504e
Error on mismatched minimal react version (#65806)
### What
Error when users installing react@18 and requires higher version

### Why

The architecture now already requires to have `react@beta` or
`react@rc`. Especially where we need to load `react-server` condition of
react, which is erroring now in react 18.
2024-05-17 10:08:28 +02:00
Zack Tanner
2ae4a4786a
fix missing experimental warning for reactCompiler (#65866)
Ensures that `reactCompiler` shows up in the experimental warning list.

<!-- 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-05-17 00:00:43 +00:00
Brandon Bayer
a753a39479
Set default stale-while-revalidate header value to 1 year (#65867) 2024-05-16 16:32:19 -07:00
vercel-release-bot
cd5287e932 v14.3.0-canary.68 2024-05-16 23:22:25 +00:00
Sebastian Silbermann
c045f0f7be
Update React from 4508873393 to 04b058868c (#65864)
Completes https://github.com/vercel/next.js/pull/65845 which only
updated Canary not Experimental.

<details>
<summary> React upstream changes</summary>

- https://github.com/facebook/react/pull/29026
- https://github.com/facebook/react/pull/29025
- https://github.com/facebook/react/pull/28743
- https://github.com/facebook/react/pull/29022
- https://github.com/facebook/react/pull/29023
- https://github.com/facebook/react/pull/29015
- https://github.com/facebook/react/pull/29016
- https://github.com/facebook/react/pull/28988
- https://github.com/facebook/react/pull/28987
- https://github.com/facebook/react/pull/28986
- https://github.com/facebook/react/pull/29014
- https://github.com/facebook/react/pull/28982
- https://github.com/facebook/react/pull/29006
- https://github.com/facebook/react/pull/28973
- https://github.com/facebook/react/pull/28841
- https://github.com/facebook/react/pull/28964
- https://github.com/facebook/react/pull/28990
- https://github.com/facebook/react/pull/29003
- https://github.com/facebook/react/pull/28989
- https://github.com/facebook/react/pull/28893
- https://github.com/facebook/react/pull/28887
- https://github.com/facebook/react/pull/28807
- https://github.com/facebook/react/pull/28978
- https://github.com/facebook/react/pull/28963
- https://github.com/facebook/react/pull/28972
- https://github.com/facebook/react/pull/28970
- https://github.com/facebook/react/pull/28816
- https://github.com/facebook/react/pull/28977
- https://github.com/facebook/react/pull/28974
- https://github.com/facebook/react/pull/28976
- https://github.com/facebook/react/pull/28975
- https://github.com/facebook/react/pull/28969
- https://github.com/facebook/react/pull/28966
- https://github.com/facebook/react/pull/28056

</details>
2024-05-16 15:32:27 -07:00
vercel-release-bot
f6a242474c v14.3.0-canary.67 2024-05-16 21:16:20 +00:00
Tim Neutkens
34445bfd2b
Ensure plugin-syntax-jsx doesn't have to be installed (#65865)
Currently `reactCompiler: true` fails to load because babel plugin JSX
is not installed, this PR ensures the correct version is used.

<!-- 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-05-16 23:13:06 +02:00
vercel-release-bot
531f7c2dda v14.3.0-canary.66 2024-05-16 20:04:48 +00:00
Tim Neutkens
e359b14881
Upgrade react@beta (#65845)
Ensures `useMemoCache` is available for the React Compiler.

Required for #65804 without having to manually enable experimental React
through e.g. taint: true.

<!-- 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: Jiachi Liu <inbox@huozhi.im>
2024-05-16 21:59:47 +02:00
Datner
9f647f311f
add effect packages into the optimized-by-default list (#65465)
### What?

Adding packages from the Effect ecosystem to the list of
optimized-by-default imports

### Why?

Effect usage includes very liberal use of `import * as Module from
"effect/Module"` and `import { Module } from "effect"`. This is usually
trees-shaken but in nextjs we must declare it to be optimized to be have
this way. To provide a better experience to users I added all the
packages in the ecosystem to the list that are possibly relevant. I
don't expect all of them to get in, but the proposal should start from
the full set of possible candidates. Not included are `/cli`,
`/printer`, `/printer-ansi`, and `/vitest`.

At the very least `effect` and `/schema` should be added for their
prevalence, but even if there is hesitance I recommend adding
`/platform` and `/platform-node` since it's natural for effect usage to
grow into benefitting from these quickly enough.

Related issue in the effect repo 
https://github.com/Effect-TS/effect/issues/2701

cited source for taken action:
[the vercel
blog](https://vercel.com/blog/how-we-optimized-package-imports-in-next-js)

### How?

Adding strings to a set

Co-authored-by: JJ Kasper <jj@jjsweb.site>
2024-05-16 19:08:46 +00:00
Steven
780e77bef1
fix: bump nft@0.27.1 (#65854)
- https://github.com/vercel/nft/issues/415
([e001d05](e001d05868))
- https://github.com/vercel/nft/issues/417
([ddc5cba](ddc5cbac23))
- https://github.com/vercel/nft/issues/419
([db6c65a](db6c65ab04))
2024-05-16 18:44:16 +00:00
Tim Neutkens
fc0778be9d
Ensure React Compiler only runs on first-party browser code (#65851)
- Ensure React Compiler runs on first-party code in Turbopack (Excludes
node_modules, but also fully skips running Babel on node_modules)
- Ensure React Compiler runs on first-party code in Webpack (Excludes
node_modules, but also fully skips running Babel on node_modules)
- Ensure React Compiler only runs on browser code -- Per React team
recommendation, it only optimizes browser-facing code currently.
- Ensure React Compiler runs on Pages Router in Webpack -- Was already
the case for 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 #

-->
2024-05-16 20:36:09 +02:00
vercel-release-bot
84014c2971 v14.3.0-canary.65 2024-05-16 18:15:02 +00:00
Jiachi Liu
afe4f2fe13
Fix the runtime for rsc layer (#65850)
### What

Fix a bug introduced in #65694 , use app-page runtime for app router
layers

### Why

This is basically reverted the route context picking up logic we had
before.

During the test we found the error thrown
> Module not found: shared-runtime module router-context cannot be used
in rsc layer

Which is caused by a `next/router` imports in rsc page. Decided to
revert to what it was before as the most safe way to load share module
contexts.

It's caused by `next-contentlayer` usage that they're using
`next/router` in server component MDX, but we cannot lint error that
from node_modules. (We actually can, but disabled that due to various
mis-usage of server/client hooks we had before)
2024-05-16 18:27:35 +02:00
vercel-release-bot
5469e6427b v14.3.0-canary.64 2024-05-16 09:25:50 +00:00
OJ Kwon
5863261cf0
feat(next): experimental react compiler support (#65804)
### What

This PR exposes new experimental configuration for next.js,
`experimental.reactCompiler`. Under the hood, this option configures to
use new experimental react compiler
(https://react.dev/learn/react-compiler#). `reactCompiler` value can be
either boolean or an object contains partial set of compiler itself's
configuration option.

For the webpack and turbopack both it is enabled by adding a babel
plugin for the react compiler. If user have an existing .babelrc, plugin
will be appended to the config. Otherwise, swc will still kicks in (for
webpack) or turbopack for the general transform but only compiler babel
plugin will run via babel.

---------

Co-authored-by: Tim Neutkens <tim@timneutkens.nl>
2024-05-16 11:22:28 +02:00
hrmny
25b767eb84
feat(turbopack-ecmascript): use import attributes for annotations (#59370) 2024-05-16 02:58:43 +00:00
Steven
56eb359bea
fix(next/image)!: set upstream timeout to 7 seconds (#65821)
This PR sets the upstream image timeout to 7 seconds so its not
unbounded (P99 is about 3 to 4 seconds).

We also set the sharp timeout to 7 seconds (P99 is about 2 seconds
although it depends on CPU).

This means an image could take at most 14 seconds to fetch and optimize.
2024-05-15 18:00:20 -07:00
Zack Tanner
46b141a7fb
fix middleware cookie initialization (#65820)
When we provide the `set-cookie` string in `x-middleware-set-cookie`, we
need to ensure that multiple values are properly delimited.

We also make sure the cookies that get passed into `RequestCookies`
aren't in `ResponseCookie` form, to prevent something like `Path=/` from
being part of `cookies()`.

<!-- 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-05-15 16:54:49 -07:00
Jiachi Liu
082072ca95
Bundle the installed react for middleware (#65811)
### What

Let `middleware` and `instrumentation` apply `react-server` exports
condition names first. When bundle the react and react-dom, bundle the
installed version instead of the built-in version.

Renamed "app" group for webpack layers to "bundled", which indicates it
will bundle all the dependencies.

### Why

Middleware and instrument are sort of isolated from app router and pages
router, if they're using react should pick up from the installed
version. Since they're in server layer so they only need to bundle the
`react-server` conditions.

x-ref: [slack
thread](https://vercel.slack.com/archives/C046HAU4H7F/p1715790385748169)
2024-05-16 01:16:53 +02:00
Shu Ding
a34d909877
Fix broken HTML inlining of non UTF-8 decodable binary data from Flight payload (#65664)
This PR ensures that any arbitrary binary data can be passed across the
RSC boundary, especially when inlined in HTML. While the Flight payloads
in RSC requests (`text/x-component`) already work, it's a different case
when we inline them directly in HTML as that's required to be a valid
string in UTF-8.

So instead of always inlining the UTF-8 decoded chunk (`new
TextDecoder('utf-8')`), we fallback non-decodable chunks to base64 and
send as a special item in `__next_f` so we can safely change it back to
a binary typed array.

---------

Co-authored-by: JJ Kasper <jj@jjsweb.site>
2024-05-15 22:30:46 +00:00
Steven H
d9ce336a13
fix(next): reject protocol-relative URLs in image optimization (#65752)
This PR introduces a **breaking change** that returns a 400 error if the
Image Optimization API is given a protocol-relative URL.

The Image Optimization API currently checks whether the given image URL
is relative by checking `url.startsWith('/')`. This means that
protocol-relative URLs, such as `//example.com`, pass the check and are
treated as relative. They in turn skip any kind of validation provided
when matching against `remotePatterns` and are passed back to the
optimation logic as a relative URL.

My knowledge of the stack stops there, but in our case at GitBook it led
to a nasty attack where non-GitBook content could be served over this
URL: https://docs.gitbook.com/_next/image?url=//example.com&w=1200&q=100
- even though we have configured `remotePatterns` to protect against it.

I originally went into the problem wanting to handle the URL properly
(treating it as an absolute URL and potentially using the protocol of
the Optimization API itself as the relative protocol), but after seeing
the code in


https://github.com/vercel/next.js/blob/canary/packages/next/src/client/legacy/image.tsx#L135

and


https://github.com/vercel/next.js/blob/canary/packages/next/src/shared/lib/image-loader.ts#L26

it feels that protocol-relative URLs are just not really supported
anywhere. My understanding is that very few uses of `next/image` will be
allowed to use protocol-relative URLs, so the impact of this breaking
change should be quite low? If others disagree I am happy to modify and
to use the protocol of the request as a stand-in for the relative
protocol.

---------

Co-authored-by: Steven <steven@ceriously.com>
2024-05-15 22:21:08 +00:00
Jiachi Liu
fdd8f0c65f
Error in build for middleware when import client-only (#65792)
Follow up for #65424 

Turn on RSC server-only and client-only checking, so it can error
earlier in build
2024-05-15 20:59:57 +02:00
Will Binns-Smith
81d5daddf3
Turbopack: Remove EcmascriptChunkingContext (#65716)
Depends on vercel/turbo#8133. See that PR for rationale.
2024-05-15 15:51:08 +00:00
hrmny
f628aa65db
feat: support import attributes (#65749)
Co-authored-by: C. T. Lin <chentsulin@gmail.com>
2024-05-15 17:15:17 +02:00
Jiachi Liu
0b261f0919
Remove process auto polyfill in edge runtime (#65751)
### What

Disable auto polyfill for process in edge runtime.

### Why

React uses process.emit behind a typeof guard now. This leads to process
being bundled and process.emit being called which triggers build
warnings since we stub process APIs since they're not supported in Edge
runtime.

There's condition like `"object" === typeof process && "function" ===
typeof process.emit` in the react build now where the 2nd condition is
falsy. Stop polyfilling to skip that condition since it's mainly for
Node.js runtime

Related to #65692
2024-05-15 12:19:47 +02:00
Luca Forstner
0840d521d5
Add clientTraceMetadata experimental option to propagate tracing data to the client (#64256)
### What?

This PR adds an experimental option `clientTraceMetadata` that will use
the existing OpenTelemetry functionality to propagate conventional
OpenTelemetry trace information to the client.

The propagation metadata is propagated to the client via meta tags,
having a `name` and a `content` attribute containing the value of the
tracing value:

```html
<html>
    <head>
        <meta name="baggage" content="key1=val1,key2=val2">
        <meta name="traceparent" content="00-0af7651916cd43dd8448eb211c80319c-b7ad6b7169203331-01">
        <meta name="custom" content="foobar">
    </head>
</html>
```

The implementation adheres to OpenTelemetry as much as possible,
treating the meta tags as if they were tracing headers on outgoing
requests. The `clientTraceMetadata` will contain the keys of the
metadata that're going to injected for tracing purpose.

### Why?

Telemetry providers usually want to provide visibility across the entire
stack, meaning it is useful for users to be able to associate, for
example, web vitals on the client, with a span tree on the server. In
order to be able to correlate tracing events from the front- and
backend, it is necessary to share something like a trace ID or similar,
that the telemetry providers can pick up and stitch back together to
create a trace.

### How?

The tracer was extended with a method `getTracePropagationData()` that
returns the propagation data on the currently active OpenTelemetry
context.
We are using `makeGetServerInsertedHTML()` to inject the meta tags into
the HTML head for dynamic requests.
The meta tags are generated through using the newly added
`getTracePropagationData()` method on the tracer.

It is important to mention that **the trace information should only be
propagated for the initial loading of the page, including hard
navigations**. Any subsequent operations should not propagate trace data
from the server to the client, as the client generally is the root of
the trace. The exception is initial pageloads, since while the request
starts on the client, no JS has had the opportunity to run yet, meaning
there is no trace propagation on the client before the server hasn't
responded.

Situations that we do not want tracing information to be propagated from
the server to the client:
- _Prefetch requests._ Prefetches generally start on the client and are
already instrumented.
- _Any sort of static precomputation, including PPR._ If we include
trace information in static pages, it means that all clients that will
land on the static page will be part of the "precomputation" trace. This
would lead to gigantic traces with a ton of unrelated data that is not
useful. The special case is dev mode where it is likely fine to
propagate trace information, even for static content, since it is
usually not actually static in dev mode.
- _Clientside (soft) navigations._ Navigations start on the client and
are usually already instrumented.

### Alternatives considered

An implementation that purely lives in user-land could have been
implemented with `useServerInsertedHTML()`, however, that implementation
would be cumbersome for users to set up, since the implementation of
tracing would have to happen in a) the instrumentation hook, b) in a
client-component that is used in a top-level layout.

### Related issues/discussions

- https://github.com/vercel/next.js/issues/47660
- https://github.com/vercel/next.js/discussions/62353 (Could be used as
an alternative to the server-timing header)
- https://github.com/getsentry/sentry-javascript/issues/9571

---------

Co-authored-by: Jiachi Liu <inbox@huozhi.im>
2024-05-15 12:19:27 +02:00
Wyatt Johnson
6c3577d73c
fix: ensure websockets are correctly passed (#65759)
Further enhancing the typings across the codebase, this resolves some
errors discovered while running tests. During development, previously,
if the websocket request was forwarded down to the route resolver, it
would fail. This is because a `Duplex` stream is not a `ServerResponse`.

I opted to use the `MockedResponse` here to ensure the remaining code
didn't change, as we're only using the resolve routes code to identify a
match rather than actually sending the response on. The response data is
sent later with the `proxyRequest` which here does have support for
`Duplex` streams.
2024-05-14 18:55:37 -07:00
Jungmin Hwang
337666bfd4
Add script to script loader when strategy prop is undefined (#65585)
### Fixing a bug

fixes #65580 

### What?

#65580 

### Why?

Currently, afterInteractive is given as the default strategy prop, but
afterInteractive is not set for the child retrieved through
React.Children, and it is an empty prop and is not added to the script
loader, so the script is not executed.

### How?

Added item to script loader when `child.props.strategy` is undefined.

---------

Co-authored-by: JJ Kasper <jj@jjsweb.site>
2024-05-14 18:28:27 -07:00
Dmitry Belyaev
1c81480168
feat: remove font family hashing in next/font css (#53608)
<!-- 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?

Adding support for supporting a custom fontFamily name when using
next/font

### Why?

By default, next/font hashes the font name when generating css to
achieve proper scoping.
However, that makes it impossible to use next/font with 3rd party
libraries that provide CSS with pre-defined font names.

### How?

To solve this, I've added a new argument to the next/font function call
– `usedFontFamilyName`.
It allows developers to pick the fontFamily name that is going to be
used in the CSS output instead of the default one and make it work with
vendor CSS files.

```
import { Inter } from "next/font/google";

const inter = Inter({
  subsets: ["latin"],
  fixedFontFamily: "Inter",
});
```

Fixes [#43452](https://github.com/vercel/next.js/discussions/43452)

---

Edit:

I've changed the implementation to use `disabledFontFamilyHashing`
boolean flag which removes the hashing but keeps the original font
family name instead of allowing a custom name

---------

Co-authored-by: JJ Kasper <jj@jjsweb.site>
Co-authored-by: Zack Tanner <1939140+ztanner@users.noreply.github.com>
2024-05-14 18:22:43 -07:00
Vercel Release Bot
411a246959
Update font data (#65768)
This auto-generated PR updates font data with latest available
2024-05-15 00:58:22 +00:00
vercel-release-bot
4229ff4e4d v14.3.0-canary.63 2024-05-14 23:21:46 +00:00
OJ Kwon
64f38c4b0b
fix(next): add alias to new react exports (#65761)
### What

There is a new react exports entrypoints in pkg.json, which we didn't
add alias as similar to other export conditions.
2024-05-14 21:44:10 +00:00
Vercel Release Bot
96df8eacc1
Update font data (#65719)
This auto-generated PR updates font data with latest available
2024-05-14 18:55:05 +00:00
OJ Kwon
85873492e7
fext(next-swc): extend internal env flag to all native bindings (#65748)
### What

`__INTERNAL_CUSTOM_TURBOPACK_BINDINGS` behaves inconsistent across
exposed bindings interface. PR adjusts to apply it to all of the
interface, to allow to use this env to override any swc binaries. This
is not a public interface, no concern of breaking changes.
2024-05-14 18:18:33 +00:00
vercel-release-bot
caf261288e v14.3.0-canary.62 2024-05-14 18:13:36 +00:00
Steven
f169b08901
fix(next/image)!: error when src has leading or trailing space (#65637)
BREAKING CHANGE:

Using the built-in image optimization API, the URL is parsed with `new
URL()` constructor which automatically trims spaces.

However, the developer may choose a 3rd party image optimization API via
`loader` or `loaderFile` (or perhaps a deployment platform that has its
own built in loader), so we shouldn't assume the API will parse the URL
in the same way as
[WHATWG](https://url.spec.whatwg.org/#:~:text=If%20input%20contains%20any%20leading%20or%20trailing%20C0%20control%20or%20space%2C%20invalid%2DURL%2Dunit%20validation%20error.).

While we could trim on the client, its probably best to fail fast and
let the developer make a conscience decision if a trailing space should
be removed or remain (by explicitly using `%20`).
2024-05-14 18:00:27 +00:00
Wyatt Johnson
46f89b095a
[ppr] Request normalization fixes (#65717)
This resolves an issue where a prefetch react server components (RSC)
request incorrectly causes cache poisoning issues during revalidation
for applications configured with partial prerendering (PPR).

It removes the test which used the header directly, and instead defers
to the `handleRSCRequest` method which includes specific environment
implementations.

This also fixes a bug where the prefetch RSC request for the root page
was not normalized.
2024-05-14 10:56:41 -07:00
Sam Ko
4d97acb27d
Revert "chore: externalize undici for bundling" (#65727)
## Why?

`undici` should be able to compile and bundle now.

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

---------

Co-authored-by: Jiachi Liu <inbox@huozhi.im>
2024-05-14 15:11:09 +02:00
Janka Uryga
7f3a75d447
fix: watch experimental/testmode in when running "pnpm dev" (#65689)
Fixes the taskfile so that `experimental/testmode` is auto-recompiled
when running `pnpm dev`.
2024-05-14 12:45:31 +02:00
Jiachi Liu
15d6667d3d
Bump acorn to replace swc class properties transform (#65715)
Bumped acorn to latest version to let it parse class properties.

Class properties and private properties support was landed in 8.6.0,
bumping acorn parser to latest version then we can parse all the
syntaxes.
2024-05-14 09:28:29 +00:00
vercel-release-bot
8dea9963d7 v14.3.0-canary.61 2024-05-13 23:22:28 +00:00
Imran Sulemanji
4128dd2bc0
fix: load the tags manifest asynchronously (#64563)
## What?
A small update to FileSystemCache to replace sync calls with async.

## Why?

`loadTagsManifest` may be called multiple times per request. Since
`loadTagsManifest` is synchronous it blocks the main thread whilst
reading from the file system which could impact server performance.
Replacing these sync calls with async has no impact for consumers of the
FileSystemCache.

Co-authored-by: JJ Kasper <jj@jjsweb.site>
2024-05-13 15:53:19 -07:00
Jiachi Liu
47769d14bc
Remove swc minify related code branches (#65690)
### What

Remove `swcMinify` related branches as the option is deprecated and it's
always enabled

* Remove the related branches for checking `config.swcMinify`
* Remove the related telemetry about `swcMinify`
2024-05-13 23:37:37 +02:00
Jiachi Liu
186afe9fb9
Reland Remove ineffective webpack rules and unused app-page context modules (#65694)
Reland #65321 

Added a test to make sure this change will not fail in `pages/api` like
the error mentioned in #65558
2024-05-13 23:37:13 +02:00
Jiachi Liu
99906416fc
Remove missingSuspenseWithCSRBailout config (#65688)
### What

Remove `missingSuspenseWithCSRBailout` and always treate the conditions
where it was used as `true`.


### Why

This was an intended behavior introduced in 14.1, which requires users
to always add suspense boundaries if it's using any hook that could bail
out to client rendering. `missingSuspenseWithCSRBailout` as `true` was
the default behavior and you could disable it with
`missingSuspenseWithCSRBailout: false` in next config. Now after the
removal you will not be able to opt-out it.
2024-05-13 23:36:24 +02:00
Michał Miszczyszyn
e2f579e0a9
fix(resolve-metadata): allow for search params in canonical URL (#65366)
When `alternates.canonical` is provided as a `URL` instance,
`searchParams` are discarded.
When canonical is provided as a string, the same search parameters work.
This behavior may be unintuitive.

#### Unexpected result (`foo=bar` is removed):
```ts
export const generateMetadata = () => {
	const canonical = new URL(`https://example.com/test?foo=bar`);

	return {
		alternates: { canonical: canonical },
	};
};
```

#### Works as expected:
```ts
export const generateMetadata = () => {
	const canonical = new URL(`https://example.com/test?foo=bar`);

	return {
		alternates: { canonical: canonical.toString() },
	};
};
```

Co-authored-by: Shu Ding <g@shud.in>
Co-authored-by: JJ Kasper <jj@jjsweb.site>
2024-05-13 14:33:03 -07:00
vercel-release-bot
9561a2988b v14.3.0-canary.60 2024-05-13 20:22:10 +00:00
Tim Neutkens
ac6e41292b
Reapply "Implement Turbopack trace server bindings" (#65419) (#65527)
Applies #65419 with the latest version of Turbopack that uses a
different websocket library.

<!-- 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-3363
2024-05-13 18:59:59 +02:00
Donny/강동윤
1518895728
fix(next-swc): Fix SWC env target - include option (#65693)
### What?

Enable private properties pass correctly.

### Why?

To allow using private properties with brand checking

### How?

Closes PACK-3059

---------

Co-authored-by: Jiachi Liu <inbox@huozhi.im>
2024-05-13 16:31:36 +00:00
Jiachi Liu
c1f8d93175
Show the new key of experimental config change warnings (#65651)
Previously we only display the warning when it's a new key format
`<object>.<property>`, we should display all cases to help users
understand where the new key is moved to

x-ref: https://x.com/huozhi/status/1789335665252921381
2024-05-13 11:20:18 +02:00
Donny/강동윤
fedb675520
fix(next-swc): Do not reuse compiler instance (#65602)
### What?

Do not reuse `Compiler` instance.

### Why?

It exists only to support preserving comments from `print()` API for
modules created with `parse()` API, but it causes a problem for
`transform()` for very huge apps.

### How?

 - Closes https://github.com/swc-project/swc/issues/8932
 - Fixes #48960
 - Fixes #65436
2024-05-13 00:54:01 +00:00
vercel-release-bot
9296434815 v14.3.0-canary.59 2024-05-12 23:22:32 +00:00
Jiachi Liu
6635cc07a4
Apply react-server conditions to middleware (#65424)
### What

Reland #57448 , add react-server condition resolving and apply
server-only rules to middleware

Closes NEXT-1653
Closes NEXT-3333

### Why

Middleware as the pre-routing layer that is indended to be light-weight.
Since it's on edge runtime and only run on server but not on client, it
doesn't need to include the client react bundles. Hence we apply
`react-server` export condition, that if users import React we can only
bundle server required APIs and if users use React client hooks we can
error.
2024-05-12 14:26:37 +02:00
vercel-release-bot
c26840909c v14.3.0-canary.58 2024-05-11 23:21:54 +00:00
Sebastian Silbermann
9084a09741
Pages router: Enable strict next/head children reconciler by default (#65418)
Closes NEXT-3330
2024-05-11 12:50:05 +02:00
Sam Ko
96a96d2ed4
chore(create-next-app): update README links (#65634)
## Why?

- Update
`https://github.com/vercel/next.js/tree/canary/packages/create-next-app`
link to `https://nextjs.org/docs/app/api-reference/create-next-app` or
`https://nextjs.org/docs/pages/api-reference/create-next-app`
2024-05-11 03:38:19 +00:00
Steven
292fd4eb3f
feat!(next/image): change default Content-Disposition to attachment (#65631)
### BREAKING CHANGE

This changes the behavior of the default image `loader` so that
[`Content-Disposition`](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Disposition#as_a_response_header_for_the_main_body)
header is now `attachment` for added protection since the API can serve
arbitrary remote images.

The new default value, `attachment`, forces the browser to download the
image when visiting directly. This is particularly important when
`dangerouslyAllowSVG` is true. Most users will not notice the change
since visiting pages won't behave any differently, only visiting images
directly.

Users can switch back to the old behavior by configuring `inline` in
next.config.js

```js
module.exports = {
  images: {
    contentDispositionType: 'inline',
  },
}
2024-05-10 21:35:48 -04:00
vercel-release-bot
b9af6a9b22 v14.3.0-canary.57 2024-05-10 23:22:03 +00:00
vercel-release-bot
406a11eefe v14.3.0-canary.56 2024-05-10 22:30:08 +00:00
Sam Ko
e4cfd3b357
chore(create-next-app): update empty templates (#65620)
## Why?

- Remove `favicon.ico` from empty templates
- Update Index pages in `default-empty` templates to be the same as the
`app-empty` templates
- x-ref: https://github.com/vercel/next.js/pull/65532
2024-05-10 22:23:44 +00:00
Ethan Arrowood
3c06a5065a
Add proper deprecation/rename warnings for server bundling option (#65575)
Follow up to https://github.com/vercel/next.js/pull/65421

This pr re-adds the old experimental options to the type definition and
adds proper warnings in the config resolver.
2024-05-10 22:23:25 +00:00
OJ Kwon
2257133e36
fix(next-swc): correct path interop to filepath for wasm (#65633)
### What

For loading wasm, path interop to absolute file path occurs in here
(https://github.com/vercel/next.js/blob/canary/packages/next/src/build/swc/index.ts#L1249)
already so shouldn't pre-populate import path when call loading wasm to
make internal path operation
(https://github.com/vercel/next.js/blob/canary/packages/next/src/build/swc/index.ts#L1247)
work.
2024-05-10 22:21:15 +00:00
vercel-release-bot
505fc7b259 v14.3.0-canary.55 2024-05-10 21:18:58 +00:00
OJ Kwon
5fb2656225
fix(next-swc): load wasm fallback if native bindings fail to load (#65623)
### What

This PR fixes regressions introduced at
https://github.com/vercel/next.js/pull/57437/files#diff-907b7be0cfc75bd37773e5ebc38d1deffa40861b8ac1cde92e4992e284a1ee59L245,
which removes to try load wasm fallback if 1. platform is supported 2.
fail to load native bindings for some reason.
2024-05-10 14:15:40 -07:00
Michael H
2c53133ac5
create-next-app - Update links for READMEs (#65548)
Updates the links to go to the respective dir version (app or pages) and
rely less on the current redirects.

Also, if app dir is default, should the folder for pages be called
"pages" instead?
2024-05-10 21:12:56 +00:00
hrmny
c98c6d6f8b
feat(turbopack): add support for bundlePagesRouterDependencies (#65520) 2024-05-10 20:51:55 +02:00
Jiachi Liu
f94e213de5
remove legacy deprecated warnings (#65579)
# What
Remove the previous deprecated flags and warnings

Removed deprecated types:

In `next.config.js`
- `experimental.incrementalCacheHandlerPath` (has moved to new options
in next 14)
- `experimental.isrMemoryCacheSize` (has moved to new options in next
14)
- `outputFileTracing` (not support customization anymore)
- `swcMinify` (not support customization anymore)

In `next/types`
- `unstable_includeFiles` (already deprecated for a while)
- `unstable_excludeFiles` (already deprecated for a while)
2024-05-10 20:13:06 +02:00
Jiachi Liu
bebda1138d
Remove @next/font resolving for font loaders (#65601)
Remove font loaders resolving for `@next/font`, users should directly
rely on `next/font`, they're intended to be removed.

Also removed the legacy tests
2024-05-10 20:12:03 +02:00