### What?
Adjust regex for file name which is used for linting.
### Why?
We should apply same validation as `error.ts` to `global-error.ts`
### How?
Closes PACK-2977
Fixes https://github.com/vercel/next.js/issues/64452
Adds a `experimental.turbo.moduleIdStrategy` field to `next.config.js`
to configure what module ID generation strategy to use.
`'named'` assigns readable module IDs based on the module's path and
functionality.
`'deterministic'` assigns small hashed numeric module IDs.
If not set, Turbopack will use `'named'` for development builds and
`'deterministic'` for production builds.
`nextConfig.experimental.dynamicIO: boolean` is a new experimental flag
that changes the static generation bailout heuristic and PPR postpone
heuristic to exclude async work that is not resolvable in the current
Task's microtask queue from prerenders. functionally it means that in
this mode fetches and db queries will now not be prerenderable unless
you opt into it with a caching API like `unstable_cache()` or the fetch
`cache: 'force-cache'` option.
### What?
Update `swc_core`.
### Why?
This update is required to use the name mangler cache, which was
recently implemented in SWC.
### How?
Closes PACK-3222
These functions were either public and/or mutually recursive, preventing
rustc's dead code analysis from finding them.
```
cargo check
cargo check --tests
```
Fixes (part of) #69330
We were using a `u32` here instead of a `u64` for no good reason.
The workaround if you're encountering this is to just use `u32::MAX`
instead, which should be large enough for all practical purposes:
`4294967295`.
## Test Plan
Build turbopack in the next.js repo:
```
pnpm pack-next
```
Follow the repro in #69330:
```
git clone https://github.com/Enkratia/css-reload-show-2.git
# edit the package.json following the instructions from `pnpm pack-next` above
rm package-lock.json
pnpm i
pnpm dev --turbo
```
## Integration Testing?
There are some tests in
`test/integration/image-optimizer/test/index.test.ts`, but I didn't see
the obviously best way to test this, as most of those tests are looking
for errors by scanning stderr, and this is about not generating any
error.
Either way, I think this is very unlikely to regress.
### What?
Improves the traversal of the module graph by doing a more exhaustive search of the children modules, thus increasing the "hit rate" for optimized module IDs (which should be 100%).
### Why?
Some structs that implement the `Module` trait return an empty list in the `references` method, but still "own" some child modules. This is the case of `EcmascriptClientReferenceModule`, for example, which returns empty in `references` but owns a `client_module` and an `ssr_module`. These modules are ignored when traversing the module graph with the `get_referenced_modules` function we used before, so neither they nor their children are ever assigned an optimized ID.
### How?
To solve this, a `children_modules` method is added to the `Module` trait, which should exhaustively return all direct children of the module. The function defaults to `primary_referenced_modules`, which simply calls `references`, but structs like `EcmascriptClientReferenceModule` can reimplement it and return "hidden" children modules like the aforementioned `client_module` and `ssr_module`.
### What?
Refactored module ID strategies implementation to walk modules graph individually for each endpoint.
Based on feedback from [next.js#68408](https://github.com/vercel/next.js/pull/68408) and [turbo#8912](https://github.com/vercel/turbo/pull/8912).
Comments marked with `NOTE(LichuAcu)` are intended to make reviewing easier and will be removed before merging.
This adds an extra `hash_salt` option to the Server Actions transform's
`generate_action_id` method which defaults to empty for now (so no
actual behavior changes). When set, the salt will be used to prefix the
payload.
(generated by graphite)
### What?
Introduce `get_specificity` method to determine the specificity of
routes.
This facilitates more accurate route matching for catchall routes by
comparing route specificity.
Modify existing route matching logic to incorporate specificity checks
and avoid route conflicts.
Add corresponding tests to validate the new specificity handling
mechanism.
Fixes#67045
Closes PACK-3154
### What?
Move `experimental.treeShaking` to `experimental.turbo.treeShaking` in Rust code.
### Why?
To disable it, we need to keep config schema and Rust types in sync.
### How?
This is effectively an optimization to make Webpack UMD modules work
better by short circuiting and not even looking at the unused branches
(e.g. AMD)
Closes PACK-2983
### What?
Improves the performance of loader tree creation.
The main change is `directory_tree_to_loader_tree` now being completely
synchronous (ignoring the setup).
This improves performance a lot (at least for the initial build), as
it's a recursive function, which was cached at every level before.
It also makes querying the loader tree easier, as not everything needs
to be an async turbo tasks function now.
#### `get_entrypoints` Performance
| | Initial | Update |
| --------- | ---------- | ------- |
| `canary` | `1300ms` | `20ms` |
| PR | `260ms` | `50ms` |
### What?
Revert swc_core upgrade, as it has a bug related to `styled_jsx`
transform.
Wasm plugin version runs after the TypeScript pass so it works, but
custom transform (next-swc) runs before the typescript pass so it
breaks.
### Why?
It broke some apps.
### How?
This should be completely equivalent. Double checked the diff and made sure that the conversions from `true`/`false` to `ReadConsistency::Strong`/`ReadConsistency::Eventual` are correct.
## Why?
Without keyword arguments in the language, boolean arguments can be hard to read. Inlay hints and type-signature-on-hover with rust-analyzer help, but it's more obvious what these do if they use a clearly labeled enum.
E.g. discussion: https://www.reddit.com/r/rust/comments/bm6s3t/rust_patterns_enums_instead_of_booleans/
Unlike my other change from a bool to an enum in #68866, I don't expect that we'd ever introduce more levels of read consistency than eventual and strong, so this PR is only about readability.
This PR changes the Server Actions SWC transform, to instead of having a
hard coded list of
`"use server"` directive typos we use a O(len) algorithm to detect
possible mistakes in the directive name. Note that the previous
`.iter()` approach is also theoretically slower O(n * len).
This was cherry-picked from a larger change which will later make this
transform more general and support different directive names (via
configurations).
Now the expected and actual version numbers are included in the error
message:
```
Package @libsql/client (serverExternalPackages or default list) can't be external
The request @libsql/client matches serverExternalPackages (or the default list), but it can't be external:
The package resolves to a different version when requested from the project directory (0.9.0) compared to the package requested from the importing module (0.6.2).
Make sure to install the same version of the package in both locations.
```
Now that `react-dom/static` is also available outside of the
experimental channel, we don't need to hard-code the react release
channel in the bundle aliases anymore.
Without this fix, `react-dom` would end up twice in our non-experimental
server runtime bundles with the changes in #68637.
<img width="1479" alt="react-dom twice in bundle"
src="https://github.com/user-attachments/assets/ed50e9ec-b984-496b-92e1-69515f2afbc8">
### What
Support merging the static metadata file conventions `favicon.ico` with
other customized metadata icon from the module export.
### Why
`favicon.ico` should be displayed everywhere as it's the icon
representative of the website for all pages. Any customized `icon` in
metadata export `export const metadata` or `export function
generateMetadata()` shouldn't override the `favicon.ico` file
convention.
Fixes#55767
---------
Co-authored-by: hrmny <8845940+ForsakenHarmony@users.noreply.github.com>
### What?
Now we have tree shaking implementation but it uses
`EcmascriptModulePartAsset` as the module type. So casting to
`EcmascriptModuleAsset` can break the tree shaking.
This PR also removes `special exports` of turbopack, which is
cumbersome. The previous analysis logic for those special exports may
depend on the value being `EcmascriptModuleAsset`, which is resolved in
this PR.
### Why?
Clean code & for future woork.
### How?
Closes PACK-3175
This updates the remaining cases where we were using the generic
`context` name for variables, field names, etc.
It also adds an `.ignore` file to prevent files like the non-text
`broken.js` from being read by these kinds of tools. This is separate
from `.gitignore`.
### What?
We have a data structure VersionedContentMap that is used in dev mode to manage hmr and source maps. This is irrelevant in prod so we can just short circuit it altogether and bail when attempting to call these during builds.
### Why?
VersionedContentMap does a lot of hashing to account for files changing during development. In production, this is pointless as we assume a static snapshot of the repo.
### How?
Replace it with an Option and bail in the case of not being configured.
Previously we used $CWD, which is not reliably the user’s app directory. This also updates the error box text to instruct the user to reference the terminal output.
Test Plan: Added a panic in Turbo and verified stderr and error box.
The default `comment_width` is `80`, which is a mismatch with the
`max_width` of `100`.
Previous discussion:
https://vercel.slack.com/archives/C03EWR7LGEN/p1716332166435329
Ran `cargo fmt` after making this change. It seems to mostly just fix
bullet points. Other places it likely can't differentiate between
wrapped text and intentional newlines.
I don't plan on going through and manually re-wrapping of all of the
comments, but over time this should get fixed as people change comments.
### What?
Removes the `turbopack-binding` crate which is unnecessary now that we
have everything in one repo.
This should improve compile times a bit.
Closes PACK-3162