Commit Graph

1409 Commits

Author SHA1 Message Date
Donny/강동윤 070d31f76d perf: Check file using SWC before applying React Compiler (#75605)
### What?

Check if the file is a file that is _interesting_ to the React Compiler before passing it to the React Compiler

### Why?

It would skip the majority of files
2025-04-15 09:20:36 +02:00
Benjamin Woodruff 581975d7cf test(turbo-tasks-fs): Add a fuzzer for the filesystem watcher (#78160)
Adds a very basic fuzzer for the filesystem watcher.

This already reveals that there's some undiagnosed bug with not re-watching deleted-and-recreated directories on Linux that does not occur on macos:

**Debian:**
![Screenshot 2025-04-14 at 11.59.14 AM.png](https://graphite-user-uploaded-assets-prod.s3.amazonaws.com/HAZVitxRNnZz8QMiPn4a/e5b26a76-0f9e-4623-9d56-b97115314041.png)

**macos:**
![Screenshot 2025-04-14 at 12.03.19 PM.png](https://graphite-user-uploaded-assets-prod.s3.amazonaws.com/HAZVitxRNnZz8QMiPn4a/ccbbf4b8-ab32-4489-b240-45206e9f0f66.png)
2025-04-14 16:37:45 -07:00
Donny/강동윤 b7280e453e build: Update swc_core to v22.3.1 (#78129)
### What?

Update `swc_core` to `v22.3.1`

ChangeLog: https://github.com/swc-project/swc/compare/swc_core%40v21.0.1...swc_core%40v22.3.1

### Why?

To keep in sync and apply recent parser performance optimizations

### How?
2025-04-14 13:06:20 +02:00
Niklas Mischkulnig 0748935603 Turbopack: proper error message for swcPlugins (#77990)
Show a redbox when specifying a non-existent plugin instead of crashing Turbopack

The error location could be better, but we don't actually know the line/column here

![Bildschirmfoto 2025-04-10 um 08 56 39](https://github.com/user-attachments/assets/c816704d-b5c6-48bc-8471-92082abe5614)
2025-04-10 22:17:23 +02:00
Sebastian "Sebbie" Silbermann 2a594945b6 Cleanup config.experimental.reactOwnerstack (#78021) 2025-04-10 12:56:15 +00:00
Tobias Koppers 664110c188 Turbopack: read asset entries strongly consistent (#77974)
### What?

Avoid eventual consistent results influencing the map state.
2025-04-09 18:38:57 +02:00
Niklas Mischkulnig 154267cb03 Turbopack: fix instrumentation asset context name (#77973)
🙈
2025-04-09 08:13:34 -07:00
Andrew Clark eb85658644 Add experimental.routerBFCache to NextConfig (#77951)
Sets up a flag that will depend on an experimental React feature
(Activity). I based this on the existing code for the `viewTransition`
flag.

I haven't implemented anything behind this flag yet; this only wires up
the flag itself. I added a basic test that renders the Activity
component to verify that it's available when the flag is on.
2025-04-09 14:42:54 +00:00
Will Binns-Smith 4f5531b140 Turbopack: support config.turbopack and deprecate config.experimental.turbopack. (#77850)
Closes PACK-4263

This:
- Adds support for using `config.turbopack` for Turbopack. The accepted value for this option is identical to the previous experimental one without the deprecated field `loaders`.
- Deprecates `config.experimental.turbo`. Warns on its use, but will continue to accept it, merging it with `config.turbopack` while preferring fields on `config.turbopack`.
- also see https://github.com/vercel/next.js/pull/77850#pullrequestreview-2749738760

Test Plan:
- [x] Convert use of `config.experimental.turbo` in tests to `config.turbopack`
- [x] Automated test for accepting the experimental option for compatibility, as well as the config merging
2025-04-09 03:42:38 -07:00
Janka Uryga 9d3b563372 add build script for next-error-code-swc-plugin (#77931)
Adds a build script for `next-error-code-swc-plugin`, runnable via `pnpm
build-error-code-plugin`. The script compiles the plugin and moves the
result to its expected location in
`packages/next/next_error_code_swc_plugin.wasm`.

I've also rebuilt the plugin and committed it -- i was getting a
different compiled output that what's currently there. Not sure if the
build is non-deterministic, a dependency changed, or if someone forgot
to recompile it, but it can't hurt.
2025-04-09 02:48:39 -07:00
Janka Uryga c0b7f72bb9 compile-time error for useLinkStatus imports in server components (#77962)
Adds `useLinkStatus` to the list of APIs that can't be imported in
server components.
2025-04-09 09:17:48 +00:00
Niklas Mischkulnig 46fe103ded Don't externalize various new next/* entrypoints (#77844)
`next/cache`,`next/form`,`next/head`, `next/compat/router`, and
`next/server` were missing in the regex
2025-04-08 14:42:22 +02:00
Tobias Koppers caa595ebbe Turbopack: handle removed routes (#77890)
### Why?

Before `get_endpoints` gives you a lot of `Vc<Endpoint>`, which we keep around and subscribe to. That is a problem as endpoint can also vanish at any time. e. g. when the folder is removed.
`Vc<Endpoint>` was not able to represent this state. The subscription throw an error as the Vc is no longer existant. So the error was technically correct here (not a bug in turbo-tasks).
But in practice we don't want to have this error. We want to have a clean end of the subscription without any error. That's why I change it to `Vc<Option<Endpoint>>`, which allows to represent the non-existance of an endpoint.
This can (resp. need to be) handled in subscriptions, which can report e. g. a `NotFound` result or a change event (for server_changed).

### What?

avoid having inactive Vcs when routes are removed.

instead use an `Option<Endpoint>` to allow respresenting removed endpoints and handle these in subscriptions correctly.
2025-04-08 10:55:27 +02:00
Donny/강동윤 66b6fa1553 feat: Disable char frequency analysis for mangler (#77887)
### What?

Disable character frequency analysis for server-side builds.

### Why?


https://vercel.slack.com/archives/C05KYT5S9FF/p1742935766157509?thread_ts=1742255598.708199&cid=C05KYT5S9FF

### How?

Closes NAR-118

---------

Co-authored-by: Tobias Koppers <tobias.koppers@googlemail.com>
2025-04-08 08:14:18 +00:00
Tobias Koppers 8c405dcc85 Turbopack: enable content hashing in production (#77775)
### What?

Enable content hashing for the client assets
2025-04-04 20:30:22 +02:00
Niklas Mischkulnig 689038b3ca Turbopack: don't include client-fs assets in NFT (#77799)
i.e. don't include logos imported in a client reference in the NFT list of the parent RSC's serverless function

Closes PACK-4257
2025-04-04 20:11:30 +02:00
Tobias Koppers b84a02be18 Turbopack: use document.currentScript instead of chunk path literal (#77773)
### What?

Instead of embedding the chunk filename into the chunk itself (which is a probably for content hashing), use `document.currentScript` to grab the chunk path.
2025-04-04 17:31:24 +02:00
Tobias Koppers df052a529a Turbopack: pass asset to chunk_path to allow to use content hash later (#77772)
### What?

Change the signuture of `ChunkingContext::chunk_path` to take an `Asset` argument. The `content()` of the `Asset` might be used in future generate a content hash for the chunk path
2025-04-04 13:18:19 +02:00
Benjamin Woodruff 56a1068c5f chore(turbo-tasks): Audit all remaining uses of Vc in a struct (#77756)
I suspect the test failures in https://github.com/vercel/next.js/pull/77661 are related to a `Vc` that should be an `OperationVc`.

I realized that we have so few uses of `Vc` inside structs and enums that it might be easier to work off of that list than to carefully audit my changes in my other PR, though it doesn't look like anything's a smoking gun here.

Either way, while it's totally valid for non-`VcValueType` structs and enums to contain unresolved `Vc`s, it's usually suboptimal, and there should probably at least be a comment explaining the choice to use an unresolved `Vc`.

I still have a long-term goal of renaming `ResolvedVc` to `Vc` and the current version of `Vc` to `UnresolvedVc`, so for that reason alone, I want everything to prefer using `ResolvedVc` "by default".
2025-04-02 16:44:27 -07:00
Niklas Mischkulnig 48725b22c7 Reapply "Turbopack: layout segment optimization for Pages" (#77339) (#77696)
A clean revert of the revert #77339 of #74815

Closes PACK-3715
2025-04-02 16:09:07 -07:00
Donny/강동윤 383a070cf3 build: Update swc_core to v19.0.0 (#77669)
### What?

Update `swc_core`. ChangeLog: https://github.com/swc-project/swc/compare/swc_core%40v16.10.0...swc_core%40v19.0.0

### Why?

To keep in sync with `@swc/core`. 

### How?
2025-04-02 17:49:53 +02:00
Benjamin Woodruff 63cb50327c chore(turbopack): Make TaskInputs use ResolvedVc (#77700)
It's totally valid for `TaskInput`s to use `Vc`, but `ResolvedVc` is marginally more preferable for a number of performance and functionality reasons (a sane `Eq`+`Hash` impl, doing work more eagerly, synchronous downcasting support).
2025-04-01 18:13:07 -07:00
Will Binns-Smith 570266a445 Turbopack: Allow overriding tsconfig path via next-config (#77563)
This:
- Adds a test asserting the user can override the tsconfig path via the
next-config. This is already supported with Next.js and Webpack.
- Implements the necessary code to pass the test and implement support
with Turbopack.

Test Plan: `pnpm test-dev test/e2e/tsconfig-path/index.test.ts && pnpm
test-dev-turbo test/e2e/tsconfig-path/index.test.ts`

Closes PACK-4215
2025-04-01 16:08:37 -07:00
Tim Neutkens 55f24e0eb0 Turbopack: Skip ssr processing when next/dynamic ssr: false (#77636)
### What?

Ensuring server-side processing for the loader function of
`next/dynamic` with `ssr: false` is properly skipped in Turbopack.

### Why?
Previously, client components imported through `next/dynamic` with `ssr:
false` were not skipped, while they are skipped in webpack. This fix
ensures consistent behavior between Webpack and Turbopack. This is a
compilation performance win for applications that leverage this pattern
heavily, as it can skip work it doesn't need to process.

Was looking at fixing one of the failing tests in the list of remaining
tests. Found it checked for this behavior and fixed it.

### How?
- Added the same `should_skip_ssr_compile` logic to the Turbopack state
that was already implemented for Webpack
- When `ssr: false` is specified and we're in the server compiler we
replace the dynamic import with an empty async function to avoid
bundling the client component on the server
2025-04-01 09:09:34 +02:00
Benjamin Woodruff 2e76e15f59 refactor(turbo-tasks): Make TraceRawVcs a supertrait of TaskInput (#77397)
For a tracing GC to work (different for cache eviction), we need `TraceRawVcs` to be able to inspect function arguments.

While a tracing GC is still far off, the immediate motivation here is using tracing to improve logging for "transient task called from persistent task" error messages.

There's one non-test mpsc queue (`ComputeUpdateStreamSender`) with a sketchy `TraceRawVcs` impl. We should have a way of excluding certain objects from GC (marking them as roots) to fix this in the GC case. IMO this doesn't really matter for non-GC debug use-cases of `TraceRawVcs`.
2025-03-31 11:04:51 -07:00
Benjamin Woodruff b005187a7f fix(turbopack): Use strongly consistent reads for sourcemaps in napi FFI boundary (#77511)
All turbo-task reads from an FFI boundary must be strongly-consistent.

Otherwise, we might propagate errors due to inconsistent cell state.

We suspect it's the root cause for this: https://vercel.slack.com/archives/C04MKMSEV3K/p1742874851690489
2025-03-25 17:06:20 -07:00
Niklas Mischkulnig 2b635e5570 Turbopack: ignore static asset imports for Edge (#77382)
Closes PACK-4072 

Ignore static asset imports in Edge, these are really intended for the client (i.e. for
pages and not routes, for example `import logo from "./logo.svg"`), while still allowing `new URL(..., import.meta.url)`.

This replicates what Webpack does. A proper solution for assets on Edge would require some change on the Next.js side to actually tell the bundler if an asset is intended for the server (e.g. for next/og: wasm, fonts), or for the browser.
2025-03-21 17:38:08 +01:00
Tobias Koppers 9f68435d39 Turbopack: implement optimized css production chunking (#77284)
### What?

Port the webpack css chunking implementation for app dir to Turbopack.

It also computes ordered entries in module batches

Pages router also uses the app dir chunking, but that's incorrect and leads to some breaking test cases.
2025-03-21 16:05:21 +01:00
Donny/강동윤 74d6e51a1f fix: Update swc_core and use rayon instead of chili (#77338)
### What?

Use `rayon` for parallelism

### Why?

`chili` seems to have some bugs regarding the CPU usage of heartbeat thread in idle mode.

### How?

 - Closes https://github.com/vercel/next.js/issues/77192
2025-03-20 17:46:39 +00:00
Jiachi Liu 34885c4fe1 Revert "Turbopack: layout segment optimization for Pages" (#77339)
Reverts vercel/next.js#74815
 
`test/integration/app-document/test/index.test.js` starts failing since
#74815

x-ref:
https://github.com/vercel/next.js/actions/runs/13972070006/job/39119143367?pr=77335
2025-03-20 16:49:52 +01:00
Niklas Mischkulnig 618263df19 Turbopack: layout segment optimization for Pages (#74815)
Closes PACK-3715

This also required some changes to the dev loader, as since
https://github.com/vercel/next.js/commit/bc05ce9, app and document are
used from the page bundle itself, and not from the app and document.

~~`_app.js` and `_document.js` are chunked first before the page (this
result is then cached and reused across pages).~~

~~Here, `_document.js` which includes lodash is only chunked once as
part of `page3.js` and the other two reuse that.~~

![Bildschirmfoto 2025-01-13 um 12 03
16](https://github.com/user-attachments/assets/a1149bb3-053a-44dd-a233-47fa4f456a83)
2025-03-20 13:58:27 +01:00
Tobias Koppers 30eed9f9e2 [Turbopack] basic production chunking for CSS (#75049)
### What?

Enable a very simple chunking for CSS. It's just chunking by batches, which should cause correct styling, but it not optimal from request count.
2025-03-18 16:08:00 +01:00
Niklas Mischkulnig 2af3d065e7 Turbopack: split up server actions modules for better treeshaking (#76877)
Closes PACK-4074

We really need to look into getting e2e tests for correct sourcemaps: PACK-4142

Fix Turbopack server action tree shaking by explicitly splitting up that module

```js
/* __next_internal_action_entry_do_not_use__ {"00c18c215a6b7cdc64bf709f3a714ffdef1bf9651d":"default","70e10665baac148856374b2789aceb970f66fec33e":"myAction"} */ import { createServerReference, callServer, findSourceMapURL } from "private-next-rsc-action-client-wrapper";
export var foo = /*#__PURE__*/ createServerReference("70e10665baac148856374b2789aceb970f66fec33e", callServer, void 0, findSourceMapURL, "myAction");
export var bar = /*#__PURE__*/ createServerReference("00c18c215a6b7cdc64bf709f3a714ffdef1bf9651d", callServer, void 0, findSourceMapURL, "default");
```
->
```js
"use turbopack no side effects";
export { foo } from "data:text/javascript,%2F%2A%20__next_internal_action_entry_do_not_use__%20%7B%2200ab21efdafbe611287bc25c0462b1e0510d13e48b%22%3A%22foo%22%7D%20%2A%2F%22use%20turbopack%20no%20side%20effects%22%3Bimport%7BcreateServerReference%2CcallServer%2CfindSourceMapURL%7Dfrom%22private-next-rsc-action-client-wrapper%22%3Bexport%20var%20foo%3D%2F%2A%23__PURE__%2A%2FcreateServerReference%28%2200ab21efdafbe611287bc25c0462b1e0510d13e48b%22%2CcallServer%2Cvoid%200%2CfindSourceMapURL%2C%22foo%22%29%3B";
export { bar } from "data:text/javascript,%2F%2A%20__next_internal_action_entry_do_not_use__%20%7B%2200ac840dcaf5e8197cb02b7f3a43c119b7a770b272%22%3A%22bar%22%7D%20%2A%2F%22use%20turbopack%20no%20side%20effects%22%3Bimport%7BcreateServerReference%2CcallServer%2CfindSourceMapURL%7Dfrom%22private-next-rsc-action-client-wrapper%22%3Bexport%20var%20bar%3D%2F%2A%23__PURE__%2A%2FcreateServerReference%28%2200ac840dcaf5e8197cb02b7f3a43c119b7a770b272%22%2CcallServer%2Cvoid%200%2CfindSourceMapURL%2C%22bar%22%29%3B";
````

- [x] Keep [sourcemaps](https://github.com/vercel/next.js/blob/canary/test/development/app-dir/source-mapping/README.md#server-actions)
2025-03-17 15:52:17 +01:00
Niklas Mischkulnig d3a2971b60 Turbopack: fix graph layout segment optimization (#77094)
The modules in the last layout segment (`server_component_entries`) were visited twice: as part of the last iteration of the for loop (which doesn't propagate its `visited_modules` because it's not a layout), and then again with `rsc_entry`.

We already do the right thing in another place:
https://github.com/vercel/next.js/blob/f42739d114695702922dab4c08d6c8223daafceb/crates/next-api/src/app.rs#L1740-L1748

Before:
![Bildschirmfoto 2025-03-17 um 11 39 41](https://github.com/user-attachments/assets/62adad85-043c-47f4-8c70-a8f5779e34a9)

After:
![Bildschirmfoto 2025-03-17 um 11 43 14](https://github.com/user-attachments/assets/62642bcf-8946-4bcd-ba16-cdd711cac383)
2025-03-17 15:22:58 +01:00
Donny/강동윤 fa214c74c1 fix(styled-jsx): Pass useLightningcss option to styled-jsx correctly (#77008)
### What?

Previously, `styled_jsx.useLightningcss` was not passed correctly. This PR fixes it.

### Why?

It's required to enable lightningcss mode for styled-jsx.
2025-03-17 20:39:32 +09:00
Jude Gao 7de4c0728b (feat) support client-side instrumentation (#76916) 2025-03-14 05:18:09 -07:00
Niklas Mischkulnig afa3c94b98 Turbopack: ChunkGroup in evaluated_chunk_group (#76593)
<!-- 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-03-14 11:28:11 +01:00
Niklas Mischkulnig b04cc97fa2 Turbopack: align chunking with graph entries (#76441)
Shouldn't have any change in behavior, but prepares for #76211
2025-03-14 11:10:16 +01:00
Donny/강동윤 3a30312049 refactor(actions): Remove turbopack magic comments (#77063)
### What?

Remove magic comments for disabling export merging in the advanced tree shaking of turbopack.

### Why?

Turbopack magic comments for tree shaking + server actions are not required anymore since https://github.com/vercel/next.js/pull/76938.
2025-03-14 15:27:55 +09:00
Niklas Mischkulnig 8de5e77256 Turbopack: fewer manifests for static metadata (#77087)
Closes PACK-3731

This test was effectively already passing, except that we unnecessarily always emitted manifests.

No need to emit the various client reference, next dynamic, server actions, ... manifests for static metadata routes.
2025-03-13 16:33:49 +01:00
Tobias Koppers 6b35981a80 Turbopack: Vc stability of ModuleGraph (#77052)
<!-- 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-03-13 10:35:33 +01:00
Tobias Koppers 35f93d124c Turbopack: create module graph strongly consistent (#77051)
<!-- 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-03-13 09:39:27 +01:00
Tim Neutkens 3e5e6dbac0 Turbopack: Implement deploymentId (#76904)
Builds on #76814

Closes PACK-4071 (implementing config.deploymentId)

This uses the new `__turbopack_load_by_url__` to load chunks through
client references in react-dom-turbopack.

After this lands I'm going to send a PR to react-dom-turbopack to switch
the original source to use `__turbopack_load_by_url__` too, landing this
PR first to make sure it passes all the Next.js tests.

<!-- 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-03-11 22:55:11 +01:00
Will Binns-Smith 13670aea5e Turbopack panics: create discussions with pre-filled errors (#76850)
This:
- Prompts users to report turbopack internal errors as new GitHub
discussions instead of issues
- Encodes the error message and debug information into the discussion
title and body respectively
- Since these encoded urls can be lengthy, it uses [Terminal
Hyperlinks](https://gist.github.com/egmontkob/eb114294efbcd5adb1944c9f3cb5feda)
to present things concisely without excessive wrapping. If the terminal
does not support this, only the error message is sent.
- Removes specific panic handling in favor of the `subscribe` napi error
handler. This seems to be the vast majority of panics.

Test Plan:

In a terminal with hyperlink support `FORCE_HYPERLINK=1 pnpm next dev
--turbo examples/basic-css/`:
```
-----
FATAL: An unexpected Turbopack error occurred. A panic log has been written to /var/folders/sk/zy7023wd30j0dxpmdv3nylm80000gn/T/next-panic-bf6bdb325db0f5ed5599cf332d8e364a.log.

To help make Turbopack better, report this error by clicking here.
-----
```

Where the link generated is [clicking
here.](https://github.com/vercel/next.js/discussions/new?category=error-report&title=Turbopack%20Error%3A%20Panic%20in%20AppProject%3A%3Anew%3A%20Some%28%22oh%20no%20new%20app%21%22%29&body=Error%20message%3A%0A%60%60%60%0APanic%20in%20AppProject%3A%3Anew%3A%20Some%28%22oh%20no%20new%20app%21%22%29%0A%0ADebug%20info%3A%0A-%20Execution%20of%20get_entrypoints_with_issues_operation%20failed%0A-%20Execution%20of%20EntrypointsOperation%3A%3Anew%20failed%0A-%20Execution%20of%20Project%3A%3Aentrypoints%20failed%0A-%20Execution%20of%20Project%3A%3Aapp_project%20failed%0A-%20Panic%20in%20AppProject%3A%3Anew%3A%20Some%28%22oh%20no%20new%20app%21%22%29%0A%60%60%60&labels=Turbopack,Turbopack%20Panic%20Backtrace)

In a terminal without hyperlink support `FORCE_HYPERLINK=0 pnpm next dev
--turbo examples/basic-css/`:

```
-----
FATAL: An unexpected Turbopack error occurred. A panic log has been written to /var/folders/sk/zy7023wd30j0dxpmdv3nylm80000gn/T/next-panic-3c5a833c682727cba1d51cc97ee0c16.log.

To help make Turbopack better, report this error by clicking here: https://github.com/vercel/next.js/discussions/new?category=error-report&title=Turbopack%20Error%3A%20Panic%20in%20AppProject%3A%3Anew%3A%20Some%28%22oh%20no%20new%20app%21%22%29&body=Error%20message%3A%0A%60%60%60%0ATurbopack%20Error%3A%20Panic%20in%20AppProject%3A%3Anew%3A%20Some%28%22oh%20no%20new%20app%21%22%29%0A%60%60%60&labels=Turbopack,Turbopack%20Panic%20Backtrace
-----
```

---------

Co-authored-by: Tobias Koppers <tobias.koppers@googlemail.com>
2025-03-10 16:22:10 -07:00
Will Binns-Smith 0ce9e53ef4 Production builds: write endpoints all at once (#75304)
This implements a new napi binding, `project.writeAllEndpointsToDisk`
which writes chunks for all endpoints.

This avoids iterating over each endpoint and calling individual napi
bindings, each resulting in a call to `emit()`. While iterating entry
points now occurs in Rust, `OutputAssets` are collected in an `IndexSet`
to prevent unnecessary `emit()` calls. This also significantly reduces
unnecessary calls to the manifest loader from JS.

Test Plan: CI

Commit before removing merge commits:
https://github.com/vercel/next.js/pull/75304/commits/189743dd261a682c5cb0a46e69f27861c612e9c2

---------

Co-authored-by: Tobias Koppers <tobias.koppers@googlemail.com>
Co-authored-by: Tim Neutkens <tim@timneutkens.nl>
2025-03-10 10:54:30 -07:00
Donny/강동윤 91d94b1c14 fix(turbopack): Fix the span of a magic comment (#76939)
### What?

Fix the span of the turbopack tree shaking magic comment.

### Why?

Previously it was printed on strange position.

### How?

Closes NAR-91

Closes PACK-4087
2025-03-10 09:10:00 +01:00
Zack Tanner 56a6c86480 Turbopack: ensure default layout is provided in default not-found entrypoint (#76912)
When Turbopack creates the default not-found entry, it does so without
providing a default root layout in case one is missing. This works ok in
Webpack since the `default-layout` is correctly added in
[next-app-loader](https://github.com/vercel/next.js/blob/4518bc91641a0fd938664b781e12ae7c145f3396/packages/next/src/build/webpack/loaders/next-app-loader/index.ts#L339-L342).

Looking at the [original
PR](https://github.com/vercel/next.js/pull/54199) that added
`default-layout` it seems it was only really ever intended for the
not-found entrypoint since in all other cases, a missing root layout
means we create one for you in dev and in build it'd be a hard error.

This also includes the other defaults that are correctly added in other
entries to match Webpack behavior. Though I'm not sure the presence of
these makes a difference when rendering the not found page

Closes NDX-858
2025-03-07 13:27:17 -08:00
Benjamin Woodruff f70760719a fix(turbopack): Use vergen-gitcl instead of shadow-rs (or vergen-git2) for napi and next-api crates to fix stale git lock files (#76889)
This does not depend on libgit2 which apparently breaks our builds on
some platforms. Instead it uses the git CLI using my PR:
https://github.com/rustyhorde/vergen/pull/406

Original PR: https://github.com/vercel/next.js/pull/76773
Revert: https://github.com/vercel/next.js/pull/76879

Manually triggered CI run to try to build all platforms:
https://github.com/vercel/next.js/actions/runs/13711866131
2025-03-07 13:24:35 -08:00
Niklas Mischkulnig 7e5e69dd25 Turbopack: deterministic server action order (#76905)
`HashMap` strikes again, causing the server action manifest order to be non-deterministic.

Less test flakeyness for `app-dir - server-action-period-hash-custom-key should have different manifest if the encryption key from process env is same`
2025-03-07 16:47:13 +01:00
Benjamin Woodruff ee5c7d39b7 Revert "fix(turbopack): Use vergen-git2 instead of shadow-rs for napi and next-api crates to fix stale git lock files" (#76879)
Reverts vercel/next.js#76773

> Looks like we broke compilation for our linux swc builds for musl/gnu
2025-03-06 11:31:21 -08:00