-
-
Notifications
You must be signed in to change notification settings - Fork 156
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
Fix use-sync-external-store import for Webpack 5 #276
Fix use-sync-external-store import for Webpack 5 #276
Conversation
Codecov ReportBase: 100.00% // Head: 100.00% // No change to project coverage 👍
Additional details and impacted files@@ Coverage Diff @@
## main #276 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 5 5
Lines 217 217
Branches 53 53
=========================================
Hits 217 217
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. ☔ View full report at Codecov. |
@@ -0,0 +1 @@ | |||
export { useSyncExternalStore } from "use-sync-external-store/shim/index.native.js"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not familiar with how modules are bundled in native, is this some kind naming convention? I see that this file isn't actually referenced anywhere else.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@molefrog it is referenced to the same degree that the .js
version is, since we are not specifying any extension at all when we import it. It is up to the bundling system to select which extension to use, whether that be .js
or .native.js
!
That being said, I'm not too familiar with react native either, all I know is that I copied this fix over verbatim from react-query and it worked for them. 😄
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was able to find the docs on .native.js
extension, it seems like their bundler can handle these types of files. Looks legit!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good.
Fixes #275
There is an open facebook PR that should fix this as well whenever it EVENTUALLY gets merged: facebook/react#25231
But in the meantime, React Query seems to have had luck with this hack.
(See TanStack/query#3561 and TanStack/query#3601)