Tobias KoppersGitHubv-work-app[bot] <262237222+v-work-app[bot]@users.noreply.github.com>ClaudeTobias Koppers
16db9d0544 Turbopack: add TURBOPACK_DEBUG_CSS_CHUNKING env var (#95080)
### What?

Adds a `TURBOPACK_DEBUG_CSS_CHUNKING` environment variable. When set to
a truthy value, the graph-based CSS chunker (`experimental.cssChunking:
"graph"`) writes a JSON snapshot of its inputs and outputs to the
current working directory on each invocation.

### Why?

We are investigating problems with the new graph-based CSS chunking
algorithm. The pipeline (`create_graph` → `make_acyclic` → `linearize` →
`split_into_chunks`) is internal to `turbopack-core` and doesn't surface
enough information through normal build output to debug bad chunking
decisions post-hoc. A side-channel dump lets us reproduce and reason
about a problematic build without instrumenting Rust on a user's
machine.

### How?

In
`turbopack/crates/turbopack-core/src/module_graph/style_groups_graph/mod.rs`,
between `split_into_chunks` and the result assembly:

- Whether the dump is enabled is cached in a `static DEBUG_DUMP_ENABLED:
LazyLock<bool>` so the env var is read exactly once per process. Truthy
= anything other than unset, empty, `0`, or `false` (case-insensitive).
- When enabled, every call to `compute_style_groups_graph` resolves
`ident_string()` for every CSS module in parallel via `try_join` and
writes a pretty-printed JSON file
`turbopack-css-chunking-debug-<unix_ms>-<seq>.json` in the current
working directory. The timestamp + atomic counter suffix ensures
concurrent or repeated calls don't clobber each other.
- Failures while writing the dump are logged to stderr and otherwise
swallowed — a debug toggle must never fail a build.

The JSON document contains:

- `chunk_groups`: `string[][]` — module idents per chunk group, in the
order the algorithm sees them.
- `global_order`: `string[]` — the flat global order produced by
`linearize`.
- `global_order_chunks`: `string[][]` — the same modules grouped by the
merged segments produced by `split_into_chunks` (e.g. `[["a","b"],
["c"], ["d","e","f"]]`).
- `modules`: `[{ ident, size, style_type }]` — per-module metadata where
`size` is the chunk item size in bytes (the same value used by the cost
model) and `style_type` is `"GlobalStyle"` or `"IsolatedStyle"`.

Verification: `cargo clippy -p turbopack-core --no-deps` is clean and
the existing `style_groups_graph` test suite passes (53 tests).

No user-facing config change, no docs change — the env var is
intentionally undocumented and only meant for triage.

Closes NEXT-
Fixes #

---------

Co-authored-by: v-work-app[bot] <262237222+v-work-app[bot]@users.noreply.github.com>
Co-authored-by: Claude <[email protected]>
Co-authored-by: Tobias Koppers <[email protected]>
2026-06-24 03:10:16 +02:00
2025-10-13 10:43:51 +02:00
2026-06-09 13:50:25 -07:00
2026-06-23 23:36:57 +00:00
…
2026-06-18 17:31:43 -07:00
2026-06-23 23:36:57 +00:00
2026-06-23 23:36:57 +00:00
…

Next.js logo

Next.js

Vercel logo NPM version License Join the community on GitHub

Getting Started

Used by some of the world's largest companies, Next.js enables you to create full-stack web applications by extending the latest React features, and integrating powerful Rust-based JavaScript tooling for the fastest builds.

Documentation

Visit https://nextjs.org/docs to view the full documentation.

Community

The Next.js community can be found on GitHub Discussions where you can ask questions, voice ideas, and share your projects with other people.

To chat with other community members you can join the Next.js Discord server.

Do note that our Code of Conduct applies to all Next.js community channels. Users are highly encouraged to read and adhere to it to avoid repercussions.

Contributing

Contributions to Next.js are welcome and highly appreciated. However, before you jump right into it, we would like you to review our Contribution Guidelines to make sure you have a smooth experience contributing to Next.js.

Good First Issues:

We have a list of good first issues that contain bugs that have a relatively limited scope. This is a great place for newcomers and beginners alike to get started, gain experience, and get familiar with our contribution process.


Security

If you believe you have found a security vulnerability in Next.js, we encourage you to responsibly disclose this and NOT open a public issue.

To participate in our Open Source Software Bug Bounty program, please email [email protected]. We will add you to the program and provide further instructions for submitting your report.

S
Description
The React Framework
Readme
2.4 GiB
Languages
JavaScript 55.6%
TypeScript 30%
Rust 12.9%
MDX 0.7%
CSS 0.7%