Commit graph

16067 commits

Author SHA1 Message Date
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
Steven
2226d2935f
chore: drop unused @webassemblyjs (#51045)
Remove these dependencies since they appear to be unused

- Closes https://github.com/vercel/next.js/pull/50928
- Closes https://github.com/vercel/next.js/pull/50123
2023-06-09 16:03:15 +00:00
Delba de Oliveira
9c44c1dca1
[Docs] Add section on how to preview docs changes on VSCode (#51019) 2023-06-09 15:16:19 +00:00
Steven
f1f5734e91
chore: pin to npm@9.6.7 (#51044)
This might fix the npm publish error

```
Error: Command failed with exit code 254 (Unknown system error -254): npm publish /home/runner/work/next.js/next.js/packages/next --access public --tag canary
```


https://github.com/vercel/next.js/actions/runs/5219901558/jobs/9422546478#step:11:9353
2023-06-09 07:58:32 -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
Delba de Oliveira
9800eaf467
[Docs] Clarify a few things about the instrumentation.ts file (#51034)
There was some confusion about where to place it.
2023-06-09 13:40:53 +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
Alain Kaiser
8370e52a32
Fix Typo in Metadata API Description (#51024)
### Fix Typo in Metadata API Description

#### Description:

This PR fixes a minor typo in the description of the Metadata API.

#### Changes:

- Fixed typo in the Metadata API description. 

**File:** `docs/02-app/01-building-your-application/05-optimizing/04-metadata.mdx`

**Old Sentence:**

> Next.js has a Metadata API that can used to define your application metadata (e.g. `meta` and `link` tags inside your HTML `head` element) for improved SEO and web shareability.

**New Sentence:**

> Next.js has a Metadata API that can be used to define your application metadata (e.g. `meta` and `link` tags inside your HTML `head` element) for improved SEO and web shareability.

This change helps improve the readability and understanding of the documentation for readers and users.

#### Checks:

- [x] Followed the Docs Contribution Guide
- [x] Linting passes (`pnpm build && pnpm lint`)
2023-06-09 12:20:41 +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
Kevin Ang
e5b88caed7
fix revalidateTag import (#51005)
This PR fixes the erroneous `revalidateTag` import on certain examples.
It was imported from `next/server`, but should be imported from
`next/cache` instead.

Co-authored-by: Delba de Oliveira <32464864+delbaoliveira@users.noreply.github.com>
2023-06-09 09:23:58 +01:00
Taylor Bryant
8484a6b9c2
Fix typos in 01-contribution-guide.mdx (#51006)
This PR fixes some small typos in the Contribution Guide.
2023-06-09 08:16:12 +00:00
Tyler Lutz
aef03cf3a5
docs: update ESLint prompt output. (#50986)
Co-authored-by: Lee Robinson <me@leerob.io>
2023-06-08 19:07:58 -07:00
PatrickCodes_
3817770bc0
docs: update Route Handlers to have JS/TS code snippet. (#51003)
Added a TS and JS switcher. Previously the code snippet did not have a
switcher. The file extension was .js when the code was TypeScript which
made it confusing to try to read.

---------

Co-authored-by: Lee Robinson <me@leerob.io>
2023-06-08 19:06:08 -07: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
vikas singh
13bd196d08
Added Azure Cosmos DB started code, containing a minimal app and README.md (#49128)
These changes contain Started Code for Azure Cosmos DB.
2023-06-08 21:42:46 +00:00
Michael Novotny
9c4b0ec9e9
Adds missing JavaScript codeblock in Opengraph Image API reference (#50996)
Also changes JavaScript examples to use `.jsx` extensions so IDEs better recognize the JSX allowed as the first argument to `ImageResponse`. 

Fixes #50141
2023-06-08 21:29:47 +00:00
JJ Kasper
1be0bdd081
Add max job timeout for build workflow (#50998)
Ensures we don't allow jobs like this one back up the queue indefinitely https://github.com/vercel/next.js/actions/runs/5214838162/jobs/9411777984?pr=50904
2023-06-08 20:58:35 +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
Mingjie Jiang
8811c1f3f6
Add appDir-specific guidance for next-router-not-mounted error (#50076)
The error `next-router-not-mounted` can also happen when one tries to use the `next/router` hook inside the app directory. The error page has been updated to reflect that, and migration guides are linked. 

Closes #47038.
2023-06-08 20:08:26 +00:00
didemkkaslan
f2cbfe3147
docs: Fix typo in colocation documentation. (#50975) 2023-06-08 12:16:48 -07:00
Tyler Lutz
3ccbe82280
Update create-next-app docs (#50981)
### What?

Update the create-next-app prompts and create-next-app --help
documentation
2023-06-08 12:16:05 -07:00
Ethan Mick
9a08206242
docs: Correct useFormStatus to be a client component (#50991)
### What?

The `useFormStatus` needs to be used in a client component. That
component should be used within a `form` for the `pending` property to
reflect the form status.

### Why?

The docs are currently not accurate.

### Notes

I could also update the name of the file to not be `form.js`, which
implies this is the entire form instead of just the submit button being
used as a component within the form.
2023-06-08 12:13:13 -07:00
Michael Novotny
61a553963d
Adds missing async to Opengraph Image code example. (#50990) 2023-06-08 12:08:04 -07: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
Shu Ding
b8e308f511
Add test for hidden form fields at the beginning of a Server Action form (#50978)
Fixes #50087. The root cause was fixed in upstream React and here's a
test to ensure it works end to end.
fix NEXT-1228
2023-06-08 19:25:56 +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
Jiwoo JEONG
b8e08abf9e
fix: add missed / at useSelectedLayoutSegment at App routing/Pages and Layout (#50956)
## Why?
- When i click `red box` in following image, page returns 404 page.
<img width="1728" alt="스크린샷 2023-06-08 오후 7 31 37" src="https://github.com/vercel/next.js/assets/63336958/903b11e3-17af-426e-8787-b6e033c14a24">

## How?
- I found that `/` is missed at `docs/02-app/01-building-your-application/01-routing/02-pages-and-layouts.mdx`.
- So I added `/`.
2023-06-08 15:33:25 +00:00
vercel-release-bot
d52c030d94 v13.4.5-canary.8 2023-06-08 15:01:09 +00:00
JJ Kasper
45db459fe1
Add corepack env for linkPackages (#50973)
x-ref:
https://github.com/vercel/next.js/pull/50933#discussion_r1222163786
2023-06-08 07:46:19 -07:00
JJ Kasper
9a3e76377a
Fix windows build check 2023-06-08 07:38:38 -07:00
JJ Kasper
63d5cf1c1d
Fix workflow check 2023-06-08 07:16:31 -07:00
JJ Kasper
23649623d7
Only upload turbopack metrics on cache miss (#50945)
Currently this is uploading every time the job is run even if it's a
cache hit and this step can take over 3 minutes un-necessarily so this
skips it if a cache hit occurred.
2023-06-08 07:07:49 -07: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
OJ Kwon
534414d54e
ci(workflow): enable test trace again (#50817)
### What?

Another attempt to https://github.com/vercel/next.js/pull/50619 and WEB-1150, trying to apply setup guard more throughly.

I still do not know why original PR passed CI but fails to subsequent PRs after merge, but hope this could be a right guard to prevent unexpected failures.
2023-06-08 10:52:49 +00:00
Delba de Oliveira
f4f34e4226
[Next Docs] Migrate new docs from next-site to Next.js repo (#50701) 2023-06-08 12:03:14 +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
Delba de Oliveira
f6ff2ef98e
[Next Docs] Update Git Workflow (#50579)
Update our git workflow in preparation for open-sourcing the content of
the docs ([linear
task](https://linear.app/vercel/issue/DX-1579/set-up-github-workflow)).

**Templates:**
- [x] Update docs issue template to encourage contributions
- [x] Update PR template to include link to new contribution guide 

**Code Owners / Reviewers:** 
- https://github.com/vercel/next.js/pull/50841

**Labels:** 
- [x] Add DevEx team to labeler.json so PRs get the "created by: DevEx
team"

**Other:** 
- [x] Remove docs manifest from CI checks as we no longer have one (keep
the manifest for errors as they live under `/pages`)
- [x] Add `unifiedjs.vscode-mdx` to the vscode extension list
2023-06-08 12:01:55 +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
Leah
f24d0cb030
fix rust install being skipped when it shouldn't be (#50946)
Co-authored-by: JJ Kasper <jj@jjsweb.site>
2023-06-07 20:32:19 -07: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
Jiachi Liu
e562ddf990
remove unused dev dep ts-node (#50939)
`ts-node` was added in #44715 but not used anymore, it has a `@types/node` dep, this alsos helps to bump node typing later
2023-06-08 02:44:16 +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