Skip to content

Include transform dependency modules in Metro worker cache key#1749

Open
fallintoplace wants to merge 2 commits into
react:mainfrom
fallintoplace:fix/transform-worker-cache-key
Open

Include transform dependency modules in Metro worker cache key#1749
fallintoplace wants to merge 2 commits into
react:mainfrom
fallintoplace:fix/transform-worker-cache-key

Conversation

@fallintoplace

@fallintoplace fallintoplace commented Jun 25, 2026

Copy link
Copy Markdown

Why this change

The Metro transform cache key did not include all transform-affecting internal workers, so changes to those modules could avoid cache invalidation.

What changed

  • Included transform internals in filesKey list in packages/metro-transform-worker/src/index.js (collectDependencies, generateImportNames, JsFileWrapping, importLocationsPlugin) and added an explicit inline policy comment describing expected cache-key coverage.
  • Improved cache-key test in packages/metro-transform-worker/src/__tests__/index-test.js:
    • Renamed test to describe intent more directly.
    • Switched assertion to toHaveBeenCalledWith(expect.arrayContaining(...)) and removed unrelated mock-return-value wiring.

Why this is safer

The cache key now reflects key internal transform inputs that can affect emitted output and avoids stale transform-cache entries when those internals evolve.

Validation

  • Not run in this pass.
  • Recommended command: yarn test packages/metro-transform-worker/src/__tests__/index-test.js

@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 25, 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 25, 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