fix(esbuild): Avoid warning when entry point has no default export
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 runinpackages/esbuild-plugin) - [x] All 86 integration tests pass (
yarn testinpackages/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
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.
I have concerns about the side-effects this adds to every bundle