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

Make `@sentry/google-cloud-serverless` ESM compat

Open AbhiPrasad opened this issue 1 year ago • 1 comments

The serverless SDKs use require to monkeypatch GCP related libraries. This does not work with ESM (and it gets even more complicated with bundling).

Currently we only emit an CJS bundle for serverless.

AbhiPrasad avatar Apr 24 '24 18:04 AbhiPrasad

and it gets even more complicated with bundling

@AbhiPrasad is this specifically when bundling to an ESM output, or even when bundling ESM -> CJS? I'm asking as I just tried updating my companies repo to Sentry v8, and although we are still bundling and having our GCP functions run in CJS "mode", we are unable to use the new @sentry/google-cloud-serverless library as our code is authored in ESM (I guess there might be some TS config hacks to work around this, but this isn't something we are willing to do).

I understand wanting to avoid supporting ESM imports to prevent people from thinking this works when executing via ESM - I presume that's the main problem, but just wanting to know the full picture if possible!

Also, is there an ETA (or at least a plan) for supporting ESM? Just wondering what priority this is at internally at Sentry!

joealden avatar May 19 '24 14:05 joealden

we are unable to use the new @sentry/google-cloud-serverless library as our code is authored in ESM

The code we ship in our @sentry/google-cloud-serverless package is CJS only at the moment: https://unpkg.com/browse/@sentry/[email protected]/package.json (although ironically, we also ship ESM code but don't provide an entry point for it)

Is the ask here to also provide an ESM (import) entry point at the moment? I recall we had a similar issue in our AWS package. I'm gonna tag @AbhiPrasad who has more context here - can we do this now or are we still blocked on something?

Lms24 avatar May 21 '24 08:05 Lms24

can we do this now or are we still blocked on something?

We can do this, but add the caveat that performance instrumentation is only supported for CJS. I can make the change!

AbhiPrasad avatar May 21 '24 18:05 AbhiPrasad