Add DependencyGraph.unstable_fromStaticFileMap - #1864
Open
vzaidman wants to merge 1 commit into
Open
Conversation
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
Contributor
|
@vzaidman has exported this pull request. If you are a Meta employee, you can view the originating Diff in D116161131. |
Collaborator
|
Thanks for exporting, mind if I commandeer this one? It looks familiar :) |
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.
Summary:
Builds a
DependencyGraphfrom a known file listing — no filesystem crawl, noFileProcessorand no cache persistence — for consumers that already know their file set and hold parsedpackage.jsoncontents in memory:hasteIdis registered as-is, so any extension ornode_modulesfiltering is the caller's policy. Three further options cover what a virtual, non-terminal consumer needs:readPackageJsonfeedsPackageCachefrom memory,unstable_dirExistsFromFileSystemresolvesdirExistsagainst the supplied listing rather thanfs.lstatSync, andunstable_rawResolutionErrorsletsDuplicateHasteCandidatesErrorandInvalidPackageErrorpropagate instead of being wrapped inAmbiguousModuleResolutionError/PackageResolutionError.Startup progress reporting is skipped on this path:
dep_graph_loadingmakesTerminalReporterprint Metro's banner, which corrupts consumers that speak a protocol over stdout. Relatedly,createFileMapnow requiresci-infolazily, as it probes ~40 environment variables on import and some sandboxed consumers disallow that.Changelog: Internal (
DependencyMapas class is not exported)Differential Revision: D116161131