getsentry / sentry-javascript-bundler-plugins

JavaScript Bundler Plugins for Sentry
https://sentry.io
BSD 3-Clause "New" or "Revised" License
141 stars 36 forks source link

tsup - _sentry-debug-id-injection-stub #616

Closed ex0ns closed 1 month ago

ex0ns commented 1 month ago

Environment

@sentry/esbuild-plugin: 2.22.4 tsup: 8.3.0

Steps to Reproduce

  1. clone https://github.com/ex0ns/sentry-tsup (or look at the dist/ folder)
  2. pnpm install && pnpm tsup-node src/index.ts
  3. node dist/index.mjs

Expected Result

Running the application with Sentry enabled.

Actual Result

node:internal/modules/esm/resolve:842
  throw new ERR_MODULE_NOT_FOUND(packageName, fileURLToPath(base), null);
        ^

Error [ERR_MODULE_NOT_FOUND]: Cannot find package '_sentry-debug-id-injection-stub' imported from /Users/guillaume/Projects/magemetrics/experiments/tsup-sentry/my-app/dist/index.mjs
    at packageResolve (node:internal/modules/esm/resolve:842:9)
    at moduleResolve (node:internal/modules/esm/resolve:915:18)
    at defaultResolve (node:internal/modules/esm/resolve:1132:11)
    at ModuleLoader.defaultResolve (node:internal/modules/esm/loader:557:12)
    at ModuleLoader.resolve (node:internal/modules/esm/loader:526:25)
    at ModuleLoader.getModuleJob (node:internal/modules/esm/loader:249:38)
    at ModuleJob._link (node:internal/modules/esm/module_job:126:49) {
  code: 'ERR_MODULE_NOT_FOUND'
}

Analysis

When looking at the file in the dist folder it is indeed starting with this strange import:

// src/index.ts?sentryProxyModule=true
import "_sentry-debug-id-injection-stub";

Which lead me to this part of the plugin:

https://github.com/getsentry/sentry-javascript-bundler-plugins/blob/75a5d1debb8793a572ab495361b613138b452bb2/packages/esbuild-plugin/src/index.ts#L45

But I have to say that I'm a bit confused about its purpose, and I can't find any documentation regarding this, I must do something wrong. I have create a repo to reproduce that: https://github.com/ex0ns/sentry-tsup (i uploaded the output in the dist folder).

I could try to work on a fix or at least provide more information on this issue, but I don't know what would be the easiest way to test or at least debug that, any pointer welcome !

I think this is related to #608 #445

lforst commented 1 month ago

Thanks for the report. I'll close this in favor of an earlier issue this week https://github.com/getsentry/sentry-javascript-bundler-plugins/issues/614

ex0ns commented 1 month ago

oh i missed this one, found two other related issue, thanks for pointing it out.