Repository navigation
Conversation
`Graph` threads a `RequireContext` per module from `buildSubgraph` through commit, snapshots and release, so that the transformer can render a context module's template. It's the one place Metro carries a transform's input on a dependency edge rather than reading it from disk. This generalises that slot to `VirtualSource`, a tagged union whose only arm for now is a `require.context`'s parameters, so that a virtual module's source can travel the same way (#2036) rather than through a second mechanism beside it. `ModuleData.resolvedContexts` becomes `virtualSources`, and `markModifiedContextModules` only considers context entries. Changelog: Internal
robhogan
added this pull request to stack #2042
October 8, 2026 12:56
RequireContext)
robhogan
marked this pull request as ready for review
October 8, 2026 13:29
RequireContext)
robhogan
removed this pull request from stack #2042
October 11, 2026 14:41
robhogan
added this pull request to stack #2057
October 11, 2026 14:41
Contributor
There was a problem hiding this comment.
馃煝 Approval recommended
The refactor consistently preserves existing context-module behavior and updates relevant tests.
0 open findings
What changed in this PR
Generalizes require.context transform inputs into the extensible VirtualSource abstraction without changing behavior.
Changes:
- Replaces
resolvedContextswith taggedvirtualSources. - Threads virtual sources through graph traversal, snapshots, and transforms.
- Updates context-module tests for the new representation.
| File | Description |
|---|---|
packages/鈥媘etro/鈥媠rc/鈥媗ib/鈥媡ransformHelpers.js |
Unwraps context virtual sources for transformation. |
packages/鈥媘etro/鈥媠rc/鈥婦eltaBundler/鈥媡ypes.js |
Defines VirtualSource and updates related types. |
packages/鈥媘etro/鈥媠rc/鈥婦eltaBundler/鈥婫raph.js |
Tracks virtual sources throughout graph lifecycle. |
packages/鈥媘etro/鈥媠rc/鈥婦eltaBundler/鈥媌uildSubgraph.js |
Carries tagged virtual sources during traversal. |
packages/鈥媘etro/鈥媠rc/鈥婦eltaBundler/鈥媉_tests__/鈥婫raph-test.js |
Updates graph expectations and transform signatures. |
packages/鈥媘etro/鈥媠rc/鈥婦eltaBundler/鈥媉_tests__/鈥媌uildSubgraph-test.js |
Verifies tagged context-source propagation. |
馃 Review effort: Balanced
馃挕 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
huntie
approved these changes
Oct 14, 2026
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.
Graphthreads aRequireContextper module frombuildSubgraphthrough commit, snapshots and release, so that the transformer can render a context module's template.It's the only place Metro carries a transform's input on a dependency edge rather than reading it from disk, which is the kind of shape we need for virtual modules.
This generalises that slot to
VirtualSource, a union whose only member for now isrequire.context's parameters.ModuleData.resolvedContextsbecomesvirtualSources, andmarkModifiedContextModulesonly considers context entries.This takes some of the noise out #2036 for ease of review, and should be read in the context of that design. No behaviour or API change.
Changelog: Internal