Skip to content

Fix RAM bundle passing the deps function (not its result) to getTransformOptions#1757

Open
durvesh1992 wants to merge 1 commit into
react:mainfrom
durvesh1992:fix/rambundle-getdependencies-callback
Open

Fix RAM bundle passing the deps function (not its result) to getTransformOptions#1757
durvesh1992 wants to merge 1 commit into
react:mainfrom
durvesh1992:fix/rambundle-getdependencies-callback

Conversation

@durvesh1992

Copy link
Copy Markdown

Summary

getRamBundleInfo hands custom getTransformOptions a callback to look up a module's transitive dependencies. But it builds that callback as:

async (x: string) => Array.from(getDependencies),

getDependencies is the function (filePath) => getTransitiveDependencies(filePath, graph). This calls Array.from on the function itself and ignores x — it never invokes getDependencies. Since the closure has arity 1, Array.from treats it as array-like via .length and returns [undefined]. So any getTransformOptions that uses this callback to compute preloadedModules/ramGroups receives [undefined] for every file it asks about.

Fix

-    async (x: string) => Array.from(getDependencies),
+    async (x: string) => Array.from(getDependencies(x)),

Test plan

jest packages/metro/src/DeltaBundler/Serializers/__tests__/getRamBundleInfo-test.js

Added a regression test that supplies a getTransformOptions which calls the callback for /root/foo.js and asserts it returns foo's transitive deps (bar, baz, qux). Fails before ([undefined]), passes after. Existing tests + snapshots unchanged (4 passed, 2 snapshots).

…formOptions

getRamBundleInfo gives custom getTransformOptions a callback to look up a
module's transitive dependencies, but it called `Array.from(getDependencies)`
on the function itself instead of `Array.from(getDependencies(x))`. Since
the closure has arity 1, Array.from treated it as array-like and returned
[undefined], so any getTransformOptions relying on this callback received
garbage regardless of the file queried.

Invoke getDependencies(x). Existing tests never exercised the callback,
which masked this.

Adds a regression test that calls the callback and asserts the real
transitive deps (fails before / passes after).
@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 Jun 30, 2026
@facebook-github-tools facebook-github-tools Bot added the Shared with Meta Applied via automation to indicate that an Issue or Pull Request has been shared with the team. label Jun 30, 2026
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. Shared with Meta Applied via automation to indicate that an Issue or Pull Request has been shared with the team.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant