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

fix(core): Pass module into loadModule #15139

Merged
merged 2 commits into from
Jan 27, 2025
Merged

Conversation

jrandolf
Copy link
Contributor

  • [-] If you've added code that should be tested, please add tests.
  • Ensure your code lints and the test suite passes (yarn lint) & (yarn test).
    Certainly! Here’s a more elegantly phrased version of your content:

The loadModule function currently utilizes require to load modules starting from the @sentry/core directory. This approach is incompatible with package managers like pnpm, which do not hoist dependencies. Consequently, when another module, such as @sentry/nextjs, invokes loadModule, it fails to locate its own dependencies because the search initiates within the @sentry/core tree.

Example Scenario

Current Behavior:

If @sentry/nextjs calls loadModule('@sentry/webpack-plugin'), the function attempts to locate @sentry/webpack-plugin within the dependencies of @sentry/core. This results in the module not being found if @sentry/webpack-plugin is not a dependency of @sentry/core.

Proposed Change:

With the current pull request, invoking loadModule('@sentry/webpack-plugin', module) directs the search to the dependencies of @sentry/nextjs instead of @sentry/core. This ensures that loadModule correctly resolves modules based on the calling module’s dependency tree, accommodating environments where dependencies are not hoisted.

Sorry, something went wrong.

Copy link
Member

@Lms24 Lms24 left a comment

Choose a reason for hiding this comment

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

Hey @jrandolf thanks for contributing! This sounds reasonable to me. Let's see if CI agrees :) In the current state, this would be a breaking change which is fine, since we're working on v9 of the SDK anyway. If you'd like to see this released for v8 of the SDK, we need to make the new parameter optional, so that there's no API breakage.

I'm just a bit surprised that this surfaces only now, given that pnpm and NextJS are used quite frequently, I'd imagine.

@jrandolf jrandolf force-pushed the develop branch 2 times, most recently from 9a2ab42 to e30fc15 Compare January 23, 2025 15:04
@jrandolf jrandolf requested a review from Lms24 January 23, 2025 15:04
@Lms24
Copy link
Member

Lms24 commented Jan 24, 2025

heads-up: just assigning myself to review and merge this on Monday. Restarted CI in the meantime. Thanks for making the parameter optional!

@Lms24 Lms24 self-assigned this Jan 24, 2025

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
Copy link
Member

@Lms24 Lms24 left a comment

Choose a reason for hiding this comment

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

Thanks!

@Lms24 Lms24 merged commit 70d53a9 into getsentry:develop Jan 27, 2025
131 checks passed
Lms24 pushed a commit that referenced this pull request Jan 27, 2025
The `loadModule` function currently utilizes `require` to load modules
starting from the `@sentry/core` directory. This approach is
incompatible with package managers like pnpm, which do not hoist
dependencies. Consequently, when another module, such as @sentry/nextjs,
invokes `loadModule`, it fails to locate its own dependencies because
the search initiates within the @sentry/core tree.
Lms24 added a commit that referenced this pull request Jan 27, 2025

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
This PR adds the external contributor to the CHANGELOG.md file, so that
they are credited for their contribution. See #15139

---------

Co-authored-by: Lukas Stracke <lukas.stracke@sentry.io>
Lms24 added a commit that referenced this pull request Jan 27, 2025

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
backport of #15139

---------

Co-authored-by: Randolf J <34705014+jrandolf@users.noreply.github.com>
Co-authored-by: Abhijeet Prasad <aprasad@sentry.io>
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.

None yet

2 participants