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

fix(esbuild): Avoid warning when entry point has no default export

Open queelius opened this issue 8 months ago • 2 comments

Summary

Fixes #747

When using @sentry/esbuild-plugin with an entry point that has no default export (common for Express.js apps), the plugin's debug ID proxy module generates:

export default OriginalModule.default;

This causes esbuild (0.25+) to emit:

▲ [WARNING] Import "default" will always be undefined because there is no matching export in "index.ts" [import-is-undefined]

The fix wraps the default export access in a function call, which prevents esbuild's static analysis from detecting the potentially missing .default property while still correctly forwarding it when present:

var _sentry_default_export = (function(m) { return m.default; })(_sentry_original_module);
export { _sentry_default_export as default };

Test plan

  • [x] Added unit tests covering: no default export (no warning), with default export (preserved), named-only exports (preserved)
  • [x] All existing unit tests pass (vitest run in packages/esbuild-plugin)
  • [x] All 86 integration tests pass (yarn test in packages/integration-tests)
  • [x] Lint passes clean (eslint ./src ./test)
  • [x] Manually verified fix eliminates the warning with esbuild 0.25.5 (version from issue report)

🤖 Generated with Claude Code

queelius avatar Mar 25 '26 07:03 queelius

Semver Impact of This PR

🟢 Patch (bug fixes)

📋 Changelog Preview

This is how your changes will appear in the changelog. Entries from this PR are highlighted with a left border (blockquote style).


Bug Fixes 🐛

  • (esbuild) Avoid warning when entry point has no default export by queelius in #901

Internal Changes 🔧

  • Add additional integration tests by timfish in #914
  • Remove unused e2e tests by timfish in #915

🤖 This preview updates automatically when you update the PR.

github-actions[bot] avatar Mar 25 '26 17:03 github-actions[bot]

I have concerns about the side-effects this adds to every bundle

timfish avatar May 04 '26 09:05 timfish