[compiler]: use default import for useMemoCache #32071
Closed
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
Follows up on #31993 not fully resolving the regression #31963, see https://github.com/sanity-io/react-compiler-runtime-regression for all the deets.
This PR explores the solution that follows what Node.js' own error outlines, using a default export:
Instead of what we currently do:
Which doesn't work in a native node.js ESM env since the polyfill is exporting
c
asmodule.exports = {c};
.The
react/compiler-runtime
is still usingexports.c = c;
, and thus were unaffected by the changes in #31963.Changing its import still works:
Test here.
How did you test this change?
The changes here were conceptually tested on the reproduction repo. I also ran
cd compiler && yarn && yarn snap:build && yarn snap --watch
. AFAIK all tests pass. I did look at the 900+ changed snapshots and AFAIK they seem correct.