sentry-javascript icon indicating copy to clipboard operation
sentry-javascript copied to clipboard

Remove @sentry/hub

Open AbhiPrasad opened this issue 3 years ago • 3 comments

Problem Statement

We have both https://github.com/getsentry/sentry-javascript/tree/master/packages/hub and https://github.com/getsentry/sentry-javascript/tree/master/packages/core, and there should never be a situation where you import @sentry/hub and you aren't using @sentry/core. As such, we should just consolidate this into 1 package (move everything in @sentry/hub into @sentry/core.)

  • Less stuff to download from npm
  • Less chance of versions getting out of sync
  • Easy to understand core -> browser -> react -> nextjs (linear deps)
  • Possible bundle size reduction from removing module boundaries

AbhiPrasad avatar Aug 31 '22 17:08 AbhiPrasad

Why didn't do it in the first place?

shezhangzhang avatar Sep 01 '22 09:09 shezhangzhang

Maybe @kamilogorek can offer us some history listens on why hub was made a seperate package.

AbhiPrasad avatar Sep 01 '22 11:09 AbhiPrasad

Whole @sentry/minimal was build around @sentry/hub. If you are writing 3rd party integrations, or plug-in widgets, you are not going to depend on @sentry/core, and can use @sentry/hub directly.

kamilogorek avatar Sep 01 '22 12:09 kamilogorek

Would it be possible to move the hub code without breaking the public API?

We could move the code to core and then have hub only depend on core and re-export the types?

The only reason I suggest this is because it becomes easier to make the changes and iterate on the codebase without creating a load of merge conflicts as v8 approaches. When we get to v8 we'd simply remove the @sentry/hub package?

The only downside I can see is that we'd be exporting the types from two different packages at the same time.

timfish avatar Sep 26 '22 10:09 timfish

We could move the code to core and then have hub only depend on core and re-export the types?

I'm going to go ahead and make the call for us to do this, esp if it makes the work in https://github.com/getsentry/sentry-javascript/issues/5611 easier.

The only downside I can see is that we'd be exporting the types from two different packages at the same time.

Internally, we can shift to only depending on core, so the chances of this causing issues will decrease.

AbhiPrasad avatar Sep 26 '22 11:09 AbhiPrasad

The only downside I can see is that we'd be exporting the types from two different packages at the same time.

We already do this all over the place, because most wrapper SDKs re-export stuff from the SDKs they wrap. I don't think it's an issue.

lobsterkatie avatar Sep 26 '22 17:09 lobsterkatie

I've reopened this and it can be closed when @sentry/hub is finally deleted and the tests are migrated to core.

timfish avatar Oct 07 '22 12:10 timfish

Happy about this change! 🚀

yordis avatar Oct 10 '22 15:10 yordis