Commit Graph
234 Commits
Author SHA1 Message Date
Cong-Cong PanandGitHub bdb87a1851 chore: update rspack to 1.4.5 (#81216)
<!-- 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 #

-->

update Rspack to 1.4.2, in this version we fix bugs when using Rspack
persistent cache in next.js.

Now user can try Rspack persistent cache by follow way:

```js
const config = {
    webpack: (config) => {
        config.experiments.cache = {
            type: 'persistent'
        };
        return config;
    },
};
```
2025-07-08 17:57:38 +00:00
JJ KasperandGitHub 58bc2f112c Migrate usage of web-server in edge-ssr (#80915)
This continues the work for the `handlers` interface for the edge
runtime and re-uses the existing `route-module` interface we have
instead of initializing and using `web-server`/`base-server`.

Validated against our deploy tests
https://github.com/vercel/vercel/actions/runs/15987684940/job/45095833866?pr=13505
https://github.com/vercel/next.js/actions/runs/15987664161/job/45095390463
2025-07-02 10:18:13 -07:00
Niklas MischkulnigandGitHub c2be57cc1d Turbopack: pass current Node.js version from JS side instead of invoking node (#80949) 2025-06-27 08:27:16 +02:00
Luke SandbergandGitHub 8ba3a99a10 [turbopack] Add user friendly names to trace labels (#80388)
# Enhance Layer Names with User-Friendly Descriptions

This PR improves the developer experience by enhancing layer names in Turbopack with user-friendly descriptions. Instead of just using internal identifiers like "app-client" or "app-rsc", the PR adds descriptive names like "Client Component Browser" or "Server Component" that better communicate the purpose of each layer to developers.

Key changes:
- Created a new `LayerName` struct that contains both the internal name and an optional user-friendly description
- Updated all layer references throughout the codebase to use this new structure
- Changed error message text from "Example import trace(s)" to "Import trace(s)" for more simplicty

These changes make error messages and debugging information more intuitive, helping developers better understand which part of the application is experiencing issues.
2025-06-26 00:10:04 -07:00
Tim NeutkensandGitHub 5802ba8122 Turbopack Build: Implement browserslist for CSS / JS (#80603)
## What?

Implement browserslist for CSS / JS handling in Turbopack.

For JS it's not fully implemented yet, but for CSS it should be good
now.
2025-06-24 19:11:06 +02:00
Luke SandbergandGitHub 19e8e3c3c2 Revert "Revert "[turbopack] Compute Import Traces for Issues"" (#80220)
Reverts vercel/next.js#80215 which was a revert of vercel/next.js#79351

Closes PACK-4105
2025-06-07 15:28:07 -07:00
Luke SandbergandGitHub 0d2e80554a Revert "[turbopack] Compute Import Traces for Issues" (#80215)
Reverts vercel/next.js#79351

See https://github.com/vercel/next.js/actions/runs/15474422003/job/43570614813#step:34:1556
2025-06-05 13:44:39 -07:00
Luke SandbergandGitHub 7a66008cae [turbopack] Compute Import Traces for Issues (#79351)
When turbopack reports an issue, compute a set of import-traces for that file so the user can better understand the context of the issue and trivially answer questions like:

* Why is this file included at all?
* Why does next think this is a client-component?

To do this we leverage the `SingleModuleGraph` and use the `astar` algorithm from `petgraph` to compute the shortest path to a root module.  This isn't the most optimal approach but should be sufficient since we don't anticipate this being a performance issue.

A complex part of this is that the module-graph tracks the relationships between _modules_ but Issues are associated with _files_.  While modules are also associated with files this is a many-to-one relationship.  This is why we might report _multiple_ traces for a single issue and also why a single file might appear multiple times in a trace.

## Open formatting questions

* how should we represent paths from other 'filesystems'?
    - for disk filesystems i could compute relative paths to the root of the current directory? the `[project]` filesystem?  For now i just use the filesystem name as a hypothetically cromulent root.


## Alternatives

The main alternative investigated was associating  Issues with `Modules` by collecting them during graph construction. This unfortunately proved to be a non-trivial performance regression and so it was abandoned.  The core problem is that we would need to introduce additional `OperationVc` and task roots to simply `collect` the issues.  This also wouldn't eliminate the duplicate traces issue, and instead we might end up reporting duplicate issues instead.

## Performance
TODO

Closes PACK-4105
2025-06-05 11:21:11 -07:00
669a8ca539 Fix(turbopack): Resolve experimentalDecorators from extended tsconfig (#79755)
Co-authored-by: Jude Gao <[email protected]>
2025-06-03 12:25:56 +02:00
Sebastian "Sebbie" SilbermannandGitHub 100881542a [test] Use NEXT_TEST_CI when forking test in CI (#79354) 2025-05-21 20:29:19 +02:00
JJ KasperandGitHub d937203f39 Implement initial handler interface for pages routes (#79260)
Continuation of https://github.com/vercel/next.js/pull/78166 this
implements the `handler` interface for pages routes, This does not move
the response handling inside of the handler yet as that will be in a
follow-up PR to keep the changes isolated. This still returns the
`RenderResult` for the `base-server` to continue to handle.

Validated against `vercel/vercel` deploy tests here
https://github.com/vercel/vercel/pull/13349
2025-05-20 16:23:50 -07:00
Zack TannerandGitHub b304b45e3a bugfix (pages): assetPrefix should not cause hard nav in development (#79176)
In development when handling the page request, we are sending the
parsedUrl with the basePath stripped but not assetPrefix. As a result,
when setting an assetPrefix, the chunk would 404 which causes a hard
nav. It'd then recover and work correctly on subsequent navs.

This applies the exact same handling we had for basePath, but for
assetPrefix.

Fixes #77241
2025-05-14 08:07:28 -07:00
Jiwon ChoiandGitHub a64f6b0735 test: replace duplicate test utils to next instance (#73624)
This PR replaces:
- `renderViaHTTP -> next.render`
- `cheerio.load -> next.render$`
- ~~`process.env.TURBOPACK` -> `isTurbopack`~~ (left as
`process.env.IS_TURBOPACK_TEST`)
2025-05-13 01:46:23 +02:00
Jiwon ChoiandGitHub f7c274328f test: remove unnecessary conditionals in error recovery tests (#73625)
This PR removed unnecessary basePath conditional checks.
2025-05-13 00:45:01 +02:00
Jiwon ChoiandGitHub d48881e4bf test: split hot module reload HMR test into multiple files (#79067)
Split long-running hot module reload hmr test to parallelize and reduce
CI time.

Port of https://github.com/vercel/next.js/pull/73620, confirmed no new
changes.
x-ref:
https://github.com/vercel/next.js/commits/canary/test/development/basic/hmr/hot-module-reload.test.ts
2025-05-13 00:39:41 +02:00
Jiwon ChoiandGitHub 7ac4eae058 test: split error recovery HMR test into multiple files (#79066)
Split long-running error recovery hmr test to parallelize and reduce CI
time.

Port of https://github.com/vercel/next.js/pull/73617, confirmed and
synced changes https://github.com/vercel/next.js/pull/78198,
https://github.com/vercel/next.js/pull/77892,
https://github.com/vercel/next.js/pull/76299,
https://github.com/vercel/next.js/pull/76290, and
https://github.com/vercel/next.js/pull/75882.

x-ref:
https://github.com/vercel/next.js/commits/canary/test/development/basic/hmr/error-recovery.test.ts
2025-05-13 00:04:58 +02:00
Jiwon ChoiandGitHub 2d4406312f test: split full reload HMR test into multiple files (#79065)
Split long-running full reload hmr test to parallelize and reduce CI time.

Port of https://github.com/vercel/next.js/pull/73619, confirmed change https://github.com/vercel/next.js/pull/78198 and synced.

x-ref: https://github.com/vercel/next.js/commits/canary/test/development/basic/hmr/full-reload.test.ts
2025-05-12 23:24:20 +02:00
Jiwon ChoiandGitHub e8a84e866c test: split basic HMR test into multiple files (#79064)
Split long-running basic hmr test to parallelize and reduce CI time.

As @huozhi mentioned at https://github.com/vercel/next.js/pull/73613#pullrequestreview-2485717304, the tests won't be separated to `__test__` dir but flattened out on the same level as the fixture dirs.

Port of https://github.com/vercel/next.js/pull/73616, confirmed no new changes.

x-ref: https://github.com/vercel/next.js/commits/canary/test/development/basic/hmr/basic.test.ts
2025-05-12 21:20:39 +02:00
Sebastian "Sebbie" SilbermannandGitHub 8ea7d4bb35 [dev-overlay] Move error.name to label (#78198) 2025-04-25 11:00:58 +02:00
Janka UrygaandGitHub 4282bc6f91 remove BrowserInterface (#78308)
rip. you served a purpose once, but now you're just getting in the way. this improves typesafety quite a bit, because `BrowserInterface` had a whole bunch of random `any`s everywhere

also
- removes `evalAsync`. no idea why that was needed, but we're happily using promises in normal eval, so it can be dropped
- adds more safety to `chain`
2025-04-18 11:16:15 -07:00
Sebastian "Sebbie" SilbermannandGitHub 2b34bfac5f [test] Remove global styled-components install (#77782) 2025-04-10 12:52:47 +00:00
Sebastian "Sebbie" SilbermannandGitHub b9d65b8afe [test] Assert on all errors in Redbox matchers (#77907) 2025-04-10 10:00:42 +02:00
Tim NeutkensandGitHub 6e51845ac4 Rename process.env.TURBOPACK to process.env.IS_TURBOPACK_TEST for tests (#77892)
Preparation for removing `process.env.TURBOPACK` being added to
Turbopack tests. That way we can properly test `next start` without
`process.env.TURBOPACK` being set.

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

## For Contributors

### Improving Documentation

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

-->
2025-04-07 14:07:55 +02:00
Sebastian "Sebbie" SilbermannandGitHub b7543a2f7f [test] Get rid of unrelated "Invalid hook call" error from tests using styled-components (#77736) 2025-04-03 10:08:01 +02:00
Zack TannerandGitHub 948d59faed exclude images and static media from dev origin check (#77417)
Excludes `/_next/image` and `/_next/static/media` as they don't contain sensitive information and prevents complications loading them in cases where they are inlined in CSS, as they'll be requested with `sec-fetch-mode: no-cors`. 

x-ref: https://github.com/vercel/next.js/issues/77344
2025-03-22 18:11:34 -07:00
Zack TannerandGitHub 74ff4f68a4 ensure /__next middleware URLs are included in the origin check (#77416)
We have special development endpoints that are also prefixed under `/__nextjs`. This updates the origin checking logic to account for those in addition to `/_next`, and adds a test.
2025-03-22 17:51:39 -07:00
Zack TannerandGitHub cdb9a8c3b3 switch development origin verification to be opt-in rather than opt-out (#77395)
To avoid breaking local development proxies and more complex setups,
this ensures that we only block cross-origin development requests when
opting into the configuration. In a future major release, this will not
be opt-in, and will require explicitly providing the allowed origins
that can access the special `/_next` endpoints.

This adds a warning when a cross origin request is detected that would
be blocked without explicit configuration.

Fixes #77073
Fixes #77253
Fixes #77344
2025-03-21 17:08:25 -07:00
JJ KasperandGitHub d928709b74 Add handling of origin in dev mode (#76880)
This ensures we don't allow cross-origin requests to be made to `/_next`
resources in dev mode. This matches existing handling that
webpack-dev-middleware does as well.
2025-03-06 22:35:58 +00:00
Sebastian "Sebbie" SilbermannandGitHub c9d93c45d2 [test] Use new Redbox matchers in pages/ gssp-ssr-change-reloading (#76788) 2025-03-04 13:46:31 +01:00
Will Binns-SmithandGitHub ad4977a757 Update error-recovery test snapshots for alternative bundler (#76299)
Passes an additional 4 tests for Rspack. Rspack error messages included
trailing whitespace when written to the DOM, so these are stripped out.
2025-02-22 22:42:11 +00:00
Jiachi LiuandGitHub 8e9f92b649 [dev-overlay] pick up build error message (#76290) 2025-02-21 14:10:39 +01:00
Jiwon ChoiandGitHub a89d55c011 [dev-overlay] Remove old Dev Overlay (#76256)
This PR removed the old overlay including the deprecated `buildActivity`
and `appIsrStatus` options.

Closes NDX-785
Closes NDX-855
Closes NDX-865
Closes NDX-866
Closes NDX-867
Closes NDX-868
2025-02-20 19:43:14 +09:00
1c85b755b5 [DevOverlay]: enable by default (#75882)
- `newDevOverlay: true` by default (enables experimental React builds on
canary until owner stacks progress further)
- `run-tests` now sets the env var for tests that were relying on it for
forking behavior
- PPR runners now run with the flag disabled to help catch regressions
in the old overlay until we remove it
- Fixed a number of tests that had outdated snapshots or missed forking
behavior because they weren't running in CI
- Disabled a test that was failing in Turbopack + Experimental React
that is unrelated to the overlay (see:
https://github.com/vercel/next.js/pull/75989)

---------

Co-authored-by: devjiwonchoi <[email protected]>
2025-02-13 10:57:32 -08:00
07e6680ddf Restore --no-mangling CLI option for next build (#75921)
The `--no-mangling` CLI option for `next build` was originally
introduced in #42633. However, we lost this feature during our migration
from Terser to SWC. As part of broader improvements for debugging
dynamic accesses with Dynamic I/O enabled, I needed this functionality
back, so I restored it for Webpack and also added it to Turbopack.

fixes #67037
fixes #50208

---------

Co-authored-by: Benjamin Woodruff <[email protected]>
2025-02-12 11:08:03 +00:00
Will Binns-SmithandGitHub f4177614a0 Split entrypoint/route handling into separate dev and prod versions (#75169)
Currently, for `handleEntrypoints`, `handlePagesErrorRoute`,
`handleRouteType`, etc, both dev and prod use cases are combined into
the same functions. This leads to a lot of branching, use-case-specific
arguments, etc. for minimal opportunity for shared code.

In a following PR, entrypoint writing for prod will be done through a
single napi call to rust, further branching the two versions.

This splits them formally, at the cost of duplicating a handful of lines
in each case. Perhaps in the future we can develop a better system for
sharing code, but this makes things far clearer and easier to maintain
in this moment.

Test Plan: CI
2025-01-23 14:25:27 +01:00
Jude GaoandGitHub 5c49eecba1 refactor: generic dev build indicator (#74615)
- Decoupled pages router specific logic from the dev build indicator to
extract a generic version
- Created a pages router specific initialize function for dev build
indicator to be called on pages router hydration
- This prepares for upcoming work on the dev build indicator for App
router
- Covered by [e2e
test](https://github.com/vercel/next.js/blob/jude/refactor-dev-build-indicator/test/integration/build-indicator/test/index.test.js)
2025-01-07 17:54:35 -05:00
Niklas MischkulnigandGitHub d3529bad5d Turbopack: next/dynamic use transitions instead of AST analysis (#73627)
- Before, there was a separate AST traversal that collected `next-dynamic` imports
- Now, we use transitions (which are inserted by the existing next-custom-transform) to tell Turbopack about the next-dynamic imports
	- Unlike Webpack (where the react-loadable identifiers are `path/to/parent-module -> ./imported-client`), Turbopack just uses the module id: `[project]/path/to/imported-client.js [app-client] (ecmascript, next/dynamic entry)`
	- the `next-dynamic` transition only inserts the marker module (i.e. for the SSR `import()`) 
	- the `next-dynamic-client` transition inserts the marker module and changes the module context (used to get the client module name)
- Now, we use the correct `AvailabilityInfo` for the next/dynamic chunks to preload, and they are not explicitly emitted. If they are for some reason not the same chunks that are actually emitted for the dynamic import, you get a hard error. (Previously, they didn't use the same `AvailabilityInfo` as the real async chunks, so they usually bundled another copy of React, and also had a different chunk name hash)
- For Turbopack, react-loadable manifests are now scoped per page instead of globally
2024-12-19 12:34:25 +01:00
Jiwon ChoiandGitHub ed267869c5 test: move HMR basic test to a separate file (#73612)
> [!NOTE]
> The "Test new tests for flakes" may fail due to the number of tests in
a single `hmr.test.ts` file.
> The follow-up stacks are to resolve the issue.

### Why?

Moved to a separate file to run the test in parallel.
2024-12-10 07:41:15 +09:00
Jiwon ChoiandGitHub 02d5294cbe test: move HMR main test to a separate file (#73611)
> [!NOTE]
> The "Test new tests for flakes" may fail due to the number of tests in
a single `hmr.test.ts` file.
> The follow-up stacks are to resolve the issue.

### Why?

Moved to a separate file to run the test in parallel.
2024-12-10 07:28:12 +09:00
Jiwon ChoiandGitHub abe7310747 test: move HMR Error Recovery test to a separate file (#73592)
> [!NOTE]
> The "Test new tests for flakes" may fail due to the number of tests in
a single `hmr.test.ts` file.
> The follow-up stacks are to resolve the issue.

### Why?

Moved to a separate file to run the test in parallel.
2024-12-10 07:16:02 +09:00
Jiwon ChoiandGitHub 8f6dd894b2 test: move HMR Full Reload test to a separate file (#73591)
> [!NOTE]
> The "Test new tests for flakes" may fail due to the number of tests in
a single `hmr.test.ts` file.
> The follow-up stacks are to resolve the issue.

### Why?

Moved to a separate file to run the test in parallel.
2024-12-10 07:05:50 +09:00
Jiwon ChoiandGitHub 3fbb2a6dd6 test: replace check to retry in hmr.test.ts (#73590)
> [!NOTE]
> The "Test new tests for flakes" may fail due to the number of tests in
a single `hmr.test.ts` file.
> The follow-up stacks are to resolve the issue.

### Why?

The test util `check` is deprecated internally, recommended to replace
to `retry`.
2024-12-07 04:29:46 +09:00
Tobias KoppersandGitHub 43c13f4e28 [Turbopack] add telemetry for persistent caching usage (#73554)
### What?

Report persistent caching as feature
2024-12-06 14:50:52 +01:00
Jude GaoandGitHub d6dd69f210 (e2e) module-level patchFileDelay flag (#72439) 2024-11-12 06:29:03 -05:00
Benjamin WoodruffandGitHub 80384ac110 Revert "feat(turbopack): Add an env var to debug-print the fast refresh invalidation reason (#72296)" (#72421)
Not sure why this is happening, but @kdy1 bisected this commit to a null pointer assertion error in napi: https://vercel.slack.com/archives/C03EWR7LGEN/p1730901839682439?thread_ts=1730899709.760659&cid=C03EWR7LGEN

Reverting until I can repro and root cause.

Closes PACK-3402
2024-11-06 11:10:18 -08:00
Benjamin WoodruffandGitHub 8abe1fd55b feat(turbopack): Add an env var to debug-print the fast refresh invalidation reason (#72296)
Setting the environment variable when building (`next dev`)

```
NEXT_TURBOPACK_INCLUDE_UPDATE_REASONS=1
```

causes `[Update Reasons]` messages to be logged to the terminal console (not in the browser) when a file is changed:

![Screenshot 2024-11-04 at 4.31.16 PM.png](https://graphite-user-uploaded-assets-prod.s3.amazonaws.com/HAZVitxRNnZz8QMiPn4a/1af5a4f0-cfba-4ca8-b188-d6be2064b0dc.png)

These messages will not appear if no reason was recorded when the invalidation happened, so this provided on a best-effort basis.

**Why?** The hope is that this can help debug cases where users get stuck in a fast refresh update loop: https://vercel.slack.com/archives/C03S8ED1DKM/p1730737898652749

Closes PACK-3374
2024-11-05 10:49:41 -08:00
Tobias KoppersandGitHub 3b9889e1d8 [Turbopack] add new backend (#69667)
### What?

Add a new turbo-tasks backend that stores data normalized and is
prepared for persistent caching.

No longer keeps state in task locals, but all state is stored
immediately. This is required for persistent caching since it could
store and resume at any point and we always need to be in a valid state.

Tasks stay dirty until recomputed. (Previously dirty was changed to
scheduled)

### Why?

* Reduced memory usage
* preparation for persistent caching
2024-10-04 09:57:55 +02:00
hrmnyandGitHub 35a053a91a feat(turbopack): add support for polling file watcher (#69684)
### What?
The normal file watcher doesn't work inside a docker container, the
workaround is to enable a polling file watcher, which was supported in
webpack but not turbopack so far.

This PR adds support for a polling file watcher to turbopack and a
`next.config.js` option to configure the polling file watcher for both
webpack and turbopack.


Unfortunately, the rust file watcher seems to be a lot slower than the
poll interval.

Closes PACK-3206
Fixes #68255
2024-10-01 19:48:05 +02:00
Sebastian "Sebbie" SilbermannandGitHub 1cb6faaee1 Extend support of Pages router to React 18 (#70219) 2024-09-25 19:08:13 +02:00
Sebastian "Sebbie" SilbermannandGitHub 16ffa0323c Add extensive hydration error test suite for Pages router (#70342) 2024-09-24 17:25:39 +02:00