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

Handle case where users use esbuild + `bundle: true`

Open lforst opened this issue 1 year ago • 7 comments

https://github.com/getsentry/sentry-javascript-bundler-plugins/issues/445#issuecomment-2061371373

We need to solve this case ^

lforst avatar Apr 17 '24 14:04 lforst

Any thoughts how to solve this? I imagine we'd need to parse some kind of config for this?

Lms24 avatar Apr 17 '24 15:04 Lms24

I think as a first step, we could ask a question pretty early on "are you using bundle: true"? If so, we redirect to something like the CLI wizard. As a more involved solution we could try parsing the config, however I see that as very difficult since the configs are JS and could have runtime logic we can't statically infer.

lforst avatar Apr 18 '24 08:04 lforst

Additionally, we could even potentially adjust the esbuild plugin to invoke the CLI with the inject command after the build has finished instead of injecting the debug ids as part of esbuild transpilation. That would definitely be a bit more error prone though.

lforst avatar Apr 18 '24 08:04 lforst

That would definitely be a bit more error prone though.

Not just error prone but also it would change the integrity hash of the script if change it afterwards. Service workers don't like that stuff xD This is always a problem with CLI inject so I wouldn't do it from within the bundler plugin by default.

Lms24 avatar Apr 18 '24 08:04 Lms24

But agree, asking is a great first step! Slightly more involved: Have a heuristic that superficially checks for bundle keyword in esbuild config and only ask if it's found?

Lms24 avatar Apr 18 '24 08:04 Lms24

But agree, asking is a great first step! Slightly more involved: Have a heuristic that superficially checks for bundle keyword in esbuild config and only ask if it's found?

Would probably work, but it would run into issues in case the option is "imported" from somewhere else, like inside of a shared config object or something.

lforst avatar Apr 18 '24 08:04 lforst

hmm yeah you're right, let's just keep it simple 😅

Lms24 avatar Apr 18 '24 08:04 Lms24