Commit graph

21405 commits

Author SHA1 Message Date
vercel-release-bot
18c2fa85ab v15.0.0-canary.51 2024-07-02 13:16:34 +00:00
hrmny
4df48390db
fix(turbopack): build all parallel routes to make sure HMR works (#67222)
### What?

Parallel routes build in a weird and render in a weird way.

To render next.js always uses the last parallel route (alphabetically I
think) as that's most likely to be the root.
Building works in the opposite order, it goes from the first to the
last.

This is fine for the first render, but after that the renderer will only
check if the file for the last parallel route has a bundle on disk and
never request it to be updated.

1. match on routes
2. build match
3. check if the last parallel route bundle exists on disk
	- if it doesn't so go back to step 2 with the next match
	- the actual match gets thrown away
4. render with the bundle for the last parallel route

The condition in step 3 will always be true after an update, because it
was built for a previous request

To fix this, turbopack will now emit all parallel routes that match a
path every time one of them gets requested.

Closes PACK-3078
Fixes #65836
2024-07-02 15:12:33 +02:00
Sebastian Silbermann
d8d8b53cd1
Allow busting reserved Github action caches (#66638) 2024-07-02 14:51:40 +02:00
vercel-release-bot
6795597a50 v15.0.0-canary.50 2024-07-01 23:22:58 +00:00
Zack Tanner
2fbdac6f82
fix prefetch bailout detection for nested loading segments (#67358)
### What
When PPR is off, app router prefetches will render the component tree up
until it encounters a `loading` segment, at which point it'll just
return some metadata about the segment and won't do any further
rendering. This is an optimization to ensure prefetches are lightweight
and don't potentially invoke expensive dynamic subtrees. However,
there's a bug in this logic that is causing it to bail unexpectedly if a
segment deeper in the tree contained a `loading.js` file.

This would mean the loading state wouldn't be triggered until the second
request for the full RSC data is initiated, resulting in an unintended
delta between when a link is clicked and the loading state is shown.

### Why
The `shouldSkipComponentTree` flag was incorrectly being set to `true`
even if the `loading.js` segment appeared deeper in the tree. Prefetch
requests from the client will always contain `FlightRouterState`, so the
logic to check for loading deeper in the tree will always be missed.


### How
This removes the `flightRouterState` check as it doesn't make sense:
prefetches will currently _always_ include the `flightRouterState`,
causing this to always short-circuit. I believe that this check is
vestigial from when we were generating static `prefetch.rsc` outputs
which is no longer the case.

This mirrors a [similar
check](b87d8fc499/packages/next/src/server/app-render/create-component-tree.tsx (L393))
when determining if parallel route(s) should be rendered.
2024-07-01 16:11:09 -07:00
Hendrik Liebau
7523f327e0
Ensure required-server-files test can exit cleanly (#66765)
When running `pnpm test-start
test/production/standalone-mode/required-server-files/required-server-files.test.ts`
locally, Jest hangs and prevents the process from exiting. In the CI,
the issue is masked because `run-tests.js` uses `--forceExit`.

The reason for the hanging process is that there are two server
instances started, and only the last one is killed. By starting and
killing the server for each test we can not only fix this, but also
prevent the `should run middleware correctly (without minimalMode, with
wasm)` test from affecting the other tests when flipping the
`minimalMode` flag in `server.js`.

I also reverted the darwin-specific overwrites of `appPort` that were
added in #65722 and #66724. I don't think those are needed because after
#65722 was created we did land #66285 which sets the hostname to be
compatible with ipv4 and ipv6. If there's still a need to keep this then
let me know, and I will restore it.
2024-07-02 00:05:28 +02:00
Hendrik Liebau
ba97c7595f
Update labeler.json (#67359)
### What?

Reflect team changes in labeler list.
2024-07-02 00:00:49 +02:00
Zack Tanner
aa832c3b2d
use fetch priority for app prefetches (#67356)
This leverages [fetch
priority](https://developer.mozilla.org/en-US/docs/Web/API/Request/Request#priority)
to ensure automatic prefetching as a result of visiting a page is sent
with "low" priority, to signal to the browser it can prioritize more
important work necessary for rendering the page.

A "temporary" prefetch (ie one that is created when there wasn't an
existing prefetch cache entry on navigation) will use a "high" priority
because it's critical to the navigation event.

All other cases will be "auto" which is the current default.
2024-07-01 14:47:56 -07:00
Steven
73b552a9a5
fix(next/image): undo tight coupling between priority=true and fetchPriority=high (#67351)
## History

When we added `priority` prop to `next/image`, there was no
`fetchPriority` so we instead used this to preload the image in the
head.

Then when browsers added support `fetchPriority`, we automatically added
`fetchPriority=high` when `priority={true}` to signal to the browser
that this was a high priority image. This priority is added to the img
and the preload.

However, we saw cases where images are blocking critical css. Per
@gnoff:

> React currently prioritizes font preloads then high priority images,
then css in the initial page load

Due to these changes in React (aka Float), we should no longer set
`fetchPriority=high`, although the user can still manually add that prop
if needed.
2024-07-01 14:42:42 -04:00
Jiwon Choi
ef83433c3e
perf: improve retrieving versionInfo on Turbo HMR (#67309)
### Why?

Identified the bottleneck of Turbopack HMR, one of the reason is that we
run `execSync` to get user's package manager and fetch their registry to
get the latest & canary version of Next.js.
This process was located at the initial of HMR, which could have been
delayed to the initial of the error handling.

### How?

- Remove getting user's package manager and just fetch from NPM
regardless the user uses Yarn.
- Used an async IIFE to await the promise of `getVerionInfo` value
inside the synchronous `ws.handleUpgrade`.

### Benchmark

> Benchmarked with console inside try-finally

#### Webpack -- no cache

| Version                              | Ready |
|-------------------------------------|---------|
| Canary | 1185ms |
| Delta | 896ms |
| Delta Webpack vs Canary Webpack | -24.39% |

#### Turbopack

| Version                              | Ready |
|-------------------------------------|---------|
| Canary | 1002ms |
| Delta (Turbopack) | 509ms |
| Delta Turbopack vs Canary Turbopack | -49.20% |

---------

Co-authored-by: Jiachi Liu <inbox@huozhi.im>
Co-authored-by: Tobias Koppers <tobias.koppers@googlemail.com>
2024-07-02 02:16:22 +09:00
Jiachi Liu
0e6e83c33d
Add warn and telemetry for customized esmExternals (#67339)
### What

* Warn with next.js when users customized `experimental.esmExternals`
value
* Add telemetry tracking on the customization usage for that flag. 0 for
no customization, 1 for used non-default customized value


### Why

`esmExternals` ideally can just remain as default value `true` which
Next.js can handle the customization properly. Since next.js app router
also supports it on canary now we're adding a warning to users that
don't modify `esmExternals` option as it could affect module resolution
on ESM packages.
2024-07-01 18:28:11 +02:00
Lee Robinson
0115636230
docs: Improve error handling docs (#67332)
Based on this discussion:
https://github.com/vercel/next.js/discussions/62681
2024-07-01 11:10:31 -05:00
Jiwon Choi
f702a14acf
chore: throw when three dot character is detected in segment (#67348)
### Why?

It could be confusing between `...` and `…`, which the later is actually
a single character.

### How?

We throw if we detect `…` instead of `...`.
2024-07-02 00:53:45 +09:00
Steven
78dc2db916
fix(next/image): improve query string validation for integers (#67293)
The Image Optimization API currently uses `parseInt()` for `w` and `q`
query string parameters.

This doesn't handle floats as you might expect and instead coerces, for
example `parseInt('99.9') === 99`.

This PR changes the runtime to match the build time validation and only
accept integers for `w` and `q`.
2024-07-01 08:10:35 -07:00
JJ Kasper
2fceb5b1aa
Fix test-new-tests args parsing (#67308)
Noticed we weren't detecting test mode correctly due to incorrect args
parsing so this fixes that

x-ref:
https://github.com/vercel/next.js/actions/runs/9725297814/job/26842454638?pr=67306#step:28:69
2024-07-01 07:27:16 -07:00
Jiwon Choi
cf71687d69
chore: add swc-build-native script at root package.json (#67345)
When developing in Next.js repo, the maintainers / contributors
sometimes need to build swc native files.

Added a script `swc-build-native` to run the command `pnpm
--filter=@next/swc build-native` which was verbose to run.
2024-07-01 23:10:07 +09:00
Arinjay Dhar
303d155c08
Improve Unstable Cache Docs (#65942)
Unstable Cache has always had a very lacking documentation page, even
though it adding its own new feature ``key parts`` . Its a normal
occurrence for us in the NextJS Discord to see new people and more
advanced users question what is the use of key parts, since the example
in the docs. was very lacking.

I have made a few changes, like adding a much more functional example
which showcases all the features of unstable cache, and also a small
difference section between tags and key parts.

---------

Co-authored-by: Sam Ko <sam@vercel.com>
2024-07-01 04:50:51 -07:00
vercel-release-bot
b9bd23baec v15.0.0-canary.49 2024-06-29 23:22:57 +00:00
Max Leiter
862a89667f
packages/next: opt ts-morph into serverExternalPackages (#67284) 2024-06-29 15:02:18 +02:00
vercel-release-bot
b1eab7fb5e v15.0.0-canary.48 2024-06-28 23:23:25 +00:00
Delba de Oliveira
fbede36bcc
Docs: Update fetch information in caching docs (#67279)
Updates data cache docs to reflect `fetch` behavior in Next.js 15 RC. 

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

---------

Co-authored-by: Sam Ko <sam@vercel.com>
2024-06-28 10:26:02 -07:00
Sam Ko
fc87f8ee12
docs(mdx): add clarification for mdxRs (#67237)
## Why?

Add clarification that you need the experimental config:

```
module.exports = withMDX({
  experimental: {
    mdxRs: true,
  },
})
```

when using [Turbopack](https://nextjs.org/docs/architecture/turbopack).

---------

Co-authored-by: Delba de Oliveira <32464864+delbaoliveira@users.noreply.github.com>
2024-06-28 05:56:25 -07:00
Sam Ko
e6983b911b
chore: update pnpm to 9.4.0 (#64945)
## Why?

Notable change of v9 is Corepack is enabled by default.  
So we can ensure all package manage/resolved exact same version of pnpm.

- [**v9.0.0**](https://github.com/pnpm/pnpm/releases/tag/v9.0.0):
Discontinued support for Node.js v16 and introduced Corepack
compatibility checks. New configuration updates include enabling
`dedupe-injected-deps` and changing the lockfile to version 9, with
better readability and resistance to Git conflicts.

...

- [**v9.4.0**](https://github.com/pnpm/pnpm/releases/tag/v9.4.0)

- Kudos to @ryota-murakami for the original :pr:! →
https://github.com/vercel/next.js/pull/64854

## Changes

- https://pnpm.io/npmrc#link-workspace-packages defaults to `false` now,
so setting it to `true`

Closes NEXT-3211
2024-06-28 04:41:35 -07:00
Zack Tanner
87e45521d2
reject actions with invalid RSC responses (#67059)
When a server action responds with something other than an RSC response,
we currently silently ignore the error and it doesn't get propagated to
any rejection handlers.

This adjusts the handling so that if the server action response is a
non-successful status code, we reject the server action promise. If the
error is `text/plain`, we'll automatically propagate the text content as
the error text. Otherwise, the promise is rejected with a fallback
message.
2024-06-28 11:18:52 +02:00
Sukka
b2eafbf6b3
refactor: replace glob w/ fast-glob in eslint plugin (#67261) 2024-06-28 08:15:35 +00:00
Sam Ko
bdd1d31d57
chore: bump turbo to 2.0.6-canary.0 (#67270) 2024-06-28 01:15:22 -07:00
GyoHeon
6474cf0fe3
chore(docs): fix miss spell (#67228)
### Improving Documentation

- Just add `'`


![image](https://github.com/vercel/next.js/assets/66263916/ce7c5e11-38e9-4937-9034-3278b36e1e2b)

Co-authored-by: Jiwon Choi <devjiwonchoi@gmail.com>
2024-06-28 07:54:33 +00:00
Mariano Álvarez
a7faeb0b80
chore(docs): improve visual appearance of badges in README.md (#67254)
## Description
This Pull Request improves the visual appearance of the badges in the
README.md file by removing unnecessary line breaks between the badge
images, eliminating the unwanted blue link lines that previously
appeared and resulting in a cleaner and more cohesive look.

### What
Removed unnecessary line breaks between badge images in the README.md
file to eliminate the unwanted blue link lines and improve the overall
visual presentation.

### Why
Previously, the badges were displayed with line breaks between them,
causing blue link lines to appear, which disrupted the clean look of the
badges. By removing these line breaks, the badges now appear without the
blue link lines, providing a more cohesive and visually appealing
README.

### How

- Removed the line breaks between badge images in the README.md file.

Co-authored-by: Jiwon Choi <devjiwonchoi@gmail.com>
2024-06-28 07:29:25 +00:00
vercel-release-bot
1441a353a9 v15.0.0-canary.47 2024-06-27 23:23:39 +00:00
Wyatt Johnson
3c6936cfbd
[ppr] Test fixes for deployment tests (#67256)
Fixes some possible race conditions by adding a few delays to the
navigation test to ensure that we wait for hydration to occur and
prefetches to finish.
2024-06-28 00:32:56 +02:00
Zack Tanner
f7d5e14863
add more examples to run-for-change script (#67250)
These examples are tested, so this ensures tests are run when these
examples change to prevent #67249
2024-06-27 19:51:06 +02:00
Zack Tanner
0a1f7e23d6
Revert "examples(with-mdx): update to MDX 3" (#67249)
Reverts vercel/next.js#62503

This is currently failing tests that use this example


[x-ref](https://github.com/vercel/next.js/actions/runs/9699835771/job/26771391310)
2024-06-27 17:24:53 +00:00
Jiachi Liu
3d3f02ecdc
fix missing command in next-codemod (#67216)
Running `pnpx @next/codemod@canary next-dynamic-access-named-export`
found the following error

```
Invalid transform choice, pick one of:
- name-default-component
- add-missing-react-import
- withamp-to-config
- url-to-withrouter
- cra-to-next
- new-link
- next-og-import
- metadata-to-viewport-export
- next-image-to-legacy-image
- next-image-experimental
- built-in-next-font
```

Turns out we're missing it in cli command list
2024-06-27 18:00:07 +02:00
Josh Goldberg ✨
72a64081b4
feat: enable @typescript-eslint/recommended in create-next-app --typescript (#52845)
Co-authored-by: eps1lon <sebastian.silbermann@vercel.com>
2024-06-27 09:37:01 +00:00
Remco Haszing
689e4b82f2
examples(with-mdx): update to MDX 3 (#62503)
### What?

Update the `with-mdx` example to MDX 3.

### Why?

The example was 2 major versions behind.

### How?

By updating the version in `package.json`. Also the `@mdx-js/react`
dependency was removed, as it doesn’t work with the app directory. Users
should use `mdx-components.tsx` instead.

Refs #59693

Co-authored-by: Sam Ko <sam@vercel.com>
2024-06-27 02:35:37 -07:00
Jophy Ye
126b9c8ff3
Update unit test docs in compliance with testing-library release (#67217)
Co-authored-by: Jiwon Choi <devjiwonchoi@gmail.com>
Co-authored-by: Sebastian Silbermann <silbermann.sebastian@gmail.com>
2024-06-27 09:32:39 +00:00
vercel-release-bot
4b7924b155 v15.0.0-canary.46 2024-06-26 23:23:20 +00:00
hrmny
18b13e04f5
fix(turbopack): add no-op resolveAbsolutePath to browser runtime (#67215)
### What?

The turbopack browser runtime was throwing an error when trying to
access `import.meta.url`.


Closes PACK-3095
Fixes https://github.com/vercel/next.js/issues/66005
2024-06-26 19:18:33 +00:00
Will Binns-Smith
c8e9e65de1
Test that nonlatin characters don’t cause hard reloads in hmr (#67077)
This test case covers https://github.com/vercel/next.js/issues/65117.

Fixes #65117
2024-06-26 11:05:26 -07:00
vercel-release-bot
ce6ce9b04b v15.0.0-canary.45 2024-06-26 14:10:16 +00:00
Wyatt Johnson
08793dd911
[ppr] Handle corrupted postponed state (#67021)
Previously, when the provided postponed state was corrupted, the render
failed which resulted in a hydration error. Instead, when the postponed
state is corrupted, we send the resume stream just for the hydration
where it'll attempt to render client side with the data that's already
available.
2024-06-26 06:52:49 -07:00
Maaz-Ahmed007
a3c36fe24c
Update 01-installation.mdx "create-next-app" had link in one place an… (#67150)
…d not in another place.

"create-next-app" in apostrophe was mentioned twice but one with link
and second without link which didn't sync together for me. So, I added
the same link to the second one, maybe I am wrong.

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

## For Contributors

### Improving Documentation

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

### Adding or Updating Examples

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

### Fixing a bug

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

### Adding a feature

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


## For Maintainers

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

### What?

### Why?

### How?

Closes NEXT-
Fixes #

-->

Co-authored-by: Jiwon Choi <devjiwonchoi@gmail.com>
2024-06-26 13:36:46 +00:00
Christian Rebelsky
b9ffa84303
fix: fix entry point for storybook, add storybook static ouput to gitignore (#67207)
This PR will fix https://github.com/vercel/next.js/issues/67206

- [x] contributing guidelines for examples are followed
- [x] lint runs without errors
2024-06-26 22:25:42 +09:00
Tim Neutkens
5999c78a4b
Upgrade Turbopack (#67209)
* https://github.com/vercel/turbo/pull/8546 <!-- Benjamin Woodruff -
Decrease default scope_stress test size, add env var config -->
* https://github.com/vercel/turbo/pull/8563 <!-- Donny/강동윤 - Update
`swc_core` to `v0.95.4` -->
* https://github.com/vercel/turbo/pull/8556 <!-- Tobias Koppers - avoid
cloning the source code -->
* https://github.com/vercel/turbo/pull/8562 <!-- Will Binns-Smith - HMR:
handle non-Latin characters in text through base64-encoded sourcemaps
-->
* https://github.com/vercel/turbo/pull/8530 <!-- Benjamin Woodruff -
Support turbo tasks inside of `mod` blocks -->
* https://github.com/vercel/turbo/pull/8542 <!-- Benjamin Woodruff -
Handle `#[cfg(...)]` attributes on turbo tasks -->
* https://github.com/vercel/turbo/pull/8529 <!-- Benjamin Woodruff -
Deduplicate persistent task get_function_name logic -->
* https://github.com/vercel/turbo/pull/8547 <!-- Benjamin Woodruff - Add
new ExitHandler API as an alternative to ExitGuard -->
* https://github.com/vercel/turbo/pull/8604 <!-- Benjamin Woodruff -
Delete unused TASK_ID_MAPPING support -->
* https://github.com/vercel/turbo/pull/8605 <!-- Benjamin Woodruff -
Remove nohash-hasher dependency -->
* https://github.com/vercel/turbo/pull/8559 <!-- Tobias Koppers - move
stateful flag into Done state -->
* https://github.com/vercel/turbo/pull/8598 <!-- Tim Neutkens - MDX
support: Ensure development transform is only used in development -->
* https://github.com/vercel/turbo/pull/8557 <!-- Tobias Koppers - reduce
size of task output struct -->
* https://github.com/vercel/turbo/pull/8558 <!-- Tobias Koppers - remove
prepared task type -->


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

## For Contributors

### Improving Documentation

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

### Adding or Updating Examples

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

### Fixing a bug

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

### Adding a feature

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


## For Maintainers

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

### What?

### Why?

### How?

Closes NEXT-
Fixes #

-->
2024-06-26 14:11:23 +02:00
Joseph
c839d589ab
fix: Narrow down from string | undefined to string (#65248)
Co-authored-by: Jiwon Choi <devjiwonchoi@gmail.com>
2024-06-26 12:42:55 +02:00
Sebastian Silbermann
a832c91ae4
Make synced react-is version more obvious (#67189) 2024-06-26 11:16:47 +02:00
Tobias Koppers
d4e349f79b
make next/dynamic visit more incremental and cacheable (#66912)
### What?

This makes extracting next/dynamic cheaper when modules have been visited before

### Why?

improved HMR and page transitions

### How?

All steps for visiting a module are extracted into a single cached function. VIsiting already visited modules costs only a single cache lookup
2024-06-26 11:11:13 +02:00
Zack Tanner
a4431a9126
skip provide-paths test when deployed (#67203)
This test cannot be run in `test-deploy` because it inspects the
contents of the `.next` folder.
2024-06-26 10:22:06 +02:00
vercel-release-bot
90f564d376 v15.0.0-canary.44 2024-06-25 23:22:44 +00:00
Ivan Torres
0d9c89bf81
Remove devdependency uuid (#67190)
Co-authored-by: torresgol10.it <torresgol10.itd@gmail.com>
Co-authored-by: eps1lon <sebastian.silbermann@vercel.com>
2024-06-25 20:50:39 +00:00