Skip to content

Add DependencyGraph.unstable_fromStaticFileMap - #1864

Open
vzaidman wants to merge 1 commit into
mainfrom
export-D116161131
Open

Add DependencyGraph.unstable_fromStaticFileMap#1864
vzaidman wants to merge 1 commit into
mainfrom
export-D116161131

Conversation

@vzaidman

Copy link
Copy Markdown
Contributor

Summary:
Builds a DependencyGraph from a known file listing — no filesystem crawl, no FileProcessor and no cache persistence — for consumers that already know their file set and hold parsed package.json contents in memory:

const graph = await DependencyGraph.unstable_fromStaticFileMap(config, {files: [{path, hasteId}], readPackageJson});

hasteId is registered as-is, so any extension or node_modules filtering is the caller's policy. Three further options cover what a virtual, non-terminal consumer needs: readPackageJson feeds PackageCache from memory, unstable_dirExistsFromFileSystem resolves dirExists against the supplied listing rather than fs.lstatSync, and unstable_rawResolutionErrors lets DuplicateHasteCandidatesError and InvalidPackageError propagate instead of being wrapped in AmbiguousModuleResolutionError / PackageResolutionError.

Startup progress reporting is skipped on this path: dep_graph_loading makes TerminalReporter print Metro's banner, which corrupts consumers that speak a protocol over stdout. Relatedly, createFileMap now requires ci-info lazily, as it probes ~40 environment variables on import and some sandboxed consumers disallow that.

Changelog: Internal (DependencyMap as class is not exported)

Differential Revision: D116161131

Summary:
Builds a `DependencyGraph` from a known file listing — no filesystem crawl, no `FileProcessor` and no cache persistence — for consumers that already know their file set and hold parsed `package.json` contents in memory:

```js
const graph = await DependencyGraph.unstable_fromStaticFileMap(config, {files: [{path, hasteId}], readPackageJson});
```

`hasteId` is registered as-is, so any extension or `node_modules` filtering is the caller's policy. Three further options cover what a virtual, non-terminal consumer needs: `readPackageJson` feeds `PackageCache` from memory, `unstable_dirExistsFromFileSystem` resolves `dirExists` against the supplied listing rather than `fs.lstatSync`, and `unstable_rawResolutionErrors` lets `DuplicateHasteCandidatesError` and `InvalidPackageError` propagate instead of being wrapped in `AmbiguousModuleResolutionError` / `PackageResolutionError`.

Startup progress reporting is skipped on this path: `dep_graph_loading` makes `TerminalReporter` print Metro's banner, which corrupts consumers that speak a protocol over stdout. Relatedly, `createFileMap` now requires `ci-info` lazily, as it probes ~40 environment variables on import and some sandboxed consumers disallow that.

Changelog: Internal (`DependencyMap` as class is not exported)

Differential Revision: D116161131
@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Aug 19, 2026
@meta-codesync

meta-codesync Bot commented Aug 19, 2026

Copy link
Copy Markdown
Contributor

@vzaidman has exported this pull request. If you are a Meta employee, you can view the originating Diff in D116161131.

@robhogan

robhogan commented Aug 19, 2026

Copy link
Copy Markdown
Collaborator

Thanks for exporting, mind if I commandeer this one? It looks familiar :)

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

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. meta-exported

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants