Skip to content

feat(app-tools): support deploy.traceOptions for dependency tracing - #8811

Open
scplay wants to merge 1 commit into
web-infra-dev:mainfrom
scplay:feat/deploy-trace-options
Open

feat(app-tools): support deploy.traceOptions for dependency tracing#8811
scplay wants to merge 1 commit into
web-infra-dev:mainfrom
scplay:feat/deploy-trace-options

Conversation

@scplay

@scplay scplay commented Aug 13, 2026

Copy link
Copy Markdown

Forward a user-configurable deploy.traceOptions to ndepe -> @vercel/nft when tracing server-side dependencies.

Tracing runs with the filesystem root as its base, so static analysis of __dirname-based patterns in the server bundle can reach unrelated system directories and abort the build when they are unreadable:

EACCES: permission denied, open '/etc/sudoers'

There was previously no way to influence tracing from user config, since no deploy preset forwarded ndepe's traceOptions passthrough.

Applied to the node, vercel and netlify presets. No defaults are added, so behavior is unchanged when the option is omitted.

Refs #8779

Summary

Forward a user-configurable deploy.traceOptions to ndepe@vercel/nft
when tracing server-side dependencies.

Tracing runs with the filesystem root as its base, so static analysis of
__dirname-based patterns in the server bundle can reach unrelated system
directories and abort the build when they are unreadable:

EACCES: permission denied, open '/etc/sudoers'

In my case @sentry/node-core's Context integration does a readdir('/etc') to
detect the Linux distribution, which is enough to pull /etc/* into the trace.
On Linux CI with stale symlinks the same root cause surfaces as
ENOENT: stat '/etc/alternatives/which.sl1.gz'. .output/static is produced
correctly — only the tracing step fails, so node_modules is never emitted into
.output.

There was previously no way to influence tracing from user config, since no
deploy preset forwarded ndepe's traceOptions passthrough. The only
workarounds were patching ndepe or vendoring the deploy plugin.

Applied to the node, vercel and netlify presets. No defaults are added, so
behavior is unchanged when the option is omitted.

Usage

export default defineConfig({
  deploy: {
    traceOptions: {
      ignore: ['etc/**', 'private/etc/**'],
    },
  },
});

ignore patterns resolve against nft's base (/), so etc/** matches /etc/sudoers. nft evaluates ignoreFn before globbing in emitAssetDirectory, so ignored directories are never walked.

Why not traceRoot

A deploy.traceRoot option was suggested in #8779, passed to nft as the tracing base. I prototyped it and it does not work as a passthrough: base in ndepe is not only nft's tracing root but also the root that ndepe resolves nft's results against, and it is hardcoded to "/". nft returns paths relative to base, so narrowing it makes resolveTracedPath("/", "global/my-app/...") produce /global/my-app/... and the trace dies one step later with ENOENT: lstat '/global'. Making traceRoot work requires threading one root through nodeFileTrace, resolveTracedPath and the isSubPath checks, and reconciling it with the separate dependencySearchRoot in the same function — a change to ndepe's path semantics, not an app-tools passthrough.

Why no built-in ignore defaults

Shipping a default system-directory list would fix this with zero config, but those paths are platform-specific (/etc vs /private/etc on macOS, /proc and /sys on Linux, arbitrary mount points in containers), so any built-in list is both incomplete and a silent policy decision made for the user. For the record, ignoring them loses nothing: with base: '/' and no ignore, 228 files under /etc enter nft's fileList, but zero can be attributed by ndepe to an npm package, so none were ever emitted.

Related Links

Refs #8779
Related: vercel/nft#601

Checklist

  • I have added changeset via pnpm run change.
  • I have updated the documentation.
  • I have added tests to cover my changes.

I left the documentation box unchecked: I couldn't find an existing config reference page for deploy (neither microFrontend nor worker appears to be documented). Happy to add one wherever you'd prefer it to live.

Forward a user-configurable `deploy.traceOptions` to ndepe -> @vercel/nft
when tracing server-side dependencies.

Tracing runs with the filesystem root as its base, so static analysis of
__dirname-based patterns in the server bundle can reach unrelated system
directories and abort the build when they are unreadable:

  EACCES: permission denied, open '/etc/sudoers'

There was previously no way to influence tracing from user config, since no
deploy preset forwarded ndepe's traceOptions passthrough.

Applied to the node, vercel and netlify presets. No defaults are added, so
behavior is unchanged when the option is omitted.

Refs web-infra-dev#8779
@changeset-bot

changeset-bot Bot commented Aug 13, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: ae5ce59

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 119 packages
Name Type
@modern-js/app-tools Minor
@modern-js/adapter-rstest Minor
@modern-js/plugin-bff Minor
@modern-js/plugin-ssg Minor
@modern-js/plugin-styled-components Minor
@modern-js/plugin-i18n Minor
@modern-js/image Minor
@modern-js/runtime Minor
@modern-js/plugin-polyfill Minor
@integration-test/alias-set Patch
app-document Patch
async-entry-test Patch
tmp Patch
bff-api-app Patch
bff-client-app Patch
bff-indep-client-app Patch
bff-hono Patch
integration-clean-dist-path Patch
integration-compatibility Patch
integration-custom-dist-path Patch
custom-file-system-entry Patch
integration-custom-template Patch
deploy Patch
deploy-server Patch
dev-server Patch
integration-disable-html Patch
entries-app-builder Patch
app-custom-entries Patch
app-custom-routes-runtime Patch
app-custom Patch
app-entry Patch
app-route Patch
app-entry-server Patch
i18n-app-csr-html-lang Patch
i18n-app Patch
i18n-app-ssr-html-lang Patch
i18n-app-ssr Patch
i18n-custom-i18n-wrapper Patch
i18n-mf-app-provider Patch
i18n-mf-component-provider Patch
i18n-mf-consumer Patch
i18n-routes Patch
i18n-routes-ssr Patch
@integration-test/image-component Patch
main-entry-name Patch
nonce Patch
pure-esm-project Patch
react-compiler-test Patch
routes-match Patch
routes Patch
app-rsbuild-hooks Patch
rsc-csr-app Patch
rsc-csr-routes Patch
rsc-ssr-app Patch
rsc-ssr-routes Patch
basic-app-rstest-browser Patch
basic-app-rstest Patch
runtime-custom-plugin Patch
runtime-custom-config-plugin Patch
select-mul-entry-test Patch
select-one-entry-test Patch
server-config Patch
server-esm-tsx Patch
server-json-script Patch
server-monitors Patch
server-prod Patch
server-routes Patch
@source-code-build/app Patch
ssg-fixtures-mega-list-routes Patch
ssg-fixtures-nested-routes Patch
ssg-fixtures-simple Patch
ssg-fixtures-web-server Patch
ssr-base-async-entry-test Patch
ssr-base-async-pre-entry-test Patch
ssr-base-json-test Patch
ssr-base-test Patch
ssr-base-fallback-test Patch
init Patch
ssr-base-loadable Patch
ssr-partial-test Patch
rsc-closing-tags-test Patch
ssr-script-loading Patch
ssr-useid-test Patch
ssr-streaming-inline-test Patch
ssr-streaming-lazy-test Patch
ssr-streaming-test Patch
styled-components-stream Patch
styled-components-string Patch
integration-tailwindcss-v2 Patch
integration-tailwindcss-v3 Patch
integration-tailwindcss-v4-tools Patch
integration-tailwindcss-v4 Patch
tmp-dir Patch
write-to-dist Patch
@modern-js/bundle-diff-benchmark Minor
@modern-js/main-doc Minor
@modern-js/tsconfig Minor
@modern-js/builder Minor
@modern-js/plugin-data-loader Minor
@modern-js/render Minor
@modern-js/bff-core Minor
@modern-js/bff-runtime Minor
@modern-js/server-core Minor
@modern-js/create-request Minor
@modern-js/prod-server Minor
@modern-js/server-runtime Minor
@modern-js/server Minor
@modern-js/server-utils Minor
@modern-js/create Minor
@modern-js/i18n-utils Minor
@modern-js/plugin Minor
@modern-js/runtime-utils Minor
@modern-js/sandpack-react Minor
@modern-js/types Minor
@modern-js/utils Minor
@modern-js/rslib Minor
@scripts/prebundle Patch
@scripts/rstest-config Patch
@scripts/release-node Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@netlify

netlify Bot commented Aug 13, 2026

Copy link
Copy Markdown

Deploy Preview for modernjs-byted ready!

Name Link
🔨 Latest commit ae5ce59
🔍 Latest deploy log https://app.netlify.com/projects/modernjs-byted/deploys/6a7d7e274c0f3200086c3cd4
😎 Deploy Preview https://deploy-preview-8811--modernjs-byted.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
Lighthouse
Lighthouse
1 paths audited
Performance: 99 (no change from production)
Accessibility: 100 (no change from production)
Best Practices: 100 (no change from production)
SEO: 100 (no change from production)
PWA: -
View the detailed breakdown and full score reports
🤖 Make changes Run an agent on this branch

To edit notification comments on pull requests, go to your Netlify project configuration.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant