Sentry esbuild plugin
- Dominant language
- TypeScript
- Stars
- 11.3k
- Forks
- 275
- PR merge metrics
- No merged PRs in 30d
Description
Hello
I'm trying to get Sentry's esbuild plugin to work in my setup and I'm struggling to make this work with tsup.
My config is very simple
```ts
export default defineConfig({
entry: ["src/nodeServer.ts"],
esbuildPlugins: [
sentryEsbuildPlugin({
org: "org",
project: "backend",
authToken: process.env.SENTRY_AUTH_TOKEN,
telemetry: false,
debug: true,
sourcemaps: {
assets: "./dist/*",
},
}),
],
format: ["esm"],
// https://github.com/getsentry/sentry-javascript-bundler-plugins/issues/614
noExternal: ["_sentry-debug-id-injection-stub"],
env: {
NODE_ENV: "production",
},
dts: false,
splitting: false,
sourcemap: true,
clean: true,
});
```
I have investigated a bit the issue and summarized everything in this post: https://github.com/getsentry/sentry-javascript-bundler-plugins/issues/614#issuecomment-2388327952. I would like to propose a solution but I'm looking for some pointer on where to start and what would be the recommended way of doing this.
My guess is that whenever this plugin's callback is called https://github.com/getsentry/sentry-javascript-bundler-plugins/blob/bd3e31f598f5badaccf011f701d94bbb9e6b6b31/packages/esbuild-plugin/src/index.ts#L232 it then call the common (i.e plugin independent) core function of the plugin, which is looking for file on disk (https://github.com/getsentry/sentry-javascript-bundler-plugins/blob/2.22.5/packages/bundler-plugin-core/src/debug-id-upload.ts#L93). However it seems that whenever we are running the esbuild plugin through tsup, those file are not written on disk yet, and the result of the `glob` function is always empty.
What would be to correct approach to fix that for tsup ? I would try to stick as close as possible to the esbuild plugin but if not possible I could even rewrite the part of the plugins that do not behave correctly with tsup.
Thanks !
Contributor guide
Research direction
Reproduce the configuration in the issue, then inspect packages/esbuild-plugin/src/index.ts around the callback at line 232 and packages/bundler-plugin-core/src/debug-id-upload.ts around line 93. Compare the callback timing with tsup's output and the glob results; done means the Sentry esbuild plugin can find and upload the generated sourcemaps when used through tsup.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- build-system, tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100