Turbopack: trace static project files referenced by packages (#98712)
### What? Allow Turbopack's native asset tracer to follow fully static application-root file references originating in packages, while continuing to block dynamic package references from traversing the application. Patterns containing alternatives retain only their fully static branches for project-root tracing. Branches containing any dynamic segment are discarded. A focused node-file-trace fixture covers a package loading an application-owned config through `path.resolve()` and `fs.existsSync()`. ### Why? Turbopack currently redirects every working-directory-relative reference from `node_modules` to the package directory. This protects builds from dynamic package expressions accidentally tracing much or all of the application, but it also prevents safe static configuration lookups such as `next-i18next.config.js` from reaching standalone output. The dynamic safeguard should remain, but known static files do not carry the same risk and should follow runtime working-directory semantics. Related to #98628. ### How? Add a pattern-level operation that extracts fully static alternatives from a normalized reference pattern. The tracing root selection uses that filtered pattern to choose the configured project working directory; dynamic-only patterns retain the existing package-directory fallback. The shared root-selection path applies this consistently to filesystem, path, worker, child-process, and specialized traced references. Existing outside-base and `node_modules` filtering tests continue to cover the safeguard. ### Verification - `cargo fmt -- --check` - `cargo test -p turbopack-core resolve::pattern` - `cargo test -p turbopack-tracing --test unit` - `git diff --check` <!-- NEXT_JS_LLM --> <!-- fleet fe000a60-fbb8-4835-b6ef-38d5684822a9 --> Co-authored-by:vercel-fleet-prod[bot] <318278635+vercel-fleet-prod[bot]@users.noreply.github.com> Co-authored-by:
Tobias Koppers <1365881+sokra@users.noreply.github.com>
Showing
Please
register
or
sign in
to comment