Skip to content

fix(react): Import default for hoistNonReactStatics - #15238

Merged
chargome merged 5 commits into
developfrom
cg/fix-default-import
Jan 31, 2025
Merged

chargome merged 5 commits into
developfrom
cg/fix-default-import

Conversation

@chargome

Copy link
Copy Markdown
Member

This came up during upgrading Sentry to our v9 alpha (getsentry/sentry#84258).

Currently our import emits this line in cjs:
hoistNonReactStatics.default(Wrapped, WrappedComponent);
Which results in a runtime error (at least in jest runners).

With this change I updated the import to use import * as hoistNonReactStaticsImport from 'hoist-non-react-statics'; which solves the issue but breaks our ts-check. For this I moved the import into a fallback util function which satisfies ts.

@chargome chargome self-assigned this Jan 30, 2025
@chargome
chargome requested review from AbhiPrasad and mydea January 30, 2025 23:59
@github-actions

github-actions Bot commented Jan 31, 2025 •

Copy link
Copy Markdown
Contributor

size-limit report 📦

Path Size % Change Change
@sentry/browser 23.03 KB - -
@sentry/browser - with treeshaking flags 22.92 KB - -
@sentry/browser (incl. Tracing) 35.8 KB - -
@sentry/browser (incl. Tracing, Replay) 72.59 KB - -
@sentry/browser (incl. Tracing, Replay) - with treeshaking flags 66.13 KB - -
@sentry/browser (incl. Tracing, Replay with Canvas) 76.85 KB - -
@sentry/browser (incl. Tracing, Replay, Feedback) 89.35 KB - -
@sentry/browser (incl. Feedback) 39.71 KB - -
@sentry/browser (incl. sendFeedback) 27.66 KB - -
@sentry/browser (incl. FeedbackAsync) 32.44 KB - -
@sentry/react 24.84 KB -3.34% -879 B 🔽
@sentry/react (incl. Tracing) 37.69 KB -2.25% -885 B 🔽
@sentry/vue 27.14 KB - -
@sentry/vue (incl. Tracing) 37.52 KB - -
@sentry/svelte 23.15 KB - -
CDN Bundle 24.23 KB - -
CDN Bundle (incl. Tracing) 35.91 KB - -
CDN Bundle (incl. Tracing, Replay) 70.56 KB - -
CDN Bundle (incl. Tracing, Replay, Feedback) 75.69 KB - -
CDN Bundle - uncompressed 70.83 KB - -
CDN Bundle (incl. Tracing) - uncompressed 106.57 KB - -
CDN Bundle (incl. Tracing, Replay) - uncompressed 217.42 KB - -
CDN Bundle (incl. Tracing, Replay, Feedback) - uncompressed 229.99 KB - -
@sentry/nextjs (client) 38.65 KB - -
@sentry/sveltekit (client) 36.3 KB - -
@sentry/node 156.36 KB - -
@sentry/node - without tracing 97.45 KB - -
@sentry/aws-serverless 106.92 KB - -

View base workflow run

Comment thread packages/react/src/profiler.tsx Outdated
chargome and others added 3 commits January 30, 2025 16:03
Co-authored-by: Catherine Lee <55311782+c298lee@users.noreply.github.com>

@mydea mydea left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice!

@chargome
chargome merged commit 25e7071 into develop Jan 31, 2025
@chargome
chargome deleted the cg/fix-default-import branch January 31, 2025 08:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants