Repository navigation
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
nodeDepEmitinvokes@vercel/nft'snodeFileTracewithbase: "/"so symlinked dependencies outsideappDir— in particular shared external pnpm stores (e.g.~/.local/share/pnpm/store/...) and framework CLIincludeEntries— do not resolve to../paths afterrealpath()and get dropped by@vercel/nft's built-inpath.startsWith(".." + path.sep)check.However, setting
base: "/"disables@vercel/nft's directory boundary guard completely. Whenever traced server bundles or dependencies contain a dynamic filesystem path expression rooted at/or above the project directory (for examplefs.readFileSync(path.resolve("/", dynamicSegment))),@vercel/nft'semitAssetDirectory/emitWildcardRequireemits an unguarded wildcard glob (glob("/**/*")):EACCES): With@vercel/nft0.27 (glob7), hitting any unreadable host directory such as/rootor isolated container sibling directories throwsEACCESand aborts deployment builds.@vercel/nft0.29+ (glob10+),globswallowsEACCESand walks every readable directory across the entire host filesystem, hurting build performance and potentially copying files from unrelated sibling repositories on the host that happen to sit withinpath.resolve(appDir, "../../../../../../").Why keeping
base: "/"+ scoping wildcard globs is preferable to changingbase(cf. #7)Setting
baseto a workspace directory (traceRoot) causes@vercel/nftto resolve package symlinks viarealpath()before computingpath.relative(base, realPath), which turns external shared pnpm store packages and externalincludeEntriesinto../paths and either fails validation or silently drops dependencies, while also requiring callers (@modern-js/app-tools, etc.) to opt in manually.Scoping wildcard globs via
ignorewhile keepingbase: "/"works out of the box with zero caller changes and preserves external pnpm store symlinks.Changes
src/utils.ts:appDir,sourceDir,includeEntries, and symlinked local packages (link:/file:/pnpm linkinnode_moduleswhoserealpathpoints outsidenode_modules), walking up to the outermost workspace root (pnpm-workspace.yaml,rush.json,eden.monorepo.json,lerna.json, orpackage.json#workspaces, falling back to.gitor nearestpackage.json) and expandingrealpath.createDefaultTraceIgnoreintraceFiles:[*?[]wildcards) are never blocked, avoiding regressions for explicit relativerequire()or custom resolution paths.emitAssetDirectory/emitWildcardRequire) are allowed only when their directory prefix prior to the first wildcard is insideallowedRootsor inside anode_modules/<pkg>package directory (including external shared pnpm stores). Host-wide globs (/**/*,/root/**/*, sibling host directories) are ignored beforeglob()runs.traceOptions.ignore(both function andstring | string[]glob patterns) on top of the default boundary.src/index.ts:allowedRootsalongsidedependencySearchRootwhen matching workspacepackage.jsonmanifests so deeply nested monorepos (> 6 directory levels) and symlinked paths also resolve cleanly..changeset/scope-default-trace-globs.md: Addpatchchangeset forndepe.Validation
pnpm exec biome check .pnpm build(ESM, CJS, and.d.tsoutput; verified CJSrequireand ESMimportsmoke checks)pnpm exec vitest --run(11 unit/integration tests passed, including a new test covering an unreadable0o000host directory, an unrelated outside-workspace host package, nested monorepo workspaces > 6 levels deep, alink:external repository with dynamic assets, an external shared pnpm store with dynamic assets, and callertraceOptions.ignorecomposition)node --test scripts/*.node-test.mjs(8 release utility tests passed)