fix(bundler-plugins): Integration with monorepo build#21479
Conversation
|
If CI passes, this can be landed after the |
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 2 potential issues.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit d665aad. Configure here.
size-limit report 📦
|
8e03cf7 to
18f6ebe
Compare
9d21d6b to
a8f4623
Compare
Update the bundler-plugins so that integration tests run in CI, and the module follows the same patterns as the rest of sentry-javascript.
a8f4623 to
b1938e8
Compare
| // keeps the per-submodule file layout the `exports` map points at. | ||
| exports: 'named', | ||
| // The source default-imports CJS Node builtins (e.g. `import crypto from 'crypto'`). | ||
| // The shared base config's `interop: 'esModule'` would emit `require('crypto').default` | ||
| // in the CJS build (undefined for real CJS modules -> runtime crash). `auto` emits the | ||
| // interop helper so default-imported CJS builtins resolve correctly. | ||
| interop: 'auto', | ||
| }, | ||
| }, | ||
| }), | ||
| ); |
There was a problem hiding this comment.
Bug: The webpack loader fallback incorrectly seeks a .mjs file in ESM contexts, but the build now outputs .js, causing crashes in non-packaged environments.
Severity: MEDIUM
Suggested Fix
Update the fallback logic to resolve to component-annotation-transform.js in both CJS and ESM contexts. This will align the fallback mechanism with the actual file names generated by the new Rollup build process, ensuring the loader can be found in non-packaged scenarios.
Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent. Verify if this is a real issue. If it is, propose a fix; if not, explain why it's
not valid.
Location: packages/bundler-plugins/rollup.npm.config.mjs#L1-L29
Potential issue: The fallback logic for the webpack plugin's component annotation loader
is incorrect. In an ESM context, where `__dirname` is undefined, the code attempts to
resolve a file with an `.mjs` extension. However, the new Rollup build configuration
outputs `.js` files for both CJS and ESM formats. This discrepancy will cause a runtime
crash when the plugin is used in a non-packaged environment (e.g., via `yarn link` or
direct monorepo consumption), as the primary module resolution will fail, and the
incorrect fallback path will be used.
Did we get this right? 👍 / 👎 to inform future reviews.

Update the bundler-plugins so that integration tests run in CI, and the module follows the same patterns as the rest of sentry-javascript.