Commit graph

9983 commits

Author SHA1 Message Date
vercel-release-bot
1d9833bc63 v14.2.0-canary.45 2024-03-27 19:12:36 +00:00
Tobias Koppers
ab5d0a2002
update turbopack (#63778)
* https://github.com/vercel/turbo/pull/7797 <!-- Tobias Koppers - fix
externals in side-effect optimized modules -->
* https://github.com/vercel/turbo/pull/7830 <!-- Tobias Koppers - Avoid
showing import map description in resolving issue when there is no
import map mapping -->
* https://github.com/vercel/turbo/pull/7833 <!-- Tobias Koppers - add
next.js trace format -->
* https://github.com/vercel/turbo/pull/7835 <!-- Tobias Koppers -
correct global start by first start time -->
* https://github.com/vercel/turbo/pull/7812 <!-- Will Binns-Smith -
Turbopack docs: Fix broken webpack loaders link -->
* https://github.com/vercel/turbo/pull/7847 <!-- Will Binns-Smith -
Turbo tasks: Reuse aggregation context and apply queued updates -->
* https://github.com/vercel/turbo/pull/7840 <!-- Tobias Koppers - add
concurrency corrected duration -->
* https://github.com/vercel/turbo/pull/7854 <!-- Tobias Koppers - fix
size_hint on count hash set -->
2024-03-27 20:09:08 +01:00
Tobias Koppers
00e9cf9dd9
fixes to next.js tracing (#63673)
### What?

* fix the span name generated for webpack build-module
* fix the time base for spans reported by manualTraceChild


Closes PACK-2835
2024-03-27 16:23:56 +00:00
Jiachi Liu
93aac0e39b
Respect non 200 status to page static generation response (#63731)
### What

In static generation phase of app page, if there's any case that we're
receiving 3xx/4xx status code from the response, we 're setting it into
the static generation meta now to make sure they're still returning the
same status after build.

### Why

During static generation if there's any 3xx/4xx status code that is set
in the response, we should respect to it, such as the ones caused by
using `notFound()` to mark as 404 response or `redirect` to mark as
`307` response.

Closes NEXT-2895
Fixes #51021
Fixes #62228
2024-03-27 16:20:02 +01:00
Josh Story
7425d51172
Fix ServerAction rejection reason (#63744)
Recently the serverActionReducer was updated to no longer use React's
thenable type to carry resolution/rejection information. However the
rejection reason was not updated so now when a server action fails we
were rejecting with `undefined` rather than the rejected reason. This
change updates the reject to use the rejection value.


Closes NEXT-2943
2024-03-26 17:46:50 -07:00
vercel-release-bot
2fc408d66d v14.2.0-canary.44 2024-03-26 23:23:31 +00:00
Zack Tanner
9b4a055033
prevent router markers from leaking (#63606)
While looking into bugfixes related to router refreshing (the other PRs
in this stack), I noticed there were situations where the `Next-URL`
header would include `/children`, or where `page$` would be present in
LoaderTree for a segment.

This updates a few spots to prevent these markers from leaking into
places they shouldn't, and shouldn't have any behavioral changes.

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

## For Contributors

### Improving Documentation

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

### Adding or Updating Examples

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

### Fixing a bug

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

### Adding a feature

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


## For Maintainers

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

### What?

### Why?

### How?

Closes NEXT-
Fixes #

-->


Closes NEXT-2902
2024-03-26 21:41:55 +00:00
Sukka
a70e55eac9
perf: download and save mkcert in stream (#63527)
Previously, Next.js would buffer the `mkcert` binary in memory and write
it to disk all at once. The pull request changes this to pipe the
download stream to the disk. This improves memory consumption by
avoiding having to load the entire `mkcert` binary into memory.

---------

Co-authored-by: JJ Kasper <jj@jjsweb.site>
2024-03-26 20:54:03 +00:00
Zack Tanner
3fc65bac75
ensure null loading boundaries still render a Suspense boundary (#63726)
This ensures that even if a `loading.js` returns `null`, that we still
render a `Suspense` boundary, as it's perfectly valid to have an empty
fallback.

This was accidentally lost in #62346 -- this brings back the
`hasLoading` prop which will check the loading module itself (rather
than the `ReactNode`) for truthiness, and I've added a test to avoid
another regression.

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

## For Contributors

### Improving Documentation

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

### Adding or Updating Examples

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

### Fixing a bug

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

### Adding a feature

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


## For Maintainers

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

### What?

### Why?

### How?

Closes NEXT-
Fixes #

-->


Closes NEXT-2936
2024-03-26 18:45:22 +00:00
Shu Ding
f840cb4882
Rename encryption key generation code (#63730)
This PR renames the API to be not specifically related to Server
Actions, as in the future it might be used by other things. It also adds
the `__next_encryption_key_generation_promise` variable to avoid
double-generating of the key when it's called concurrently (e.g. by the
node server and edge server compilers).

Closes NEXT-2938
2024-03-26 18:25:23 +00:00
Wyatt Johnson
4ee00d4f88
[PPR] Dynamic API Debugging (#61798)
<!-- 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?

This adds dynamic usage logging when the `__nextppronly` query parameter
is set and partial prerendering has been enabled. This will print the
stack trace for the accesses for all Dynamic API's that were called.
This includes those API's that were called during the flight render if
they were called before the static shell was ready.

### Why?

To take the most advantage of partial prerendering, it's important to
track where Dynamic API's are called so developers can determine what
has caused part of the component tree not to be included in the static
shell. This also helps debug situations where the error thrown by
Dynamic API's (used internally for tracking and interruption) are caught
but not re-thrown, but due to the implementation of the flight renderer
provided by React, we are unable to distinguish between errors that are
swallowed by user code or by the flight renderer.

### How?

Instead of using a boolean to track **if** a dynamic API was used, this
actually captures the stack at the callsite, allowing developers to find
the location in the codebase that invoked it.

Closes NEXT-2399
2024-03-26 18:19:07 +00:00
Jiachi Liu
d01a621961
Polish dev-overlay text styling (#63721)
Follow up for #63522 

Adding more polish details for the dev overlay header
- The quoted text uses lighter color of text and use default font weight
- Use the same color for the link and give it a bold font weight
- Use the wilder support sans font for apple devices


### After vs Before
<img width="335" alt="image"
src="https://github.com/vercel/next.js/assets/4800338/a401f958-a5a1-443d-b2e9-f011de44f882">

<img width="335" alt="image"
src="https://github.com/vercel/next.js/assets/4800338/4b1340b7-6664-47ef-8935-cf715d6a3f63">




Closes NEXT-2935
2024-03-26 16:29:06 +00:00
Balázs Orbán
7569c8087a
feat(log): improve dev/build logs (#62946)
Co-authored-by: Jiachi Liu <inbox@huozhi.im>
2024-03-26 15:33:09 +01:00
vercel-release-bot
c7dbbd9a54 v14.2.0-canary.43 2024-03-25 23:22:56 +00:00
JJ Kasper
866b418123
Add Next.js version to process title (#63686)
Makes debugging a little easier by showing the Next.js version in the
process title as well.

x-ref: [slack
thread](https://vercel.slack.com/archives/C03KAR5DCKC/p1711401562557429?thread_ts=1711400819.248569&cid=C03KAR5DCKC)

Closes NEXT-2924
2024-03-25 21:44:39 +00:00
JJ Kasper
cf9e647f41
Auto map optimizePackageImports to transpilePackages for pages (#63537)
This ensures `optimizePackageImports` doesn't unexpectedly fail to apply
for `pages` as they aren't transpiled/bundled by default without either
`transpilePackages` being used or `experimental.bundlePagesExternals`.
This also ensures our docs correctly show this config in the pages docs
as currently in only shows in `app`.

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

Closes NEXT-2884
2024-03-25 12:17:02 -07:00
Balázs Orbán
752d6e49d5
feat(error-overlay): style tweaks (#63522) 2024-03-25 12:37:12 -06:00
grajen3
043bbaa731
perf: conditionally import Telemetry (#63574)
<!-- 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?

Make Telemetry import in `packages/next/src/server/lib/router-server.ts`
lazy and conditional

### Why?

`Telemetry` in that module is only used when `opts.dev` is truthy, so in
production mode the module is imported and used.

Cost of importing that module is quite significant chunk of starting
`standalone` server. Those are example logs I got from
https://www.npmjs.com/package/require-times (with updates to make it
work as that is pretty old package that wasn't updated and doesn't work
as is) on the server:

Before the change:
```
total: 658ms
646ms node_modules/next/dist/server/lib/start-server.js
  479ms node_modules/next/dist/server/lib/router-server.js
    149ms node_modules/next/dist/telemetry/storage.js
      87ms node_modules/next/dist/compiled/@edge-runtime/ponyfill/index.js
        86ms node_modules/next/dist/compiled/@edge-runtime/primitives/index.js
          1ms node_modules/next/dist/compiled/@edge-runtime/primitives/load.js
            23ms node_modules/next/dist/compiled/@edge-runtime/primitives/fetch.js.text.js
            12ms node_modules/next/dist/compiled/@edge-runtime/primitives/url.js.text.js
            1ms node_modules/next/dist/compiled/@edge-runtime/primitives/events.js.text.js
            1ms node_modules/next/dist/compiled/@edge-runtime/primitives/structured-clone.js.text.js
      41ms node_modules/next/dist/compiled/conf/index.js
        12ms node_modules/next/dist/compiled/semver/index.js
      12ms node_modules/next/dist/telemetry/project-id.js
      3ms node_modules/next/dist/telemetry/post-payload.js
      1ms node_modules/next/dist/compiled/is-docker/index.js
      1ms node_modules/next/dist/telemetry/anonymous-meta.js
        1ms node_modules/next/dist/compiled/is-wsl/index.js
    100ms node_modules/next/dist/server/base-server.js
      17ms node_modules/next/dist/server/future/route-matcher-providers/app-page-route-matcher-provider.js
        7ms node_modules/next/dist/lib/is-app-page-route.js
        7ms node_modules/next/dist/server/future/normalizers/built/app/index.js
          3ms node_modules/next/dist/server/future/normalizers/built/app/app-page-normalizer.js
            2ms node_modules/next/dist/server/future/normalizers/absolute-filename-normalizer.js
              1ms node_modules/next/dist/shared/lib/page-path/absolute-path-to-page.js
            1ms node_modules/next/dist/lib/page-types.js
          2ms node_modules/next/dist/server/future/normalizers/built/app/app-bundle-path-normalizer.js
            1ms node_modules/next/dist/shared/lib/page-path/normalize-page-path.js
          1ms node_modules/next/dist/server/future/normalizers/built/app/app-filename-normalizer.js
          1ms node_modules/next/dist/server/future/normalizers/built/app/app-pathname-normalizer.js
        1ms node_modules/next/dist/server/future/route-matcher-providers/manifest-route-matcher-provider.js
      15ms node_modules/next/dist/server/app-render/strip-flight-headers.js
      13ms node_modules/next/dist/server/future/route-modules/helpers/response-handlers.js
        13ms node_modules/next/dist/server/web/spec-extension/adapters/request-cookies.js
      8ms node_modules/next/dist/server/future/normalizers/locale-route-normalizer.js
      4ms node_modules/next/dist/server/api-utils/index.js
        2ms node_modules/next/dist/server/web/spec-extension/adapters/headers.js
          1ms node_modules/next/dist/server/web/spec-extension/adapters/reflect.js
      4ms node_modules/next/dist/server/render-result.js
        3ms node_modules/next/dist/server/stream-utils/node-web-streams-helper.js
          1ms node_modules/next/dist/lib/scheduler.js
      4ms node_modules/next/dist/server/future/route-matcher-providers/pages-api-route-matcher-provider.js
        3ms node_modules/next/dist/server/future/normalizers/built/pages/index.js
          1ms node_modules/next/dist/server/future/normalizers/built/pages/pages-filename-normalizer.js
          1ms node_modules/next/dist/server/future/normalizers/built/pages/pages-pathname-normalizer.js
        1ms node_modules/next/dist/lib/is-api-route.js
      2ms node_modules/next/dist/server/future/route-matcher-managers/default-route-matcher-manager.js
        1ms node_modules/next/dist/server/future/route-matchers/locale-route-matcher.js
      2ms node_modules/next/dist/server/future/route-matcher-providers/app-route-route-matcher-provider.js
      2ms node_modules/next/dist/server/lib/match-next-data-pathname.js
      2ms node_modules/next/dist/server/future/route-modules/checks.js
      1ms node_modules/next/dist/lib/is-edge-runtime.js
      1ms node_modules/next/dist/shared/lib/runtime-config.external.js
      1ms node_modules/next/dist/server/lib/revalidate.js
      1ms node_modules/next/dist/shared/lib/router/utils/escape-path-delimiters.js
      1ms node_modules/next/dist/server/future/route-matcher-providers/pages-route-matcher-provider.js
        1ms node_modules/next/dist/server/future/route-matchers/pages-route-matcher.js
      1ms node_modules/next/dist/server/send-response.js
      1ms node_modules/next/dist/shared/lib/router/utils/get-route-from-asset-path.js
      1ms node_modules/next/dist/server/lib/server-action-request-meta.js
    83ms node_modules/next/dist/server/lib/router-utils/filesystem.js
      22ms node_modules/next/dist/lib/load-custom-routes.js
        4ms node_modules/next/dist/lib/try-to-parse-path.js
          2ms node_modules/next/dist/lib/is-error.js
            1ms node_modules/next/dist/shared/lib/is-plain-object.js
          1ms node_modules/next/dist/compiled/path-to-regexp/index.js
        2ms node_modules/next/dist/lib/redirect-status.js
          1ms node_modules/next/dist/client/components/redirect-status-code.js
        1ms node_modules/next/dist/shared/lib/escape-regexp.js
      16ms node_modules/next/dist/server/future/normalizers/request/rsc.js
      13ms node_modules/next/dist/shared/lib/router/utils/index.js
        10ms node_modules/next/dist/shared/lib/router/utils/is-dynamic.js
          3ms node_modules/next/dist/server/future/helpers/interception-routes.js
            1ms node_modules/next/dist/shared/lib/router/utils/app-paths.js
              1ms node_modules/next/dist/shared/lib/page-path/ensure-leading-slash.js
        1ms node_modules/next/dist/shared/lib/router/utils/sorted-routes.js
      9ms node_modules/next/dist/shared/lib/page-path/normalize-path-sep.js
      4ms node_modules/next/dist/shared/lib/router/utils/middleware-route-matcher.js
        4ms node_modules/next/dist/shared/lib/router/utils/prepare-destination.js
          1ms node_modules/next/dist/client/components/app-router-headers.js
          1ms node_modules/next/dist/server/api-utils/get-cookie-parser.js
      4ms node_modules/next/dist/lib/metadata/get-metadata-route.js
        2ms node_modules/next/dist/server/server-utils.js
        1ms node_modules/next/dist/lib/metadata/is-metadata-route.js
      1ms node_modules/next/dist/compiled/lru-cache/index.js
      1ms node_modules/next/dist/lib/file-exists.js
      1ms node_modules/next/dist/lib/recursive-readdir.js
      1ms node_modules/next/dist/shared/lib/router/utils/path-match.js
      1ms node_modules/next/dist/shared/lib/router/utils/route-regex.js
      1ms node_modules/next/dist/shared/lib/router/utils/route-matcher.js
      1ms node_modules/next/dist/server/future/normalizers/request/postponed.js
        1ms node_modules/next/dist/shared/lib/page-path/denormalize-page-path.js
      1ms node_modules/next/dist/server/future/normalizers/request/prefetch-rsc.js
    35ms node_modules/next/dist/server/lib/router-utils/resolve-routes.js
      11ms node_modules/next/dist/server/body-streams.js
      1ms node_modules/next/dist/server/lib/server-ipc/utils.js
      1ms node_modules/next/dist/shared/lib/router/utils/relativize-url.js
      1ms node_modules/next/dist/server/future/normalizers/request/next-data.js
      1ms node_modules/next/dist/server/lib/mock-request.js
    22ms node_modules/next/dist/server/serve-static.js
      20ms node_modules/next/dist/compiled/send/index.js
        1ms node_modules/next/dist/compiled/fresh/index.js
    22ms node_modules/next/dist/server/pipe-readable.js
      20ms node_modules/next/dist/server/web/spec-extension/adapters/next-request.js
        18ms node_modules/next/dist/server/web/spec-extension/request.js
          15ms node_modules/next/dist/server/web/next-url.js
            12ms node_modules/next/dist/shared/lib/router/utils/format-next-pathname-info.js
              1ms node_modules/next/dist/shared/lib/router/utils/add-path-prefix.js
            1ms node_modules/next/dist/shared/lib/i18n/detect-domain-locale.js
          2ms node_modules/next/dist/server/web/spec-extension/cookies.js
            1ms node_modules/next/dist/compiled/@edge-runtime/cookies/index.js
      1ms node_modules/next/dist/lib/detached-promise.js
    19ms node_modules/next/dist/compiled/compression/index.js
    16ms node_modules/next/dist/server/lib/dev-bundler-service.js
    4ms node_modules/next/dist/trace/index.js
      3ms node_modules/next/dist/trace/trace.js
        2ms node_modules/next/dist/trace/report/index.js
          1ms node_modules/next/dist/trace/report/to-telemetry.js
          1ms node_modules/next/dist/trace/report/to-json.js
    2ms node_modules/next/dist/server/lib/router-utils/proxy-request.js
      1ms node_modules/next/dist/server/server-route-utils.js
    1ms node_modules/next/dist/server/node-environment.js
    1ms node_modules/next/dist/shared/lib/utils.js
    1ms node_modules/next/dist/lib/find-pages-dir.js
    1ms node_modules/next/dist/server/lib/router-utils/is-postpone.js
  140ms node_modules/next/dist/server/next.js
    84ms node_modules/next/dist/server/config.js
      20ms node_modules/next/dist/shared/lib/match-remote-pattern.js
        18ms node_modules/next/dist/compiled/micromatch/index.js
      17ms node_modules/next/dist/compiled/zod/index.js
      14ms node_modules/next/dist/shared/lib/constants.js
        8ms node_modules/@swc/helpers/cjs/_interop_require_default.cjs
      3ms node_modules/next/dist/compiled/find-up/index.js
        1ms node_modules/next/dist/compiled/p-limit/index.js
      3ms node_modules/next/dist/telemetry/ci-info.js
        1ms node_modules/next/dist/compiled/ci-info/index.js
      2ms node_modules/next/dist/server/config-shared.js
        1ms node_modules/next/dist/shared/lib/image-config.js
      2ms node_modules/@next/env/dist/index.js
      2ms node_modules/next/dist/telemetry/flush-and-exit.js
      2ms node_modules/next/dist/lib/find-root.js
      1ms node_modules/next/dist/server/setup-http-agent-env.js
      1ms node_modules/next/dist/shared/lib/router/utils/path-has-prefix.js
    21ms node_modules/next/dist/server/lib/trace/tracer.js
      5ms node_modules/next/dist/compiled/@opentelemetry/api/index.js
      1ms node_modules/next/dist/server/lib/trace/constants.js
    13ms node_modules/next/dist/shared/lib/router/utils/format-url.js
    12ms node_modules/next/dist/build/output/log.js
      9ms node_modules/next/dist/lib/picocolors.js
    3ms node_modules/next/dist/server/require-hook.js
    1ms node_modules/next/dist/server/node-polyfill-crypto.js
    1ms node_modules/next/dist/lib/constants.js
    1ms node_modules/next/dist/server/lib/utils.js
  14ms node_modules/next/dist/compiled/watchpack/watchpack.js
  3ms node_modules/next/dist/compiled/debug/index.js
  1ms node_modules/next/dist/server/lib/format-hostname.js
  1ms node_modules/next/dist/server/lib/app-info-log.js
  1ms node_modules/next/dist/lib/turbopack-warning.js
```

And after the change:
```
total: 516ms
499ms node_modules/next/dist/server/lib/start-server.js
  303ms node_modules/next/dist/server/lib/router-server.js
    103ms node_modules/next/dist/server/base-server.js
      42ms node_modules/next/dist/server/future/route-matcher-providers/app-page-route-matcher-provider.js
        38ms node_modules/next/dist/server/future/normalizers/built/app/index.js
          20ms node_modules/next/dist/server/future/normalizers/built/app/app-page-normalizer.js
            18ms node_modules/next/dist/server/future/normalizers/absolute-filename-normalizer.js
              17ms node_modules/next/dist/shared/lib/page-path/absolute-path-to-page.js
            1ms node_modules/next/dist/lib/page-types.js
          17ms node_modules/next/dist/server/future/normalizers/built/app/app-bundle-path-normalizer.js
            16ms node_modules/next/dist/shared/lib/page-path/normalize-page-path.js
          1ms node_modules/next/dist/server/future/normalizers/built/app/app-pathname-normalizer.js
        1ms node_modules/next/dist/lib/is-app-page-route.js
        1ms node_modules/next/dist/server/future/route-kind.js
        1ms node_modules/next/dist/server/future/route-matcher-providers/manifest-route-matcher-provider.js
      10ms node_modules/next/dist/server/send-response.js
      8ms node_modules/next/dist/server/future/normalizers/locale-route-normalizer.js
      4ms node_modules/next/dist/server/api-utils/index.js
        2ms node_modules/next/dist/server/web/spec-extension/adapters/headers.js
          1ms node_modules/next/dist/server/web/spec-extension/adapters/reflect.js
      3ms node_modules/next/dist/server/render-result.js
        2ms node_modules/next/dist/server/stream-utils/node-web-streams-helper.js
      3ms node_modules/next/dist/server/future/route-matcher-providers/pages-api-route-matcher-provider.js
        2ms node_modules/next/dist/server/future/normalizers/built/pages/index.js
          1ms node_modules/next/dist/server/future/normalizers/built/pages/pages-bundle-path-normalizer.js
        1ms node_modules/next/dist/server/future/route-matchers/pages-api-route-matcher.js
      2ms node_modules/next/dist/server/future/route-matcher-providers/app-route-route-matcher-provider.js
        1ms node_modules/next/dist/lib/is-app-route-route.js
        1ms node_modules/next/dist/server/future/route-matchers/app-route-route-matcher.js
      2ms node_modules/next/dist/server/future/route-modules/helpers/response-handlers.js
        1ms node_modules/next/dist/server/web/spec-extension/adapters/request-cookies.js
      2ms node_modules/next/dist/server/lib/match-next-data-pathname.js
      1ms node_modules/next/dist/lib/is-edge-runtime.js
      1ms node_modules/next/dist/shared/lib/runtime-config.external.js
      1ms node_modules/next/dist/server/lib/revalidate.js
      1ms node_modules/next/dist/shared/lib/router/utils/escape-path-delimiters.js
      1ms node_modules/next/dist/server/future/route-matcher-managers/default-route-matcher-manager.js
      1ms node_modules/next/dist/server/future/route-matcher-providers/pages-route-matcher-provider.js
      1ms node_modules/next/dist/shared/lib/router/utils/get-route-from-asset-path.js
      1ms node_modules/next/dist/server/app-render/strip-flight-headers.js
      1ms node_modules/next/dist/server/future/route-modules/checks.js
      1ms node_modules/next/dist/server/lib/server-action-request-meta.js
    91ms node_modules/next/dist/server/lib/router-utils/filesystem.js
      21ms node_modules/next/dist/lib/load-custom-routes.js
        16ms node_modules/next/dist/lib/try-to-parse-path.js
          13ms node_modules/next/dist/lib/is-error.js
            1ms node_modules/next/dist/shared/lib/is-plain-object.js
          2ms node_modules/next/dist/compiled/path-to-regexp/index.js
        3ms node_modules/next/dist/lib/redirect-status.js
          1ms node_modules/next/dist/client/components/redirect-status-code.js
      16ms node_modules/next/dist/server/future/normalizers/request/prefetch-rsc.js
      12ms node_modules/next/dist/lib/metadata/get-metadata-route.js
        10ms node_modules/next/dist/server/server-utils.js
        1ms node_modules/next/dist/shared/lib/isomorphic/path.js
      9ms node_modules/next/dist/shared/lib/router/utils/route-regex.js
        1ms node_modules/next/dist/shared/lib/router/utils/remove-trailing-slash.js
      6ms node_modules/next/dist/shared/lib/router/utils/index.js
        3ms node_modules/next/dist/shared/lib/router/utils/is-dynamic.js
          2ms node_modules/next/dist/server/future/helpers/interception-routes.js
            1ms node_modules/next/dist/shared/lib/router/utils/app-paths.js
              1ms node_modules/next/dist/shared/lib/page-path/ensure-leading-slash.js
        1ms node_modules/next/dist/shared/lib/router/utils/sorted-routes.js
      5ms node_modules/next/dist/shared/lib/router/utils/middleware-route-matcher.js
        5ms node_modules/next/dist/shared/lib/router/utils/prepare-destination.js
          1ms node_modules/next/dist/shared/lib/router/utils/parse-url.js
          1ms node_modules/next/dist/client/components/app-router-headers.js
          1ms node_modules/next/dist/server/api-utils/get-cookie-parser.js
      2ms node_modules/next/dist/compiled/lru-cache/index.js
      2ms node_modules/next/dist/server/future/normalizers/request/postponed.js
        1ms node_modules/next/dist/shared/lib/page-path/denormalize-page-path.js
      1ms node_modules/next/dist/lib/file-exists.js
      1ms node_modules/next/dist/lib/recursive-readdir.js
      1ms node_modules/next/dist/shared/lib/router/utils/path-match.js
      1ms node_modules/next/dist/server/future/normalizers/request/rsc.js
    24ms node_modules/next/dist/server/pipe-readable.js
      22ms node_modules/next/dist/server/web/spec-extension/adapters/next-request.js
        20ms node_modules/next/dist/server/web/spec-extension/request.js
          17ms node_modules/next/dist/server/web/next-url.js
            13ms node_modules/next/dist/shared/lib/i18n/detect-domain-locale.js
            2ms node_modules/next/dist/shared/lib/router/utils/format-next-pathname-info.js
              1ms node_modules/next/dist/shared/lib/router/utils/add-path-suffix.js
            1ms node_modules/next/dist/shared/lib/router/utils/get-next-pathname-info.js
          3ms node_modules/next/dist/server/web/spec-extension/cookies.js
            1ms node_modules/next/dist/compiled/@edge-runtime/cookies/index.js
        1ms node_modules/next/dist/server/web/utils.js
      1ms node_modules/next/dist/lib/detached-promise.js
    22ms node_modules/next/dist/server/serve-static.js
      21ms node_modules/next/dist/compiled/send/index.js
    18ms node_modules/next/dist/server/lib/router-utils/resolve-routes.js
      11ms node_modules/next/dist/server/body-streams.js
      1ms node_modules/next/dist/server/lib/server-ipc/utils.js
      1ms node_modules/next/dist/shared/lib/router/utils/relativize-url.js
      1ms node_modules/next/dist/server/future/normalizers/request/next-data.js
      1ms node_modules/next/dist/server/lib/mock-request.js
    18ms node_modules/next/dist/compiled/compression/index.js
      1ms node_modules/next/dist/compiled/bytes/index.js
    10ms node_modules/next/dist/server/lib/dev-bundler-service.js
    4ms node_modules/next/dist/trace/index.js
      2ms node_modules/next/dist/trace/trace.js
        2ms node_modules/next/dist/trace/report/index.js
          1ms node_modules/next/dist/trace/report/to-json.js
    3ms node_modules/next/dist/server/lib/router-utils/proxy-request.js
      2ms node_modules/next/dist/server/server-route-utils.js
        1ms node_modules/next/dist/server/request-meta.js
    2ms node_modules/next/dist/shared/lib/utils.js
    1ms node_modules/next/dist/server/node-environment.js
    1ms node_modules/next/dist/lib/find-pages-dir.js
    1ms node_modules/next/dist/server/lib/router-utils/is-postpone.js
  157ms node_modules/next/dist/server/next.js
    99ms node_modules/next/dist/server/config.js
      24ms node_modules/next/dist/shared/lib/match-remote-pattern.js
        5ms node_modules/next/dist/compiled/micromatch/index.js
      17ms node_modules/next/dist/compiled/zod/index.js
      15ms node_modules/next/dist/shared/lib/constants.js
        1ms node_modules/@swc/helpers/cjs/_interop_require_default.cjs
        1ms node_modules/next/dist/shared/lib/modern-browserslist-target.js
      4ms node_modules/next/dist/compiled/find-up/index.js
        1ms node_modules/next/dist/compiled/p-limit/index.js
      4ms node_modules/next/dist/telemetry/ci-info.js
        2ms node_modules/next/dist/compiled/ci-info/index.js
      3ms node_modules/next/dist/server/config-shared.js
        1ms node_modules/next/dist/shared/lib/image-config.js
      2ms node_modules/next/dist/telemetry/flush-and-exit.js
      2ms node_modules/next/dist/lib/find-root.js
      2ms node_modules/next/dist/server/setup-http-agent-env.js
      2ms node_modules/next/dist/shared/lib/router/utils/path-has-prefix.js
        1ms node_modules/next/dist/shared/lib/router/utils/parse-path.js
      1ms node_modules/@next/env/dist/index.js
    17ms node_modules/next/dist/server/lib/trace/tracer.js
      14ms node_modules/next/dist/compiled/@opentelemetry/api/index.js
      1ms node_modules/next/dist/server/lib/trace/constants.js
    13ms node_modules/next/dist/lib/constants.js
    5ms node_modules/next/dist/shared/lib/router/utils/format-url.js
      1ms node_modules/@swc/helpers/cjs/_interop_require_wildcard.cjs
      1ms node_modules/next/dist/shared/lib/router/utils/querystring.js
    4ms node_modules/next/dist/build/output/log.js
      1ms node_modules/next/dist/lib/picocolors.js
    3ms node_modules/next/dist/server/require-hook.js
    1ms node_modules/next/dist/server/lib/utils.js
  7ms node_modules/next/dist/compiled/watchpack/watchpack.js
  3ms node_modules/next/dist/compiled/debug/index.js
  2ms node_modules/next/dist/server/lib/format-hostname.js
    1ms node_modules/next/dist/server/lib/is-ipv6.js
  1ms node_modules/next/dist/server/lib/app-info-log.js
  1ms node_modules/next/dist/lib/turbopack-warning.js
```

I would not pay much attention to absolute numbers as there will be
variance and those are single runs - but from first "require time dump"
you can estimate importing Telemetry (that might be unused) is costing
149ms / 658ms ~= 22.5% of entire time spent on importing modules -
that's pretty significant

### How?

By moving static import/require from top level to conditional code path
that actually uses it. This code path already have some modules
lazy/conditionally loaded. `packages/next/src/telemetry/storage.ts`
doesn't seem to have import side effects so at least on my first glance
it doesn't seem like moving import should cause problems?

Co-authored-by: JJ Kasper <jj@jjsweb.site>
2024-03-25 17:50:40 +00:00
Shu Ding
9677c87e8a
Improve TypeScript plugin for server boundary (#63667)
For problems like #62821, #62860 and other, the only way to improve the
DX would be relying on the type checker to ensure that Server Actions
are async functions. Inlined definitions will always be checked by SWC
(as they're always syntactically defined as functions already), but
export values are sometimes determined at the runtime.

Also added `react-dom` related methods to the disallow list for the
server layer.

Examples:


https://github.com/vercel/next.js/assets/3676859/ac0b12fa-829b-42a4-a4c6-e1c321b68a8e


https://github.com/vercel/next.js/assets/3676859/2e2e3ab8-6743-4281-9783-30bd2a82fb5c


https://github.com/vercel/next.js/assets/3676859/b61a4c0a-1ad4-4ad6-9d50-311ef3450e13



Closes NEXT-2913
2024-03-25 18:37:10 +01:00
vercel-release-bot
c2e3d9ac18 v14.2.0-canary.42 2024-03-25 15:57:25 +00:00
Andrew Gadzik
f9d73cc2fa
Move Playwright to be a peerDependency of next.js (#63530) 2024-03-25 11:48:47 +01:00
Janka Uryga
f509de950b
Fix react-dom aliases for edge RSC (#63619)
Follow up to #63588, we missed edge there

Closes NEXT-2905
2024-03-25 11:37:23 +01:00
Donny/강동윤
6b6590592e
Update turbopack (#63541)
# Turbopack

* https://github.com/vercel/turbo/pull/7815 <!-- Tobias Koppers - fix
alias in getResolve -->
* https://github.com/vercel/turbo/pull/7796 <!-- Donny/강동윤 - Update
`swc_core` to `v0.90.24` -->
* https://github.com/vercel/turbo/pull/7775 <!-- Tobias Koppers - fix
single css chunks with import context -->
* https://github.com/vercel/turbo/pull/7776 <!-- Tobias Koppers - change
port of trace-server -->
* https://github.com/vercel/turbo/pull/7763 <!-- Tobias Koppers -
Tracing improvements -->
* https://github.com/vercel/turbo/pull/7813 <!-- Tobias Koppers - fix
webpack loader incorrectly calling custom_evaluate -->
* https://github.com/vercel/turbo/pull/7764 <!-- Tobias Koppers - fix
some small bugs in turbo-tasks that are required for GC -->
* https://github.com/vercel/turbo/pull/7816 <!-- Chris Olszewski -
chore: remove some unused imports -->
* https://github.com/vercel/turbo/pull/7823 <!-- OJ Kwon -
fix(sourcemap): update sourcemap, remove checker -->

### What?

Update SWC crates to
ad932f0921

### Why?

To keep in sync.

### How?



 - Closes PACK-2807
 - Closes PACK-2819

---------

Co-authored-by: Tim Neutkens <tim@timneutkens.nl>
2024-03-25 03:15:02 +00:00
vercel-release-bot
ce0120954e v14.2.0-canary.41 2024-03-24 23:23:19 +00:00
vercel-release-bot
2746990135 v14.2.0-canary.40 2024-03-23 23:21:07 +00:00
vercel-release-bot
65d699e7d7 v14.2.0-canary.39 2024-03-22 21:20:06 +00:00
Andrew Gadzik
15b68d4c91
Enable all pages under the browser context to proxy to the test proxy (#63610)
This fixes an issue when playwright spawns a new page from the same
context (a popup window) where requests were not being proxied correctly

Co-authored-by: Shu Ding <g@shud.in>
2024-03-22 22:16:17 +01:00
Jiachi Liu
8e8a86ee8f
Add alias for react-dom react-server condition (#63588)
`react-dom` also contains a `react-server` condition that need to be
picked up in RSC bundle layer, like what we did for react. This will
ensures the server runtime smaller and you don't accidentally use the
client apis on server side.


Closes NEXT-2898

---------

Co-authored-by: Janka Uryga <lolzatu2@gmail.com>
2024-03-22 10:21:54 -07:00
vercel-release-bot
fe87d8c6f9 v14.2.0-canary.38 2024-03-22 12:39:08 +00:00
Kiko Beats
0f6a6b232a
chore: upgrade @edge-runtime/cookies (#63602) 2024-03-22 10:58:49 +00:00
Tim Neutkens
66be631d8a
Remove lodash from external packages list (#63601)
## What?

Since the work that Shu did for optimizing large barrel dependencies
marking lodash as external is no longer required.

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

## For Contributors

### Improving Documentation

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

### Adding or Updating Examples

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

### Fixing a bug

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

### Adding a feature

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


## For Maintainers

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

### What?

### Why?

### How?

Closes NEXT-
Fixes #

-->


Closes NEXT-2899
2024-03-22 10:56:38 +00:00
Tobias Koppers
fe989a2360
the argument might be written with underscores (#63600)
### What?

You can pass `--max_old_space_size=` with underscores instead of dashes
which wasn't handled yet.

### Why?

### How?



Closes PACK-2817
2024-03-22 10:46:40 +01:00
vercel-release-bot
368e9aa9ae v14.2.0-canary.37 2024-03-21 23:51:55 +00:00
vercel-release-bot
d1248a7536 v14.2.0-canary.36 2024-03-21 23:23:03 +00:00
Jiachi Liu
053db6af8e
Remove the erroring on force-dynamic in static generation for app route (#63526)
### What
* Remove the erroring of force-dynamic is not able to use during static
generation
* Export the route segments properly in sitemap conventions

### Why

We discovered this error is showing up when users are using
force-dynamic with generating multi sitemaps.

When you have a dynamic `route /[id]/route.js` , and you have
generateSitemaps defined which is actually using `generateSitemaps`
under the hood , then you set the route to dynamic with `export dynamic
= 'force-dynamic'`.

We should keep the route still as dynamic. `generateStaticParams` is
only for generating the paths, which is static in build time. And the
`force-dynamic` is going to be applied to each generated path.

Closes NEXT-2881
2024-03-22 00:15:20 +01:00
Andrew Gadzik
4c467a2638
Improve experimental test proxy (#63567)
Followup on https://github.com/vercel/next.js/pull/52520 and
https://github.com/vercel/next.js/pull/54014

**Enhancements**
- Removes `--experimental-test-proxy` CLI argument from `next dev` and
`next start`
- Adds a new experimental config option `testProxy?: boolean`
- Instead of throwing an error, return the `originalFetch` response if
the current request context does not contain the `Next-Test-*` HTTP
headers

**Why?**
These changes allow us to write mixed Integration + E2E tests within the
same Playwright process.

```ts
// some-page.spec.ts

test.describe('/some-page', () => {
	test('some integration test', async ({ page, next }) => {
	  // by using the `next` fixture, playwright will send the `Next-Test-*` HTTP headers for 
	  // every request in this test's context.
	  next.onFetch(...);
	  
	  await page.goto(...);
	  await expect(...).toBe('some-mocked-value');
	});

	test('some e2e test', async ({ page }) => {
	  // by NOT using the `next` fixture, playwright does not send the `Next-Test-*` HTTP headers
	  await page.goto(...);
	  await expect(...).toBe('some-real-value');
	});
})
```

Now I can run `next dev` and locally develop my App Router pages AND run
my Playwright tests against instead of having to,
- run `next dev` to locally develop my change
- ctrl+c to kill server
- run `next dev --experimental-test-proxy` to locally run my integration
tests

---------

Co-authored-by: Sam Ko <sam@vercel.com>
2024-03-21 21:31:29 +00:00
Maël Nison
7de7cbf283
Upgrades enhanced-resolve (#63499)
This PR upgrades `enhanced-resolve` to `5.16.0` so as to benefit from
https://github.com/webpack/enhanced-resolve/pull/301, recently merged.

Without this diff, importing dependencies from files from external PnP
projects would fail. It's a little niche, but I'm working on a
documentation website that leverages that to allow deploying multiple
websites from the same template.

Co-authored-by: Sam Ko <sam@vercel.com>
Co-authored-by: Steven <steven@ceriously.com>
2024-03-21 15:27:15 -04:00
vercel-release-bot
04f5781c1b v14.2.0-canary.35 2024-03-21 17:49:30 +00:00
Steven
abe74a5211
fix: call instrumentationHook earlier for prod server (#63536)
This ensures that the instrumentation hook for Node.js will run
immediately during `next start` instead of waiting for the first request
like does it `next dev`.

However, if there is a separate instrumentation hook for Edge, that will
still be lazy evaluated and wait until the first request.

Fixes #59999 
Fixes NEXT-2738
2024-03-21 13:11:03 +00:00
Will Binns-Smith
aeafed9405
Turbopack: Fail when module type is unhandled (#63535)
This causes Turbopack to fail and communicate when a file with an
unhandled or unregistered extension is built.

Test Plan: `TURBOPACK=1 pnpm test-dev
test/development/basic/hmr.test.ts`


Closes PACK-2803
2024-03-21 00:36:01 +00:00
vercel-release-bot
c0f9d246d1 v14.2.0-canary.34 2024-03-20 23:22:37 +00:00
Juan Settecase
e4cd547a50
feat: add support for localizations in sitemap generator (#53765)
### What?

Following up with [this
suggestion](https://github.com/vercel/next.js/discussions/53540) I went
ahead and implemented the proposal for the Next.js team to merge it if
they agree.

Things to keep in mind:
- Google has [three different
ways](https://developers.google.com/search/docs/specialty/international/localized-versions#methods-for-indicating-your-alternate-pages)
to do this. The three of them are equivalent
- Google seems to be the only search engine supporting this approach.
The rest of them should ignore it

### Why?

This is supported by
[Google](https://developers.google.com/search/docs/specialty/international/localized-versions#example_2)
to better understand the site when the same page is available in
multiple languages.

### How?

- I added a new key to the `MetadataRoute.Sitemap` type called
`alternates` which accepts just one sub key `languages` similar to the
current one in the
[Metadata](https://nextjs.org/docs/app/api-reference/functions/generate-metadata#alternates)
object
- I updated the `resolveSitemap` method to process the new key and
generate the expected sitemap
- I updated the related tests and documentation to reflect the new
syntax

---------

Co-authored-by: Jiachi Liu <inbox@huozhi.im>
2024-03-20 17:00:20 +00:00
vercel-release-bot
833df606b2 v14.2.0-canary.33 2024-03-19 23:22:30 +00:00
Zack Tanner
3ed46abcda
Fix interception/detail routes being triggered by router refreshes (#63263)
### What
Actions that revalidate the router state by kicking off a refetch (such
as `router.refresh()` or dev fast refresh) would incorrectly trigger an
interception route if one matched the current URL, or in the case of
already being on an intercepted route, would trigger the full detail
page instead.

### Why
Interception rewrites use the `nextUrl` header to determine if the
requested path should be rewritten to a different path. We currently
forward that header indiscriminately, which means that if you were on a
non-intercepted route and called `router.refresh()`, the UI would change
to the intercepted content instead (since it would treat it the same as
a soft-navigation).

### How
This updates various reducers to only forward the `nextUrl` header if
there's an interception route present in the tree. If there is, we want
to refresh its data, rather than the data for the underlying page. The
reverse is also true: if we were on the "full" page, and triggered a
`router.refresh()`, we won't forward `nextUrl` meaning it won't fetch
the interception data.

In order to determine if an interception route is present in the tree, I
had to add a new segment type for dynamic interception routes, as by the
time they reach the client they are stripped of their interception
marker.

**Note: There are a series of bugs related to `router.refresh` with
parallel/interception routes, such as the previous page/slot content
disappearing when triggering a refresh. This does not address all of
those cases, but I'm working through them!**

Fixes #60844
Fixes #62470
Closes NEXT-2737
2024-03-19 15:42:41 -07:00
vercel-release-bot
ad4a7bf403 v14.2.0-canary.32 2024-03-19 22:10:11 +00:00
Ethan Arrowood
d2838ce31e
Simplify createRootLayoutValidatorStream (#63484)
This PR is a follow up to #63427 and simplifies the
`createRootLayoutValidatorStream` function to check each chunk
individually instead of combining all of them into one. This should
improve performance

Closes NEXT-2868
2024-03-19 14:46:39 -07:00
JJ Kasper
d4f5368f2c
Update RSC etag generation handling (#63336)
Currently when we generate payloads in app router, the order of RSC
chunks aren't deterministic even if the content stays the same. This
means that any caches that rely on etags for detecting changes in
content aren't able to reliably cache/and avoid invalidating properly.
To avoid this we can manually sort the content before generating the
etag. Eventually this can be fixed upstream in react although that is a
bigger lift so we are doing this for now to alleviate the issue.

x-ref: [slack
thread](https://vercel.slack.com/archives/C042LHPJ1NX/p1709937748240119?thread_ts=1709856182.174879&cid=C042LHPJ1NX)

Closes NEXT-2825
2024-03-19 21:45:21 +00:00
JJ Kasper
b2b5ab4aff
Update tags limit handling for max items (#63486)
Continuation of https://github.com/vercel/next.js/pull/55083 this
ensures we also properly warn when the max number of tags is hit and we
must filter them out so that users are aware of this. Related
documentation is also updated to reflect this limit.

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

Closes NEXT-2870

---------

Co-authored-by: Steven <steven@ceriously.com>
2024-03-19 12:02:35 -07:00
Zack Tanner
7d20ba17b8
Fix instant loading states after invalidating prefetch cache (#63256)
In #61573, I updated the navigation reducer to request a new prefetch
entry if it's stale. But this has the unintended consequence of making
instant loading states effectively useless after 30s (when the prefetch
would have expired). Blocking navigation and then rendering the loading
state isn't ideal - if we have some loading data in a cache node, we
should re-use it.

Now that #62346 stores loading data in the `CacheNode`, we can copy over
`loading` during a navigation.

This PR repurposes `fillCacheWithDataProperty` which wasn't being used
anywhere, to instead be a utility we can use to programmatically trigger
a lazy fetch on a particular segment path by nulling out it's data while
copying over other properties. We could have used the existing util
as-is, but ideally we only have a single spot where lazy fetching can
happen, which currently is in `LayoutRouter`.

When a stale prefetch entry is detected, rather than applying the data
to the tree, this PR will copy over the `loading` nodes and will
"delete" the data so it can be refetched.

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

## For Contributors

### Improving Documentation

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

### Adding or Updating Examples

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

### Fixing a bug

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

### Adding a feature

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


## For Maintainers

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

### What?

### Why?

### How?

Closes NEXT-
Fixes #

-->


Closes NEXT-2806
2024-03-19 12:02:12 -07:00
Tobias Koppers
14f16c7050
update turbopack (#63475)
* https://github.com/vercel/turbo/pull/7762 <!-- Tobias Koppers - avoid
panic -->
* https://github.com/vercel/turbo/pull/7750 <!-- Tobias Koppers - fix
ASSET_PREFIX -->
* https://github.com/vercel/turbo/pull/7761 <!-- Tobias Koppers -
process source maps from webpack loaders -->
2024-03-19 15:58:19 +01:00
vercel-release-bot
7943315cce v14.2.0-canary.31 2024-03-19 14:48:23 +00:00
Sam Ko
73b4bfbc20
chore(next/font): update @capsizecss/metrics package to the latest (#63440)
## Why?

-
https://github.com/seek-oss/capsize/releases/tag/%40capsizecss%2Fmetrics%402.2.0

Closes NEXT-2854
2024-03-19 00:22:17 +00:00
Zack Tanner
15e76ead7e
Update React from 6c3b8dbfe to 14898b6a9 (#63439)
Update React from 6c3b8dbfe to 14898b6a9.

### React upstream changes

- https://github.com/facebook/react/pull/28580

Closes NEXT-2853
2024-03-19 00:18:18 +00:00
Ethan Arrowood
229cb14834
Eliminate unnecessary decode operations in node-web-streams-helpers.ts (#63427)
This PR is strictly a performance improvement. It should not change
implementation behavior in anyway.

This PR replaces `decoder.decode()` operations by operating with the
encoded `Uint8Array` instances directly. I added some utility functions
to make things a bit easier to understand.

Ideally, this change also maintains a fair amount of code readability. 

Will measure estimate performance improvement shortly.

Closes NEXT-2848
2024-03-18 23:23:35 +00:00
vercel-release-bot
1439503b3b v14.2.0-canary.30 2024-03-18 23:21:43 +00:00
Will Binns-Smith
1f5d3179ac
Turbopack HMR: Reload when recovering from server-side errors (#63434)
Test Plan: `TURBOPACK=1 pnpm test-dev
test/development/basic/gssp-ssr-change-reloading/test/index.test.ts


Closes PACK-2767
2024-03-18 14:57:24 -07:00
OJ Kwon
e12535c706
build(cargo): bump up turbopack (#63429)
### What

fix test/development/acceptance-app/app-hmr-changes.test.ts.

Closes PACK-2765
2024-03-18 21:11:37 +00:00
Ethan Arrowood
b39a4d5971
fix x-forwarded-port header (#63303)
Follow up to https://github.com/vercel/next.js/issues/61133 that will
rely on `x-forwarded-proto` value if it exists in order to default the
`x-forwarded-port` value.

Closes NEXT-2820
2024-03-18 20:45:33 +00:00
vercel-release-bot
57da10beea v14.2.0-canary.29 2024-03-18 19:47:03 +00:00
Tim Neutkens
dd7b05897a
Add Bun lockfile to project root resolving heuristic (#63112)
## What?

Got a report from @juliusmarminge that running examples in the
[uploadthing monorepo](https://github.com/pingdotgg/uploadthing) would
result in resolving errors with Turbopack.
Turns out the monorepo root couldn't be resolved and the reason for that
is that they are using `bun install` as the package manager, which we
didn't account for in the `findRootLockFile` logic. This PR adds
`bun.lockb` to the existing list that already check npm/pnpm/yarn.

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

## For Contributors

### Improving Documentation

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

### Adding or Updating Examples

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

### Fixing a bug

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

### Adding a feature

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


## For Maintainers

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

### What?

### Why?

### How?

Closes NEXT-
Fixes #

-->


Closes NEXT-2766
2024-03-18 17:44:18 +01:00
Jiachi Liu
e1a7de0d04
feat(error-overlay): handle script under html hydration error (#63403)
script tag cannot be placed under html directly, users reported a case
in #51242 that having `<Script>` under html will cause hydration error,
this will display the React hydration error related warning of bad usage
for it.

You will see this warning in dev overlay instead of displaying nothing
```
In HTML, <script> cannot be a child of <html>.
This will cause a hydration error.
```

Added two other react warnings detection patterns  as well
* `Warning: In HTML, text nodes cannot be a child of <%s>.\nThis will
cause a hydration error.',`
* `Warning: In HTML, whitespace text nodes cann...`

But tested they're not generating hydration errors, only warnings in
console, so we don't need to have tests for them.

Closes NEXT-2835
2024-03-18 11:40:01 +01:00
vercel-release-bot
8b9e18503c v14.2.0-canary.28 2024-03-18 10:01:02 +00:00
Shu Ding
391925808b
Code refactor (#63391)
Two small changes. There's no need to check `payload === undefined` as
it will always be a string. At the other place we can reuse the global
`textEncoder` instance.

Closes NEXT-2830
2024-03-18 10:34:30 +01:00
Tobias Koppers
46a5882223
New CSS chunking algorithm (#63157)
### What?

This fixes more CSS ordering issues with production and webpack dev.

* CSS Modules must not be side effect free as side effect free modules
are per definition order independent which is not true for CSS
* fix order of iterating module references
* disable splitChunks for CSS
* special chunking for CSS with loose and strict mode
* more test cases

Closes PACK-2709
2024-03-18 10:29:13 +01:00
Oliver Lassen
af5b31c238
bug: Fields truncated when submitting form using Server Actions (#59877)
When using Server Actions with a form the fields are getting truncated
at 1MB because of `busboy`'s default `fieldSize` limit of 1MB.

This PR tries to solve https://github.com/vercel/next.js/issues/59277
however there is a mismatch about `fieldSize` and `bodySize`. I have
tried creating a PR for `busboy`
https://github.com/mscdex/busboy/pull/351 to allow configuring a max
size for the entire body.

### TODO:

- [ ] Figure out if this is acceptable
- [ ] Throw error when `bodySizeLimit` is hit.

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

-->

Fixes #59277, closes #61462.

---------

Co-authored-by: Shu Ding <g@shud.in>
2024-03-18 09:08:29 +00:00
Shu Ding
107cfbfec7
Use correct protocol and hostname for internal redirections in Server Actions (#63389)
Currently, we always fallback to https as the protocol for redirection
requests inside Server Actions even for the local server host, which can
be `0.0.0.0` and result in SSL errors.

Closes #63114, partially resolves
https://github.com/vercel/next.js/issues/62903#issuecomment-1984179180.

Closes NEXT-2829
2024-03-18 10:01:45 +01:00
vercel-release-bot
8d5e9178f9 v14.2.0-canary.27 2024-03-17 23:23:04 +00:00
vercel-release-bot
f1a999ee73 v14.2.0-canary.26 2024-03-16 22:31:13 +00:00
vercel-release-bot
3b6b04ae2c v14.2.0-canary.25 2024-03-16 20:06:26 +00:00
Tobias Koppers
43d911406b
add conditions for webpack loader rules (#63333)
### What?

* Allow to apply webpack loaders depending on "conditions".
* add a few next specific conditions depending on context type

### Why?

Some loaders need different behavior depending on context

### How?


Closes PACK-2748
2024-03-16 21:02:10 +01:00
Jiachi Liu
53c21881de
fix(error-overlay): matching html tag with brackets in hydration error (#63365)
### What

* The tags extracted from hydration errors could be "<div>" and "p", we
need to stripe the brackets "<>" for matching the tag name from
component stack
* Change the dimmed text color to lighter so you can see it better in
light mode

#### After vs Before

<img width="450"
src="https://github.com/vercel/next.js/assets/4800338/6caed5ac-c073-41cc-a699-eb29f3785d59">

<img width="450"
src="https://github.com/vercel/next.js/assets/4800338/926aa80f-2a49-4362-b77e-16b819955b0a">


Closes NEXT-2828
2024-03-16 19:24:54 +00:00
Jumpei Ogawa
dc2be6483f
Add JSM (ESM) support for next/lib/find-config (#63109)
Fixes #34448

Before this PR, next/lib/find-config fails to load \*.config.mjs files
and \*.config.js files when `"type": "module"` is set in package.json.
It expects CommonJS files although the \*.config.{js|mjs} files are
written in JS modules format (i.e. using `import` and `export`).
This PR fixes it so that it can load configs written in JS modules
format.

---------

Co-authored-by: Jiachi Liu <inbox@huozhi.im>
2024-03-16 16:03:24 +00:00
Josh Story
6a6dd9cd2a
Fixes typo in Route handler static generation error handling (#63345)
Error had a typo in it. it should be `force-dynamic` not
`dynamic-error`.

Closes NEXT-2827
2024-03-16 11:25:46 +01:00
Will Binns-Smith
aa13705514
Turbopack HMR: Log when more errors cause full page reload (#63220)
Turbopack HMR: Log when more errors cause full page reload

Depends on vercel/turbo#7715

This adds messaging when HMR updates fail because:

- An HMR update could not be applied, such as updating an anonymous
function component
- An update follows a server-rendered error

Test Plan: See now passing tests in the manifest

Closes PACK-2728
2024-03-15 16:51:02 -07:00
vercel-release-bot
fd692b61e0 v14.2.0-canary.24 2024-03-15 23:22:11 +00:00
Jiachi Liu
955a81bf39
Polish the display color styles for component diff (#63342)
### What
In component diff view, dim the indirect components so that users can
focus on the adjacent ones, and can easily locate the bad tags in
visual.

We still have the `^^^` text for jest snapshots, but they'll not
visually displayed for users, as the red text is enough for users to
notice the incorrect one and `^^^` was more like a terminal text styles
that we don't need to bring them in the web UI.

#### After

<img width="400"
src="https://github.com/vercel/next.js/assets/4800338/9a24f830-14b4-49a2-948a-5afbced8ec6f">

#### Before

<img width="400"
src="https://github.com/vercel/next.js/assets/4800338/c3ee593a-956b-447e-bad2-88007159d00f">


Closes NEXT-2826
Closes NEXT-2771
2024-03-15 23:08:18 +01:00
Tim Neutkens
2417bf9b6f
Ensure changes in optimizePackageImports invalidate webpack cache (#63284)
## What?

Makes sure changes to `optimizePackageImports` apply when there is an
existing 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

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

### Adding or Updating Examples

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

### Fixing a bug

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

### Adding a feature

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


## For Maintainers

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

### What?

### Why?

### How?

Closes NEXT-
Fixes #

-->


Closes NEXT-2817
2024-03-15 14:35:59 +01:00
Donny/강동윤
8cf86bba25
fix(turbopack): Remove error overlay when pages/_app is fixed (#63306)
### What?

Apply same patch as https://github.com/vercel/next.js/pull/62983 for
`pages/_app.js`

### Why?

To make turbopack match behavior of webpack mode, and make the test
passs

### How?

Closes PACK-2407
2024-03-15 12:03:08 +09:00
Zack Tanner
5e3bac5c1e
Store loading data in CacheNode (#62346)
This changes how loading components are provided to `LayoutRouter` to instead be part of the `CacheNode`. This makes it so that we can copy it over/expire it in a similar way to the `data` property on a `CacheNode`. Consequently, this fixes a bug in PPR navigations, where 2 different loading states (the prefetched one, followed by the updated one) might be displayed upon navigating. 

Note: This disables a PPR test that asserts the loading data gets expired after 5 minutes. As implemented, the loading data will remain cached for a particular segment. 

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

## For Contributors

### Improving Documentation

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

### Adding or Updating Examples

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

### Fixing a bug

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

### Adding a feature

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


## For Maintainers

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

### What?

### Why?

### How?

Closes NEXT-
Fixes #

-->


Closes NEXT-2557
2024-03-14 16:32:51 -07:00
vercel-release-bot
39a8429ac4 v14.2.0-canary.23 2024-03-14 23:21:31 +00:00
Ziya Fenn
94d69bb847
Fix URL displayed in Server Action bodysizelimit error (#63295)
<!-- 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 #

-->

Current URL points to a non-existing anchor. Updated url to point to
next-config options.
2024-03-14 18:08:08 +00:00
Jiachi Liu
6556a342b9
fix: hydration error display for text under tag case (#63288)
There's a type of hydration warning is mismatch `"text content"` under a
`<tag>`, such as `Did not expect server HTML to contain the text node
"bad text" in <div>.`, we need to treate them separately from the text
diff or bad neseting tags.

### After

![image](https://github.com/vercel/next.js/assets/4800338/4dabfeae-b42a-4232-ab55-1704db36f5ce)


### Before


![image](https://github.com/vercel/next.js/assets/4800338/1da14435-cb3a-4883-84c8-7f0ce4c83b21)


Closes NEXT-2819
2024-03-14 16:03:28 +01:00
vercel-release-bot
847b340180 v14.2.0-canary.22 2024-03-14 12:45:30 +00:00
Donny/강동윤
92fbd7802c
build: Update turbopack (#63273)
# Turbopack changes

* https://github.com/vercel/turbo/pull/7726 <!-- OJ Kwon - feat(node): augment webpack loader's logger context -->
* https://github.com/vercel/turbo/pull/7729 <!-- Donny/강동윤 - Update `swc_core` to `v0.90.22` -->
2024-03-14 08:53:14 +00:00
Dima Voytenko
82dc672af9
Disable cache in testmode (#63265)
Fixes #63127.
2024-03-14 00:20:54 -07:00
Donny/강동윤
6d45c3252c
fix(turbopack): Remove error overlay when issue is resolved (#62983)
### What?

Subscribe to changes of `_error` pages.

### Why?

To make the error overlay disappear when the error is fixed.

I tried skipping related entries by using `continue;` from
5f3b13584c/packages/next/src/server/dev/hot-reloader-turbopack.ts (L675-L684),
but it resulted in it page being rendered in the background while error
overlay does not disappear.

We need to remove the errors from `/_error` page to make the error
overlay disappear, so I tried removing them from the map and it worked.

### How?

Closes PACK-2405
Closes PACK-2644

---------

Co-authored-by: hrmny <8845940+ForsakenHarmony@users.noreply.github.com>
2024-03-14 04:31:37 +00:00
Sam Ko
0a697cf044
fix(route-handlers): make sure preflight has CORS headers (#63264)
## Why?

When we just have a POST route handler, it seems CORs is not working
properly. This is because we break out of the loop here
768a92b15b/packages/next/src/server/future/route-modules/app-route/helpers/auto-implement-methods.ts (L38)
when a `GET` isn't present before we add the correct headers and status
to the preflight `OPTION`.

- Closes https://github.com/vercel/next.js/issues/57999

Closes NEXT-2813

---------

Co-authored-by: JJ Kasper <jj@jjsweb.site>
2024-03-14 00:59:57 +00:00
vercel-release-bot
768a92b15b v14.2.0-canary.21 2024-03-13 23:21:44 +00:00
JJ Kasper
8f09bc44f7
Fix middleware catch-all rewrite case (#63254)
This ensures we properly set the matched header when applying a
middleware skip optimization so that the client router has enough
context to finish resolving the dynamic route params.

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

Closes NEXT-2803
2024-03-13 14:14:04 -07:00
Steven
02a06175e3
feat: add deploymentId config (#63198)
This PR stabilizes an experimental feature that was added in a previous
PR https://github.com/vercel/next.js/pull/50470

It allows the user to set `deploymentId` in `next.config.js`, which is a
unique identifier for a deployment that will be included in each
request's query string or header.

This PR is easier to review with whitespace hidden:
https://github.com/vercel/next.js/pull/63198/files?w=1

Closes NEXT-2789
2024-03-13 16:46:50 -04:00
OJ Kwon
49004e3e15
feat(turbopack): emit well known error into cli (#63218)
### What

This is stopgap substitution to webpack's wellknownerrorsplugin. When
webpack compilation hits known errors kind it emits compilation errors
into cli (and dev overlay both) while turbopack currently only emits
into error overlay. PR simply detects if given issue is well known, and
then logs into std.

Probably a long term there should be proper wiring instead; but for now
this allows to make few things work out of the box.

Closes PACK-2727
2024-03-13 13:38:38 -07:00
Ethan Arrowood
1ff10a03c6
enable optimizeServerReact by default (#62658)
Enable the `experimental#optimizeServerReact` configuration by default. 

Disable the `optimize_use_state` option for the optimization as this may
cause issues in React 19

Closes NEXT-2640
2024-03-13 13:44:47 -06:00
Donny/강동윤
2e19459c88
fix(turbopack): Do not report hmr timing twice (#63227)
### What?

Make turbopack not emit HMR timing report twice.

### Why?

We should not report HMR update twice.

### How?

Closes PACK-2581

---------

Co-authored-by: Tobias Koppers <tobias.koppers@googlemail.com>
2024-03-13 17:30:06 +00:00
vercel-release-bot
9d601afb08 v14.2.0-canary.20 2024-03-13 17:25:13 +00:00
Donny/강동윤
013ba06810
chore: Update swc_core to v0.90.21 (#63031)
### What?

- Update `swc_core` to fix performance regression caused by the creation
of the `tokio` runtime.

This PR practically reverts
https://github.com/vercel/next.js/pull/62441.

 - Apply various minifier bug fixes.

   - https://github.com/swc-project/swc/pull/8730
   - https://github.com/swc-project/swc/pull/8733
   - https://github.com/swc-project/swc/pull/8725
   - https://github.com/swc-project/swc/pull/8726
   - https://github.com/swc-project/swc/pull/8727

- Apply https://github.com/swc-project/plugins/pull/271 (Closes
PACK-2714)


### Why?

Someone reported a performance regression. See
https://github.com/swc-project/swc/issues/8708

### How?

Closes PACK-2693

---------

Co-authored-by: Tobias Koppers <tobias.koppers@googlemail.com>
2024-03-13 17:11:43 +00:00
Jiachi Liu
ed893fa0d3
Use SWC to valid client next/navigation hooks usage in server components (#63160)
### What

Use SWC to check invalid client hooks of `next/navigation` imports in
server components.
Follow up of #62456 

Remove the runtime error APIs for `next/navigation` rsc version.
Add `next/navigation` react-server version alias in turbopack.

This PR also refactored the invalid server layer APIs detection into a
map, where key is import path and value is an array of client APIs.
During the traversing we will get the import source easily, this makes
extending the logic much easier

### Why

Previously we're using the runtime error to check it, but it has to run
first then the error will be thrown. If we error first in build time
with this check it's much faster and we this align on both side between
webpack and turbopack.
2024-03-13 16:37:36 +01:00
Tim Neutkens
8ef121dff5
Implement new runtime_type for Turbopack (#63212)
## What?

Implementation of https://github.com/vercel/turbo/pull/7711

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

## For Contributors

### Improving Documentation

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

### Adding or Updating Examples

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

### Fixing a bug

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

### Adding a feature

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


## For Maintainers

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

### What?

### Why?

### How?

Closes NEXT-
Fixes #

-->


Closes NEXT-2791

---------

Co-authored-by: Tobias Koppers <tobias.koppers@googlemail.com>
2024-03-13 16:16:57 +01:00
Zack Tanner
500bc1fe1b
make CacheNode properties non-optional (#63219)
No behavior changes in this PR -- this is a refactor to remove the
optional types on `CacheNode` to be more explicit when we aren't copying
over a value and to help with monomorphization. There's still work to be
done to ensure consistent property order, which will come in a separate
PR.

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

## For Contributors

### Improving Documentation

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

### Adding or Updating Examples

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

### Fixing a bug

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

### Adding a feature

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


## For Maintainers

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

### What?

### Why?

### How?

Closes NEXT-
Fixes #

-->


Closes NEXT-2794
2024-03-13 08:16:15 -07:00
Donny/강동윤
3e6720c364
build: Update turbopack (#63229)
# Turbopack

* https://github.com/vercel/turbo/pull/7719 <!-- Tobias Koppers - accept
css files outside of the project as virtual assets -->
* https://github.com/vercel/turbo/pull/7661 <!-- Tobias Koppers - more
efficient node.js process startup -->
* https://github.com/vercel/turbo/pull/7720 <!-- Tobias Koppers -
generate correct async module handling for side effects optimization -->
* https://github.com/vercel/turbo/pull/7718 <!-- Donny/강동윤 -
fix(turbopack): Fix CSS Modules class name for lightningcss mode -->

### What?

Update tests to make CSS Modules of `lightningcss` work with CSS grids.

### Why?

`lightningcss` enforces the class name to end with `[local]`.

See: https://lightningcss.dev/css-modules.html#css-grid


### How?

Closes PACK-2731
2024-03-13 10:13:56 +00:00
Balázs Orbán
9603b20900
fix: re-export internal path (#63222)
### What?

### Why?

### How?

[Slack
thread](https://vercel.slack.com/archives/C03S8ED1DKM/p1710283738235509)

Closes NEXT-2795
2024-03-13 09:55:23 +01:00
Balázs Orbán
55714b4163
fix(error-overlay): show Turbopack indicator for any staleness level (#63130) 2024-03-13 00:37:27 +01:00
vercel-release-bot
ca10b73cd5 v14.2.0-canary.19 2024-03-12 23:22:31 +00:00
Zack Tanner
0312d4a1a9
fix revalidation issue with route handlers (#63213)
### What
When a route handler uses an API that opts it into dynamic rendering
(such as `no-store` on a fetch), and also specifies a `revalidate` time,
the `revalidate` time is ignored and route is treated as fully static.

### Why
`revalidate: 0` and `revalidate: false` have different semantic
meanings: `false` essentially means cache forever, whereas `0` means
it's dynamic. Since `0` is also falsey, the code we have to fallback
with a default `revalidate` value for route handlers is incorrectly not
marking the route as dynamic, and as a result, caching the route without
an expiration time.

### How
This updates the fallback handling for app routes respect a revalidation
value of `0`, so that the page can properly be marked dynamic.

### Test Explanation
This adds 2 new routes handlers: both have a revalidation time specified
& use `no-store` on a fetch, but only one of them specifies `export
const dynamic = 'force-static'`. The one that doesn't specify
`force-static` is correctly omitted from the prerender manifest. The one
that is `force-static` is correctly in the prerender manifest with the
right expiration time. An additional test case was added to verify that
this data refreshes after the specified interval.

Closes NEXT-2764
2024-03-12 15:57:36 -07:00
Balázs Orbán
6464f677c3
fix(error-overlay): strip line+column from webpack internal frames (#63133)
Co-authored-by: Jiachi Liu <inbox@huozhi.im>
2024-03-12 23:42:56 +01:00
Balázs Orbán
8ff1fd8f71
fix(log): improve error when dynamic code eval is disallowed (#62999) 2024-03-12 23:31:32 +01:00
Shu Ding
977f5ff72e
fix: Loose Server Actions runtime check (#63200)
Addresses some feedback in #62821. This will re-allow implementations
like:

```js
'use server'

export const f = wrapper(async () => {})
```

Where `wrapper` creates a sync function that returns a promise. Although
it will still be silently converted to an async function under the hood.

Closes NEXT-2790
2024-03-12 22:03:29 +00:00
Tobias Koppers
18547d5fd0
add support for assets in edge (#63209)
### What?

add support for `new URL(..., import.meta.url)` assets in edge. e. g.
needed for og-image.

### Why?

### Turbopack Changes

* https://github.com/vercel/turbo/pull/7712 <!-- Tobias Koppers - allow
to use full urls in browser runtime -->

Closes PACK-2725
2024-03-12 21:37:16 +00:00
OJ Kwon
11af8dd96f
build(cargo): bump up turbopack (#63205)
* https://github.com/vercel/turbo/pull/7696 <!-- Leah -
fix(turbopack-ecmascript): always create values from object
destructuring -->
* https://github.com/vercel/turbo/pull/7709 <!-- OJ Kwon - build(cargo):
bump up deps, resolve build failures

Resolves build failurs with recent transitive deps bump.



Closes PACK-2720
2024-03-12 21:50:10 +01:00
vercel-release-bot
c1daa769f6 v14.2.0-canary.18 2024-03-12 17:31:06 +00:00
JJ Kasper
aa7ae420c6
Fix generateMetadata race condition (#63169)
This ensures we properly catch/handle `generateMetadata` errors during
eager evaluating of nested `generateMetadata` functions in the tree.
Previously if we eager evaluated a child metadata function that threw an
error e.g. `notFound()` and but the parent metadata function took longer
the thrown error would be an unhandled rejection causing the process to
crash depending on the environment.

Fixes: NEXT-2588


Closes NEXT-2786
2024-03-12 17:23:02 +00:00
Yuval Lotem
fb1190425c
fix: x-forwarded-port header is 'undefined' when no port in url (#60484)
### What?
See this issue - https://github.com/vercel/next.js/issues/61133

following this change https://github.com/vercel/next.js/pull/57815
`x-forwarded-port` header value is 'undefined' if the URL has no port

### Why?
x-forwarded-port 'undefined' makes other http-proxy throw 405 error for
the invalid header value

### How?
Give default 80 port if the URL has no port

---------

Co-authored-by: Ethan Arrowood <ethan@arrowood.dev>
2024-03-12 16:45:50 +00:00
vercel-release-bot
0e9baea77f v14.2.0-canary.17 2024-03-12 15:10:31 +00:00
Tim Neutkens
54adb71a8d
Ensure undefined values end up being replaced (#63138)
## What?

Follow-up to #63128

`JSON.stringify(undefined)` ends up with the value `undefined`. However
for Webpack/Turbopack to correctly inject `undefined` into the code it
has to be the string `'undefined'`. This change ensures the
serialization takes into account that case.

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

## For Contributors

### Improving Documentation

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

### Adding or Updating Examples

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

### Fixing a bug

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

### Adding a feature

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


## For Maintainers

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

### What?

### Why?

### How?

Closes NEXT-
Fixes #

-->


Closes NEXT-2773
2024-03-12 16:04:50 +01:00
Tim Neutkens
7de0f478c6
Ensure PromiseLikeOfReactNode is not included in .d.ts files (#63185)
Fixes the compile error on all test runs currently:
https://github.com/vercel/next.js/actions/runs/8243077904/job/22543375810?pr=63167#step:27:345

The root cause is that `.d.ts` files automatically include inferred
return types automatically, in this case `tsc` included React class
component `render()` return types in the `.d.ts` for e.g.
error-boundary.tsx / redirect-boundary.tsx. This is a problem because
yesterday that return type was changed:
bf659aefa7 (diff-1d64e275d9755825ba)[…]520436dbd8e1f1fd9fc66a9
and that change also removes one of the previous types that the `.d.ts`
in Next.js automatically included.

This PR changes the `render()` return type to be explicit instead of
inferred, this makes sure that the `.d.ts` file includes only `:
React.ReactNode` instead of the many types of return values allowed.

The reason I went with the explicit type instead of e.g. upgrading
`@types/react` is that upgrading the types would cause existing
applications that use older versions of `@types/react` would break. The
current change ensures it works in both cases.

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

## For Contributors

### Improving Documentation

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

### Adding or Updating Examples

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

### Fixing a bug

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

### Adding a feature

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


## For Maintainers

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

### What?

### Why?

### How?

Closes NEXT-
Fixes #

-->


Closes NEXT-2787
2024-03-12 12:51:35 +00:00
vercel-release-bot
d4069559f2 v14.2.0-canary.16 2024-03-11 23:23:31 +00:00
vercel-release-bot
6d0d1fe347 v14.2.0-canary.15 2024-03-11 22:00:55 +00:00
Zack Tanner
465109eab3
ensure mpa navigations to the same URL work after restoring from bfcache (#63155)
### What
When triggering an MPA navigation (also commonly referred to as a "hard
navigation"), and then restoring the previous page via the browser's
bfcache, subsequent requests to the same link wouldn't navigate until
reloading the page or performing a different navigation.

### Why
MPA navigations in app router are handled in a fairly unconventional
way: the router state is updated with an indication that an external URL
was clicked, and once the router sees the pending navigation, it kicks
off a `location.replace` or `location.push` with the specified URL **in
render**. The router then suspends indefinitely to prevent committing
the render. However, the router will only make the `replace`/`push`
request if there's not already a pending navigation to that same URL.

The pending check is needed to avoid continuously calling
`push`/`replace` when unrelated router state changes occur (for example,
if I hover over a link and trigger a prefetch action and the router
re-renders, it shouldn't make another `location.push` call to the same
URL that's pending)

However, the source of the bug is that the variable that holds this
pending state is also restored by the browser's cache, since it takes a
snapshot prior to exiting the page. This means that when clicking the
browser back button, `pendingMpaPath` would still be set to the URL we
just came from. When clicking the link again, it would see that the
requested URL is the same as the pending URL, and not perform any
history actions.

### How
This clears the pending value when the router is restored from bfcache.

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

-->

[slack
x-ref](https://vercel.slack.com/archives/C0676QZBWKS/p1710169967246929)

Closes NEXT-2781
Closes NEXT-2776
2024-03-11 14:55:04 -07:00
vercel-release-bot
da72b60e37 v14.2.0-canary.14 2024-03-11 20:51:37 +00:00
Apostolos Tsakpinis
a00458b5e9
fix typo in server/config.ts (#62795)
lager -> larger

---------

Co-authored-by: samcx <sam@vercel.com>
2024-03-11 19:12:00 +00:00
pacexy
0bad7143d7
Fix webpack HMR for pages on the edge runtime (#60881)
This fixes the issue that build error is not cleared correctly during
`next dev` even if the build succeeds, and we have to re-run `next dev`
to make it work.

It appears only when:

1. page runtime is `edge`
2. use webpack hot reloader
3. import components in the `edge` page

Reproduction:
https://github.com/pacexy/nextjs-edge-webpack-hmr-reproduction

I recorded a screenshot to make it easier to understand:


https://github.com/vercel/next.js/assets/32255488/0ddc21bf-2ea7-49ce-b682-c89dea757c61

Closes NEXT-2168

---------

Co-authored-by: Jiachi Liu <inbox@huozhi.im>
2024-03-11 16:53:04 +01:00
Wyatt Johnson
7057d1ebf5
[PPR] Support rewrites in middleware (#63071)
### What?

This fixes a special case where rewrites wouldn't work when resuming a
dynamic page.

### Why?

Previously, as routes would direct-match against entries in the cache,
this takes the `x-matched-path` as the source of truth for these
requests if the `x-now-route-matches` header is not present.
2024-03-11 09:05:26 -06:00
Tim Neutkens
76c9496027
Refactor define-env-plugin to have stricter types (#63128)
## What?

Working on some refactors to fix a bug with `undefined` handling for
Turbopack. This is the first step by making define-env-plugin.ts have
stricter types so that we can easily find which values are set to
`undefined`.

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

## For Contributors

### Improving Documentation

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

### Adding or Updating Examples

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

### Fixing a bug

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

### Adding a feature

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


## For Maintainers

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

### What?

### Why?

### How?

Closes NEXT-
Fixes #

-->


Closes NEXT-2768
2024-03-11 14:34:47 +01:00
Donny/강동윤
d55699d5f7
feat(turbopack): Enable lightningcss for turbopack by default (#62565)
# Turbopack

* https://github.com/vercel/turbo/pull/7682 <!-- Will Binns-Smith -
Turbopack HMR: url-encode sourceURLs -->
* https://github.com/vercel/turbo/pull/7524 <!-- Donny/강동윤 -
feat(turbopack): Enable lightningcss for turbopack by default -->


### What?

Enable lightningcss by default, for `--turbo` mode.

### Why?

It's time to do it 😄 

### How?

Turbopack counterpart: https://github.com/vercel/turbo/pull/7524


Closes PACK-2600
2024-03-11 06:49:43 +00:00
vercel-release-bot
6fee6b271b v14.2.0-canary.13 2024-03-10 23:23:45 +00:00
Balázs Orbán
1e26cceff4
refactor(error-overlay): unify Pages/App router error overlay source (#62939) 2024-03-10 22:34:30 +01:00
vercel-release-bot
fff9ddc204 v14.2.0-canary.12 2024-03-09 23:23:12 +00:00
mattddean
6da6388b62
Correctly deserialize undefined unstable_cache data (#59126)
<!-- 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 #

-->

The value `undefined` can be saved to the incremental cache as
`undefined` (`JSON.stringify(undefined)`) with no errors, but when
retrieving it, we attempt to parse it as JSON using
`JSON.parse(undefined)`. This throws an error. We should instead
deserialize `undefined` as `undefined` when retrieving.

relevant discussion: #59087

---------

Co-authored-by: Sam Ko <sam@vercel.com>
2024-03-08 22:07:09 -08:00
Dima Voytenko
b8d63702f3
OTEL: add next.rsc attribute for RSC requests (#63074)
`next.rsc: boolean` attribute to indicate whether it's a RSC request
2024-03-08 21:58:00 -08:00
OJ Kwon
42b42a6498
build(cargo): bump up turbopack (#63073)
### What

* https://github.com/vercel/turbo/pull/7684 <!-- OJ Kwon -
feat(resolve): skip alias to d.ts -->



Closes PACK-2702
2024-03-09 01:29:21 +00:00
vercel-release-bot
a2457c979b v14.2.0-canary.11 2024-03-08 23:24:43 +00:00
Jiachi Liu
664073e86f
Fix metadata url cases should not append with trailing slash (#63050)
### What

Exclude the cases like external urls and relative urls with query from
appending trailing slash when it's needed.

The process is:
- If it's a uncertain string path (relative url, could start with `'./'`
or `/`), convert to relative that starts with `/`;
- then we covert the url (string or URL) to string url
- We do the check if we need to append the trailing slash

### Why

In #62109 we added functionality that can only append trailing slash
when we appended trailing slash to some metadata url like `canonical`
url and open graph url when the config is enabled.
For urls with queries, the trailing slash can also be omitted.
For the external urls (different origin comparing to `metadataBase`) we
don't need to append trailing slash as they're not the same web app.

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

Closes NEXT-2762
Closes NEXT-2753
2024-03-08 21:16:16 +01:00
Wyatt Johnson
ea56c8f7ad
DX: add route context to dynamic errors for app routes (#62844)
Gives the users pathname context on routes that access Dynamic API's so
that if these errors are caught they can modify their code accordingly.
This is a followup to #61332.


Closes NEXT-2695
2024-03-08 11:35:24 -07:00
vercel-release-bot
5482940dd9 v14.2.0-canary.10 2024-03-08 15:19:20 +00:00
Tobias Koppers
72d88c1596
app layouts/pages depend on shared main files (#63042)
### What?

avoid duplication of next.js internals in app dir

For the example/hello-world:

Before:

```
Route (app)                                          Size     First Load JS
┌ ○ /                                                15 kB           184 kB
└ ○ /_not-found                                      15 kB           184 kB
+ First Load JS shared by all                        169 kB
  ├ chunks/[project]__929616._.js                    85.2 kB
  ├ chunks/[project]_packages_next_dist_0f911b._.js  83.2 kB
  └ other shared chunks (total)                      230 B
```

After:

```
Route (app)                                          Size     First Load JS
┌ ○ /                                                15 kB           104 kB
└ ○ /_not-found                                      15 kB           104 kB
+ First Load JS shared by all                        88.9 kB
  ├ chunks/[project]_packages_next_dist_0f911b._.js  83.2 kB
  └ other shared chunks (total)                      5.7 kB
```


Closes PACK-2695

### Turbopack changes

* https://github.com/vercel/turbo/pull/7617 <!-- OJ Kwon -
feat(turbopack): add missing webpack context property -->
* https://github.com/vercel/turbo/pull/7676 <!-- Tim Neutkens -
Implement minify for Turbopack runtime file -->
* https://github.com/vercel/turbo/pull/7677 <!-- Tobias Koppers - add
FullContextTransition -->
2024-03-08 16:12:33 +01:00
vercel-release-bot
af5b4db98a v14.2.0-canary.9 2024-03-08 08:29:26 +00:00
Tim Neutkens
36e401ecc5
Enable minification for Turbopack (#62994)
## What?

Implementation for https://github.com/vercel/turbo/pull/7660. Enables
minification of browser files.

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

## For Contributors

### Improving Documentation

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

### Adding or Updating Examples

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

### Fixing a bug

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

### Adding a feature

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


## For Maintainers

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

### What?

### Why?

### How?

Closes NEXT-
Fixes #

-->


Closes NEXT-2742

---------

Co-authored-by: Tobias Koppers <tobias.koppers@googlemail.com>
2024-03-08 08:11:50 +01:00
Will Binns-Smith
bd72f39ca8
Turbopack + pages router: recover from runtime errors by reloading (#63024)
An iteration of #62359, this uses the module-local flag instead of a
shared dedicated module for flagging runtime errors, correctly reloading
the page when these occur.

Test Plan: See now-passing tests in the manifest.


Closes PACK-2690
2024-03-07 17:24:50 -08:00
Jiachi Liu
25be9cafec
Fix the plugin state for async modules in webpack plugins (#62998)
### What

Use the plugin state directly in flight plugins to access the async
modules collection

### Why

This change is cherry-picked from #62349 , where I found the plugin
state didn't store the async modules reousces properly due to the clone
of the array in flight manifest plugin. So for flight manifestp plugin
itself, it's holding a different instance rather than the one from proxy
state.

Closes NEXT-2743
2024-03-08 00:25:32 +01:00
vercel-release-bot
ea5b23c870 v14.2.0-canary.8 2024-03-07 23:24:26 +00:00
vercel-release-bot
0b679a0fed v14.2.0-canary.7 2024-03-07 21:37:05 +00:00
OJ Kwon
710933b033
feat(next): fallback lightning if swc/wasm loaded (#62952)
### What?

Currently wasm binding cannot build lightningcss, until we can make it
work falls back to normal css if lightningcss is enabled + wasm bindings
are loaded.



Closes PACK-2678
2024-03-07 13:30:14 -08:00
Donny/강동윤
03d89bc56d
Update turbopack (#62971)
# Turbopack

* https://github.com/vercel/turbo/pull/7625 <!-- Tobias Koppers -
generate calls of bindings correctly without this context -->
* https://github.com/vercel/turbo/pull/7621 <!-- Donny/강동윤 - fix: Fix
purity lint for CSS Modules in swc mode -->
* https://github.com/vercel/turbo/pull/7640 <!-- Tobias Koppers - very
dynamic requests will only lead to a warning -->
* https://github.com/vercel/turbo/pull/7639 <!-- Donny/강동윤 - build:
Update `swc_core` to `v0.90.17` -->


### What?

Update turbopack

### Why?

To keep in sync

### How?
2024-03-07 14:30:54 +01:00
Jiachi Liu
27ed7820a8
[error overlay] move missing tags error inside error overlay (#62993)
### What

* Move missing html tags error into error overlay, from outside we don't
have to manually determine when to render a dummy component with runtime
missing tag error or error overlay.
* Add brackets `<>` to the html tags in the error



![image](https://github.com/vercel/next.js/assets/4800338/cd3467b7-74c2-477e-8516-c31761adb064)


### Why

In #62815, we're having throwing an missing required error, this will
trigger another runtime error. Then when error overlay caught it through
error event listener, it will render it as an unhandled runtime error:

You will see the below message in the overlay.
```
Unhandled Runtime Error
Error: The following tas are missing...

[Error stack]
```

This error message will bring a message that the error is happened on
client during runtime, but actually we already know that is a user side
mistake which doesn't have a error trace. This couldn't hmr as you fix
the error as well.

This PR moves the rendering into error overlay that we're aware of the
errors and can render the correct html on client, with the `html` tag
attached with error id and `body` wrapping the error overlay. We tell
overlay that there're missing tags through props, let it handle
everything inside.

It can also hmr once you fix the error. One drawback is that when you
re-introduce the error, it might trigger react DOM updates exception
(`Failed to execute 'removeChild' on 'Node': The node to be removed is
not a child of this node.`) instead of the "missing tags" message again.
Besides that the HMR works properly.

Closes NEXT-2741
2024-03-07 14:24:00 +01:00
Balázs Orbán
5740ef3e1e
refactor(ts): type fastRefresh (#62848) 2024-03-07 12:21:17 +01:00
Donny/강동윤
5be869b667
build: Update swc_core to v0.90.17 (#62924)
### What?

Update SWC crates.

### Why?

To keep in sync.

### How?

Closes PACK-2670
2024-03-07 11:25:16 +09:00
Zack Tanner
b580b87269
Pass whole prefetch entry rather than status property (#62345)
No change in behavior -- this PR updates `applyFlightData` and its recursive functions to receive the prefetch entry rather than a boolean. We only use the actual prefetch entry in `fillLazyItemsTillLeafWithHead` but I found kept getting confused about what this argument was needed for when it was provided so far away from the part where we read the boolean. 

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

## For Contributors

### Improving Documentation

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

### Adding or Updating Examples

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

### Fixing a bug

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

### Adding a feature

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


## For Maintainers

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

### What?

### Why?

### How?

Closes NEXT-
Fixes #

-->


Closes NEXT-2556
2024-03-06 17:14:14 -08:00
James Mikrut
a1e294b706
Remove Payload from server-external-packages.json (#62965)
Payload is moving to ESM, and we need to be removed from the default
list of `serverComponentsExternalPackages`.

This PR simply removes Payload from the default list. Developers can add
it back in if they are using older versions of Payload.

---------

Co-authored-by: JJ Kasper <jj@jjsweb.site>
2024-03-06 15:52:40 -08:00
vercel-release-bot
dd6cfd9882 v14.2.0-canary.6 2024-03-06 23:22:59 +00:00
Sam Ko
ee273c42bc
chore(next-font): update @capsize/metrics package to the latest (#62896)
## Why?

We need to be up-to-date with this package so our `next/font` is working
optimally. → https://github.com/seek-oss/capsize/releases.

Unlikely related to the latest
[comment](https://github.com/vercel/next.js/issues/47115#issuecomment-1979248754),
but a good reminder I need to check this regularly (or we should
automate it, or have a better solution).

Closes NEXT-2715
2024-03-06 12:04:20 -08:00
vercel-release-bot
e28be5377f v14.2.0-canary.5 2024-03-06 19:57:27 +00:00