Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[rcr] Re-export useMemoCache in top level React namespace #31139

Merged
merged 1 commit into from
Oct 7, 2024

Conversation

poteto
Copy link
Member

@poteto poteto commented Oct 7, 2024

In order to support using the compiler on versions of React prior to 19,
we need the ability to statically import c (aka useMemoCache) or
fallback to a polyfill supplied by react-compiler-runtime (note: this
is a separate npm package, not to be confused with
react/compiler-runtime, which is currently a part of react).

To do this we first need to re-export useMemoCache under the top level
React namespace again, which is additive and thus non-breaking. Doing so
allows react-compiler-runtime to statically either re-export
React.__COMPILER_RUNTIME.c or supply a polyfill, without the need for
a dynamic import which is finicky to support due to returning a promise.

In later PRs I will remove react/compiler-runtime and update the
compiler to emit imports to react-compiler-runtime instead.

[ghstack-poisoned]
Copy link

vercel bot commented Oct 7, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
react-compiler-playground ✅ Ready (Inspect) Visit Preview 💬 Add feedback Oct 7, 2024 7:22pm

@react-sizebot
Copy link

The size diff is too large to display in a single comment. The GitHub action for this pull request contains an artifact called 'sizebot-message.md' with the full message.

Generated by 🚫 dangerJS against 443a9a3

@poteto poteto merged commit b78a7f2 into main Oct 7, 2024
184 checks passed
@poteto poteto deleted the gh/poteto/25/head branch October 7, 2024 20:31
github-actions bot pushed a commit that referenced this pull request Oct 7, 2024
In order to support using the compiler on versions of React prior to 19,
we need the ability to statically import `c` (aka useMemoCache) or
fallback to a polyfill supplied by `react-compiler-runtime` (note: this
is a separate npm package, not to be confused with
`react/compiler-runtime`, which is currently a part of react).

To do this we first need to re-export `useMemoCache` under the top level
React namespace again, which is additive and thus non-breaking. Doing so
allows `react-compiler-runtime` to statically either re-export
`React.__COMPILER_RUNTIME.c` or supply a polyfill, without the need for
a dynamic import which is finicky to support due to returning a promise.

In later PRs I will remove `react/compiler-runtime` and update the
compiler to emit imports to `react-compiler-runtime` instead.

DiffTrain build for [b78a7f2](b78a7f2)
github-actions bot pushed a commit that referenced this pull request Oct 7, 2024
In order to support using the compiler on versions of React prior to 19,
we need the ability to statically import `c` (aka useMemoCache) or
fallback to a polyfill supplied by `react-compiler-runtime` (note: this
is a separate npm package, not to be confused with
`react/compiler-runtime`, which is currently a part of react).

To do this we first need to re-export `useMemoCache` under the top level
React namespace again, which is additive and thus non-breaking. Doing so
allows `react-compiler-runtime` to statically either re-export
`React.__COMPILER_RUNTIME.c` or supply a polyfill, without the need for
a dynamic import which is finicky to support due to returning a promise.

In later PRs I will remove `react/compiler-runtime` and update the
compiler to emit imports to `react-compiler-runtime` instead.

DiffTrain build for [b78a7f2](b78a7f2)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed React Core Team Opened by a member of the React Core Team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants