Commit graph

11977 commits

Author SHA1 Message Date
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
Zack Tanner
85162c890c
remove next-action header when following a redirect (#65615)
When a server action performs a redirect, we send an RSC request to the
redirect URL so that everything can be handled in a single roundtrip.

However, we forward the `next-action` header to that request. This means
that the intra-app RSC request will be incorrectly associated with an
action, and any rewrites we do for `next-action` requests (such as the
work in the Next.js builder to ensure actions are routed to streaming
outputs) won't be handled correctly.

<!-- 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-10 09:13:27 -07:00
Tim Neutkens
8c5add23a8
Handle nonce on Next.js injected script/link tags (#65508)
## What

Ensures `nonce` is added to script and link tags Next.js renders.
Additional cases it now handles:

- We already passed `nonce` to the React rendering, though not
consistently on all cases where `renderToStream` is called, I'm
surprised there haven't been more reports of this, but now it will pass
it on all cases where React rendering is called that I could find
- In `get-layer-assets.tsx` we now pass `nonce` to both the `script` and
`link` tags
- When calling `ReactDOM.preload` the nonce was missing as well, ensured
that the nonce is included in that case as well.

Added a test that mimicks the reproduction by adding `next/font` in this
case.

Fixes #64037
Closes PACK-2973  

<!-- 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-10 16:21:22 +02:00
vercel-release-bot
cc10bf5d1f v14.3.0-canary.54 2024-05-09 23:22:54 +00:00
Lee Robinson
09a385669b
fix: ignore all .env files for create-next-app by default (#61920)
We've seen too many instances of folks accidentally committing their
`.env` files that I feel it's time to make this change.

Up until now, Next.js has recommended that you use `.env.local` when
working locally to store your environment variables. Some developers do
intentionally want to commit their `.env` file without secret values to
source control. However, the ecosystem is fragmented on `.local`
support.

There are tools which require secrets values that do _not_ support
`.local` and require using `.env`. This means that it's possible to dump
your secret values into a `.env` file and commit to source control,
thinking that the defaults would have you covered.

This change updates the defaults for `create-next-app` to ignore all
`.env` files by default. If you want to commit then, you opt-in by
modifying your `.gitignore`, versus the opposite.

Related: https://x.com/complexlity/status/1755890800527892716

---------

Co-authored-by: Sam Ko <sam@vercel.com>
2024-05-09 11:21:27 -07:00
vercel-release-bot
c3c0c4f8a3 v14.3.0-canary.53 2024-05-09 17:22:50 +00:00
Sam Ko
c07497eb9c
chore(create-next-app): add --empty flag (#65532)
## Why?

Adding an `--empty` flag so we can easily create an empty Create Next
App template.

Closes NEXT-3367

---------

Co-authored-by: Ahmed Abdelbaset <A7med3bdulBaset@gmail.com>
2024-05-09 17:18:20 +00:00
Jiachi Liu
af9ac76abe
Remove rsc esm client module extra exports (#65519)
### What

Remove the extra `__esModule` and `$$typeof` export for ESM client
module

For a client page reference, it changed on server side in renderer:

Previous: `{ __esModule, $$typeof, default }`
Now: `{ default }`

### Why

The Module object itself appears as a client reference but it can't be
rendered since it's not a real reference. I'm not sure why it was added
but I think the right thing for an ESM module is to not treat the module
itself as a client reference but only the objects inside of it. E.g. the
"default" export. That's what React does upstream for ESM modules.

Closes NEXT-3360
2024-05-09 19:04:19 +02:00
vercel-release-bot
718d94a21c v14.3.0-canary.52 2024-05-09 11:01:48 +00:00
Jiachi Liu
09baadfd70
Remove auto appending xml extension to dynamic sitemap routes (#65507)
### What

Remove the auto appending `.xml` extension to the sitemap routes when
it's a dynamic route.


### Why

Previously we were adding `.xml` to `/[...paths/]sitemap` routes, but
the bad part is when you use it to generate multiple sitemaps with
`generateSitemaps` in format like `/[...paths/]sitemap.xml/[id]`, which
doesn't look good in url format and it can be inferred as xml with
content-type. Hence we don't need to add `.xml` in the url.

Before this change it could also result into the different url between
dev and prod:
dev: `/sitemap.xml/[id]`
prod: `/sitemap/[id].xml` 

Now it's going to be aligned as `/sitemap/[id]`. Users can add extension
flexiblely.

Closes NEXT-3357
2024-05-09 11:05:24 +02:00
Jiachi Liu
9ee7d7f76f
Revert "Remove ineffective webpack rules and unused app-page context modules" (#65558)
Reverts vercel/next.js#65321

Missed covering `api` layer, got reported with below error. Revert it
for now and will re-land it with more tests

```
../../node_modules/.pnpm/next@14.3.0-canary.51_@opentelemetry+api@1.7.0_react-dom@18.2.0_react@18.2.0/node_modules/next/dist/client/components/navigation.js
02:23:13
Module not found: shared-runtime module app-router-context cannot be used in api layer
02:23:13
https://nextjs.org/docs/messages/module-not-found
```
2024-05-09 09:45:30 +02:00
vercel-release-bot
067eac6383 v14.3.0-canary.51 2024-05-08 23:22:49 +00:00
vercel-release-bot
5ff2731c58 v14.3.0-canary.50 2024-05-08 19:53:50 +00:00
hrmny
64b718c661
chore: update prettier to 3.2.5 (#65092) 2024-05-08 21:47:14 +02:00
OJ Kwon
531348d864
feat(next): revise server component error message (#65468)
### What

Coming from internal feedback:
https://vercel.slack.com/archives/C046HAU4H7F/p1714858224393659
2024-05-08 12:39:37 -07:00