Conversation

mydea

Extracted out from #16565

I noticed that our modulesIntegration is pretty limited:

  1. It does nothing on EMS
  2. It does not work on Next.js (even though that is CJS)

This PR makes this a bit more robust (not perfect):

  1. It generally now also tries to look at process.cwd() + 'package.json' and take the dependencies and devDependencies from there. this should generally work in esm apps now as well, at least at a basic level. You do not get all dependencies and versions may be ranges, but better than nothing.
  2. For Next.js, we inject a modules list based off the package.json at build time, as we do not have proper access to this at runtime.

@mydeamydea requested review from Lms24 and AbhiPrasad June 12, 2025 12:28
@mydeamydea self-assigned this Jun 12, 2025
@mydeamydea force-pushed the fn/better-modules-integration branch from b9ac82d to 7f29495 Compare June 12, 2025 12:28
@github-actionsGitHub Actions

size-limit report 📦

PathSize% ChangeChange
@sentry/browser23.99 kB--
@sentry/browser - with treeshaking flags23.76 kB--
@sentry/browser (incl. Tracing)38.69 kB--
@sentry/browser (incl. Tracing, Replay)76.78 kB--
@sentry/browser (incl. Tracing, Replay) - with treeshaking flags69.87 kB--
@sentry/browser (incl. Tracing, Replay with Canvas)81.54 kB--
@sentry/browser (incl. Tracing, Replay, Feedback)93.6 kB--
@sentry/browser (incl. Feedback)40.73 kB--
@sentry/browser (incl. sendFeedback)28.7 kB--
@sentry/browser (incl. FeedbackAsync)33.59 kB--
@sentry/react25.76 kB--
@sentry/react (incl. Tracing)40.67 kB--
@sentry/vue28.36 kB--
@sentry/vue (incl. Tracing)40.55 kB--
@sentry/svelte24.01 kB--
CDN Bundle25.48 kB--
CDN Bundle (incl. Tracing)38.77 kB--
CDN Bundle (incl. Tracing, Replay)74.64 kB--
CDN Bundle (incl. Tracing, Replay, Feedback)80.1 kB--
CDN Bundle - uncompressed74.48 kB--
CDN Bundle (incl. Tracing) - uncompressed114.89 kB--
CDN Bundle (incl. Tracing, Replay) - uncompressed228.86 kB--
CDN Bundle (incl. Tracing, Replay, Feedback) - uncompressed241.69 kB--
@sentry/nextjs (client)42.33 kB--
@sentry/sveltekit (client)39.17 kB--
@sentry/node150.5 kB+0.02%+25 B 🔺
@sentry/node - without tracing98.38 kB+0.04%+31 B 🔺
@sentry/aws-serverless124.14 kB+0.03%+33 B 🔺

View base workflow run

Comment on lines +137 to +139
...packageJson.dependencies,
...packageJson.devDependencies,
Copy link
Member

Choose a reason for hiding this comment

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

l/maybe something to follow up on in the future: Would be cool to add some kind of flag to differ between dependencies and devDependencies. Doesn't have to happen now of course

@mydeamydea force-pushed the fn/better-modules-integration branch from 96b9078 to 988111d Compare June 12, 2025 15:05
@mydeamydea force-pushed the fn/better-modules-integration branch from 988111d to cec19a7 Compare June 12, 2025 15:17

Choose a reason for hiding this comment

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

There's probably a bunch of edge cases here with monorepos and mixed esm/cjs environments that we don't account for, but I think this is a good starting point.

@mydeamydea merged commit c92a9b0 into develop Jun 13, 2025
145 checks passed
@mydeamydea deleted the fn/better-modules-integration branch June 13, 2025 06:36
Sign up for free to join this conversation on . Already have an account? Sign in to comment
None yet
None yet

Successfully merging this pull request may close these issues.