|
Hi, it looks to me like tree shaking isn't working (or working well) with Remix and esbuild. It is working well for us with our code, an other libraries like HeroIcons. I read the docs: https://docs.sentry.io/platforms/javascript/guides/remix/configuration/tree-shaking/ But I don't see how to set those flags like Thanks! Alex |
Replies: 10 comments 2 replies
|
Hey! You can use https://esbuild.github.io/api/#define to set flags like As for the rest - could you provide your In addition, is this bundle analysis with |
|
Thanks. Do you know how to do that in the context of remix?
Its not obvious that it's possible to configure esbuild
…On Mon, Feb 6, 2023, 5:14 AM Abhijeet Prasad ***@***.***> wrote:
Hey! You can use https://esbuild.github.io/api/#define to set flags like
__SENTRY_DEBUG__, which should then tree-shake this automatically.
As for the rest - could you provide your Sentry.init from your client
config? That will allow us to tell what should/shouldn't be in the final
bundle.
In addition, is this bundle analysis with --tree-shaking=true supplied to
esbuild? I think you need that flag, or --bundle to enable tree shaking
with esbuild.
—
Reply to this email directly, view it on GitHub
<#7058 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AABELQSRWOFSGDW64TEJOW3WWD2LJANCNFSM6AAAAAAUSHQGJY>
.
You are receiving this because you authored the thread.Message ID:
***@***.***
.com>
|
|
I tried this, with this in my remix.config.js: It doesn't seem to have impacted the sentry part of the bundle size much, I think it went down 9kb. Is that the expected result? |
|
Here is my Sentry.init on the client: |
|
also, your docs here https://docs.sentry.io/platforms/javascript/guides/remix/configuration/tree-shaking/ have an anchor |
|
So... how do I determine what the default integrations are, so I can include them in a custom init? |
|
Ok here's what I've got, does this look correct? |
|
Ok I've implemented that, and made sure we're avoiding all imports like |
|
9kb is about the expected result when you're stripping away the debug statements with The thing is you're still importing Doing Further, looking at your bundle, you can see that a very big part is just RRWeb which is used for Session Replay. Are you using that? |
|
Thanks for the response. We're not using replay. I got things working, I think the issue was that Remix uses esbuild, and to properly tree shake requires ESM modules, but our own internal libraries were CJS, and they used sentry too. Once we converted them to ESM they treeshake, and it looks like sentry does now too, looks like we're down to 61kb now, nice! |




Thanks for the response. We're not using replay. I got things working, I think the issue was that Remix uses esbuild, and to properly tree shake requires ESM modules, but our own internal libraries were CJS, and they used sentry too.
Once we converted them to ESM they treeshake, and it looks like sentry does now too, looks like we're down to 61kb now, nice!