Commit graph

15541 commits

Author SHA1 Message Date
Shu Ding
b6e0c350ed
Update the mutableCookies class to accept extra options (#48877)
This PR changes `mutableCookies` from `RequestCookies` to a
`ResponseCookies` instance, and it now accepts extra options for each
cookie. Take a look at the tests for more details.

cc @styfle

---------

Co-authored-by: Steven <steven@ceriously.com>
2023-04-26 19:13:03 +00:00
JTaylor0196
f7baa56792
update example Deploy button URLs (#48842)
### What?
Updates Deploy button URLs for all listed examples here:
https://github.com/vercel/next.js/tree/canary/examples

### Why?
The Deploy URLs are currently broken and result in a failed clone
attempt on Vercel.

### How?
The URLs have been changed from https://vercel.com/new/git/external?… to
-> https://vercel.com/new/clone?…
(Last updated
[here](8eaabe2fb0)
in 2021)
2023-04-26 13:31:44 -04:00
Tobias Koppers
6e896d3dc8
add missing aliases for next/dynamic and next/head (#48871)
### What?

missing aliases for app dir functionality

### Why?

### How?
2023-04-26 18:53:36 +02:00
Kiko Beats
1274713b1a
edge: expose Websocket constructor (#48870)
This PR make possible to use WebSocket in an Edge Function 🙂
2023-04-26 17:38:39 +02:00
Martin Wahlberg
c390c1662b
Add missing word to getStaticProps documentation (#48854)
### What?
Added missing `that` to documentation for getStaticProps

### Why?
This change fixes grammar.

### How?
Updated the text.
2023-04-26 14:02:53 +00:00
OJ Kwon
f3d5c2fe9e
refactor(next-swc): turbopack_ecmascript_plugins (#48671)
<!-- 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?

This PR is necessary changes to apply
https://github.com/vercel/turbo/pull/4662. Need turbopack bump to make
CI pass.

---------

Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2023-04-26 15:55:53 +02:00
Shu Ding
b21fd96606
Implement MutableRequestCookies in server entries (#48847)
Similar to #47922 but based off the latest server implementation and #48626:

> This PR implements the MutableRequestCookies instance for cookies() based on the current async context, so we can allow setting cookies in certain places such as Server Functions and Route handlers. Note that to support Route Handlers, we need to also implement the logic of merging Response's Set-Cookie header and the cookies() mutations, hence it's not included in this PR.
>
> fix [NEXT-942](https://linear.app/vercel/issue/NEXT-942)

This PR also adds the same support for Custom Routes.

cc @styfle.

fix NEXT-942, fix NEXT-941.
2023-04-26 13:19:01 +00:00
Tim Neutkens
da2804f974
Fix scrolling on navigation in app (#48863)
## What?

When investigating #48852 I found that when there's a `segmentPath` set
in the `focusAndScrollRef` it would compare that entire path with the
`segmentPath` of the layout-router. This logic works in cases where the
entire page is rendered but doesn't take into account cases where for
example a suspense boundary is triggered below the common layout.

Because of the order `useEffect` is run in we can already assume that if
a more specific match existed it would have scrolled there. As that is
not the case in e.g. #48852 it ended up opting out of scrolling
entirely. In order to fix that the logic needs to be different, it needs
to check if the layout-router's `segmentPath` matches, if it matches
every level then we can apply scrolling in that layout-router.

## How?

Implemented the opposite of the current logic, running `.every` on the
layout-router segmentPath instead of on the router provided segmentPath.

Fixes #48852
Fixes NEXT-1053

Related PR #48862

<!-- 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-04-26 14:33:58 +02:00
Jan Kaifer
6902e5b547
Fix issues where saving next.config.js too quickly could result in multiple dev servers running at once (#48857)
We were adding filling in our cleanup function after we started our server. So If we restarted while the server was starting, we would fire an empty cleanup function which would lead to the server not being cleaned up (once it starts).

The only slight issue is that it won't watch for changes while cleaning up the previous run (waiting for the server from the last run to start and finish).

fix NEXT-1052
2023-04-26 09:58:50 +00:00
vercel-release-bot
1c0c61a66c v13.3.2-canary.7 2023-04-26 08:38:47 +00:00
Tobias Koppers
5a46b01ab9
update turbopack (#48846)
* https://github.com/vercel/turbo/pull/4692 
* https://github.com/vercel/turbo/pull/4595 
* https://github.com/vercel/turbo/pull/4690 
* https://github.com/vercel/turbo/pull/4663
2023-04-26 06:55:37 +00:00
Shu Ding
f12aa35b0d
Fix accessing strict of undefined in writeConfigurationDefaults (#48799)
Fixes the 

```
TypeError: Cannot read properties of undefined (reading 'strict')
    at writeConfigurationDefaults
```

error.

Co-authored-by: JJ Kasper <jj@jjsweb.site>
2023-04-25 15:53:21 -05:00
Shu Ding
641d419ada
Add async context to server request handler (#48626)
This PR adds an `AsyncLocalStorage` wrapper to the action handler, so
underlying function calls can tell if it's running in that.
2023-04-25 18:45:10 +02:00
Shu Ding
ac8de9fae8
Polyfill FormData with edge-runtime primitives (#48826)
It makes more sense to use the `FormData` from `@edge-runtime/primitives` to ensure the version and implementation are aligned, and avoid importing extra modules (as we always import the Edge Runtime).
2023-04-25 15:55:31 +00:00
Tobias Koppers
8602bf35e0
fix query for app dir in turbopack (#48828)
### What?

Fix the query for app dir

### Why?

it's not correct in app dir
2023-04-25 15:31:07 +00:00
Shu Ding
287e379b92
Vendor react@experimental (#48697)
Part of #47759 (which had been reverted twice so here we only land a part of the change), relates to NEXT-926. Thanks to #48506 we can soon switch between these two channels during runtime.

Also fixes a problem of `renderKind` (only revealed after upgrading React), it should be also based on the `match` kind.
2023-04-25 14:29:02 +00:00
Shu Ding
f08cab3b0f
Only track client entry modules in the client reference manifest (#48814)
This is currently an overhead, that we check a module's layer (`mod.buildInfo.rsc?.type === RSC_MODULE_TYPES.client`) and put all client modules in the client reference manifest, but the manifest is only used for accessing these entry modules. So here we change the util to check if it's an client entry instead.

With this change the client manifest of a test app decreased from 177 KB to 70 KB.

Ref: 5b609e264f/packages/next/src/build/analysis/get-page-static-info.ts (L50-L64)
2023-04-25 12:27:53 +00:00
Jiachi Liu
0f6b357181
Improve typing of resolve metadata (#48670)
Improve array resolving in metadata, remove ts comments for errors
2023-04-25 10:17:54 +00:00
vercel-release-bot
9863935f44 v13.3.2-canary.6 2023-04-25 09:13:29 +00:00
Tim Neutkens
ee86ace5ce
Fix hash apply after server-patch action (#48813)
### What?

Mux reported that their website does not scroll to hash when clicking a search result. Found it's related to `server-patch` triggering and overriding the hashFragment. That should be preserved similarly to `apply`.

### How?

handleMutable had a default of `null` instead of using the existing value. It should use the existing value.
2023-04-25 09:05:44 +00:00
Donny/강동윤
a18f50a321
fix: Update @swc/helpers to v0.5.1 (#48808)
### What?

Update `@swc/helpers` to `v0.5.1`.

### Why?

Webpack merges `@swc/helpers@v0.4.x` and `@swc/helpers@v0.5.x`, due to `resolve.alias` config in 2f6ff0dab3/packages/next/src/build/webpack-config.ts (L1070-L1072)

To workaround it, `@swc/helpers@v0.5.1` reexports from entries just like `v0.4`.

### How?

Closes WEB-948
Fixes #48593
2023-04-25 04:32:27 +00:00
vercel-release-bot
79c73887cd v13.3.2-canary.5 2023-04-25 01:30:47 +00:00
Steven
ce2e2265e6
Add missing repository prop to package.json in swc-wasm (#48805)
- Follow up to https://github.com/vercel/next.js/pull/48803

Fixes
https://github.com/vercel/next.js/actions/runs/4791615248/jobs/8523283909#step:10:258
2023-04-24 20:24:55 -05:00
vercel-release-bot
2f6ff0dab3 v13.3.2-canary.4 2023-04-24 22:21:45 +00:00
Steven
7e97dc5ebf
Add missing repository prop to package.json (#48803)
This should fix the following error:

```
npm ERR! 422 Unprocessable Entity - PUT https://registry.npmjs.org/@next%2fswc-darwin-x64 - Failed to validate repository information: package.json: "repository.url" is "undefined", expected to match "git+https://github.com/vercel/next.js" from provenance
```

https://github.com/vercel/next.js/actions/runs/4787411938/jobs/8512829488#step:10:74

- Related to https://github.com/vercel/next.js/pull/48757
2023-04-24 17:17:06 -05:00
Philip Nguyen
4973420765
Fix typo in errors/version-staleness.md (#48797) 2023-04-24 20:03:44 +00:00
Preston Landers
7fb4d27053
Fix Windows path in route join (#48603) (#48779)
A change here: (#48202) 958150d
Caused a URL to be joined with `path.join`, which on Windows inserts a backslash character. Changing to `path.posix.join` fixes this.

Breaks next build on Windows when paths like `favicon.ico` are in the source dir.

Fixes #48603
2023-04-24 19:12:25 +00:00
Jiachi Liu
5b609e264f
Error on legacy runtime config under app dir (#48774)
When you're using `config` object with `runtime` we'll show a warning and recomment you to move to `export const runtime = ...` for runtime property as it's documented as recommended. This PR adds a error for `next build` to avoid logs are truncated during multi-workers build and you're aware of the config which doesn't take effect with seeing the error

Follow up for #48630
link [NEXT-426](https://linear.app/vercel/issue/NEXT-426)
2023-04-24 18:33:29 +00:00
Shu Ding
03f34625e5
Polyfill FormData for Node.js < 18 (#48783)
We currently use `URLSearchParams` to represent `FormData` but it's not really the same thing. And in Node.js 16 there's no `FormData` available so we can polyfill it via Undici.
2023-04-24 15:48:10 +00:00
vercel-release-bot
2196cbe405 v13.3.2-canary.3 2023-04-24 14:16:49 +00:00
Steven
b3afc46e1c
fix: npm publish provenance permissions (#48757)
Co-authored-by: Jiachi Liu <inbox@huozhi.im>
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2023-04-24 14:08:55 +00:00
Jan Kaifer
8460373c26
Fix issue with instrumentation in a standalone build (#48615) 2023-04-24 13:49:46 +00:00
Shu Ding
39498d604c
Prefer realpathSync.native over realpathSync (#48698)
Interesting learning from
[this](https://sun0day.github.io/blog/vite/why-vite4_3-is-faster.html#fs-realpathsync-issue),
that `fs.realpathSync` is 70x slower than `fs.realpathSync.native`.
Kudos to the Vite team!
2023-04-24 15:00:06 +02:00
Jan Kaifer
db764c35e6
Add support for async instrumentation register (#48575) 2023-04-24 11:43:50 +00:00
Chris
2679ab672d
Update naming for Next.js Analytics (#48618)
Updates the name of Next.js Analytics to Next.js Speed Insights

closes ALY-579

---------

Co-authored-by: Steven <steven@ceriously.com>
Co-authored-by: Tim Neutkens <tim@timneutkens.nl>
2023-04-24 12:14:45 +02:00
Alex Kirszenberg
7fdcb172f9
Lazy DevHtmlAsset chunk generation (#48768)
This fixes a perf regression introduced in the chunking refactor, where
we would be eagerly generating all assets from the web entry and
fallback sources.

See https://github.com/vercel/turbo/pull/4679

This also brings the following updates from vercel/turbo:

* https://github.com/vercel/turbo/pull/4669 <!-- Tobias Koppers - make
the invalidation reason easier to read -->
* https://github.com/vercel/turbo/pull/4670 <!-- Tobias Koppers -
dev-server content might change any time, we can't cache them -->
* https://github.com/vercel/turbo/pull/4653 <!-- OJ Kwon -
fix(ecmascript): displayname for styled_components -->
* https://github.com/vercel/turbo/pull/4679 <!-- Alex Kirszenberg - Lazy
DevHtmlAsset chunk generation --> (this change)
2023-04-24 12:11:24 +02:00
vercel-release-bot
1e9d53ebae v13.3.2-canary.2 2023-04-24 09:23:39 +00:00
Tim Neutkens
e631ab9853 Revert "Add npm package provenance on publish (#48693)"
This reverts commit 1c007cee2f.
2023-04-24 11:19:18 +02:00
vercel-release-bot
e720a1efa4 v13.3.2-canary.1 2023-04-24 08:14:15 +00:00
Tim Neutkens
7e380e3967
Compile Next.js core client-side files using default target (#48750)
### What?

Compiles Next.js core files using the same default target as client-side
files, ensuring that `async`/`await` and such are not turned into
generators.

The client-side files are all opted into compilation during dev/build
already so if you create a browserslist config that will still apply in
the same way. This change only changes the output of the core files.

### How?

Moved the default we use in Next.js into a separate `.js` file so that
it can be imported from the taskfile-swc plugin, this way we're using
the same defaults.

<!-- 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-04-24 09:53:29 +02:00
vercel-release-bot
2bfde63b78 v13.3.2-canary.0 2023-04-23 21:57:48 +00:00
Steven
743a59dfab
Add support for draft mode (#48669)
Draft Mode is very similar to Preview Mode but doesn't include any
additional data.

This PR implements support for Draft Mode in `pages` and a future PR
will implement support in `app`.

fix NEXT-992
2023-04-23 21:33:34 +00:00
Afonso Jorge Ramos
2e99645b6c
docs: update Image props (#48726)
Hey! Hope this can help anyone dealing with this in the future.

I'm also using the `TinaMarkdown` provider to generate my MDX and one of the things that I've found helpful so that the image was better handled in the browser was to set position to `undefined`, as it was the only way to unset it from `absolute`, which was affecting the visual aspect of the page.

Co-authored-by: Steven <229881+styfle@users.noreply.github.com>
2023-04-23 20:28:03 +00:00
Sreetam Das
06700235dd
fix: TS plugin showing warning for global-error file's reset prop (#48756)
The TS plugin incorrectly gives a warning for the `reset` prop in the `global-error.tsx` file. This was previously reported and fixed for the `error.tsx` file.
- https://github.com/vercel/next.js/issues/46573
- https://github.com/vercel/next.js/pull/46898

---

You can see a reproduction on [CodeSandbox](https://codesandbox.io/p/sandbox/summer-dawn-b0gydg?file=%2Fapp%2Flayout.tsx&selection=%5B%7B%22endColumn%22%3A16%2C%22endLineNumber%22%3A18%2C%22startColumn%22%3A16%2C%22startLineNumber%22%3A18%7D%5D) — `global-error.tsx`'s `reset` prop has the following warning: 

```
Props must be serializable for components in the "use client" entry file, "reset" is invalid. ts(71007)
```

I haven't filed an issue for this yet since this was a simple enough fix, but happy to create one if needed :)
2023-04-23 18:04:20 +00:00
Steven
1c007cee2f
Add npm package provenance on publish (#48693)
https://github.blog/2023-04-19-introducing-npm-package-provenance/
2023-04-23 02:12:53 +00:00
Wyatt Fry
16a2c64cf5
typo (#48716)
"ran" is conjugated, which cannot be used after the verb "to be", only the infinitive "run" is correct here.
2023-04-23 01:53:33 +00:00
Jiachi Liu
7de1a4070d
Reland "app-router: new client-side cache semantics" (#48695)
Reverts vercel/next.js#48688
fix NEXT-1011
2023-04-22 10:41:08 +00:00
Shu Ding
485955bb36
Do not suggest adding "use client" if using next/router in app (#48680)
Feedback form @MaxLeiter, that we shouldn't tell the user to add "use client" in this case:

![image](https://user-images.githubusercontent.com/3676859/233697824-65e8013b-f292-4f77-bdff-d421269ba750.png)
2023-04-21 23:41:52 +00:00
Shu Ding
a875d5a4f5
Use decodeReplyFromBusboy in node runtime (#48686)
When sending a multipart form data, we currently wait until the entire update finishes before we decode it via `decodeReply`. This way is universal in both runtimes (as we don't have `decodeReplyFromBusboy` in Edge), but also not efficient.

This PR changes it to use `decodeReplyFromBusboy` in the Node runtime, which can decode the payload during streaming as well as file update support.
2023-04-21 23:20:43 +00:00
Shu Ding
490dc864c6
Add test case for #48506 (#48696)
Closes NEXT-228
Closes NEXT-227
2023-04-21 22:59:08 +00:00