-
Notifications
You must be signed in to change notification settings - Fork 47k
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
Add package.json exports for use-sync-external-store #26230
base: main
Are you sure you want to change the base?
Add package.json exports for use-sync-external-store #26230
Conversation
29d0a5f
to
70e246d
Compare
Comparing: ca2cf31...5e6fa47 Critical size changesIncludes critical production bundles, as well as any change greater than 2%:
Significant size changesIncludes any change greater than 0.2%: (No significant changes) |
Could you check the same steps as the test plan in #25231? I guess my PR had to patch some files because it's still on old Rollup? |
Ah missed that there was already a PR for this. Any reason it hasn't been merged? |
@eps1lon Fixed a couple small things and ran your test repo against the latest commit and all passes now. |
So this change could be released as SemVer Minor while #25231 would be SemVer Major? |
I think so, yes. |
Hiya, folks. I'm working on upgrading React-Redux to have full ESM/CJS compat for our upcoming v9.0 major, and just ran into this lovely problem myself. In our case, we'll need to be importing I just did a quick check and confirmed that hand-editing a locally installed import { useSelector } from "react-redux";
console.log(useSelector) Could we get this merged and released? |
any update on this? |
This pull request has been automatically marked as stale. If this pull request is still relevant, please leave any comment (for example, "bump"), and we'll keep it open. We are sorry that we haven't been able to prioritize reviewing it yet. Your contribution is very much appreciated. |
This is definitely not stale! |
* feat(package/core): scoped query * feat(package/subscriptions): drop the package for graphql-ws * feat(packages/utils): drop unused package * fix(packages/logger): scoped query shim * feat: refactor resolvers for react * chore: error message * feat(packages/react): new core shim * fix: facebook/react#26230 * fix: generated subscription client * feat(packages/gqty): compat with queryFetcher and subsscriptionsClient * chore(compat): queryFetcher and subscriptionsClient * fix(package/react): infinite render loop * feat(package/gqty): separate Cache instantiation from client * chore(package/gqty): compat and optimized normalization * fix(package/react): react hooks * chore(deps): upgrade multidict * feat(package/gqty): rename fetchPolicy to cachePolicy * feat(package/gqty): add reload in cachePolicy * fix(package/react): consistent API * feat(package/react): Added onComplete for useMutation * feat(packages/cli): interactive mode * feat(examples): added the gnt example * fix(package/react): missing fetches in useQuery * fix(package/react): incorrect suspense in usePrepared * feat(package/cli): rename introspectionOptions to introspections * fix(deps): upgrade faulty multidict * fix(ci): use esm imports * fix(packages/gqty): compat, cache option should be optional. * fix(ci): dlx errors * feat(package/gqty): batching with microtask * chore(package/cli): refactor generated client * chore: remove legacy website * feat(package/gqty): passthru return types of selectors * chore(deps): upgrade testing-library for React 18 * fix(examples/vite): compatibility with v3 * chore(package/gqty): warn about empty selections * fix(packages/gqty): pure peer dep of graphql-ws * feat(package/gqty): edge compatible microtask * chore(examples/github): remove stale example * chore(deps): upgrade and dedupe typescript * feat(package/gqty): added extensions option * fix(packages/react): defaults to soft to match the docs * fix(packages/react): better simulate useTransactionQuery * chore(docs): self-contained images in README.md * fix(packages/react): flaky waitFor * chore(deps): make type-fest optional * feat(package/cli): error handling in generated client * chore(package/cli): code-splitting for watch mode * chore(deps): remove ws dependency * fix(package/react): infinite render loop * fix(package/react): early cache hydration * fix(package/react): default mode * feat(core): even more stickier fetches * chore: verbatimModuleSyntax * chore: test grommet fetch loop * fix(package/react): properly dispose cache subscribers * chore(deps): update esbuild * feat(cli): prompt for destination * fix(packages/react): infinite fetch via stale proxy #1588 * feat(examples/gnt): add bundle analyzer * fix(cli): compat with config.introspection * fix(cli): fetch all schemas before merging * fix(cli): install peer dep 'graphql' * fix(cli): allow disable subscription via arg * fix(packages/cli): typo on options definition * feat(cli): add negative options * fix(gqty): safe auto-selection on nullable interfaces * feat(gqty): remove default return from resolve() * fix(package/react): clear selections post-fetch in useQuery (#1594) * chore(compat): normalize import.meta.url to increase compatibility. * fix(package/gqty, package/react): error handling * feat(chore): prettier v3 * fix(cli): revert prettier to v2, deps are not ready for it * fix(package/react): reduce over-fetching between renders #1594 * feat(cli): enable suspense in the generated client * chore(examples/gnt): simulate noverby's infinite fetch bug * fix(package/react): reduce infinite fetch when normalization is disabled * fix(package/react): prevent non-query types from sticky fetching * chore(ci): test theguild's snapshot action * fix(cli): missing default import in watch mode * feat(cli): do not exit on fetch errors during watch mode * chore(deps): remove unused packages * chore(lint): add prettier-plugin-jsdoc * feat(package/react): add extensions option to useMutation * chore(prettier): remove jsdoc plugin to prevent noisy changes * feat(package/react): increase compatibility with non-web environments * fix(package/react): prevent infinite fetches * feat(package/react): experimental greedy fetch * feat(package/gqty): expose aliasLength option * feat(package/gqty): supress empty warnings when onEmptyResolve is specified * chore(exampels/vite-react): upgrade deprecated deps * feat(package/logger): fix fetch timer * chore(packages/gqty): user communication on fallbacks * chore(ci): fix release errors * chore(packages/gqty): prevent fetching stale inputs * chore(package/gqty): add mutation test for the new core * chore(examples/vite-react): clean up for suspense * fix(package/gqty): properly batch with microtask * feat(package/cli): allow force disabling of react * feat(package/react): add initialLoadingState option * chore(package/gqty): tidy up file structure * fix(packages/react): prevent fetch loops from cofetching resolvers * fix(packages/gqty): disable initialLoadingState upon first fetch * fix(package/gqty): rerender after first fetch to refresh isLoading * chore(examples/gnt): upgrade nhost client * chore: fix type resolutions in esm * chore(packages/cli): TypeScript v5 friendly type imports * chore(packages/react): reduce redundant iterations * chore(deps): upgrade pnpm * chore(examples/gnt): preparation work for Supabase example API * chore(package/react): remove experimental feature
@acdlite any chance of getting this merged? it seems this is blocking ESM adoption in client libraries like Redux |
Pinging @rickhanlonii - I think we briefly discussed this at ReactConf. |
This would also allow Apollo Client to use the shim - currently we ship an inlined copy of the package, as the missing |
This pull request has been automatically marked as stale. If this pull request is still relevant, please leave any comment (for example, "bump"), and we'll keep it open. We are sorry that we haven't been able to prioritize reviewing it yet. Your contribution is very much appreciated. |
Very bump |
Bump @sebmarkbage @shuding This is causing errors in my |
Fixes #24590
Closes #25231
Summary
We recently added support for Node ESM to React Aria, allowing all of our packages to be loaded via
import
. However, one problem remains –import 'use-sync-external-store/shim'
throws an error:This occurs both when using Node and when using webpack (e.g. in Next.js), which treats dependencies resolved from
.mjs
files as more strictly.This PR adds the "exports" field to package.json for use-sync-external-store, mapping the various extensionless and directory specifiers to the correct locations. Building the package itself as ESM is not necessary, we only need package exports for it to work in Node. This matches what
react-dom
and other packages with modules under subpaths do as well.For backward compatibility I have included all files in the package in the exports map, since non-exported files will throw an error.
How did you test this change?
Copied the build output into a directory under
node_modules
, and ranimport('use-sync-external-store/shim')
in a Node REPL. Also copied this into a Next.js project and it worked.