Turbopack: avoid project-wide traces from package directories (#99238)
### What? Limit Turbopack's package-origin project-root tracing to statically named **files**, while resolving the complete original request relative to the package as before. This applies to filesystem, directory, child-process and Node worker references. ### Why? Static does not necessarily mean narrow: `node-gyp-build`'s `path.resolve(dir || '.')` contains a static `'.'` branch. Tracing that from the application root as a directory recursively includes unrelated application assets. We still need packages to find explicitly named application config files. ### How? Analysis records two candidate contexts without inspecting the filesystem: an optional app-root context for static file paths, and a package-local fallback for the original request. At reference resolution, the app-side lookup keeps only fully static file matches; directories and symlinked directories cannot recursively expand there. The package-side lookup independently traces the full pattern, including dynamic alternatives and directory contents. Both results are combined so even a mixed file/directory expression can retain its app config **and** package-local assets; the combination preserves distinct files sharing a request key and deduplicates identical modules. Protobuf `includeDirs` uses the same reference path. Regression fixtures cover a `node-gyp-build`-style `'.'` fallback, mixed file/directory alternatives with same-named files in both contexts, symlinked directories and files, a missing optional config, and Node worker references. The webpack/@vercel/nft path is unchanged. **Verification:** 93 tracing tests and 65 core resolve tests pass; focused Clippy with warnings denied, Rust formatting and diff checks pass. Production next-site size impact has not been independently measured in this fixture. Related: #98628, #98712, #99080. <!-- 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