Commit graph

9365 commits

Author SHA1 Message Date
Yash Singh
f59710e907
feat: support for numeric separators in revalidate config (#51438)
### Fixing a bug

- [x] Related issues linked using `fixes #number`
- [x] 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

### What?

Currently, when the check on validating the type of `revalidate` is run,
we use the `Number` function to parse the value of `revalidate`, however
the `Number` function takes a
[`StringNumericLiteral`](https://tc39.es/ecma262/2023/#prod-StringNumericLiteral)
which doesn't allow the usage of the `_` separator to format your
numbers. This PR allows you to add numeric separators in the
`revalidate` export.

### Why?

When configuring the actual code, we should be allowed to use numeric
separators as it is a syntax that is supported by most runtimes.

### How?

A simple `replaceAll` call that removes all `_`s between digits.

Closes NEXT-1122
Fixes #49485

---------

Co-authored-by: JJ Kasper <jj@jjsweb.site>
2023-06-21 17:22:29 -07:00
Andrey Krasovsky
2cae83d0f2
fix(typo): rename var name in comment (#51531)
Co-authored-by: JJ Kasper <jj@jjsweb.site>
2023-06-21 16:01:46 -07:00
Wyatt Johnson
77ef61ea35
Route Module Updates (#51433)
Small QOL improvements to `RenderResult` and `RouteModule` setup. This
also adds a test to verify that headers aren't sent on responses that
have already been sent.

---------

Co-authored-by: JJ Kasper <jj@jjsweb.site>
2023-06-21 15:30:24 -07:00
Jiachi Liu
f2263f0a6c
Auto fill title/images/description from openGraph for twitter if missing (#51453)
Follow up: #50854 
x-ref: [slack
thread](https://vercel.slack.com/archives/C03KAR5DCKC/p1687016097811079)

---------
2023-06-21 15:19:22 -07:00
vercel-release-bot
4e5fef4f36 v13.4.7 2023-06-21 21:12:57 +00:00
vercel-release-bot
6dd06dbe4d v13.4.7-canary.4 2023-06-21 20:38:43 +00:00
Shu Ding
a0cc4aa65e
Revert "Fix standalone not found" (#51506)
Reverts vercel/next.js#51172

Fixes #51482.
2023-06-21 13:15:05 -07:00
vercel-release-bot
c30f21fa77 v13.4.7-canary.3 2023-06-21 18:59:34 +00:00
JJ Kasper
9d043f6e35
Ensure upgrade request has request meta (#51590)
x-ref: [slack
thread](https://vercel.slack.com/archives/C03S8ED1DKM/p1686906407341689)
2023-06-21 11:52:12 -07:00
Tobias Koppers
343438ff3b
Revert "add edge rendering for app dir for Turbopack" (#51617)
Reverts vercel/next.js#50830
2023-06-21 10:34:55 -07:00
Tobias Koppers
36a7aff6d6
use env var to switch next.js to turbopack mode (#51353)
### What?

this forces all tests to use turbopack independent of the way they invoke next dev

### Why?

some tests were not running turbopack

fixes WEB-1187
2023-06-21 13:52:14 +00:00
Jimmy Lai
bc9ed9de98
router: support layout/special files as direct children of parallel routes (#51604)
follow up on #51413 where I kinda forgot to support parsing layout files in sub routes in a parallel segment.

This should fix it by making sure that we check at all level of the app loader tree and by creating an implicit inner `children` for all parallel slot



link NEXT-1301
2023-06-21 11:16:21 +00:00
JJ Kasper
f6998e30a8
Update id env prefix (#51588)
Removes `__` prefix and ensures it's available on client/server as
expected.

x-ref: [slack
thread](https://vercel.slack.com/archives/C04TNLL0LSK/p1687197571572119)
2023-06-20 16:41:28 -07:00
Joshua Baker
2d2180f43d
Moved new line to warnOnce call (#51552)
<!-- Thanks for opening a PR! Your contribution is much appreciated.
To make sure your PR is handled as smoothly as possible we request that
you follow the checklist sections below.
Choose the right checklist for the change(s) that you're making:

## For Contributors

### Improving Documentation

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

### Adding or Updating Examples

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

### Fixing a bug

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

### Adding a feature

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


## For Maintainers

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

### What?

### Why?

### How?

Closes NEXT-
Fixes #

-->

### What/Why

The `console.log` call was running per request and polluting logs.

### Locally

```
$ next start
- ready started server on 0.0.0.0:3000, url: http://localhost:3000
- info Loaded env from /next/.env.local

- warn metadata.metadataBase is not set for resolving social open graph or twitter images, fallbacks to "http://localhost:3000". See https://nextjs.org/docs/app/api-reference/functions/generate-metadata#metadatabase














^C
```

### Vercel

<img width="352" alt="Screenshot 2023-06-20 at 12 08 56@2x"
src="https://github.com/vercel/next.js/assets/160484/dee72cd3-aa4e-46d8-886f-9476b9345498">

Co-authored-by: JJ Kasper <jj@jjsweb.site>
2023-06-20 16:13:45 -07:00
vercel-release-bot
3d23faa6cd v13.4.7-canary.2 2023-06-20 22:12:57 +00:00
Shu Ding
3847592e44
Add docs links to RSC errors (#51557)
When working with React Server Components, it's essential to have a
clear understanding of how they function and how to troubleshoot any
errors that may arise. This PR adds links to our documentation whenever
an error related to React Server Components occurs.
2023-06-20 23:40:15 +02:00
Zack Tanner
b32c1ea12d
fix typo in x-next-revalidate-tag-token header (#51432)
### What?
While looking into some things related to the FileSystemCache, I came
across this typo introduced in #49227. Not sure how it's currently
manifesting but figured it'd be worth correcting
2023-06-20 08:30:22 -07:00
Jiachi Liu
fc172eeac1
Fix font styles on react dev overlay (#51518)
Fixes font styles change introduced in #49782

### Visuall Diff - After vs Before

<img src="https://github.com/vercel/next.js/assets/4800338/92f6af3a-9728-4dc5-b3d0-b21eefd16164" width="400">
<img src="https://github.com/vercel/next.js/assets/4800338/df88c9dd-b710-4a0a-a1aa-131adb55efa6"  width="400">
2023-06-20 11:36:29 +00:00
JJ Kasper
41ce805de5
Revert "Next Build Turbo POC (#49942)" (#51538)
This reverts commit 7d0bdab83e.

This is failing all builds blocking releases so this reverts it for now
to allow further investigation async.
2023-06-19 21:54:04 -07:00
Shu Ding
30bb252434
Fix shared action module in two layers (#51510)
Currently an "action module" (files with `"use server"` on top) can be
imported by both the server and client layers. In that case, we can't
fork that action module into two modules (one on the server layer, one
on the action layer), but only create it once on the server layer.

This ensures that the action module instance doesn't get forked.

Closes #50801.
fix NEXT-1265
2023-06-19 21:45:51 +02:00
Tobias Koppers
5e51c08f83
add edge rendering for app dir for Turbopack (#50830)
### What?

* allow to use `runtime = "edge"` for app dir in turbopack
* move common imports from next-app-loader to
`packages/next/src/server/app-render/entry-base.ts`
* move common turbopack code to communicate between JS and Rust into
separate files

### Why?

A lot test cases depend on edge rendering

### How?

---------

Co-authored-by: Alex Kirszenberg <alex.kirszenberg@vercel.com>
2023-06-19 19:28:41 +02:00
Alex Kirszenberg
7d0bdab83e
Next Build Turbo POC (#49942)
This contains the original POC for `next build --turbo`. The implementation is _just enough_ to get pages building, and doesn't support the app router yet.

I'll write more details here on the implementation and what the next steps are next week.

Necessary changes on the Turbo side: https://github.com/vercel/turbo/pull/4998
2023-06-19 14:36:05 +00:00
Jimmy Lai
5b7b91f3c5
router: add layout and other file supports to parallel routes (#51413)
This PR fixes a bug in which the layout files were not picked up if they were direct children of a parallel route slot.

Note: there's a bunch of other files that I've used for debugging that are not used for the test but I'm leaving them for future me.




link NEXT-969
2023-06-19 12:35:41 +00:00
Jiachi Liu
bd466842a0
Fix pnpm lock (#51503)
Reverting unexpected pnpm-lock changes from a3ef99acd9
2023-06-19 11:48:41 +00:00
vercel-release-bot
a3ef99acd9 v13.4.7-canary.1 2023-06-16 13:57:51 +00:00
Shu Ding
46981388aa
Fix bundling of Server Actions (#51367)
There're 3 layers in the RSC module graph: server → client → action. "Action" means that a Client Component re-enters the server layer by importing a file with `"use server"`, and it should behave the same as the server layer but you can't enter the client layer again (hence we have a 3rd layer name).

Since the action layer has the same behavior and module resolution rules, it should be bundled just like the server layer.

Closes #50658. Originally the issue was that `auth/next` isn't being bundled on the action layer, and it has the async local storage imported. Because of that, that storage comes from node_modules instead of the server bundle.
fix NEXT-1290
2023-06-16 13:47:48 +00:00
JJ Kasper
1528a49bf1
Revert "Route Module Updates Redux" (#51409)
This appears to still be hitting the previous issue mentioned in
https://github.com/vercel/next.js/pull/51322

Reverts vercel/next.js#51373
2023-06-16 05:44:03 -07:00
vercel-release-bot
cbb69b2cfc v13.4.7-canary.0 2023-06-16 01:02:52 +00:00
JJ Kasper
da98193602
Lock down server IPC address (#51378)
This attempts to avoid IPv6 and IPv4 resolve issues across network
setups by locking down our internal IPC requests to just one address for
consistency. This way there aren't issues when `localhost` resolves to
one or the other in different cases.

x-ref: https://github.com/vercel/next.js/issues/49677
2023-06-15 17:58:10 -07:00
Wyatt Johnson
ab3f707eff
Route Module Updates Redux (#51373)
Small QOL improvements to `RenderResult` and `RouteModule` setup.
2023-06-15 22:45:49 +00:00
vercel-release-bot
ce4aa787e8 v13.4.6 2023-06-15 21:21:35 +00:00
vercel-release-bot
019ed1c39b v13.4.6-canary.8 2023-06-15 20:08:03 +00:00
Shu Ding
7d7d5a762d
Fix shared layer bundling in Edge Runtime (#51348)
Our shared layer matcher doesn't contain `next/dist/esm`, which breaks Server Actions when there're cookie/header accesses.

Closes #50099. Fix NEXT-1229
2023-06-15 13:03:51 +00:00
Tobias Koppers
a806f1ad84
Update turbopack (#51336)
### What?

update Turbopack and sync dependencies with turbo

### Turbopack changes

* https://github.com/vercel/turbo/pull/5303
2023-06-15 09:39:17 +00:00
vercel-release-bot
c59c39a431 v13.4.6-canary.7 2023-06-15 03:58:41 +00:00
JJ Kasper
bdcca0ccff
Fix CSS deploy id case (#51325)
x-ref: [slack
thread](https://vercel.slack.com/archives/C04MEB9L9RQ/p1686787663510239?thread_ts=1686770561.895939&cid=C04MEB9L9RQ)
2023-06-14 20:28:18 -07:00
mknichel
1660fdfcbb
Update Next.js code owners (#51319)
This PR updates `.vercel.approvers` files to fix some validation errors
and to more closely match desired behavior for assigning and notifying
members of the team for reviews that was discussed on an internal Slack
thread.

- Owners files for `.cargo/` and `.config/` are moved to their
respective directories instead of being placed at the root.
- Fixes the `@vercel/next-js` team name (it uses a dash instead of a
period)
- Adds `:notify` to reviewers so that all of the people listed are
notified of the pull request, but only a single person would be
requested as a reviewer.
- `@vercel/web-tooling:optional` was made optional so that they are not
requested for any change to `pnpm-lock.yaml` but still have the ability
to approve PRs that modify it.

---------
2023-06-14 20:07:32 -07:00
JJ Kasper
f9ae5b7f31
Revert "test(next-dev): hard fail if next-dev runs with turbopack intenral flag" (#51327)
Reverts vercel/next.js#51308
2023-06-14 20:06:55 -07:00
OJ Kwon
a7c31cc509
test(next-dev): hard fail if next-dev runs with turbopack intenral flag (#51308)
<!-- Thanks for opening a PR! Your contribution is much appreciated.
To make sure your PR is handled as smoothly as possible we request that
you follow the checklist sections below.
Choose the right checklist for the change(s) that you're making:

## For Contributors

### Improving Documentation

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

### Adding or Updating Examples

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

### Fixing a bug

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

### Adding a feature

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


## For Maintainers

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

### What?

### Why?

### How?

Closes NEXT-
Fixes #

-->

### What?

WEB-1183

Context:
https://vercel.slack.com/archives/C04KC8A53T7/p1686768648161459?thread_ts=1686763527.218549&cid=C04KC8A53T7

We'd like to avoid false positives to the test cases if test supposed to
run turbopack (having __INTERNAL_ flags) but somehow test fixture does
not run turbopack correctly.
2023-06-14 19:29:59 -07:00
vercel-release-bot
dde67aec5a v13.4.6-canary.6 2023-06-15 01:39:48 +00:00
JJ Kasper
2e68ff7dc0
Revert "Route Module Cleanup" (#51322)
x-ref: [slack
thread](https://vercel.slack.com/archives/C04MEB9L9RQ/p1686788708114089?thread_ts=1686770561.895939&cid=C04MEB9L9RQ)

Reverts vercel/next.js#50936
2023-06-14 18:30:14 -07:00
Shu Ding
38d1f1699d
Fix Server Actions compiler (#51318)
Make sure we are using `var` instead of `const` as we always put the new
appended statements to the end of the module body, but they can still be
referenced before in the HOC case in the runtime. This causes a runtime
error.

Tl;dr: `a = 1; var a` is fine, but `a; const a = ...` will result in a
compilation error.

Closes #49344.
2023-06-14 17:01:05 -07:00
JJ Kasper
409668107d
Revert "Prefer module fields for RSC server layer" (#51316)
Closes: https://github.com/vercel/next.js/issues/51309

Reverts vercel/next.js#51179
2023-06-14 16:55:38 -07:00
JJ Kasper
115b6ad953
Allow configuring analyzerMode in bundle-analyzer (#47468)
It's valid to want to output JSON instead of HTML for the bundle
analyzer so we can expose this specific config the same as
`openAnalyzer`. cc @mknichel
2023-06-14 16:33:39 -07:00
vercel-release-bot
40ce621901 v13.4.6-canary.5 2023-06-14 21:54:03 +00:00
Shu Ding
9a36f337da
Simplify server CSS handling (#51018)
Remove the Server CSS manifest and related logic, and use the chunkGroup
CSS files instead for each entry to inject stylesheet links.

Why was that manifest needed in the first place? When implementing CSS
collection for RSC and nested layout initially, we collect CSS imports
at each layer and create corresponding client entries. But then soon got
hit by the problem of duplication and improper tree-shaking. Two layers
can have the same CSS imported so we solved it in a way that "if an
upper layer imports this module, skip it in child layers". Note that
this is deduped by module, so we need to keep the information of "layer
(entry) → CSS modules" somewhere, in a manifest.

Another reason is that we create the client entry before Webpack
optimizes modules, so we can inject the client entry into the same
compilation. But that means the collected client modules from the server
layer are not properly optimized (DCE). **This is a general issue at the
moment that's not specifically related to CSS, although using that
manifest to collect DCE'd info and join the original collected CSS files
with that info temporarily solved it.** That's why I disabled some tests
related to font CSS collection and want to improve it in a more general
way.

Why is that not needed anymore? Main reason is to keep a good balance
between duplication and number of chunks, and delegate the decision to
Webpack's splitChunks plugin. It is not possible to get to a point of 0
duplication unless we ship every CSS module as a single chunk. And since
in #50406 we made the duplication better but at the chunk asset level,
instead of the original module level.

Prior work: #50406, #50610.
2023-06-14 14:43:08 -07:00
mPaella
d492b937e2
fix: Incorrect build size outputs for app dir (#50768)
### What?
Fixes https://github.com/vercel/next.js/issues/50129

### Why?
The current denormalization of app dir paths doesnt account for the
normalization done in `normalizeAppPath`, causing build log outputs for
certain paths such as anything under a route groups to be incorrect

### How?
There's 2 ways this could be fixed:

1.) Denormalize the app dir paths by reading the
`app-path-routes-manifest.json` and mapping back to the original file
path
2.) (what I chose to do) Normalize the keys of `appBuildManifest`

### Result

App dir paths, including route groups, now have their correct output
size

<img width="494" alt="image"
src="https://github.com/vercel/next.js/assets/93682696/0eee79b8-7d60-4c88-b07a-dfb750aa9592">

---------

Co-authored-by: JJ Kasper <jj@jjsweb.site>
2023-06-14 14:24:57 -07:00
bri
c76653f2f7
chore: update next/font/google font list (#49969)
Ran script `update-google-fonts`, adding these fonts to `next/font/google`:

- [Instrument Sans](https://fonts.google.com/specimen/Instrument+Sans)
- [Noto Sans Nag Mundari](https://fonts.google.com/noto/specimen/Noto+Sans+Nag+Mundari)
- [Wix Madefor Display](https://fonts.google.com/specimen/Wix+Madefor+Display)
- [Wix Madefor Text](https://fonts.google.com/specimen/Wix+Madefor+Text)

and updating these fonts:
- [Radio Canada](https://fonts.google.com/specimen/Radio+Canada) (added `canadian-aboriginal` subset)

Co-authored-by: JJ Kasper <22380829+ijjk@users.noreply.github.com>
2023-06-14 21:03:44 +00:00
tom
d4c2335b0f
chore: add dark mode for dev overlay (#48601)
This PR adds a dark mode to the error overlay which respects the browsers color scheme.
I just did this because I was blinded by the dev overlay a lot today and thought this change might be appreciated.

Screenshot (dark mode):
<img width="2056" alt="image" src="https://user-images.githubusercontent.com/17279485/233201837-0d005e10-d73f-4ddd-9f4a-285829ec63b1.png">
 
Screenshot (retained light mode):
<img width="1064" alt="image" src="https://user-images.githubusercontent.com/17279485/233202019-83ec79d8-d2ca-44c8-bc0a-7696355dfe72.png">


Co-authored-by: JJ Kasper <22380829+ijjk@users.noreply.github.com>
2023-06-14 20:33:07 +00:00
JJ Kasper
916d2aa4d5
Validate i18n locale domain (#50220)
The `domain` value is meant to be a hostname and not include `http` or
port so this ensures we validate it doesn't contain `:` unexpectedly
causing invalid behavior.

Closes: https://github.com/vercel/next.js/issues/49656
x-ref:
https://github.com/vercel/next.js/issues/24991#issuecomment-870418366

---------

Co-authored-by: Jiachi Liu <inbox@huozhi.im>
2023-06-14 11:07:58 -07:00
Wyatt Johnson
616ae108d9
Route Module Cleanup (#50936)
This cleans up some setup functions within the route modules, improves logic around headers, and handles the case where the URL is invalid better for routes using the request adapters.
2023-06-14 17:54:23 +00:00
OJ Kwon
2761cf34fa
feat(turbopack): enable sassOptions (#51259)
### What?

Minor fix to remove guards to the config since turbopack have this feature enabled.
2023-06-14 17:27:04 +00:00
Shu Ding
754c6480cb
Invalidate client cache when cookies have changed in Server Actions (#51290)
Similar to tags and paths, when `cookies().set()` is called we have to
invalidate the client router cache as well so routes with
`cookies().get()` will not holding the stale data. This is critical for
auth and other scenarios.

In the future we can have an optimization to only invalidate routes that
actually rely on cookies, similar to paths.
2023-06-14 17:26:27 +02:00
Jimmy Lai
c6c4a3d3eb
app router: fix double fetch on prefetch={false} (#51292)
This PR fixes a few reports that we were double fetching when navigating via a link that had prefetch false.

## Context

The bug was happening because we were inadvertently eagerly fetching even if we potentially bailed out of the optimistic navigation, which would then trigger another fetch from going through the regular navigation path.

There's potentially another bug here where we should potentially not bail out of optimistic navigation in the cases reported but we can fix that later.



fix #49844
link NEXT-1287
2023-06-14 13:42:14 +00:00
vercel-release-bot
cbeecba83b v13.4.6-canary.4 2023-06-14 11:21:24 +00:00
Tim Neutkens
dd937bde09
Remove edge functions tracking in dev server (#51122)
## What?

While looking at the CPU profile of booting up Vercel's site I noticed
that we call `getPageStaticInfo` a lot. Looking into this more it turns
out `getPageStaticInfo` is currently called for all routes, `pages` and
`app`, even though the data is only being used to keep track of which
routes are edge functions, however, this is already tracked as part of
the build output so this didn't make sense to me. First I tried
commenting out this entire block and all tests were passing, so I
removed it except for middleware as middleware can provide a `matcher`
which does need to be known before compiling the file as of right now.

After that change a different set of tests started failing, specifically
the one that checks if we warn correctly. Interestingly by fixing
`getPageStaticInfo` being called early and for all routes it also caused
these warnings to no longer trigger as there was a case in the manifest
plugin that called `getPageStaticInfo` with less information. Calling
`getPageStaticInfo` there was not needed either as we call
`getPageStaticInfo` at the beginning of the build for each entrypoint so
we already have the information required, it just had to be passed down
so that the manifest plugin could use it.

For Vercel's site this change improves booting the dev server by over 1
second.

Related to #48748

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

- 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>
2023-06-14 13:17:16 +02:00
vercel-release-bot
c8f65ede87 v13.4.6-canary.3 2023-06-14 06:52:30 +00:00
JJ Kasper
f676d001b6
Correct build workers perf issue (#51271)
This continues off of https://github.com/vercel/next.js/pull/49937 and
https://github.com/vercel/next.js/pull/50194 ensuring we don't regress
on build perf due to reducing the amount of workers being used in
parallel.

Fixes: https://github.com/vercel/next.js/issues/51201
Fixes: https://github.com/vercel/next.js/issues/50555
2023-06-13 23:23:50 -07:00
Joost De Cock
667a90262b
[docs] Clarify .md handling with @next/mdx (#49785)
…iles as MDX

I got bitten by this passage because it reads as if merely changing the
`extension` setting will cause `.md` files to be loaded as MDX.

See: https://github.com/mdx-js/mdx/issues/2302

<!-- 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 or adding/fixing 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>
2023-06-13 22:53:04 -07:00
Riqwan Thamir
825eefe7c0
Add mikroORM to external package list (#50487)
### What?

Adds mikroORM to external package list

### Why?

To prevent developers using
[MedusaJS](https://github.com/medusajs/medusa) modules with NextJS from
having to add this in their next config.

---------

Co-authored-by: JJ Kasper <jj@jjsweb.site>
2023-06-13 22:49:50 -07:00
Choi Sumin
8ac9b342e3
chore(router): fix typo in comment (#50581)
<!-- 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 or adding/fixing Examples

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

### Fixing a bug

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

### Adding a feature

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



## For Maintainers

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

### What?

### Why?

### How?

Closes NEXT-
Fixes #

-->


### What?

fix typo in comment (withRoute -> withRouter)
2023-06-13 21:10:36 -07:00
Baffin Lee
2bd76827f0
Fix build error about trace file and edge route (#50808)
<!-- 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 or adding/fixing Examples

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

### Fixing a bug

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

### Adding a feature

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



## For Maintainers

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

### What?

### Why?

### How?

Closes NEXT-
Fixes #

-->

### What?

Error occurs when processing trace file rules of edge route.

### Why?

Edge routes have no trace files, so we don't need to process exclude and
include rules about it's trace file.

### How?

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

Co-authored-by: JJ Kasper <jj@jjsweb.site>
2023-06-13 21:04:10 -07:00
Zack Tanner
3427d324d8
fix: app router hash scrolling should respect scroll-padding (#51268)
When navigating to a route with a hash parameter, the layout router
jumps to the element by scrolling to the node's `offsetTop` value.
However, this will ignore `scroll-padding`, which deviates from browser
behavior.

It looks like this isn't an issue in the pages router which currently
makes use of
[`scrollIntoView`](https://github.com/vercel/next.js/blob/canary/packages/next/src/shared/lib/router/router.ts#L2262).

Closes NEXT-1171
Fixes #49612

---------
2023-06-13 20:50:51 -07:00
Baffin Lee
4ef3982f62
chore: remove useless duplicate code (#50705)
<!-- 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 or adding/fixing Examples

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

### Fixing a bug

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

### Adding a feature

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



## For Maintainers

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

### What?

### Why?

### How?

Closes NEXT-
Fixes #

-->

## What?

Remove useless duplicate code in `next-server.ts`, there are exactly the
same code in next lines.

## Why?

That code have no side effect, run it twice won't make any difference,
seems like someone forgot to delete it.


![image](https://github.com/vercel/next.js/assets/17738556/848d4b03-78cd-40a4-ae8b-a3126101efac)

Co-authored-by: JJ Kasper <jj@jjsweb.site>
2023-06-13 20:38:01 -07:00
Willem-Jaap
0bda6287b6
fix(cli): add all available options to cli commands, format them consistently (#48708)
### What?
Add all available options to cli commands
Consistent formatting for all options

### Why?
Options were not consistent across all commands, some were missing



Co-authored-by: Steven <229881+styfle@users.noreply.github.com>
Co-authored-by: JJ Kasper <22380829+ijjk@users.noreply.github.com>
2023-06-14 02:36:08 +00:00
Michael Novotny
94accfacf1
Adds homepage to eslint-config-next package (#51059)
Fixes (partially) #50843.

---------

Co-authored-by: Steven <steven@ceriously.com>
Co-authored-by: JJ Kasper <jj@jjsweb.site>
2023-06-13 11:22:05 -07:00
Delba de Oliveira
3d41ccb916
Update codeowners (#51250)
Tweak code owners after some testing and feedback. 

- Move the Next.js team up to be optional global code owners (so that everyone can review but are not tagged for review). Global individuals should still be tagged if there are no specific `.vercel.approvers` files in subdirectories.
- Adds @vercel/devex to image files so there's coverage on those files for the docs
- Target specific folder and files for Styfle to get notified
- Deletes some rules in the old GitHub codeowners
2023-06-13 17:47:12 +00:00
Will Binns-Smith
8f4ae065e0
Turbopack: remove __internal_nextjs_integration_test compile-time feature (#51204)
This removes the `__internal_nextjs_integration_test` compile-time feature. This would end up requiring an additional set of build targets for running integration tests was only used for two cases:

* Determining whether to read from an env var to load mocked Google fonts responses in next/font/google tests. This now uses the presence of this variable to determine whether to use mocked responses.
* Enabling the `next-dev/serializable` feature. This is now set directly instead.

Test Plan:
* Integration tests with Turbopack.
* Manual test of next/font/google with Turbopack
2023-06-13 16:26:44 +00:00
Jiachi Liu
6e5169b17a
Add buildId into RSC payload (#50974)
Co-authored-by: Tim Neutkens <tim@timneutkens.nl>
2023-06-13 17:58:07 +02:00
Shu Ding
9ffea84080
Simplify the client manifest structure (#51183)
Both of our bundlers won't split different exports of a module into different chunks, we can rely on https://github.com/facebook/react/pull/26624 to simplify the structure. This reduces the size of the client reference manifest by ~70%.
2023-06-13 15:25:39 +00:00
Sora Morimoto
0840793abf
Fix all 404 links (#51209)
I found some 404 links in jsdoc, so I used ripgrep to find and fix all the broken links to fix all the other links in this PR.
2023-06-13 14:25:40 +00:00
vercel-release-bot
b80dc83b23 v13.4.6-canary.2 2023-06-13 13:13:56 +00:00
vercel-release-bot
6e9113fe59 v13.4.6-canary.1 2023-06-12 22:32:21 +00:00
Jiachi Liu
9d0129c635
Fix standalone not found (#51172)
Fixes #50232

Passing down the private env into `'render-server'` module to pick up the proper react with require-hook in standalone server
fix NEXT-1260
2023-06-12 21:14:32 +00:00
Jiachi Liu
8a11835fbe
Strip _rsc query for navigation between app and page (#51195)
Fix a missing case from #50970

When navigating from app to page, the `_rsc` query should still be stripped
2023-06-12 20:36:36 +00:00
Steven
a6a9d65c8c
fix: helpful error when output: export and next export -o (#51191)
We already have a warning when using `next export` with `output: export` because the `next export` is effectively a no-op (the exported output was already generated during `next build`).

However, this PR ensures that `next export -o <dir>` throws an error when `output: export` is defined because the files were already emitted to the `distDir` in the `next build` step and we can't safely no-op at this point.

We also guide the user to the correct solution which is to use `output: export` along with `distDir: <dir>` in your next.config.js (instead of mixing legacy behavior with the new behavior).

fix #48207
fix NEXT-980
2023-06-12 20:15:58 +00:00
Shu Ding
de83bf5598
Revert "Do not merge chunkGroups' CSS files" (#51193)
Reverts vercel/next.js#51103
2023-06-12 19:42:06 +00:00
Delba de Oliveira
d106155c9c
Update next/head warning to link to the correct docs page (#51013)
Fixes https://github.com/vercel/next.js/issues/50844
2023-06-12 19:16:04 +00:00
Jiachi Liu
74225d1945
Prefer module fields for RSC server layer (#51179)
Follow up for #50548 

There're some packages like `aws-sdk-js-v3` which doesn't have a exports field yet: 

```
  "main": "./dist-cjs/index.js",
  "types": "./dist-types/index.d.ts",
  "module": "./dist-es/index.js",
 ```
 
 This PR let u pick up by the js assets based on main fields, will prefer `"module"` field instead of `"main"`
 
 Closes NEXT-1286
2023-06-12 17:50:12 +00:00
Shu Ding
b664cdb1c0
Add option for debugging CPU usage (#51174)
Add a `NEXT_CPU_PROF` environment variable to programmatically profile CPU for the router worker and two render workers. This is helpful because the `--cpu-prof` isn't reliably writing the result (#27406) especially with our multi-process architecture.

![CleanShot-2023-06-12-GS9p3SbN@2x](https://github.com/vercel/next.js/assets/3676859/b7cf80d2-a35a-4e90-978d-dec70be89f90)
2023-06-12 15:31:36 +00:00
Tobias Koppers
6b0a6f0c25
add turbopack integration tests to CI (#50904)
### What?

* enable turbopack tests in new CI
* split pre-build step into native and JS builds to allow to start
native tests faster
* update swc_core to sync with turbo
* update turbopack

### Why?

Running our test suite is still important as long we don't have the full
integration test suite enabled.

### Turbopack updates

* https://github.com/vercel/turbo/pull/5215 <!-- OJ Kwon - ci(workflow):
upload benchmark results to datadog -->
* https://github.com/vercel/turbo/pull/5239 <!-- OJ Kwon -
fix(swc_plugin): use shared runtime -->
* https://github.com/vercel/turbo/pull/3090 <!-- CHEN Yuan - Docs: prior
to run testcases, add guides to install dependencies for testcases. -->
* https://github.com/vercel/turbo/pull/5264 <!-- Tobias Koppers - update
test runner -->

---------

Co-authored-by: JJ Kasper <jj@jjsweb.site>
2023-06-12 07:47:43 -07:00
vercel-release-bot
bb092bc127 v13.4.6-canary.0 2023-06-12 11:38:47 +00:00
Jiachi Liu
aa3e043bbf
Add unique search query for RSC requests to be cacable on CDN (#50970)
Adding a `_rsc` query for RSC payload requests so that they can be
differentiated on resources level for CDN cache for the ones that didn't
fully respect to VARY header.

Also stripped them for node/edge servers so that they won't show up in
the url

x-ref:
https://github.com/vercel/next.js/pull/49140#issuecomment-1549405009

Closes #49140
Closes NEXT-1268
2023-06-12 11:52:36 +02:00
Shu Ding
38d789f826
Do not merge chunkGroups' CSS files (#51103)
This is a temporary fix before we can ship #51018 (more details there). If there're multiple chunk groups holding the same CSS module, we use files from the first one. This has some flaws but still better than our current status.
2023-06-11 16:05:26 +00:00
Jiachi Liu
cfd64aab55
Fix windows metadata slashes (#51088)
Fixes #51086

The path is used as href, should be normalized as posix style
fix NEXT-1282
2023-06-10 23:30:32 +00:00
vercel-release-bot
db10dd6740 v13.4.5 2023-06-10 22:03:48 +00:00
vercel-release-bot
d683006526 v13.4.5-canary.12 2023-06-10 21:17:36 +00:00
Shu Ding
2ede83560f
Remove redundant condition (#51070)
This review comment was sent after merging the PR: https://github.com/vercel/next.js/pull/51067#discussion_r1224745071

The layer condition doesn't do anything if `hasServerComponents` is disabled.
2023-06-10 20:50:43 +00:00
vercel-release-bot
41d92fe3fd v13.4.5-canary.11 2023-06-10 19:47:11 +00:00
vercel-release-bot
387430c659 v13.4.5-canary.10 2023-06-09 23:46:48 +00:00
JJ Kasper
32a9c3553f
Fix another case with app router revalidation (#51076)
This ensures we don't attempt streaming a response during revalidation
in deployed environments.

x-ref: https://github.com/vercel/next.js/pull/51062
x-ref: [slack
thread](https://vercel.slack.com/archives/C03S8ED1DKM/p1686216024812579)
2023-06-09 16:40:41 -07:00
Steven
1a0b5d25c6
fix: moduleResolution: bundler support in tsconfig.json (#51065)
- Fixes https://github.com/vercel/next.js/issues/47858
- Closes https://github.com/vercel/next.js/pull/50289

fix #47858
fix NEXT-1281

Co-authored-by: Kevin Wolf <3157426+kevinwolfcr@users.noreply.github.com>
2023-06-09 21:48:13 +00:00
Jiachi Liu
2bc1061609
Apply optimization to middleware when using babel (#51067)
Like how we handled RSC loader transform before, we also apply swc
loader to middleware to make sure the imports optimization is applied so
og package won't be bundled

Fixes #50492
2023-06-09 13:33:14 -07:00
JJ Kasper
804552590e
Update app router revalidate handling on deploy (#51062)
This ensures we clear the RSC headers during revalidate when deployed so
that the HTML revalidation isn't treated as the RSC revalidation.
2023-06-09 13:23:44 -07:00
Simon Podlipsky
be960ccd02
fix: verbatimModuleSyntax: true support in tsconfig.json (#48018)
### What?

When `verbatimModuleSyntax: true` is set, `isolatedModules: true` are not allowed by TS

### Why?

Next always adds `isolatedModules: true` which causes TS error.

### How?

- Fixes #46509

fix NEXT-689

Co-authored-by: Steven <229881+styfle@users.noreply.github.com>
2023-06-09 19:07:30 +00:00
Jiachi Liu
558632b5f2
Avoid server insertion react key warning (#51053)
Wrap server inseration children with react key to avoid react key
warning display
2023-06-09 10:18:19 -07:00
JJ Kasper
4080f63505
Ensure id handling applies for dynamic import in pages (#51049)
Noticed this case wasn't handled in pages so added additional test
coverage and patched the case.
2023-06-09 09:51:51 -07:00
JJ Kasper
480df20086
Ensure headers instance is serialized (#51047)
This makes sure we properly include headers in the cache key when a
headers instance is used.

x-ref: [slack
thread](https://vercel.slack.com/archives/C042LHPJ1NX/p1686234796532989)
2023-06-09 09:35:45 -07:00
Michael Novotny
55b29fb351
Updates prettier to latest version. (#51000)
There are some incoming docs / MDX changes where prettier will throw an error when using the older version. Updating prettier before I bring in those changes.

Looks like the most notable change is adding parentheses around `typeof` checks in TypeScript. 

**Before**

```
export type Locale = typeof i18n['locales'][number]
```

**After**

```
export type Locale = (typeof i18n)['locales'][number]
```
2023-06-09 14:58:19 +00:00
Jiachi Liu
2a2890cae6
Fix esm module import warning for middleware loader (#51014)
We need to spread the module into an object instead of access the module exports that could not exist, to avoid triggering the warning. Fix the bad loader change introduced in #50548 

```
Attempted import error: './middleware.js' does not contain a default export (imported as '
mod').
- info Using locally built binary of @next/swc
- warn You are using an experimental edge runtime, the API might change.
- wait compiling...
- warn ../../../../packages/next/dist/build/webpack/loaders/next-middleware-loader.js?abso
lutePagePath=%2FUsers%2Fhuozhi%2Fworkspace%2Fnext.js%2Ftest%2Fe2e%2Fapp-dir%2Fapp%2Fmiddle
ware.js&page=%2Fmiddleware&rootDir=%2FUsers%2Fhuozhi%2Fworkspace%2Fnext.js%2Ftest%2Fe2e%2F
app-dir%2Fapp&matchers=!
Attempted import error: './middleware.js' does not contain a default export (imported as '
mod').
- wait compiling...
```
2023-06-09 14:14:50 +00:00
Jimmy Lai
41675c07cb
edge: use JSON parse instead of inlining the manifests objects (#50960)
Manifests tend to be really big and our strategy is to inline them in the edge function script itself and we're hitting some constraints this way. 

This PR switches this behaviour via inlining the script and creating a JS object at runtime instead, with the hope that the parsing time will be faster as JSON.parse is very well optimised in V8.

The end goal ofc is to have smaller manifests but this should be a good stopgap.



link NEXT-1273
2023-06-09 12:58:55 +00:00
Jiachi Liu
f19b31ad93
Fix rsc payload fetch failures due to state tree encoding (#51017)
Encode the state tree where the content could contain unicode when
request the RSC payload, to avoid the fetch failure due to bad encoding
for headers

Fixes #48728
fix NEXT-1258
2023-06-09 12:06:00 +02:00
Balázs Orbán
96e47d3f37
chore: mark forceOptimisticNavigation as internal (#47905)
### What?

Hide internal API.

### Why?

Ref: https://vercel.slack.com/archives/C035J346QQL/p1669125601246609?thread_ts=1669125167.045259&cid=C035J346QQL

### How?

Mark the internal property with `@internal` so it's not shown by IntelliSense.

Related #47894
2023-06-09 09:36:36 +00:00
vercel-release-bot
f2dfa1a92a v13.4.5-canary.9 2023-06-09 08:30:52 +00:00
JJ Kasper
cdd366fd97
Fix usage of router.refresh() with Draft Mode in App Router (#50941)
After enabling Draft Mode, `router.refresh()` was incorrectly causing the page to crash and do a full page refresh.

This PR fixes this case.

Co-authored-by: Steven <229881+styfle@users.noreply.github.com>
2023-06-09 00:15:55 +00:00
Will Binns-Smith
994c61a807
Turbopack next/font/google: Use capsize's xWidthAvg to compute fallbacks (#50878)
Instead of using azAvgWidth for next/font/google, use xWidthAvg as the webpack implementation does. For now, next/font/local in both the webpack and Turbopack implementations continue to use azAvgWidth. We should align these in the future.

Test Plan: We now pass 26 next/font tests in Turbopack, up from 22.
2023-06-08 23:02:28 +00:00
Jiachi Liu
f2e637d24d
Upgrade webpack to 5.86.0 (#50992)
To resolve issue #49382, we found layer doesn't get applied for dynamic imports, so we fixed it on webpack side in https://github.com/webpack/webpack/pull/17310

This PR is to upgrade webpack to 5.86.0 with that patch as a precedence. After this we need to fix the `next/image` client components is missing in client reference manifest when using dynamic imports to fix the issue.
2023-06-08 20:35:12 +00:00
Shu Ding
5150506452
Move required chunk collection to the upper level (#50983)
This is an optimization to make the plugin faster, we're currently doing
redundant work `getAppPathRequiredChunks()` for all modules during
`recordModule()` while it's not changing.
2023-06-08 20:22:38 +02:00
Steven
9a9d095b54
Bump to typescript@5.1 (#50557)
We need to upgrade TypeScript to land the following fixes:

- https://github.com/vercel/next.js/pull/50289
- https://github.com/vercel/next.js/pull/48018

And it should fix async components:
- https://twitter.com/sebsilbermann/status/1664356039876124672

Also see this related TS 5.0 issue:

- https://github.com/microsoft/TypeScript/issues/53402
2023-06-08 17:18:37 +00:00
Jiachi Liu
a035224dc3
Pick esm main fields and condition names first for RSC server layer (#50548)
For RSC server layer so far we bundle all dependencies, ESM format is the better one rather than CJS to analyze and tree-shake out the unused parts. This PR changes pick the condition names that are in ESM format first for server layer.

Also fixes the misorder of condition names of edge runtime, `conditionNames` should only contain either ESM or CJS, previously the main fields are mixed with conditon names which is not expected for webpack, we separate them now.

Since we're picking ESM instead CJS now, the error of require `exports * from` doesn't exist anymore, but if you're using a CJS dependency which require a ESM package, it will error. This is the existing behavior for our webpack configuration but could happen on server layer bundling

Other related changes:

* Imports are hoisted in ESM, so migrate`enhanceGlobals` to a imported module
* Use `...` to pick the proper imports by import expression, and prefer the `react-server` / `edge-light` condition names for corresponding cases
* Remove edge SSR duplicated `middleware` export checking
2023-06-08 16:24:03 +00:00
Wyatt Johnson
ea63e92e87
Bump @types/node (#50940)
This bumps @types/node to 20.2.5 to prepare for upgrades to other packages requiring updated Node.js typescript types.
2023-06-08 15:52:17 +00:00
vercel-release-bot
d52c030d94 v13.4.5-canary.8 2023-06-08 15:01:09 +00:00
Shu Ding
b7d438cfc1
Invalidate prefetch cache when a tag or path has been revalidated on the server (#50848)
This makes sure that if `revalidateTag` is called in a Server Action, the client router cache and prefetch cache are invalidated correctly so following navigations won't reuse the cache that might hold stale data.

Similar case for `revalidatePath`. I left a TODO where we can't just invalidate the subtree under the revalidate paths because of current implementation limitations. To ensure correctness, we just do the same as `revalidateTag`.
2023-06-08 13:44:42 +00:00
Shu Ding
2010928d9a
Drop the chunks field in the client manifest for SSR (#50959)
The `ssrModuleMapping`/`edgeSSRModuleMapping` fields store information
for the Flight client that does SSR to resolve the correct modules in
the SSR bundle. This works as a module ID mapping between the client
bundle and the SSR bundle. During the mapping, we can drop the `chunks`
field because we don't actually have external chunks to load during SSR
as everything is locally `require`'d.

This reduces the client manifest size by at least 20%.
2023-06-08 14:47:24 +02:00
Delba de Oliveira
8c2e5bd072
Update codeowners to use Vercel Spaces (#50841)
Move as much of codeowners as possible to use Vercel Spaces. 

1. Makes `@timneutkens @ijjk @shuding @huozhi @feedthejim` global owners
2. Make the `@vercel/next-js` team _optional_ owners of **/docs**,
**/errors**, and **/contributing**, makes team owners of a few packages
as per old config.
3. Make `@vercel/devex` (docs and devrel) owners of **/docs**,
**/errors**, and **/contributing**
4. Make `@vercel/devrel` (devrel only) owners of **/examples**
5. Make `@vercel/web-tooling` owners of specific files and folders (as
per old config)

Leaves @styfle as owner of **image** files on the old config since this
pattern `/**/*image*/** ` can't be used with Vercel Spaces.

Note: We cannot add * or / at the end of files.
[Docs](https://spaces-docs.vercel.sh/docs/code-owners#:~:text=Code%20Owners%20files%20are%20meant%20to%20encourage%20distributed%20ownership%20definitions%20across%20a%20codebase.)
2023-06-08 12:02:18 +02:00
JJ Kasper
22ea7d9909
Revert "Revert "update turbopack"" (#50947)
Fixed in https://github.com/vercel/next.js/pull/50946

Reverts vercel/next.js#50942
2023-06-08 04:02:03 +00:00
Shu Ding
18d2f7da33
Fix shorthand prop wrongly handled in the Server Actions compiler (#50937)
This PR fixes the case of having a shorthand prop `{ id }` referenced from a non-top level closure in the Server Actions compiler. The main problem is that an `Ident` in `PropOrSpread` is not considered as an `Expr`.

See corresponding issue report and test case for more details.
fix #50445
fix NEXT-1254
2023-06-08 03:03:54 +00:00
JJ Kasper
2a62513ecd
Revert "update turbopack" (#50942)
The builds are failing 

x-ref:
https://github.com/vercel/next.js/actions/runs/5206362546/jobs/9392872573
x-ref:
https://github.com/vercel/next.js/actions/runs/5206362546/jobs/9392873009
x-ref:
https://github.com/vercel/next.js/actions/runs/5206362546/jobs/9392873120

Reverts vercel/next.js#50819
2023-06-07 19:02:29 -07:00
Leah
0d46361f8e
update turbopack (#50819)
### Turbopack Updates
* https://github.com/vercel/turbo/pull/5156 
* https://github.com/vercel/turbo/pull/5159 
* https://github.com/vercel/turbo/pull/5162 
* https://github.com/vercel/turbo/pull/5161 

* https://github.com/vercel/turbo/pull/5174 
* https://github.com/vercel/turbo/pull/5178 
* https://github.com/vercel/turbo/pull/5121 
* https://github.com/vercel/turbo/pull/5200 
* https://github.com/vercel/turbo/pull/5207 
* https://github.com/vercel/turbo/pull/5211 
* https://github.com/vercel/turbo/pull/5210 
* https://github.com/vercel/turbo/pull/5221 
* https://github.com/vercel/turbo/pull/5218 
* https://github.com/vercel/turbo/pull/5226 
* https://github.com/vercel/turbo/pull/5139 
* https://github.com/vercel/turbo/pull/5227 
* https://github.com/vercel/turbo/pull/5189
2023-06-08 01:23:14 +00:00
JJ Kasper
06abd63489
Add experimental caseSensitiveRoutes config (#50869)
This adds an experimental `caseSensitiveRoutes` config that currently applies for `rewrites`, `redirects`, and `headers` to change the default of case-insensitive. 

x-ref: [slack thread](https://vercel.slack.com/archives/C02K2HCH5V4/p1686080359514479?thread_ts=1686077053.623389&cid=C02K2HCH5V4)
x-ref: [slack thread](https://vercel.slack.com/archives/C057RG6Q9MX/p1686078875948069?thread_ts=1686077882.133609&cid=C057RG6Q9MX)
x-ref: https://github.com/vercel/next.js/issues/21498
2023-06-07 21:50:22 +00:00
JJ Kasper
6ef76195a5
Update next-swc handling for PR stats (#50933)
This fixes the wasm swc build being used for PR stats unexpectedly since
pnpm pack wasn't actually including the swc binary. This also adds a
hard error preventing the wasm swc binary from being leveraged in the
future for PR stats.

x-ref:
[vercel/next.js/actions/runs/5193512579/jobs/9364168639](https://github.com/vercel/next.js/actions/runs/5193512579/jobs/9364168639)
x-ref:
https://github.com/vercel/next.js/pull/50853#issuecomment-1579055731

---------

Co-authored-by: Steven <steven@ceriously.com>
2023-06-07 14:31:57 -07:00
Jiachi Liu
8eb14280e8
Polish error page styling (#50916)
Polish default client error page styling:

* shrink the `line-height` to `2em` for better mobile display
* remove `text-align: left` to let the text center properly

#### After vs Before
(both **app router** and **pages** default client error page)
<p>
<img width="300" alt="image" src="https://github.com/vercel/next.js/assets/4800338/de7260af-7046-4783-8f82-8ac5f39f25b7">
<img width="300" alt="image" src="https://github.com/vercel/next.js/assets/4800338/f4207809-f11f-448d-95ec-0a32b54f3562">
</p>


#### After
(both **app router** and **pages** default client error page)


Closes NEXT-1263
2023-06-07 17:54:48 +00:00
Toru Kobayashi
675dec04ca
fix: App Router with assetPrefix: / (#49622)
This is a follow-up PR for #49403.

#49403 validates `assetPrefix` is not a relative path. But App Router throws an error with the `assetPrefix: "/"` option. So I've fixed this.

<img width="964" alt="Screenshot 2023-05-10 at 23 41 56" src="https://github.com/vercel/next.js/assets/250407/6e83cb57-468c-46d6-a91a-747ad39d6c3c">

`assetPrefix: "/"` has no meaning, but it shouldn't fail.
2023-06-07 14:46:02 +00:00
vercel-release-bot
e19007df42 v13.4.5-canary.7 2023-06-07 09:53:16 +00:00
Josh Story
92b29d2f17
Update react to latest versions (#50604)
Update Vendored React Dependencies
2023-06-07 09:50:27 +00:00
Tim Neutkens
9a1db5fc5e
Add additional font-loader spans for tracing (#50889)
## What?

Adds additional spans for running postcss and fontloader in next-font-loader.
2023-06-07 09:32:07 +00:00
Tim Neutkens
a24c607a4d
Add layer to module trace (#50851)
## What?

Adds `layer` to the traces for `build-module-x`, will allow us to figure
out in what layer the module was compiled, as you can now get multiple
for the same module.

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

## For Contributors

### Improving Documentation or adding/fixing 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 #

-->
2023-06-07 10:51:42 +02:00
Jiachi Liu
452d390ec0
Fill basic twitter metadata with opengraph when missing (#50854)
When twitter metadata is not provided but opengraph metadata is, fill the opengraph basic information for twitter metadata.
Twitter card can't be displayed if there's no information from twitter meta tags, at least the `twitter:card`. We fill the `title` `description` and `images` these 3 overlapped properties from opengraph image so they can be displayed properly

Closes NEXT-1111
2023-06-06 20:54:14 +00:00
Justin Ridgewell
1a2fac2b5a
[turbopack]: Use tip-of-branch for benchmarks (#50615)
With vercel/turbo#5156, we'll be able to install our the locally built `next` package. Before, we'd test the tip-of-branch `next-dev` binary against the last cut `next` canary, which causes headaches when we make breaking changes.

With this PR, we'll now test tip-of-branch `next-dev` binary against a tip-of-branch `next` package, and breaking changes can be properly benched.

Fixes WEB-1133
2023-06-06 20:36:11 +00:00
JJ Kasper
1e0566b9ac
Update id config handling (#50847)
Adds a separate flag for leveraging the env variable.
2023-06-06 07:54:06 -07:00
Kiko Beats
218c683db7
upgrade edge-runtime dependency (#50636)
Hello,

We removed some core non-necessary dependencies that make Edge Runtime
smaller 🙂.

Also, Edge Runtime is exposing `WebSocket`, so nothing additional should
be done.

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

---------

Co-authored-by: Wyatt Johnson <accounts+github@wyattjoh.ca>
2023-06-06 16:13:44 +02:00
Wyatt Johnson
099ca3a36a
Pages Route Module Rendering (#50404)
This starts the process of moving the rendering logic for pages into the
bundle. The `render` method on the module now provides the same
capability as the underlying `renderHTML` method available on the
`NextNodeServer`. In the next few change sets, more layers of the
rendering pipeline will shift into the bundled code, removing them from
the main boot path.

---------

Co-authored-by: JJ Kasper <jj@jjsweb.site>
2023-06-06 16:12:04 +02:00
Tim Neutkens
230641adfd
Bail out of 404 page when favicon.ico doesn't exist (#50795)
## What?

Anytime you open a Next.js application that doesn't have a `favicon.ico`
you'll notice `/_error` is being compiled because the browser requests
`favicon.ico`. This PR ensures the 404 page is not compiled in
development for that request. It helps a little with compilation speed.

<!-- 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 or adding/fixing 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: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2023-06-06 10:58:40 +02:00
Jiachi Liu
ec5ba3184b
Shrink the react key size in metadata RSC payload (#50739)
Follow up for #50678 as @gnoff commented in https://github.com/vercel/next.js/pull/50678#pullrequestreview-1457858336

Now metadata is shorter with the shorter key with just numbers

```
self.__next_f.push([1,"5:[[\"$\",\"meta\",\"0\",{\"charSet\":\"utf-8\"}],[\"$\",\"meta\",\"1\",{\"name\":\"viewport\",\"content\":\"width=device-width, initial-scale=1\"}]]\n"])
```
2023-06-06 08:51:00 +00:00
JJ Kasper
8e9613fae5
Update fetch dynamic error handling (#50822)
Updates to not throw the dynamic server error inside of the patched
fetch as it's typical for fetch errors to be caught and handled and this
error is not meant to be caught by users. This instead throws it during
rendering so we can ensure we catch it instead of users.

x-ref:
https://github.com/vercel/next.js/actions/runs/5182384027/jobs/9339123096
2023-06-05 21:47:01 -07:00
vinay
c2d7bbd1b8
change(create-next-app): Get-pkg-manager logic change. (#50372)
Simplified Get-pkg-manager logic.

---------

Co-authored-by: Steven <steven@ceriously.com>
2023-06-05 19:31:10 -04:00
OJ Kwon
78ed08d88e
fix(next-swc): reenable filesystem cache (#50651)
### What?

Quick fix for the regressions that next.js cannot load plugin due to missing filesystem cache.
2023-06-05 15:42:13 +00:00
vercel-release-bot
b04c70573a v13.4.5-canary.6 2023-06-05 13:13:22 +00:00
Tim Neutkens
8ab38cef41
Improve compile time on large application (#50792)
## What?

While investigating slow compilation for a page on vercel.com in
development I found that there was close to 10 seconds of time
unaccounted for in `.next/trace`. Ran a profile and found that time was
spent in watchpack `batch`, specifically calling `close` many times.
When I tried to debug this further by running unbundled webpack I
noticed the same issue didn't exists.

### Before

<img width="1329" alt="Before"
src="https://github.com/vercel/next.js/assets/6324199/9ace4628-db04-4de7-993f-65aef9dffc55">

### After

<img width="1278" alt="After"
src="https://github.com/vercel/next.js/assets/6324199/55d5e58b-4a27-4235-8dea-723a7a78c117">

## Raw numbers

<table>
<tr>
 <td>Before</td>
 <td>After</td>
 <td>Delta</td>
 <td>Delta (percent)</td>
</tr>
<tr>
 <td>13840 ms</td>
 <td>3580 ms</td>
 <td>-10260 ms</td>
  <td>-74.13%</td>
</tr>
</table>

## How?

Investigated further and found that specifically not minifying watchpack
solved the issue.

<!-- 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 or adding/fixing 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 #

-->
2023-06-05 15:05:54 +02:00
vercel-release-bot
ccee374e2a v13.4.5-canary.5 2023-06-05 07:18:40 +00:00
Tim Neutkens
dd714796d7
Optimize next-app-loader resolving speed (#50745)
## What?

We recently implemented an optimized resolving method for `app` in Turbopack, this ports some of the main changes in that resolving logic to optimize `next-app-loader` which during compilation resolves the tree structure that we use to render in `app-render.tsx`.

Here's the results for a page that is nested a few levels deep on vercel.com using App Router. These results only cover `next-app-loader`, not any modules compiled below it.

### Before

<img width="671" alt="CleanShot 2023-06-03 at 22 36 26@2x" src="https://github.com/vercel/next.js/assets/6324199/0edeb060-2460-4a7d-95a7-1c22ea26a065">

### After

<img width="673" alt="CleanShot 2023-06-03 at 22 55 10@2x" src="https://github.com/vercel/next.js/assets/6324199/f40964fc-b169-4d95-8711-73cbff3ec76a">


## Raw numbers

<table>
<tr>
 <td>Before</td>
 <td>After</td>
 <td>Delta</td>
 <td>Delta (percent)</td>
</tr>
<tr>
 <td>1.620 ms</td>
 <td>76.39 ms</td>
 <td>-1.543.61 ms</td>
  <td>-95.2%</td>
</tr>
</table>

## How?

Changed the resolving logic to use `fileExists`, looping over the provided pageExtensions.
For Turbopack we have a process that does only one pass for generating all trees. That also only reads directories instead of checking individual files, which is even better (<5ms for generating all possible trees) but this PR is a quick win that has a big impact already without refactoring the entire entries generation in webpack.
2023-06-05 06:51:02 +00:00
vercel-release-bot
793d9bfc6a v13.4.5-canary.4 2023-06-02 17:59:01 +00:00
Steven
d13fe04f1e
fix: conditional cookies in draft mode (#50660)
fix NEXT-1246
2023-06-02 17:30:10 +00:00
Will Binns-Smith
e657741b99
next/font: tolerate missing unused fields in capsize map (#50708)
Some font entries in capsize do not include fields like `cap_height` and `x_height`. Since these are unused by next/font, remove these from the serde structure entirely.

Additionally, this makes it so that failing to read or deserialize the capsize map results in an `Error` rather than a `FontFallbackError`, which causes a build failure rather than silently omitting a fallback font. `next/font` should always include this map, and it obscured the real issue here. However, a missing entry in this map _should_ result in omitting a fallback.
2023-06-02 17:10:28 +00:00
Toru Kobayashi
a7afb53a87
fix: a11y issues in the overlay component (HMR) (#49782)
This is a follow-up PR for #49460.

I've fixed some a11y issues at #49460, but I've noticed that Next has other overlay implementations.
So I've applied that into another implementation, which seems to be for HMR overlay.

There is another overlay implementation for Turbopack, so I'll fix it later.

- https://github.com/vercel/next.js/tree/canary/packages/react-dev-overlay/src/internal
- https://github.com/vercel/next.js/tree/canary/packages/next/src/client/components/react-dev-overlay/internal
- https://github.com/vercel/next.js/tree/canary/packages/next-swc/crates/next-core/js/src/overlay/internal

I couldn't get the way to run an application with `--turbo` in the monorepo by `next-with-deps`. I tried `pnpm next-with-deps --turbo ./examples/app-dir-mdx`, but I've got the `Error: Cannot find module 'next/dist/server/node-polyfill-fetch'` error  and couldn't fix it. I tried building `next-swc` by `pnpm build-native`, but couldn't fix the error.
How can I run a local application with `--turbo`?

I expect this is a temporary fix because it would be nice if I could remove duplicated components by removing duplicated components and importing from one place.
I feel `packages/react-dev-overlay` is the right place for this because it's a separate package. But `packages/react-dev-overlay` imports some modules from `next/dist/client/components/react-dev-overlay/`, which is an opposite dependency.

e.g. afddb6ebda/packages/react-dev-overlay/src/client.ts (L3)

I've also found `@next/react-dev-ovrelay` is imported from `package/next` as a combiled package like `next/dist/compiled/@next/react-dev-overlay/dist/client`

- afddb6ebda/packages/next/src/client/dev/error-overlay/hot-dev-client.ts (L31-L37)
- afddb6ebda/packages/next/src/server/dev/next-dev-server.ts (L61-L66)

What do you think? I'll work on this if it makes sense.
2023-06-02 16:18:18 +00:00
Jiachi Liu
062dc38fb9
Fix image loader file emission path for edge runtime (#50683)
[slack-thread](https://vercel.slack.com/archives/C04DUD7EB1B/p1685646762333709?thread_ts=1685643782.265269&cid=C04DUD7EB1B)

Using image in pages SSR emitting the static image files into `<rootDir>/static/media`, which should be located at `<rootDir>/.next/static/media`
2023-06-02 14:01:53 +00:00
Jiachi Liu
1b9fea7a8c
Perf: reduce metadata RSC payload (#50678)
### What
Currently when all the metadata rendered as JSX as server components, all the empty metadata which should be skipped as they're rendered as `null` in JSX, are still included in the RSC payload. This helps reduce the initial html size.

### How

Change the JSX components into function calls, and filter out the nullable component that won't be rendered, then they won't show up in the react tree and be serialized.

Before
```
self.__next_f.push([1, "5:[[[\"$\",\"meta\",null,{\"charSet\":\"utf-8\"}],null,null,null,null,null,null,null,null,null,null,[\"$\",\"meta\",null,{\"name\":\"viewport\",\"content\":\"width=device-width, initial-scale=1\"}],null,null,null,null,null,null,null,null,null,null,[]],[null,null,null,null],null,null,[null,null,null,null,null],null,null,null,null,null]\n"])
```

After
```
self.__next_f.push([1, "5:[[[\"$\",\"meta\",\"charset\",{\"charSet\":\"utf-8\"}],[\"$\",\"meta\",\"viewport:width=device-width, initial-scale=1\",{\"name\":\"viewport\",\"content\":\"width=device-width, initial-scale=1\"}]]]\n"])
```


Closes NEXT-1232
2023-06-02 11:30:42 +00:00
Shu Ding
89a62ac4c8
Remove cssFiles field (#50610)
This field is no longer needed. Although removing it might cause
unnecessary styles being included that could be tree-shaken potentially,
it solves a more critical issue of missing CSS resources: since now CSS
import can be "hoisted" to its parent entry (e.g. a layout), we can't
simply get all used CSS resources from the "leaf entry" (e.g. a page).
2023-06-02 09:24:03 +02:00
Shu Ding
a0314c09cc
Ensure user-installed opentelemetry package has the minimal required version (#50554) 2023-06-02 08:28:29 +02:00
Shohei Maeda
0a61aa18d6
Add new Google-InspectionTool token to known bot UA list (#50467)
Google apparently started using a new bot UA token recently:

- https://kw.linkedin.com/posts/garyillyes_google-crawler-user-agent-overview-google-activity-7064560799226175488-g_nh
- https://developers.google.com/search/docs/crawling-indexing/overview-google-crawlers#google-inspectiontool
2023-06-01 22:58:44 +00:00
Leah
eb85e79941
fix @vercel/turbopack-node types (and more turbopack updates) (#50605)
for #50557 

## Turbopack Updates

* https://github.com/vercel/turbo/pull/5131 <!-- Tobias Koppers - sync
dependencies with next.js -->
* https://github.com/vercel/turbo/pull/5138 <!-- Justin Ridgewell - Fix
`vdbg!` depth and JSON error messages -->
* https://github.com/vercel/turbo/pull/5141 <!-- Leah - fix
`@vercel/turbopack-node` types by adding reference to compiled package
-->
2023-06-01 15:27:13 +00:00
vercel-release-bot
e40e6b64bf v13.4.5-canary.3 2023-06-01 08:46:09 +00:00
JJ Kasper
8253fa0938
Add experimental id handling (#50470)
x-ref: [slack
thread](https://vercel.slack.com/archives/C04TNLL0LSK/p1684879925060159)
2023-05-31 18:09:10 -07:00
Justin Ridgewell
0c3cc04591
[turbopack]: Fix HEAD requests (#50366)
I noticed while testing that we're getting a bunch of 500 errors after #50241 merged. Turns out that `fetchNextData` will [fetch `HEAD` requests](https://github.com/vercel/next.js/blob/cf9591cd/packages/next/src/shared/lib/router/router.ts#L619-L621) for background priority. The problem is that, somewhere, the Next router is draining the body from HEAD responses, leading us to trying to `JSON.parse` an empty string.

This changes the way we return results to the Turbopack router. Instead of `JSON.stringify`ing the result into the body (which will be drained by something), we directly return the result. And it saves us a `stringify` -> `parse` -> `stringify` round trip, so that's nice.

I took the chance to clean up some of our boilerplate code, too.
2023-05-31 23:00:55 +00:00
Max Leiter
0a6a6abcd3
packages/font: run update-google-fonts script (#50608) 2023-05-31 22:31:26 +02:00
Gal Schlezinger
a2c27aab1c
[edge] bump @edge-runtime/* package suite (#49092)
Bumping `@edge-runtime/*` <picture data-single-emoji=":edge-runtime:" title=":edge-runtime:"><img class="emoji" width="20" height="auto" src="https://emoji.slack-edge.com/T0CAQ00TU/edge-runtime/b940e917443aa49f.png" alt=":edge-runtime:" align="absmiddle"></picture>  packages to their latest beta, as we had some huge improvements and big changes on how it works internally.

* Using the latest `undici` which provides a WebSocket implementation
* Less polyfill usage as we load modules in the Node.js realm, and can reuse modules from Node.js as time goes on <picture data-single-emoji=":just-right2:" title=":just-right2:"><img class="emoji" width="20" height="auto" src="https://emoji.slack-edge.com/T0CAQ00TU/just-right2/588cf34d02f4b3bd.png" alt=":just-right2:" align="absmiddle"></picture> 
* `instanceof` checks now work within the realm <picture data-single-emoji=":mind_blown:" title=":mind_blown:"><img class="emoji" width="20" height="auto" src="https://emoji.slack-edge.com/T0CAQ00TU/mind_blown/0186b6f181040126.gif" alt=":mind_blown:" align="absmiddle"></picture>
2023-05-31 08:03:20 +00:00
Shu Ding
6318d50a4a
Fix global SCSS on Node.js <= 14 (#50185)
Fixes #45052. See the comments and related issue thread.
2023-05-31 00:24:08 +02:00
Tobias Koppers
0539b9c96e
update swc_core and turbopack (#50519)
## What

* updates swc_core
* updates turbopack

# Turbopack Changes

* https://github.com/vercel/turbo/pull/5050 
* https://github.com/vercel/turbo/pull/5107 
* https://github.com/vercel/turbo/pull/5094
2023-05-30 15:46:46 +00:00
vercel-release-bot
a4f2bbbe20 v13.4.5-canary.2 2023-05-30 12:00:55 +00:00
Shu Ding
470e48c001
Fix CSS duplication related problems (#50406)
This PR fixes a couple of categories of CSS issues in App Router, that
come from the same root cause.

### 1. Duplicated styles being loaded in different layers

This issue has been described in
https://github.com/vanilla-extract-css/vanilla-extract/issues/1088#issuecomment-1563931144.
If a CSS module (or a global CSS) is referenced in multiple layers (e.g.
a layout and a page), it will be bundled into multiple CSS assets
because each layer is considered as a separate entry.

<img width="1141" alt="CleanShot-2023-05-26-GoB9Rhcs@2x"
src="https://github.com/vercel/next.js/assets/3676859/8e0f5346-ee64-4553-950a-7fb44f769efc">

As explained in that issue, we have to bundle all CSS modules into one
chunk to avoid a big number of requests.

### 2. CSS ordering issues (conflicts)

This is likely causing https://github.com/vercel/next.js/issues/48120.
When the layer-based bundling and ordering logic applies to CSS, it can
potentially cause non-deterministic order. In this example, button A in
the layout should be in blue. However when button B is imported by the
page, button A becomes red. This is an inconsistent experience and can
be hard to debug and fix.

<img width="1090" alt="CleanShot-2023-05-26-Ar4MN5rP@2x"
src="https://github.com/vercel/next.js/assets/3676859/4328d5d7-23af-4c42-bedf-30f8f062d96a">
2023-05-30 13:55:10 +02:00
vercel-release-bot
e8bf78591f v13.4.5-canary.1 2023-05-30 10:12:56 +00:00
Tim Neutkens
f85b45fb31
Optimize Next.js bootup compilation (#50379)
## What?

Currently we use the initial compile to add entrypoints that we know are
going to be used in the application. For example the Next.js runtime,
`react`, `react-dom`, and such. While this was the right default when
Next.js only had `pages`, it's no longer true when both `pages` and
`app` exist. E.g. when you're working on a page using App Router we'd
still compile `pages/_app`, `pages/_document`, and `pages/_error` even
though those would not be used. In case of larger applications (e.g.
Vercel's application) this would mean thousands of extra modules being
compiled even though you don't need them for the page you're looking at.
Similarly we'd compile the Next.js runtime for App Router even when
you're only using `pages`.

This PR changes the handling to only compile the entries that are needed
for the current set of visited pages (on-demand-entries). If that set
only includes `app` entrypoints then the `pages` related files will be
excluded. If the set contains both `app` and `pages` both will be
included. Similarly for `amp`, if you don't use `amp: true` / `amp:
hybrid` the development runtime will not be compiled.

📔 Note: This is specifically for webpack, Turbopack already compiles
everything needed lazily so it didn't have this limitation.

#### Before

```
- event compiled client and server successfully in 1079 ms (306 modules)
- event compiled client and server successfully in 155 ms (306 modules)
```

With opening `/`:

```
- event compiled client and server successfully in 1118 ms (306 modules)
- event compiled client and server successfully in 157 ms (306 modules)
- event compiled client and server successfully in 599 ms (486 modules)
```

Total: 1.874ms (Note: This number is much higher when `pages/_app`
imports many modules).

#### After

```
- event compiled client and server successfully in 118 ms (20 modules)
- event compiled client and server successfully in 65 ms (20 modules)
```

📔 Note: opening the page then causes the Next.js / React runtime to be
compiled ofcourse

```
- event compiled client and server successfully in 115 ms (20 modules)
- event compiled client and server successfully in 57 ms (20 modules)
- event compiled client and server successfully in 1137 ms (361 modules)
```

Total: 1.309ms (Note: This number is not affected by`pages/_app`
importing many modules).

## How?

We can only apply this optimization after we've looped over the list of
on-demand entries, as that has the required metadata. Hence why I went
with deleting the keys for each respective type of entrypoint (`pages`,
`app`, `amp`).

<!-- 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 or adding/fixing 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>
2023-05-30 12:03:24 +02:00
JJ Kasper
679d864c5f
Revert "land: Include charset=utf-8 with x-component Content-Type header" (#50472)
This change isn't necessary per
https://github.com/vercel/next.js/pull/50060#issuecomment-1562897282 and
doesn't alleviate the root issue that was attempting to be addressed
instead that is related to a different issue upstream which is being
investigated.

Reverts vercel/next.js#50314
2023-05-29 10:21:54 -07:00
JJ Kasper
29c2e89bd1
Break up large test suites (#50458)
This breaks up some of our longest running tests which allows more
parallelizing of the tests. This also moves turbopack tests filtering
back to an allow list as it is running a lot of unrelated tests
currently which isn't ideal. We should only be running against tests
that are explicitly testing turbopack e.g. build tests should not be
duplicated in the turbopack group.

```sh
test/integration/css/test/group-1.test.js: 762.655
test/integration/edge-runtime-module-errors/test/index.test.js: 695.309
test/integration/css/test/group-2.test.js: 671.848
test/integration/i18n-support/test/index.test.js: 518.173
test/integration/scss-modules/test/index.test.js: 451.704
test/integration/css-features/test/index.test.js: 417.318
test/integration/css-modules/test/index.test.js: 403.405
test/integration/eslint/test/index.test.js: 381.563
test/integration/500-page/test/index.test.js: 371.134
test/integration/telemetry/test/index.test.js: 367.691
test/development/acceptance-app/ReactRefreshLogBox.test.ts: 335.878
test/integration/create-next-app/templates.test.ts: 334.01
test/integration/scss/test/group-2.test.js: 327.255
test/integration/scss/test/group-1.test.js: 318.574
test/integration/edge-runtime-configurable-guards/test/index.test.js: 313.834
test/e2e/instrumentation-hook/instrumentation-hook.test.ts: 294.618
test/development/acceptance-app/error-recovery.test.ts: 283.355
test/e2e/app-dir/app/vercel-speed-insights.test.ts: 278.242
test/integration/create-next-app/index.test.ts: 272.442
```
2023-05-28 13:59:41 -07:00
Keyan Zhang
8e202610a4
App Router: fix relative query/hash handling in next/link and router push/replace (#49521)
## Problem
Relative hash/query handling in `next/link` (e.g. `<Link
href="#hello">`) is broken in App Router, especially if you're on a
nested route.

This wasn't a problem in `/pages` because the href always get fully
resolved in `<NextLink>`; i.e. if you have `<Link href="#hash" />` on
`/hello`, it'll resolve the href to `/hello#hash` and use that
everywhere.

However, in App Router, `<Link>` no longer uses the current location to
resolve the href:
5451564f36/packages/next/src/client/link.tsx (L450-L457)

Therefore navigating with `new URL(href, location.origin)` will skip the
current path and always apply the relative hash/query to the _root_
route:
5451564f36/packages/next/src/client/components/app-router.tsx (L208-L215)

## Solution
Not 100% sure if this is the best solution, but since `app-router` is
already reading `window.location`, I'm using `location.href` as the base
URL to resolve the href.

I grep'd for `location.origin` and checked other callsites; seems like
only `app-router` deals with user specified hrefs.

Fixes https://github.com/vercel/next.js/issues/42157 &
https://github.com/vercel/next.js/issues/44139, and potentially
https://github.com/vercel/next.js/issues/48554 and
https://github.com/vercel/next.js/issues/22838

## Test Plan
```
pnpm testheadless test/e2e/app-dir/navigation
```

---------
2023-05-28 10:29:00 -07:00
Shohei Maeda
3f164abd25
Add cache-control header on 304 response (#50408)
Next.js currently does not return `cache-control` header on 304 response. Accordingly to RFC, Next.js should include it as well: https://www.rfc-editor.org/rfc/rfc9110#section-15.4.5

> The server generating a 304 response MUST generate any of the following header fields that would have been sent in a [200 (OK)](https://www.rfc-editor.org/rfc/rfc9110#status.200) response to the same request:
> 
> - [Content-Location](https://www.rfc-editor.org/rfc/rfc9110#field.content-location), [Date](https://www.rfc-editor.org/rfc/rfc9110#field.date), [ETag](https://www.rfc-editor.org/rfc/rfc9110#field.etag), and [Vary](https://www.rfc-editor.org/rfc/rfc9110#field.vary)
> - **_Cache-Control_** and Expires (see [[CACHING](https://www.rfc-editor.org/rfc/rfc9110#CACHING)])
2023-05-28 12:44:11 +00:00
JJ Kasper
a3ab542630
Add new build and test workflow (#50436)
This adds new `build and test` and `build and deploy` workflows in favor
of the existing massive `build, test, and deploy` workflow. Since the
new workflows will use `pull_request_target` this waits to remove the
existing workflow until the new one is tested.

While testing this new workflow flakey behavior in tests have also been
addressed. Along with the new workflow we will also be leveraging new
runners which allow us to run tests against the production binary of
`next-swc` so this avoids slight differences in tests we've seen due to
running against the dev binary.

Furthermore we will have a new flow for allowing workflow runs on PRs
from external forks which will either require a comment be checking a
box approving the run after each change or a label added by the team.

The new flow also no longer relies on `actions/cache` or similar which
have proven to be pretty unreliable.

Tests runs with the new workflow can be seen here
https://github.com/vercel/next.js/actions/runs/5100673508/jobs/9169416949
2023-05-27 21:02:31 -07:00
Tobias Koppers
fe6bb0ace9
Refactor internal modules (#50338)
### What?

create internal modules via `context.process` with
`ReferenceType::Internal`

### Why?

We need this for future refactoring where we want to the internal
modules with transitions.

### Turbopack Changes

* https://github.com/vercel/turbo/pull/5095 <!-- Tobias Koppers - allow
to create internal modules via AssetContext -->
* https://github.com/vercel/turbo/pull/5104 <!-- Alex Kirszenberg -
Stable chunk list ident -->
* https://github.com/vercel/turbo/pull/5106 <!-- Tobias Koppers -
followup fix -->

---------

Co-authored-by: Alex Kirszenberg <alex.kirszenberg@vercel.com>
2023-05-27 08:22:15 +02:00
Wyatt Johnson
10b82baf5a
Rename header conversion functions (#50389)
To prevent confusion with`IncomingHttpHeaders`, this renames the functions used to convert back and forth between `OutgoingHttpHeaders` and `Headers`:

- Rename `fromNodeHeaders` to `fromNodeOutgoingHttpHeaders`
- Rename `toNodeHeaders` to `toNodeOutgoingHttpHeaders`
2023-05-26 20:53:34 +00:00
Tim Neutkens
466d199de7
Fix runtime:edge with large next.config.js (#50396)
## What?

Fixes a bug reported on the vercel.com app where `runtime: 'edge'` would
get stuck compiling.

## How?

Ensures we base64 the config when passing it to the loader, instead of
just JSON.stringifying it.

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

## For Contributors

### Improving Documentation or adding/fixing 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 #

-->
2023-05-26 21:35:59 +02:00
Jiachi Liu
b993949155
Upgrade vendored @vercel/og (#50395)
* upgrade `@vercel/og` to latest
* fix precompile script
2023-05-26 19:02:53 +00:00
Wyatt Johnson
a56066c5ab
Pages Route Module (#50070)
This exports the named exports from the user's page route file and
exports a new `routeModule` stub. This stub will be the new rendering
mechanism used for pages within `pages/` and will serve to allow us to
deprecate large chunks of the server code to instead live within the
pages entrypoints.

TLDR;

- Route Modules now accept a `definition` so that they have their full
route definition
- Exports are now hoisted from the userland module by name to prevent
name collisions
- A new `PagesRouteModule` stub was added that will in the future
contain all the pages rendering logic

---------

Co-authored-by: Tim Neutkens <tim@timneutkens.nl>
2023-05-26 19:17:43 +02:00
최지원
2aa68ae287
fix: eslint not ignoring "/app" (#50261)
## Why?
```
src/app/layout.tsx
```
![code](https://github.com/vercel/next.js/assets/120007119/3cc991f8-a96d-4ffb-9f84-4dfdbcac5318)

**eslint[@next/next/no-before-interactive-script-outside-document](https://nextjs.org/docs/messages/no-before-interactive-script-outside-document)**
> `next/script`'s `beforeInteractive` strategy should not be used outside of `pages/_document.js`. 

## How?
- Possibility of pathname starts with "/" on OS X and Linux, so added condition to check file path starting with "/"
- e.g. "/src/app" or "/app"
- Added test code



Passed 
- `pnpm build && pnpm lint`
- `pnpm jest test/unit/eslint-plugin-next/no-before-interactive-script-outside-document.test.ts`

Extends #46609
Fixes #50096
Fixes NEXT-1230
2023-05-26 16:27:42 +00:00
Alex Kirszenberg
62af2007ce
Next.js Turbo build: turbopack-ecmascript-runtime and ChunkData (#50375)
This PR is extracted from https://github.com/vercel/next.js/pull/49942
and mostly contains changes necessary after the Turbopack PR adding the
Node.js production runtime https://github.com/vercel/turbo/pull/4998,
without any of the actual Next Build stuff, in order to be able to merge
both quickly.

* ChunkData moved from tp-dev to tp-core, the ES-serializable part moved
to tp-ecmascript;
* all runtime types moved to tp-ecmascript-runtime

This also upgrades Turbopack to turbopack-230526.2:

* https://github.com/vercel/turbo/pull/5102 <!-- Donny/강동윤 - refactor:
Fix binary bloat caused by `ValueDebugFormat` impl -->
* https://github.com/vercel/turbo/pull/4998 <!-- Alex Kirszenberg -
Node.js production runtime POC -->
2023-05-26 13:38:25 +02:00
Steven
68b34de96e
fix: edge runtime with next/legacy/image (#50343)
- Fixes https://github.com/vercel/next.js/issues/50307
- Related to https://github.com/vercel/next.js/pull/45601

fix #50307
fix NEXT-1237
2023-05-26 13:38:10 +02:00
vercel-release-bot
5d9597879c v13.4.5-canary.0 2023-05-26 10:36:33 +00:00
Shu Ding
3418eaf470
Fix CJS optimizer (#50376)
Avoid the new `VarDecl` being inserted multiple times.
2023-05-26 12:31:51 +02:00
Tim Neutkens
cf9591cd23
Ensure App Router and Pages Router modules can't share chunks (#50327)
## What?

Ensures the name of the chunk is not the same between two modules in different layers.
E.g. if you import 'button-library' in App Router and Pages Router we don't want these to be bundled in the same chunk as they're never used on the same page.

## How?

Added the layer to the chunk name hash generation in splitChunks. Ensures the two modules don't have the same chunk name generated, as discussed with @sokra.

Follow-up to #50324
2023-05-25 23:14:35 +00:00
Jiachi Liu
5831d0c124
Fix static metadata routes runtime when root layout is in edge runtime (#50351)
Since the static metadata routes should always be static that can be
optimized, they should be marked as default runtime (or basically no
runtime). This PR change the runtime detection, if it's a static
metadata route file, its runtime will be erased.

So that it won't be picked up by `edge-app-route-loader` and then by
`next-image-loader` which emits the unexpected static file

Fixes NEXT-1238
2023-05-25 15:39:57 -07:00
vercel-release-bot
26835bdba5 v13.4.4 2023-05-25 22:02:44 +00:00
vercel-release-bot
8c17a4b688 v13.4.4-canary.13 2023-05-25 21:31:39 +00:00
조상현
2b5205a910
makeDir should use func (#50136)
Co-authored-by: Steven <229881+styfle@users.noreply.github.com>
2023-05-25 20:11:27 +00:00
vercel-release-bot
0c968b8e2a v13.4.4-canary.12 2023-05-25 18:50:55 +00:00
Shu Ding
592f592b07
Fix SWC loader options for files outside of RSC layers (#50341)
The React Server Component transform of SWC shouldn't be enabled for
files that are not part of "app layers", for example middleware.
2023-05-25 19:49:26 +02:00
vercel-release-bot
3870abf049 v13.4.4-canary.11 2023-05-25 16:20:33 +00:00
Tobias Koppers
187d1bff40
remove allowlist, only use denylist, enable newly passing tests (#50325)
### What?

* remove allowlist
* add script to print enabled test cases
* enable test suites that turbopack is newly passing
2023-05-25 15:37:28 +02:00
Shu Ding
25ce787d76
Fix missing error when using Actions on the client layer without enabling the feature flag (#50257)
If using Server Actions on the client layer without enabling the
`serverActions` feature, the build should error. Add a test case to
ensure #50199 works.
2023-05-25 14:22:27 +02:00
Jiachi Liu
8725b6c376
Add missing react-dom/client alias (#50324)
Fixes #50312
fix NEXT-1235
2023-05-25 12:10:02 +00:00
Tobias Koppers
46369f5746
do not apply sass loader on existing loaders (#50308)
follow up for #50259

---------

Co-authored-by: Justin Ridgewell <justin@ridgewell.name>
2023-05-25 13:42:22 +02:00
Tobias Koppers
06f505c78b
Parallelize Turbopack CI tests (#50292)
### What?

Parallel jobs

### Why?

Timeouts otherwise


Co-authored-by: JJ Kasper <22380829+ijjk@users.noreply.github.com>
2023-05-25 07:46:02 +00:00
vercel-release-bot
831a1a99c3 v13.4.4-canary.10 2023-05-25 04:20:36 +00:00
JJ Kasper
e09efd5e5c
land: Include charset=utf-8 with x-component Content-Type header (#50314)
Lands https://github.com/vercel/next.js/pull/50060 with lint fixes and
updated tests.

Closes: https://github.com/vercel/next.js/pull/50060

---------

Co-authored-by: Leah Lundqvist <leah@pigeon.sh>
2023-05-24 21:05:12 -07:00
JJ Kasper
027aa72f47
Fix catch-all edge app route (#50313)
This ensures we properly normalize app pages in the `web-server` so that
it doesn't fail to match/interpolate properly.

Fixes: https://github.com/vercel/next.js/issues/43384
2023-05-24 20:30:54 -07:00
Justin Ridgewell
12e22edd74
[turbopack]: Serve _devMiddlewareManifest.json from router (#50241)
This change allows the Turbopack's node router to serve
`_next/static/development/_devMiddlewareManifest.json` file, which is
just the matchers for middleware routes. This is usually handled by the
node dev server anyways, but we were filtering out the route so that
Turbopack could handle it.

But, Turbopack doesn't implement the route matching logic at all, it's
all handled by our node router. So Turbopack can't know what the
middleware matchers are. Having the router just handle this like the
normal dev server is both easy and efficient (I don't want to spin up
_another_ node instance just to transform the matchers into the expected
format).

Fixes WEB-979

---------

Co-authored-by: JJ Kasper <jj@jjsweb.site>
2023-05-24 17:55:29 -07:00
Jiachi Liu
1079c10064
Alias next/server for edge runtime (#50268)
* For edge runtime, map `next/server` to esm assets to get benefit from
tree-shaking
* Mark process.turbo flag as `false` when running with webpack

Closes NEXT-1212

Compare with canary (13.4.4-canary.8)

#### Middleware

##### before vs after
<img width="319" alt="image"
src="https://github.com/vercel/next.js/assets/4800338/ffa3e744-8f14-4c61-9f5a-ccd04b8911f2">
<img width="317" alt="image"
src="https://github.com/vercel/next.js/assets/4800338/fc974a39-49f3-439a-966c-07af3c71db05">



#### Edge route

##### before vs after
<img width="313" alt="image"
src="https://github.com/vercel/next.js/assets/4800338/bea6e7bb-5875-4a6b-899f-94ad6a8df902">

<img width="314" alt="image"
src="https://github.com/vercel/next.js/assets/4800338/1783fb03-b473-496a-bb97-fa613fe58d7a">
2023-05-24 15:34:29 -07:00
vercel-release-bot
ed60646a19 v13.4.4-canary.9 2023-05-24 22:21:36 +00:00
Tobias Koppers
e15eb2a443
fix sass handling after refactoring (#50259)
### What?

Push sass into the css pipeline
2023-05-25 00:10:51 +02:00
Maia Teegarden
e257068b5f
Add root detection utils (#50305)
A previous
[PR](https://github.com/vercel/next.js/pull/49110#discussion_r1183282878)
tried to reuse `rawNextConfig.experimental.outputFileTracingRoot` before
invoking Turbopack, but that will always be undefined because
`assignDefaults` hasn't been called yet. This creates a shared utility
to be reused.
2023-05-24 14:51:47 -07:00
JJ Kasper
a7a9777ddc
Update unstable_cache key to include args (#50301)
As discussed this includes arguments passed to `unstable_cache` to
cacheKey automatically so users don't have to remember to do this
manually.
2023-05-24 13:46:48 -07:00
JJ Kasper
1619a6a5a9
Update server invoke-request (#50296)
Follow-up to https://github.com/vercel/next.js/pull/50293 we can now
avoid this normalizing which isn't as reliable as being able to rely on
`localhost` directly since we can't assume it maps to `127.0.0.1`
always.

x-ref:
https://github.com/vercel/next.js/actions/runs/5072034311/jobs/9109241689
2023-05-24 12:41:07 -07:00
JJ Kasper
47546ddccc
Update next start listening to behave consistently (#50293)
Fixes next start listening as it currently behaves in-consistently
between dev and start, this shouldn't break any existing behavior as the
default is to listen on all interfaces and if it needs to be locked down
it still can be.

x-ref:
https://github.com/vercel/next.js/actions/runs/5065560220/jobs/9094296465
2023-05-24 11:06:41 -07:00
Javi Velasco
aa91de56ce
Remove static analysis of process.env (#50260)
Since there is no longer a limitation that requires us to static analyze
`process.env`, this PR removes it from the build process and updates the
corresponding documentation.
2023-05-24 08:19:02 -07:00
vercel-release-bot
f1df0d009b v13.4.4-canary.8 2023-05-24 11:08:12 +00:00
Shu Ding
18ba2085b4
Fix edge case in the CJS optimizer (#50258)
Previously we are ignoring idents in all var declarators in the check,
so it's still possible to fail in some edge cases. CC @kdy1
2023-05-24 13:02:22 +02:00
Donny/강동윤
fcfd63065b
feat(next-swc): Add CJS optimizer again (#50249)
### What?

This reverts commit 6ebc725fe6 / #50247.

### Why?

#49972 is reverted due to bugs, and I'm retrying it.

### How?

Closes WEB-1072
Closes WEB-1097
Closes NEXT-1156 (as it's reopened by the revert PR)

fix #48469

---------

Co-authored-by: Shu Ding <g@shud.in>
2023-05-24 09:38:31 +02:00
vercel-release-bot
0e339a8542 v13.4.4-canary.7 2023-05-24 06:12:54 +00:00
JJ Kasper
b5e8d6531b
Fix free port handling (#50248)
Follow-up to https://github.com/vercel/next.js/pull/48019 ensures we
don't use arbitrary ports by incrementing favoring always getting a
fresh free port instead. Also favors exact address for internal IPC
requests instead of `localhost`.
2023-05-23 22:13:10 -07:00
JJ Kasper
6ebc725fe6
Revert "feat(next-swc): Implement CJS optimizer" (#50247)
This seems to be failing with the WASM builds so this reverts to allow
further investigation

x-ref:
https://github.com/vercel/next.js/actions/runs/5062818601/jobs/9088828339
x-ref:
https://github.com/vercel/next.js/actions/runs/5061364458/jobs/9085596546
x-ref:
https://github.com/vercel/next.js/actions/runs/5062868910/jobs/9092170727

Reverts vercel/next.js#49972
2023-05-23 21:45:37 -07:00
vercel-release-bot
fce5fa6ff0 v13.4.4-canary.6 2023-05-23 23:07:34 +00:00
Jiachi Liu
130fe65bde
Fix alias for react-dom/server (#50238)
A bad alias was introduced in #50128

Fixes #50225
2023-05-23 16:00:59 -07:00
Donny/강동윤
ec8bf53907
feat(next-swc): Implement CJS optimizer (#49972)
### What?


Implement a CJS optimizer for next-swc


### Why?

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

Assuming most CJS files are transpiled from ESM, we can mimic
tree-shaking using an AST transform.

### How?

Closes WEB-1072
Fixes #48469


fix NEXT-1156

---------

Co-authored-by: Shu Ding <g@shud.in>
2023-05-23 21:38:07 +02:00
vercel-release-bot
ba9aa63417 v13.4.4-canary.5 2023-05-23 19:34:54 +00:00
Tobias Koppers
bf7a556204
enable more test cases for turbopack (#50154)
### What?

Enable more test cases to run with turbopack

### Why?

These test suites are passing and are not flaky.
2023-05-23 20:21:56 +02:00
Cowboy Ho
90331f38cc
fix: NODE_OPTIONS='--inspect' in next dev for debugging (#48019)
## Bug

This fix closes #47083 issue 
This fix closes #47561 issue
This fix closes #48376 issue
**Invalid repetition PRs:** #47671 (this PR changing expired code)
(This issue still exist on
[v13.4.3-canary.1](https://github.com/vercel/next.js/releases/tag/v13.4.3-canary.1)

- [x] Related issues linked using `fixes #number`

### What?
When running `NODE_OPTIONS='--inspect' next dev`, 
the render server didn't start with `--inspect`. 
In some cases, 
the `--inspect` flag will be passed when `__NEXT_DISABLE_MEMORY_WATCHER`
was set.

### Why?
Since #47208 revamped some startup processes, the `NODE_OPTIONS`
environment parameter is not passed down to the render server worker.

### How?
Just add back the original startup process.


![image](https://user-images.githubusercontent.com/14261588/230398898-791e6909-6f4c-493b-937d-058a7b788849.png)


link NEXT-1176

---------

Co-authored-by: JJ Kasper <jj@jjsweb.site>
2023-05-23 11:03:08 -07:00
Shu Ding
1a40651267
Add special route types to the link type declaration (#50066)
This PR adds generated type definitions for `Link` hrefs with only search, hash or with a protocol.

Closes #49825.
fix NEXT-1203
2023-05-23 17:36:09 +00:00
Tobias Koppers
33b8e6157f
change static path to /_next/static/media (#50207)
### What?

align output path of turbopack and webpack

### Why?

passing test cases

### Turbopack Changes

* https://github.com/vercel/turbo/pull/5072 <!-- Tobias Koppers -
improve asset path -->
2023-05-23 18:39:27 +02:00
vercel-release-bot
9eaf4f5dc8 v13.4.4-canary.4 2023-05-23 16:03:50 +00:00
Jesse Koldewijn
2fa58c3a88
fix: Added blockfrost-js, lucid-cardano & mongoose package to srvExtPackages to prevent issue #49783 from happening. (#49938)
fixes #49783

### What?
Added the following packages to the server component exclusion list
which prevents these packages from going through the currently default
compile pipeline for apps that use the App Router. Packages added are:
"@blockfrost/blockfrost-js", "@jpg-store/lucid-cardano" and "mongoose".
(For instance, mongo was already in this exclusion list)

### Why?
These packages are required by the
"@emurgo/cardano-serialization-lib-nodejs" packages and break when not
added to this list while using the app router.

### How?
I've added these packages to the server-external-packages json file in
the Next.js package's lib directory.
2023-05-23 17:41:59 +02:00
Tim Neutkens
eba9e39ea4
Ensure NEXT_DYNAMIC_NO_SSR_CODE has a unique name (#50219)
## What?

Ensures `NEXT_DYNAMIC_NO_SSR_CODE` has a unique error code value, this
accidentally had the value for dynamic server usage (e.g. calling
cookies()) which caused the warning to be shown as shown in #48442.

## How?

Changed the digest value to something unique.


Fixes NEXT-1125
Fixes #48442

<!-- 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 or adding/fixing 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 #

-->
2023-05-23 08:37:57 -07:00
JJ Kasper
0718dbb7a5
Fix static workers distributing (#50194)
This removes the `computeWorkerKey` from our static workers as this
doesn't work in practice as efficiently as we hoped since a single page
can have thousands of paths to render which won't be distributed to
separate workers if the same worker key is returned.

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

**Before**

![before](https://github.com/vercel/next.js/assets/22380829/da1e0a03-8b15-42a6-a2ac-6e4ff29c350d)


**After**

![after](https://github.com/vercel/next.js/assets/22380829/b27354f6-bcdb-4cad-888c-7d6b143e0ee2)
2023-05-23 08:32:05 -07:00
Tobias Koppers
3d40cb01ab
refactor webpack loaders (#49535)
### What?

* allow to apply existing pipeline
* change webpack loader key to glob for more flexibility
* add test cases
* add special error message when using the old config syntax

Old config:

```js
experimental: {
 turbo: {
  loaders: {
   ".mdx": ["mdx-loader"]
  }
 }
}
```

New config

``` js
experimental: {
 turbo: {
  rules: {
   // key is a glob now
   // normal syntax will treat the result as ecmascript code
   "*.mdx": ["mdx-loader"],
   // glob allows more advanced matching
   "./images/**/*.png": {
    loaders: ["image-optimize-loader"],
    // result of loader will be handled in other steps
    // under the same name/path (here .png)
    // This will use the existing .png pipeline (static asset)
    // It might also use other rules matching .png.
    as: "*"
   },
   "*.generate-image.js": {
    loaders: ["image-generation-loader"],
    // It also possible to pass this under a different name
    // into the pipeline. Here it will treat the result as png image
    as: "*.png"
   }
  }
 }
}
```

### Why?

More flexibility and allowing to use the builtin module handling over
non-js types.

fixes WEB-1009

### Turbopack changes

* https://github.com/vercel/turbo/pull/4955 <!-- OJ Kwon -
refactor(turbopack-ecmascript): deprecate enable_emotion, enable_styled*
-->
* https://github.com/vercel/turbo/pull/4880 <!-- Tobias Koppers -
refactor webpack loader execution -->

---------

Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2023-05-23 17:21:25 +02:00
Tim Neutkens
03d6dcc08d
Move debugging variable into useEffect (#50210)
## What?

Ensures the debugging variables are only assigned when the values
change.

<!-- 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 or adding/fixing 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 #

-->
2023-05-23 13:41:01 +02:00
vercel-release-bot
fa9c6021b4 v13.4.4-canary.3 2023-05-23 11:17:35 +00:00
OJ Kwon
2fc0160a26
test(turbopack): run next.js integration tests with denylist (#50172)
<!-- 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 or adding/fixing Examples

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

### Fixing a bug

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

### Adding a feature

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



## For Maintainers

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



### Why?

### How?

Closes NEXT-
Fixes #

-->

### What?

WEB-1086.

This PR flips the way running next.js integration test with Turbopack,
instead of using allowlist to run selectively enabled test now uses
denylists. The immediate effect is now any new test being added (as a
new file) will be executed with Turbopack by default, and should be
manually excluded if it fails.

Still, the number of tests we run remains same.
2023-05-23 10:55:33 +02:00
Justin Ridgewell
1e86c8b5be
Add the node condition to import resolution (#50007)
This adds the `node` condition, so that importing a node module that
uses `exports` with a `node` specified will prioritize that file. Eg,
[uuid](https://github.com/uuidjs/uuid/blob/4de23a60/package.json#L25-L31)'s
`package.json` will now resolve to the `./dist/esm-node/index.js` in our
SSR builds, instead of the default `./dist/esm-browser/index.js`

Fixes WEB-1051
2023-05-23 08:43:34 +00:00
Tobias Koppers
df85ad1ec0
add tracing for turbopack (#49920)
### What?

adds `NEXT_TURBOPACK_TRACING` env var to enable tracing. Writes into `.next/trace.log`

There are 4 presets:

* `NEXT_TURBOPACK_TRACING=overview` gives a overview of requests and modules processed.
* `NEXT_TURBOPACK_TRACING=next` above plus details for next.js
* `NEXT_TURBOPACK_TRACING=turbopack` above plus details for turbopack
* `NEXT_TURBOPACK_TRACING=turbo-tasks` above plus details for turbo-tasks

Published release builds will only allow `overview` to work, since all detailed instrumentation is statically disabled.

see https://github.com/vercel/turbo/pull/4966 for more details

### Why?

get more insight into build times

### Turbopack changes

* https://github.com/vercel/turbo/pull/4995 
* https://github.com/vercel/turbo/pull/5049 
* https://github.com/vercel/turbo/pull/5053 
* https://github.com/vercel/turbo/pull/4966
2023-05-23 05:25:56 +00:00
vercel-release-bot
3b6f286d4c v13.4.4-canary.2 2023-05-23 04:29:21 +00:00
Jiachi Liu
6f2e140037
Fix pages react alias (#50128)
Fix react and react-dom aliases are not properly set for `pages/`

* Remove alias react-dom internals to `{}` in edge runtime as we're using server rendering stub as alias
* Add `react$`, `react-dom$` missing aliases
* Only apply alias to builtin react/react-dom when it's app dir assets.
* Add `react|react-dom/package.json` resolving to require-hook
* Fix hmr issue that sometimes it will perform a reload when a hard navigation is triggered
2023-05-22 23:37:27 +00:00
JJ Kasper
f4bb4aa73c
Fix react fetch deduping without next cache (#50187)
This ensures we don't reference the wrong fetch global bypassing react's
patched fetch so that it can properly fallback to react's fetch deduping
when next cache is disabled for a specific fetch.

x-ref: [slack
thread](https://vercel.slack.com/archives/C042LHPJ1NX/p1684518670927189?thread_ts=1682974724.765039&cid=C042LHPJ1NX)
fixes: https://github.com/vercel/next.js/issues/50031
2023-05-22 16:13:02 -07:00
Steven
f56722c971
fix: add missing draftMode type to GetServerSidePropsContext (#50184)
This `draftMode` prop was missing from the previous PR:

- https://github.com/vercel/next.js/pull/48669 

It was added on `GetStaticPropsContext` but not on
`GetServerSidePropsContext` so this PR fixes it.

---------
2023-05-22 15:16:12 -07:00
JJ Kasper
a1633948ad
Add warning for edge with force-static (#50182)
Currently the edge runtime does not support static generation so this adds a warning when `force-static` is leveraged with `edge-runtime` as it will cause unexpected behavior. Support is being investigated so this isn't a hard error at the moment. 

x-ref: [slack thread](https://vercel.slack.com/archives/C03S8ED1DKM/p1684783403551589)
2023-05-22 20:54:15 +00:00
JJ Kasper
91e3c007cf
Fix env variables set in next.config.js (#50179)
This ensures we properly persist env values set from `next.config.js`
across workers.

Fixes: https://github.com/vercel/next.js/issues/49541
2023-05-22 13:29:41 -07:00
vercel-release-bot
789f253e7a v13.4.4-canary.1 2023-05-22 15:12:14 +00:00
Tim Neutkens
21e677e95b
Failing tests for 404 back/forward (#50047)
## What?

After landing #49855 I found a few more edge cases with not-found not
behaving as expected:
- When navigating directly to a not-found page (e.g. `/testabc`) the
error boundary would not reset as there were multiple levels being
triggered at the same time.
- When running in production navigating back/forward to the not found
page caused the page to become empty

Both issues are fixed by this PR. I've added tests for both.

## How?

- Ensures `asNotFound` is not set on the layout-router, it causes all
levels to trigger not-found, even though only app-router needs it
- Ensures navigations to 404 are always a mpaNavigation (browser
navigation) instead of trying to do a client-side navigation (mirrors
what we do in `pages`)

Fixes NEXT-1209
Fixes NEXT-1218
Fixes #49823

<!-- 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 or adding/fixing 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 #

-->
2023-05-22 17:04:36 +02:00
Tobias Koppers
309bfdb3fd
update test snapshots (#50159)
### What?

follow up for https://github.com/vercel/next.js/pull/50137

### Why?

I accidentally merged the PR with broken tests
2023-05-22 14:49:59 +02:00
Abhishek Kadam
a8621c7bb2
[create-next-app]: respecting the user's init.defaultBranch git con… (#49960)
### What?
This commit makes sure `create-next-app` doesn't ignore user's git configuration (`init.defaultBranch`).
### Why?
Hard coding configurations of a user is annoying (for the user).


Co-authored-by: Steven <229881+styfle@users.noreply.github.com>
2023-05-20 23:53:58 +00:00
OJ Kwon
77a3172b8e
feat(turbopack): initial sass-loader support (#49882)
<!-- 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 or adding/fixing Examples

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

### Fixing a bug

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

### Adding a feature

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



## For Maintainers

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



### Why?

### How?

Closes NEXT-
Fixes #

-->

### What?
WEB-654.

This PR attempts to implement initial sass support in turbopack, via
sass-loadder. Internally it points to sass-loader compiled in next.js
(`next/dist/sass-loader..`) with next.config.js's option. Still it is
not a complete implementation, for example sourceMap is not supported by
upstream turbopack.

PR requires turbopack side changes as well.
2023-05-20 00:38:12 +00:00
vercel-release-bot
804ca09383 v13.4.4-canary.0 2023-05-19 22:20:30 +00:00
Karl Horky
347da42eb1
Add optional generic parameter to NextResponse (#47526)
Fixes #45943

### What?

Allow for type checking the return type of a Route Handler in the `app/`
directory:

[TypeScript
Playground](https://www.typescriptlang.org/play?#code/MYewdgzgLgBAkgOQCoFEBKCCCAZAyjAXhlwE8BbAIxABsAKAcgEswoBTAJzAENqZ3WIAB3ARW9AJQAoSawAew9rGDUuECDARyoaAcMisAPACEQAExKEYAVzABrMCADuYAHwwtrMKfU6hI1jAA3pIwMADaiKgYOLgAugBcQSGhMCbmAPyJaSQANMkAvtKhoJBQ7FbAUCDstFQZWWYkcGCMsAA+MGBW1NQ5MMytib56os2tloH54kkpMBBWghy1jX0DUFLJoVAAFowQEcjoWHixE4WhhcnQXFCMwDAAVhDgBgBSz2DZLsvmie-g2VWLSgmRgw38Y3WiU0sm0un8bw+XxmKQA9KiYAABKAQAC0ckWlXx7HY1RgSF26j2nRAsGYMGojAoqNMIDIfEYAHNtrAHI4+lwvDBHAFgIL6LAuFZOWRPHSoAA6TYwErQPjw-RDDWiSzg-QKp7gH65frAqSzfhQKycTqsRwaLR60S0fh+fV1E2ukasc0wQqXAnVWAAMxslUY4BgAHEUEhaOJoY7tYZAlwKMBEgBGABMAGZ8m5AjB0dHPBw7jAuOxOVZZSwYIJVKJTMlGMGYLQALI3bYK9iC1lkeMwNwABgVAFZpkXlZbrWAHbCnawDR9aKn01m81NixjAKDkNPcJOqiQ9Kuq-EqBWSc5tMLhbtEq6NgVMrGDiXosm-9B3JYPHCkuwp6NKaoAkqwV4BvIQYwKGYDhpGMZINm8aJkuyZBLuGggDAnJluwFZVjWdawFYzatu2XY9n2A5ssOY6TtOMCzqwVp3kmj4roaYDrmmGYwDm+bTP+h6ASelZgBYZ5cMAwCsIIbAthcN5sfOi4Pt6z68a+76ft+si-iJ+5icewGSdJoGyfJimsC2hRAA)

![Screenshot 2023-03-25 at 16 59
51](https://user-images.githubusercontent.com/1935696/227728328-43350f50-5067-4d27-8701-000569e757cc.png)

### Why?

There is currently no nice way to enforce the return type of a Route
Handler in the `app/` directory.

This is possible with `NextApiResponse` in the `pages/` directory,
because of this PR:

- https://github.com/vercel/next.js/pull/7841

### How?

This implements a generic parameter for the `NextResponse` class, which
can be used to pass a type argument when setting the return type for a
Route Handler.

<!-- 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 or adding/fixing 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: Shu Ding <g@shud.in>
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2023-05-19 23:40:06 +02:00
JJ Kasper
d6a3e7d07b
Remove node-sass from peerDependencies (#50065)
This removes `node-sass` from being explicitly marked as a peer
dependency as it's not recommended anymore and `sass` is already marked
as a `peerDependency`, further when auto-install peer dependencies is
enabled it can cause this to be pulled in unexpectedly
2023-05-19 13:10:10 -07:00
Justin Ridgewell
3558208df3
Add x-forwarded-* headers to turbopack renders (#50012)
This PR forwards the [new
`ServerInfo`](https://github.com/vercel/turbo/pull/5018) struct to
Turbopack's rendering processes, allowing it to initialize the
requesting headers with the `x-forwarded-*` headers. These headers, and
`x-forwarded-proto` in particular, are necessary for [NextAuth to
work](https://github.com/nextauthjs/next-auth/blob/f62c0167/packages/next-auth/src/core/index.ts#L73-L76).

These headers are initialized in the non-turbo server via
[`http-proxy`](https://github.com/http-party/node-http-proxy/blob/9b96cd72/lib/http-proxy/passes/web-incoming.js#L58-L86).

Fixes WEB-1064
2023-05-19 12:57:02 -07:00
Jiachi Liu
702eb17638
Fix client references extraction of CJS exports analysis (#50059)
client refs are not correctly extracted as we're using regex to get the exports names from cjs file. The regex was extracting some bad names from the code source, this PR fixes the regex to make sure they extract the correct content

Fixes NEXT-1213
2023-05-19 19:42:46 +00:00
Shu Ding
d381d581cf
Fix types of cookies() (#50052)
As explained in the comments, the `cookies()` API is a mix of request and response cookies. For `.get()` methods, we want to return the request cookie if it exists. For mutative methods like `.set()`, we return the response cookie type instead.
fix #50049
fix NEXT-1211
2023-05-19 19:02:16 +00:00
Shu Ding
26ea9c6333
Always defer close tags to be the suffix of body stream (#50056)
Currently the suffix logic is for pages so nothing happens in app dir. This PR changes it to **always** apply the `createSuffixStream(closeTag)` transform, to defer `</body></html>` to the end of the stream.
fix #48372
fix NEXT-1200
2023-05-19 18:25:04 +00:00
Jiachi Liu
f0d0811a42
Fix default metadata is missing in root not-found (#50044)
* Adding default metadata to root not found under root layout
* Refactor the tests a bit, previously it only checks if the text existed in html, it actually exisits in flight response

Fixes #49979
Closes NEXT-1207
2023-05-19 17:50:03 +00:00
Justin Ridgewell
448b74291e
[turbopack]: Update renamed SubpathValue (#49636)
https://github.com/vercel/turbo/pull/4895 renamed `ExportsValue` into
`SubpathValue`

---------

Co-authored-by: Tobias Koppers <tobias.koppers@googlemail.com>
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2023-05-19 18:46:10 +02:00
Jiachi Liu
0800ea7eec
Error in next export when serverActions is enabled (#50039)
Reland #49959 as it was reverted in #50019

* Only error when runing `next export` or `output` is "export"
* Add e2e test


Closes NEXT-634
2023-05-19 17:53:21 +02:00
Shu Ding
771141dcc9
Server Actions: Fix member expr in closure captured values (#50020)
For static member expressions like `foo.bar`, we currently treat it as one whole Ident `foo.bar` and pass it over the `$$bound` array as one value. That causes a problem where the Ident inside the function body needs to be converted, because it can no longer access to `foo`.

Closes #49985. 
fix NEXT-1206
2023-05-19 15:05:59 +00:00
Wyatt Johnson
1dcff1da62
Pages Module Transition (#49962)
This serves to create the loader that will allow us to transition more
of the rendering logic into each of the bundled entrypoints. This only
applies to pages routes inside the `pages/` folder in the node
environment.

fix NEXT-985

---------

Co-authored-by: JJ Kasper <jj@jjsweb.site>
2023-05-19 08:45:18 -06:00
OJ Kwon
dd85daaf4e
test(turbopack): script to sync latest test lists (#50008)
<!-- 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 or adding/fixing Examples

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

### Fixing a bug

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

### Adding a feature

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



## For Maintainers

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

### What?

### Why?

### How?

Closes NEXT-
Fixes #

-->

This PR adjusts manifests for the next.js test with Turbopack, as I
found upstream test keep changing and need to sync its latests state
into the manifest.

Manifest is now .js file contains 2 arrays, one for the enabled, and
others for the disabled. Disabled doesn't mean it's always failing
though.
2023-05-19 09:10:29 +02:00
vercel-release-bot
66a0083235 v13.4.3 2023-05-19 06:20:19 +00:00
vercel-release-bot
f299b0d86e v13.4.3-canary.3 2023-05-19 03:14:37 +00:00
Steven
4b4925f4e8
fix: set cookies followed by redirect() (#49965)
- Fixes #49237 


fix NEXT-1120

Co-authored-by: Wyatt Johnson <633002+wyattjoh@users.noreply.github.com>
2023-05-19 00:17:19 +00:00
JJ Kasper
ea9b1f5ebc
Remove custom handling for prebundled react env (#49954)
This removes the previous handling for the prebundled react env we were
setting in favor of https://github.com/vercel/vercel/pull/9974

We need to wait to land this until
https://github.com/vercel/vercel/pull/9974 has been rolled

Fixes: https://github.com/vercel/next.js/issues/49169
Fixes: https://github.com/vercel/next.js/issues/49753
x-ref: https://github.com/vercel/next.js/issues/48948
2023-05-18 16:51:18 -07:00
Tim Neutkens
c2da56e194
Fix going back to page after applying hash link (#50006)
## What?

@steven-tey noticed that on upstash.com that scrolling to hash keeps
happening regardless of the hash being set:

- Open site
- Click `Pricing` which adds `#pricing` and scrolls to the
`id="pricing"`
- Click `About` 
- Click on the logo

You'll notice that navigating back to the homepage ends up scrolling to
the `id="pricing` instead of to the top of the page.

## How?

This happened because we didn't reset the `hashFragment` and
`segmentPaths` for scrolling when scroll was applied, which means it
would keep that value in the state and would be applied as such on
navigation.

This PR ensures that besides setting `apply` to `false` we also reset
the `hashFragment` and `segmentPaths`.

Fixes NEXT-1205

<!-- 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 or adding/fixing 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>
2023-05-18 16:33:58 -07:00
Steven
783acc59a0
fix: warning fetch for [object Request] specified (#50003)
This PR fixes a warning that previous looked like the following:

```
Warning: fetch for [object Request] specified "cache: default" and "revalidate: 60", only one should be specified.
```
2023-05-18 23:20:05 +00:00
Steven
0a81cc0f16
Revert "Error in next export when serverActions is enabled" (#50019)
Reverts vercel/next.js#49959 since the PR [was failing CI](https://github.com/vercel/next.js/actions/runs/5015634314/jobs/8991545593#step:6:179)
fix NEXT-634
2023-05-18 22:26:02 +00:00
Tim Neutkens
babe50364e
Reset not-found and error boundary when navigating (#49855)
## What?

Currently the error boundary state does not reset when a navigation
happens because the `key` does not change. Because of that navigating
using next/link when the error boundary is in the open state ends up not
rendering the contents of the new navigation, instead it keeps the error
boundary contents.

## How?

This PR uses a pattern that is recommended in the React docs (setState
during render) to reset the error boundary if the `usePathname` value
has changed, it is used as a proxy for a new navigation.

Fixes #47862
Fixes NEXT-963
Fixes #49736
Fixes #49732
Fixes #49599


<!-- 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 or adding/fixing 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 #

-->
2023-05-18 22:06:57 +02:00
Shu Ding
eaea2084de
Error in next export when serverActions is enabled (#49959)
Since a server is always required for Server Actions, they won't work
with static exports at all.
fix NEXT-634

Co-authored-by: Jiachi Liu <inbox@huozhi.im>
2023-05-18 17:56:02 +02:00
Shu Ding
c7e5d76717
Fix custom server React resolution with app dir and pages both presented (#49805)
If running Next.js in the custom server with both app and pages directories presented, a standalone server needs to serve all traffic and the server running in main thread should be a no-op. (cc @ijjk).

Fixes the problem described here: https://github.com/vercel/next.js/issues/49355#issuecomment-1537536063.
2023-05-18 01:31:43 +00:00
Jiachi Liu
a09dc5f268
Add @vercel/og to external server packages (#49944)
`@vercel/og` should also be treated as external package as precompiled one (x-ref: #48844)

As it's ESModule, it could escalate the importee modules to become ESM as well, then `require()` won't be able to load the proper module, we need to switch to await the require result (just like **dynamic import**) for node module loader

[slack thread](https://vercel.slack.com/archives/C03KAR5DCKC/p1683577269970609?thread_ts=1683569728.697039&cid=C03KAR5DCKC)
2023-05-17 21:23:31 +00:00
JJ Kasper
f3ae39530a
Update default for appDocumentPreloading config for minimalMode (#49952)
This config shouldn't be needed in minimal mode as code is evaluated
just-in-time
2023-05-17 14:00:59 -07:00
vercel-release-bot
20db2f3b0d v13.4.3-canary.2 2023-05-17 16:59:53 +00:00
JJ Kasper
917b9aefeb
Move build workers count change behind flag (#49937)
It seems the build workers count calc change that was made in https://github.com/vercel/next.js/pull/47823 caused a regression in performance as we aren't utilizing as many workers as we previously did so this moves that change behind an experimental flag while additional tweaking is investigated. 

x-ref: https://github.com/vercel/next.js/pull/47823
Fixes: https://github.com/vercel/next.js/issues/49593
2023-05-17 15:54:42 +00:00
Alex Kirszenberg
91861210a7
Port sorted-routes.ts to Rust (#48334)
`getSortedRoutes` is used in the `BuildManifestPlugin`, which I'm in the
process of porting to Next.js Turbo as part of Next Build. As such, I
ported it to Rust using GPT-4 (with manual review over the code).

The resulting code is not particularly idiomatic nor optimized Rust
code, but it passes all tests (similarly converted) and should be more
than fast enough for now.

In the process of porting, GPT-4 made some "suggestions" (read: it
automatically and silently changed parts of the code) which actually fix
some formatting issues with errors:
https://github.com/vercel/next.js/pull/48298

Co-authored-by: Tobias Koppers <tobias.koppers@googlemail.com>
2023-05-17 17:00:21 +02:00
Alex Kirszenberg
051c90d43c
Introduce NextMode (#49852)
This introduces a `NextMode` enum that controls which mode Next.js Turbo
is currently running in:
* `NextMode::Development`: `next dev`
* `NextMode::Build`: `next build`

Requires https://github.com/vercel/turbo/pull/4972

This also update Turbopack to `turbopack-230517.2` with the following
changes:

* https://github.com/vercel/turbo/pull/4972 <!-- Alex Kirszenberg -
Configure React development flag, inherit NODE_ENV from execution
context -->

---------

Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2023-05-17 16:22:50 +02:00
Jiachi Liu
7641278f82
Fix port value for metadataBase (#49924)
metadataBase is using `process.env.PORT` to construct a host when there's no `metadataBase` specified in layout. Dev server needs to pass down the PORT env from the parent prcoess.

Fixes #49807
Fixes #49859
Closes #49889
2023-05-17 13:37:47 +00:00
Shu Ding
4970811c5d
Fix chained .bind of Server Actions (#49874)
This makes sure that you can `.bind` a Server Action multiple times. Thanks to the feedback from @sophiebits:  https://github.com/vercel/next.js/pull/49422#pullrequestreview-1419134304
2023-05-16 22:36:17 +00:00
OJ Kwon
de08f8b3d3
refactor(next-core): move transforms to plugin (#49621)
### What? 

relateed to WEB-1048.

Moving emotion to the plugin, deprecate enable_emotion option.
2023-05-16 17:47:31 +00:00
Shu Ding
05a9e0ac49
Fix conflict when re-exporting multiple Client References (#49468)
Closes #49324. Default export should only be added in the loader
generated boundary file when it actually exists.

fix NEXT-1112
2023-05-16 12:35:12 +02:00
Alex Kirszenberg
2dade5df48
Refactor pages structure (#49802) 2023-05-16 11:52:57 +02:00
Donny/강동윤
e5ad96edd5
chore(turbopack): Update swc_core to v0.76.6 (#49792)
### What?

Updates `swc_core` to `v0.76.x`, which adds support for `Explicit Resource Management` (stage 3)

### Why?

It's stage 3

### How?

Closes WEB-1040


---

turbopack counterpart: https://github.com/vercel/turbo/pull/4937

Co-authored-by: Tobias Koppers <1365881+sokra@users.noreply.github.com>
2023-05-16 05:08:17 +00:00
vercel-release-bot
33bdf6105c v13.4.3-canary.1 2023-05-16 03:01:47 +00:00
Leah
aeed1c770a
add support for globally providing mdx components to turbopack (#49818)
### What?

Adds support for `mdx-components` at the root/src directory.
This is a feature `next-mdx` already has:
https://github.com/vercel/next.js/tree/canary/packages/next-mdx#usage-1

Fixes WEB-1012

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

### Turbopack updates

* https://github.com/vercel/turbo/pull/4949 <!-- OJ Kwon -
refactor(turbopack): deprecate single react_refresh options -->
* https://github.com/vercel/turbo/pull/4944 <!-- Leah - add mdx
`providerImportSource` option -->
2023-05-16 00:45:08 +00:00
OJ Kwon
a7601213ab
refactor(next-core): consolidate react_refresh options (#49822)
<!-- 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 or adding/fixing Examples

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

### Fixing a bug

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

### Adding a feature

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



## For Maintainers

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



### Why?

### How?

Closes NEXT-
Fixes #

-->

### What?

WEB-1049. Removes separate enable_refresh options.
2023-05-15 19:31:42 +00:00
Leah
138a795263
turbo-binding -> turbopack-binding (#49816) 2023-05-15 17:02:25 +00:00
Travis Arnold
6fd866bfd7
add @swc/core to server external packages (#49721)
<!-- 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 or adding/fixing 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 #

-->

Adds `@swc/core` to the default external server packages for use in
packages within node_modules. This package is useful for generating
documentation and is related to #48739. Ideally, this would be respected
by the `serverComponentsExternalPackages` options.

Co-authored-by: JJ Kasper <jj@jjsweb.site>
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2023-05-15 17:56:23 +02:00
Alex Kirszenberg
f6f07c0894
Apply user-defined PostCSS transforms to foreign code (#49463)
We specifically avoid running most transforms on foreign code without
the `transpile_packages` option, but PostCSS transforms should be an
exception.
2023-05-15 15:34:23 +00:00
Donny/강동윤
5aaa6ff65e
fix: Disable tracing/release_max_level_off for wasm, too (#49639)
### What?

Along with https://github.com/swc-project/plugins/pull/182, this PR will
allow using trace-level logging for debugging turboapck.

### Why?

Requested by @sokra 

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

### How?

Closes WEB-1035
2023-05-15 16:16:12 +02:00
Shu Ding
ca32decdad
Fix cookies().set missing in types (#49806)
Closes #49259. Note that even if we allow `.set` in the types, it will still error when called in wrong places (such as Server Components).
fix NEXT-1090
2023-05-15 13:07:49 +00:00
Fonger
afddb6ebda
fix(image): preload should respect referrerPolicy (#49584)
This is a bug fix PR.

We should respect referrerPolicy when preloading a priority next/image

Reproduce codesandbox: https://codesandbox.io/p/sandbox/boring-fog-4o28oi
As you can see, the image still request with `referer` header although we have `referrerPolicy="no-referrer" in img attribute.

<img width="645" alt="image" src="https://github.com/vercel/next.js/assets/5862369/6a2779d3-e0e2-4dfe-80d2-c8a4243f430b">
2023-05-13 20:33:07 +00:00
JJ Kasper
3323702018
Rework client router filter handling (#49741)
This simplifies the implementation for the client router filter and
makes the error rate configuring more accurate. Additional tests haven't
been added as this is still a matter of probability and existing tests
cover the client router behavior.

Example scenario of filter size/false positives with an error rate of
`0.01%`:

```sh
entries: 128 filter size: 4986 bytes, gzip size: 627 bytes
false positives with 100000 samples: 26 0.026%
```

x-ref: [slack
thread](https://vercel.slack.com/archives/C04K237UHCP/p1683129488543039)
2023-05-13 12:09:57 -07:00
JJ Kasper
c3f54ec441
Remove old-space-size filtering from dev server (#49727)
We shouldn't filter this from the router worker as this is where the dev
server runs and should be able to allocate more memory.

x-ref: [slack
thread](https://vercel.slack.com/archives/C04MEB9L9RQ/p1683823794069839?thread_ts=1683756338.246099&cid=C04MEB9L9RQ)
2023-05-13 12:03:16 -07:00
OJ Kwon
cad6d3aa22
refactor(next-core): deprecate custom_ecmascript_transforms (#49629)
<!-- 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 or adding/fixing Examples

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

### Fixing a bug

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

### Adding a feature

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



## For Maintainers

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



### Why?

### How?

Closes NEXT-
Fixes #

-->



### What?

WEB-1031.

Deprecate old custom_ecmascript_transforms, consolidate to use
ecmatransforms_plugin instead.
Requires https://github.com/vercel/turbo/pull/4886 .

---------

Co-authored-by: Alex Kirszenberg <alex.kirszenberg@vercel.com>
Co-authored-by: Leah <github.leah@hrmny.sh>
2023-05-12 19:43:25 +00:00
vercel-release-bot
a9e204ca8c v13.4.3-canary.0 2023-05-12 11:58:04 +00:00
Tim Neutkens
a0edc92bbc
Optimize trace span relationships (#49697)
## What?

- Ensures `add-entry` falls under `make`
- Ensures the rootmost module falls under `add-entry`, which is the
entry that caused the module to be compiled
- Ensures `seal` related spans have the `seal` span as parent
- Adds some additional spans under `seal`.

### Before

<img width="455" alt="CleanShot 2023-05-12 at 12 30 43@2x"
src="https://github.com/vercel/next.js/assets/6324199/2c79fa0c-e22f-43bf-a2fe-dae67629b712">

### After

<img width="304" alt="CleanShot 2023-05-12 at 12 30 06@2x"
src="https://github.com/vercel/next.js/assets/6324199/3918dc89-2bc0-4f11-a646-553fe1f0fbf4">


<!-- 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 or adding/fixing 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 #

-->
2023-05-12 13:01:07 +02:00
vercel-release-bot
328cc8ffa8 v13.4.2 2023-05-11 23:37:55 +00:00
vercel-release-bot
5ef99faa28 v13.4.2-canary.6 2023-05-11 20:41:36 +00:00
Lee Robinson
fa1370fd9b
Update links from beta to stable docs. (#49349)
Now that the beta docs have been merged into stable with the release of
13.4, this updates all links as some paths have changed due to
redirects.

---------

Co-authored-by: Steven <steven@ceriously.com>
Co-authored-by: Tobias Koppers <tobias.koppers@googlemail.com>
Co-authored-by: JJ Kasper <jj@jjsweb.site>
2023-05-11 11:52:29 -07:00
Fernando Dingler
0f332055d4
fix: Standalone node http server starts accepting requests before next handler is ready (#49548)
### Fixing a bug

Fixes #49536
Fixes #49338

### What?
Starting on next.js 13.4.0, the `server.js` file created by the
standalone output is incorrect because it does not wait until the Next
handler is ready before node http server starts accepting requests.

Initial requests will produce the following error:

```
TypeError: handler is not a function
at Server.<anonymous> (/tmp/app/server.js:29:11)
at Server.emit (node:events:513:28)
at parserOnIncoming (node:_http_server:998:12)
at HTTPParser.parserOnHeadersComplete (node:_http_common:128:17)
```

### Why?
The creation of the next server takes roughly 800ms on a basic hello
world app which causes the initial requests to fail because the
`handler` variable is not initialized.

### Solution
This changes the order of code so that Next Server is initialized before
the Node HTTP server and awaits until the promise is completed to kick
off the HTTP server.

### Alternative code

```js
let handler;

const server = http.createServer(async (req, res) => {
  try {
    await waitUntilHandlerIsReady(); // <---- wait here
    await handler(req, res);
  } catch (err) {
    console.error("Failed to call handler", err);
    res.statusCode = 500;
    res.end("Internal Server Error");
  }
});

async function waitUntilHandlerIsReady() {
  if (!handler) {
    await new Promise((resolve) => setTimeout(resolve, 200));
    await waitUntilHandlerIsReady();
  }
}
```

---------

Co-authored-by: Tim Neutkens <tim@timneutkens.nl>
Co-authored-by: JJ Kasper <jj@jjsweb.site>
2023-05-11 10:36:40 -07:00
Alex Kirszenberg
5781401d49
misc: Apply PR comments from #49206 (#49647)
This PR applies suggestions from @jridgewell's review of
https://github.com/vercel/next.js/pull/49206
2023-05-11 14:51:40 +00:00
Shu Ding
1a867bbb06
Add missing config vars into Webpack cache key (#49663)
Add missing `serverActions` and `typedRoutes` to the Webpack config
cache key as they can affect the build assets.
2023-05-11 07:22:27 -07:00
Noel Kim (김민혁)
f169c32d3f
chore(jest): Simplify isServer expression (#48330)
<!-- 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 or adding/fixing 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 #

-->
2023-05-11 13:49:40 +02:00
Alex Kirszenberg
34f551d9b7
Rename Turbopack/tasks crates to common prefixes (#49446)
See https://github.com/vercel/turbo/pull/4866

This also updates Turbopack to turbopack-230511.2 with the following
changes:

* https://github.com/vercel/turbo/pull/4636 <!-- Alex Kirszenberg - Add
support for logging events and intervals in the macOS profiler -->
* https://github.com/vercel/turbo/pull/4793 <!-- OJ Kwon - ci(workflow):
enable more test -->
* https://github.com/vercel/turbo/pull/4886 <!-- OJ Kwon -
refactor(ecmascript-plugins): update serverdirective signature -->
* https://github.com/vercel/turbo/pull/4866 <!-- Alex Kirszenberg -
Rename Turbopack/tasks crates to common prefixes -->
2023-05-11 11:34:36 +00:00
Jimmy Lai
02d020c459
actions: fill prefetchCache with revalidation payload (#49576)
This fixes a bug where the revalidation value was not stored into the
prefetch cache, leading you to potentially see stale value when
re-reading from the prefetch cache.

<!-- 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 or adding/fixing 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 #

-->

link NEXT-1134

Co-authored-by: Tobias Koppers <tobias.koppers@googlemail.com>
2023-05-11 11:38:19 +02:00
Jorge Carrera Diez
1f561a67dd
Add playwright to external package list (#49649)
Add playwright to the list of packages that can't be bundled,

[related](https://github.com/vercel/next.js/pull/49597)

Co-authored-by: Tim Neutkens <tim@timneutkens.nl>
2023-05-11 11:33:42 +02:00
Tim Neutkens
3e14cf698b
Add puppeteer to external packages list (#49597)
## What?

Add puppeteer to the list of packages that can't be bundled, as it
breaks when bundled as shown in #49383.


Fixes #49383
Fixes NEXT-1136


<!-- 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 or adding/fixing 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 #

-->
2023-05-11 11:30:59 +02:00
Jimmy Lai
85c2921bf5
app-router: add support for parallel routes in useParams (#49595)
This PR changes `useParams` to return all dynamic params present in the
tree as opposed to only those on the canonical/URL path


<!-- 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 or adding/fixing 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 #

-->

link NEXT-1108

Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
Co-authored-by: Tim Neutkens <tim@timneutkens.nl>
2023-05-11 10:32:41 +02:00
vercel-release-bot
062fbf6d2d v13.4.2-canary.5 2023-05-11 05:02:19 +00:00
JJ Kasper
bc4515d8b6
Ensure initialHeaders are normalized (#49643)
This makes sure we have the initial headers in the correct shape during
build.

Fixes: https://github.com/vercel/next.js/issues/49374
2023-05-10 21:44:11 -07:00
Jimmy Lai
e6d50ec6b4
interception routes: fix rewrites order (#49615)
This PR fixes an issue where the rewrites were applied too early and
thus not working with other beforeFiles rewrites

<!-- 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 or adding/fixing 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 #

-->

link NEXT-1148

Co-authored-by: JJ Kasper <jj@jjsweb.site>
2023-05-10 21:07:34 -07:00
JJ Kasper
2eeb1c1bd1
Fix fetchCache and no-store handling (#49638)
Follow-up to https://github.com/vercel/next.js/pull/49628 this updates
the `export const fetchCache` handling and `cache: 'no-store'` handling
as discussed which also aligns with our docs here
https://nextjs.org/docs/app/api-reference/file-conventions/route-segment-config#fetchcache

- `export const fetchCache = 'force-cache'`: forces all fetches to be
cached regardless of `cache: 'no-store'` but cacheable `revalidate`
values still take priority
- `export const fetchCache = 'default-cache'`: ensures fetches are
cached even if they come after a `cache: 'no-store'` fetch but don't
override `cache: 'no-store'` itself.
- without `export const fetchCache`, we still disable fetch cache for
successive fetches after a fetch that does `cache: 'no-store'`

x-ref: [slack
thread](https://vercel.slack.com/archives/C03KAR5DCKC/p1683732826894469)
2023-05-10 20:42:25 -07:00
JJ Kasper
f3222471c6
Update cache method handling during build (#49633)
This ensures we properly handle fetch cache during build.
2023-05-10 17:02:02 -07:00
JJ Kasper
ce746ef5c2
Handle unstable_cache in pages (#49624)
Ensures this method works in pages the same as in app as discussed. 

x-ref: [slack
thread](https://vercel.slack.com/archives/C042LHPJ1NX/p1683242040712889)
x-ref: [slack
thread](https://vercel.slack.com/archives/C042LHPJ1NX/p1683724596461329)
2023-05-10 13:59:48 -07:00
Shu Ding
2f3a503d8b
Allow export decl with any init value in the actions compiler (#49600)
Because of the flexibility of export declarations, we can't know the
exact export type of exported values so we should allow all of them.
Especially when we already have runtime checks.
fix #49378
fix NEXT-1137
2023-05-10 19:46:21 +02:00
Jimmy Lai
2f9ff160aa
interception route: fix route groups breaking the referrer computation (#49602)
This PR fixes a bug during path normalisation where `/(foo)/` would
break because it would return `` per the function logic. A simple fix is
to just ensure we always return a `/` as the default if the
normalisation returns an empty string.

<!-- 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 or adding/fixing 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 #

-->

link NEXT-1118
2023-05-10 17:30:14 +02:00
Jimmy Lai
824c7fdb4a
actions: make cookies.set revalidate (#49582)
This PR adds revalidation for the current page you're on when you call
cookies.set.

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

## For Contributors

### Improving Documentation or adding/fixing 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 #

-->

link NEXT-1097
2023-05-10 17:29:54 +02:00
Jimmy Lai
958e34e012
actions: forward fetch rejections to the action handler (#49577)
Pretty edge case-y but this PR fixes the case where a fetch error happens for an action and we want to handle at the action handler level.



link NEXT-1123
2023-05-10 15:07:03 +00:00
runjuu
a7fd95e3cd
Fix unexpected object mutation while resolving Open Graph (#49514)
Modifying an object passed from external sources can unintentionally
lead to unpredictable behavior.

By changing the implementation from in-place object modification to
returning a new object, we can make the method more predictable.

fixes #49501

<!-- 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 or adding/fixing 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 #

-->

link NEXT-1121

---------

Co-authored-by: Jiachi Liu <inbox@huozhi.im>
Co-authored-by: Tobias Koppers <tobias.koppers@googlemail.com>
2023-05-10 14:51:48 +02:00
Anders Kjær Damgaard
428342dbdf
Add --use-yarn flag to create-next-app (#49407)
# Add `--use-yarn` flag to `create-next-app`

fixes #49405

- [x] Implement `--use-yarn` flag
- [x] Update docs
- [x] Add tests

Co-authored-by: Tobias Koppers <tobias.koppers@googlemail.com>
2023-05-10 14:51:12 +02:00
Donny/강동윤
54ea0d95a0
feat: Allow trace-level logging for non-published release builds (#49564)
### What?

Disable `tracing/release_max_level_info` for non-published release
builds. I modified CI script to strip out logging for published
binaries.

### Why?

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

It's required to print logging for turbopack.

### How?

Closes WEB-1032

---------

Co-authored-by: Tobias Koppers <tobias.koppers@googlemail.com>
2023-05-10 14:50:36 +02:00
Justin Ridgewell
ba4c2f2b4a
Add test for appdir referenced images (#49242)
### What?

Regression test for https://github.com/vercel/next.js/pull/49236


### Why?

### How?
2023-05-10 11:17:49 +00:00
Karl Horky
4743dc6124
Add stub Route type for typedRoutes (#48099)
### What? Why? How?

Add a stub `Route` type to avoid TS errors with `typedRoutes: true`
before `next dev` and `next build` are run

Ref:
https://github.com/vercel/next.js/pull/47931#issuecomment-1500476147

<!-- 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 or adding/fixing 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: Shu Ding <g@shud.in>
2023-05-10 12:34:27 +02:00
Alex Kirszenberg
6a3f96e6b3
Add tests for HMR (#49206)
This adds tests for Turbopack HMR as part of the Next.js turbo
integration test suite.
2023-05-10 12:34:05 +02:00
Toru Kobayashi
ac6addbf63
fix: a11y issues in react-dev-overlay (#49460)
This is a part of fix of #47351

This fixes two issues #47351 mentioned.

1. Buttons must have discernible text
-
https://dequeuniversity.com/rules/axe/4.6/button-name?application=axe-puppeteer

Before:
<img width="549" alt="Screenshot 2023-05-08 at 22 37 00"
src="https://user-images.githubusercontent.com/250407/236839743-3383aea0-f59a-4f2a-9dff-f24de692a97c.png">

This PR:
<img width="447" alt="Screenshot 2023-05-08 at 22 38 50"
src="https://user-images.githubusercontent.com/250407/236839785-3b29b74e-e4db-4ff3-a87c-b69712196264.png">

You can see the accessibility name.

3. Heading levels should only increase by one
-
https://dequeuniversity.com/rules/axe/4.6/heading-order?application=axe-puppeteer

I didn't fix the following issue in this PR because it caused the change
in appearance for the overlay.
I'll fix it as another PR.

2. Elements must have sufficient color contrast
-
https://dequeuniversity.com/rules/axe/4.6/color-contrast?application=axe-puppeteer

<!-- 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 or adding/fixing 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 #

-->
2023-05-10 12:27:43 +02:00
OJ Kwon
1ed7544696
refactor(next-core): remove ast cloning in custom transform (#49560)
### What?

- closes WEB-1024.

Minor refactoring to avoid explicit AST cloning. Still visitors are
using fold though.

### Turbopack changes

* https://github.com/vercel/turbo/pull/4869
* https://github.com/vercel/turbo/pull/4879
* https://github.com/vercel/turbo/pull/4881
2023-05-10 11:07:40 +02:00
Steven
11a7117d40
chore: cross-platform rm -rf script (#49529)
- Closes https://github.com/vercel/next.js/issues/42433
- Closes https://github.com/vercel/next.js/pull/43105
- Closes https://github.com/vercel/next.js/pull/49522
2023-05-10 01:14:37 +00:00
vercel-release-bot
f02cc9f849 v13.4.2-canary.4 2023-05-10 00:28:37 +00:00
JJ Kasper
e3e76a45ee
Add experimental compile/generate handling (#49491)
This implements experimental`compile`/`generate` commands to allow
separate the compilation and static generation steps of the build.
Initially this is for testing and follows same experimental rules which
aren't covered by semver.

Note: most changes are just spacing changes so disabling that in the
diff will be helpful.

x-ref: [initial
thread](https://www.notion.so/vercel/bbdbba2016ed464eb5263d325fecc02f?pvs=4)
x-ref: [slack
thread](https://vercel.slack.com/archives/C03DQ3QFV7C/p1676591260523589?thread_ts=1676554904.334789&cid=C03DQ3QFV7C)
2023-05-09 17:00:08 -07:00
Jiachi Liu
ef2b8f8696
Fix canonical url for dynamic routes (#49512)
The `pathname` in app-render was actually "page" (e.g. `/blog/[slug]`),
with special url conventions. Instead we should use actual request url
as pathname. Rename previous `pathname` arg to `pagePath` for better
readability

Also improved the url validation
2023-05-09 16:31:06 -07:00
OJ Kwon
71d8064b3d
feat(next-core): relay transform plugin (#48899)
<!-- 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 or adding/fixing Examples

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

### Fixing a bug

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

### Adding a feature

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



## For Maintainers

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

### Why?

### How?

Closes NEXT-
Fixes #

-->

#### What
Part 1 for WEB-848. 

This PR implements initial path to enable relay compiler option in
Turbopack. PR is based on approach WEB-955, that passing custom plugin
transform itself instead of trying to pass down configuration into
turbopack. In result, this PR requires counterpart turbopack PR at
https://github.com/vercel/turbo/pull/4721.

PR also refactors next-shared's transform bit, as we have grown number
of custom transforms.

Unfortunately there are some runtime errors with this transforms, so it
is not possible to use relay actually yet. WEB-956 tracks this.
(https://github.com/swc-project/plugins/pull/179)

---------

Co-authored-by: Tobias Koppers <tobias.koppers@googlemail.com>
Co-authored-by: JJ Kasper <jj@jjsweb.site>
2023-05-09 11:09:34 -07:00
OJ Kwon
0dce75f642
ci(test): enable turbopack test (#49466)
<!-- 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 or adding/fixing Examples

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

### Fixing a bug

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

### Adding a feature

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



## For Maintainers

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



### Why?

### How?

Closes NEXT-
Fixes #

-->

### What?

closees WEB-1019.

As discussed, this PR enables running a set of next.js integration tests
with turbopack as blocking CI check. The tests listed as `enabled` is
considered as stable, that should not fail in any case except upstream
test flakyness.

Current approach is simple as we have only small set of tests and does
not consider it becomes a bottleneck. Adding a test under
https://github.com/vercel/next.js/pull/49466/files#diff-fdc68d6039dbe36607cda253b318cd3598a09a94ccb8994f3695aa1d9e1e404bR2
will makes run with turbopack in the CI. in the future, I'll revise test
suite itself so runner, or test case can mark & execute test with
existing test group / scheduling.
2023-05-09 10:46:54 -07:00
Shu Ding
000d022b4e
Support .bind syntax with Action functions (#49422)
This PR implements initial support for `.bind` syntax for inline actions
(not top-level `"use server"` files yet). For example:

```js
export default function Page({ foo, x, y }) {
  async function action(a, b, c, d) {
    'use server'
    console.log(a, b, c, d)
  }

  return <ClientComp action={action.bind(null, foo[0], foo[1], foo.x, foo[y])} />
}
```

Is now valid.

Fixes NEXT-1109.
2023-05-09 19:05:20 +02:00
Shu Ding
d9b82a9535
Fix HMR support for server layer imported SASS and SCSS (#49534)
Closes #43396.

https://github.com/vercel/next.js/issues/43396#issuecomment-1538638785
fix NEXT-684
2023-05-09 16:28:37 +00:00
Shu Ding
881d202962
Fix server CSS imports and HMR not working properly in specific conditions (#49462)
In Hot Reloader we use `mod.resource.replace(/\\/g, '/').includes(key)`
to see if the module is the entry. However that `includes` check isn't
solid. Say the entry key is `app/path/page`, these will all be matched:

```
app/path/page.js
app/path/page.css
app/unrelated/app/path/page/another/page.js
```

This PR fixes that and added a test case. I'm unsure if this fixes the
newly reported cases in #43396.

fix NEXT-1110
2023-05-09 17:48:19 +02:00
lijianan
201ab71ee7
type: update React.CSSProperties type to Record (#49186)
<!-- 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 or adding/fixing 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 #

-->
update React.CSSProperties type to Record

---------

Co-authored-by: Parbez <imranbarbhuiya.fsd@gmail.com>
2023-05-09 15:16:55 +02:00
Darsh Patel
81f5ed7aa2
Fix: Router.query contains _next when using middleware with dynamic routes (#48753)
Fixes: #43598

This was a tricky one to find! Not sure why more people aren't
complaining about this issue, was super annoying in my use case since
links had the wrong URL.

## What?
This issue only occurred when basepath was defined and middleware and
dynamic pages are being used.
Example from the reproduction repo mentioned in the issue tagged:
<img width="686" alt="Screenshot 2023-04-23 at 9 32 55 PM"
src="https://user-images.githubusercontent.com/11258286/233850968-e14f6b49-858b-410e-b8f9-93c90447090a.png">


## Why?
`nextConfig` wasn't passed to `getNextPathnameInfo` function, hence the
basePath wasn't removed from a intermediate variable and that trickled
down to cause this issue.

Added test case based on the issue reproduction repo

---------

Co-authored-by: Jimmy Lai <laijimmy0@gmail.com>
2023-05-09 12:49:27 +02:00
Wojciech Grzebieniowski
e570ad4e56
Fix Node Crypto polyfill (#49288)
### What?

Allow overwriting the `global.crypto` property when polyfilling it.

### Why?

#48941 introduced `global.crypto` polyfill. The problem is that if some
library (e.g.
[xksuid](https://github.com/ValeriaVG/xksuid/blob/main/src/index.node.mjs))
tries to do the same thing, it breaks as `global.crypto` is defined as
non-writable[^1]. Arguably libraries should check for `global.crypto`
presence before overwriting it BUT I think polyfill should match the
actual implementation[^2].



### How?

Make `global.crypto` `enumerable` and `configurable`, as well as define
`set` implementation[^3].

[^1]:
![image](https://user-images.githubusercontent.com/7079786/236440322-7bcf1b18-8fcc-4bb9-b9b4-0f2eb032f5ba.png)

[^2]:
![image](https://user-images.githubusercontent.com/7079786/236437260-d3abdb0c-134f-4c9d-aab8-de7bf4d7c831.png)

[^3]:
![image](https://user-images.githubusercontent.com/7079786/236440393-1c469035-a9f1-4fbe-9ce7-c0308e980510.png)

---------

Co-authored-by: Tim Neutkens <tim@timneutkens.nl>
2023-05-09 09:48:12 +02:00
vercel-release-bot
8d228780e7 v13.4.2-canary.3 2023-05-09 01:27:04 +00:00
Toru Kobayashi
dbb412437a
fix: better error message with an invalid assetPrefix (#49403)
fixes #47641

This adds a friendly error for loading a font error caused by the
invalid `assetPrefix` setting.

Current:
<img width="747" alt="image"
src="https://user-images.githubusercontent.com/250407/236685607-c03b6160-9e8c-4c88-80e1-714f6a140588.png">


This PR:
<img width="890" alt="image"
src="https://user-images.githubusercontent.com/250407/236685499-da4c3d69-0f97-458d-8709-dcc43475e0e9.png">


<!-- 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 or adding/fixing 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>
2023-05-08 16:14:48 -07:00
JJ Kasper
71d354363e
Fix external rewrite with body (#49487)
This ensures we use the proper body stream when rewriting to an external
resource as currently it tries to consume an already read body stream.

Fixes: https://github.com/vercel/next.js/issues/48040
2023-05-08 15:22:02 -07:00
Shu Ding
20e13490ab
Restrict useOptimistic and useFormStatus APIs on the server layer (#49331)
This PR extends `invalid_server_react_dom_apis` with
`experimental_useOptimistic` and `experimental_useFormStatus` to create
early compile-time errors.
2023-05-09 00:02:32 +02:00
JJ Kasper
5ca02a875c
Fix actions redirect handling (#49483)
This ensures we properly strip conflicting headers from being forwarded
when handling the redirect request/response in actions.

x-ref: [slack
thread](https://vercel.slack.com/archives/C042LHPJ1NX/p1683218335368759)

Fixes: 

```sh
failed to get redirect response TypeError: fetch failed
    at Object.fetch (node:internal/deps/undici/undici:11413:11) {
  cause: RequestContentLengthMismatchError: Request body length does not match content-length header
      at write (node:internal/deps/undici/undici:9907:41)
      at _resume (node:internal/deps/undici/undici:9885:33)
      at resume (node:internal/deps/undici/undici:9787:7)
      at connect (node:internal/deps/undici/undici:9776:7) {
    code: 'UND_ERR_REQ_CONTENT_LENGTH_MISMATCH'
  }
}
```
2023-05-08 14:41:58 -07:00
Jiachi Liu
b20d5f2df7
Fix metadata image route encoding (#49482)
Fix the bad encoded buffer introduced in #49323
2023-05-08 14:16:34 -07:00
JJ Kasper
00ed2ba7cc
Fix revalidate: false detection in app (#49473)
When revalidate isn't defined in the tree at all and a fetch without
cache/revalidate fields is done we are incorrectly marking the initial
revalidate period with a time based value when it should be `false`.
This causes pages that should be fully static to revalidate
unexpectedly.

x-ref: [twitter
thread](https://twitter.com/diegohaz/status/1655638433795014657)
x-ref: [slack
thread](https://vercel.slack.com/archives/C03S8ED1DKM/p1683566860136879)
2023-05-08 13:19:41 -07:00
vercel-release-bot
3a5501e678 v13.4.2-canary.2 2023-05-08 19:41:35 +00:00
Shu Ding
7730ee1c38
Add request-async-storage to the shared layer (#49470)
This should fix the `requestAsyncStorage not available` error. [Related
report](https://vercel.slack.com/archives/C03S8ED1DKM/p1683553422581859).
2023-05-08 21:33:55 +02:00
Jiachi Liu
5b5c4c3209
Replace metadata clone with custom handler in dev (#49343) 2023-05-08 20:47:41 +02:00
Lee Robinson
e6cfc155a7
Add link to Server Actions docs. (#49384)
To learn more 😄

Co-authored-by: JJ Kasper <jj@jjsweb.site>
2023-05-08 11:09:20 -07:00
Steven
1c005eb303
Revert "Temporarily disable app dir export integration test" (#49311)
- Reverts vercel/next.js#48291
- Fixes #49059 
- TODO: move these tests to `./tests/e2e/*` to avoid flakes (that will be a follow up PR)
fix NEXT-1092
2023-05-08 17:38:33 +00:00
vercel-release-bot
660d531b6a v13.4.2-canary.1 2023-05-08 16:14:45 +00:00
Jiachi Liu
96c7acf6ad
Inline static data buffer instead of using fs read (#49323) 2023-05-08 16:20:44 +02:00
Jimmy Lai
44e9f0b28c
app-router: add startTransition call to revalidate dispatcher (#49453)
This PR wraps the server patch dispatcher with a transition, we generally want all router dispatch to go through one

I'll follow up on tests properly later



link NEXT-1096
2023-05-08 13:17:17 +00:00
vercel-release-bot
c93747eb33 v13.4.2-canary.0 2023-05-08 09:19:39 +00:00
Tim Neutkens
e15741daca
Remove empty config warning (#49435)
## What?

Removes the empty `next.config.js` warning. Given that `create-next-app` now ships with an empty config with the type definition comment the warning is no longer needed.

## How?

Removed the warning, removed the tests.

Fixes NEXT-1107
2023-05-08 08:58:14 +00:00
Andrew Clark
7e02f11e3a
Upgrade React to 18.3.0-canary-16d053d59-20230506 (#49402)
Fixes a bug where `useFormStatus` crashed during SSR.

Includes the following upstream changes:

- [16d053d59](https://github.com/facebook/react/commits/16d053d59) Add useFormStatus to server rendering stub ([#26788](https://github.com/facebook/react/pull/26788)) (Andrew Clark)
- [efb381bbf](https://github.com/facebook/react/commits/efb381bbf) [Release Script] Print a hint where to get the token ([#26783](https://github.com/facebook/react/pull/26783)) (dan)
- [b00e27342](https://github.com/facebook/react/commits/b00e27342) Use native scheduler if defined in global scope ([#26554](https://github.com/facebook/react/pull/26554)) (Samuel Susla)
- [783e7fcfa](https://github.com/facebook/react/commits/783e7fcfa) React DevTools 4.27.6 -> 4.27.7 ([#26780](https://github.com/facebook/react/pull/26780)) (Ruslan Lesiutin)
- [377c5175f](https://github.com/facebook/react/commits/377c5175f) DevTools: fix backend activation ([#26779](https://github.com/facebook/react/pull/26779)) (Ruslan Lesiutin)
2023-05-07 16:43:06 +00:00
Jiachi Liu
9028a169ac
Add typescript version to next-info (#49346)
typescript version could be helpful for determing user's problem with ts, especially typing with react
2023-05-06 03:17:15 +00:00
Tim Neutkens
061443f804
Fix issue where nextP is not replaced in searchParams (#49315)
## What?

Fixes a bug with iterating over the searchParams while `delete` and
`append` are used.

This is the minimal example of what happened:

```js
const searchParams = new URLSearchParams('a=valueA&b=valueB&c=valueC')

for(const key of searchParams.keys()) {
    console.log(key)
    if(key === 'b') {
      searchParams.delete('b')
      searchParams.append('bb', 'valueBB')
    }
}
```

Output is:

```
a
b
bb
```

Instead of:

```
a
b
c
bb
```

The reason seems to be that the iterator uses an internal count while
iterating, e.g. the implementation in JavaScriptCore:
0743137c2f/Source/WebCore/html/URLSearchParams.cpp (L155-L163)


This can't be reproduced with `new Map()` or `new Set()`.

This PR fixes it by only iterating over the keys that are known before
the loop starts.

Fixes an issue [reported by
users](https://vercel.slack.com/archives/C03S8ED1DKM/p1683007482211449).

<!-- 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 or adding/fixing 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 #

-->
2023-05-05 21:55:47 +02:00
Shu Ding
ef8fef1350
Fix link not being GC'd sometimes (#49318)
The `app-link-gc` module should treat the link with just pathname as the
href and full URL as the same resource. This avoids duplicate styles
during HMR:

<img width="482" alt="CleanShot 2023-05-05 at 18 12 12@2x"
src="https://user-images.githubusercontent.com/3676859/236511257-af510ed2-8e21-430a-bf71-24931b10e5de.png">

[Related bug report
(internal)](https://vercel.slack.com/archives/C03KAR5DCKC/p1683295788069859).
2023-05-05 20:23:35 +02:00
Leah
75eccf7c7f
make sure server component externals only apply to files resolvable by node (#49147)
Fixes WEB-959
2023-05-05 17:33:30 +00:00