Skip to content

fix(esbuild): avoid warnings for entries without a default export - #26123

Closed
adityareddy-dev wants to merge 1 commit into
getsentry:developfrom
adityareddy-dev:fix/esbuild-missing-default-export
Closed

adityareddy-dev wants to merge 1 commit into
getsentry:developfrom
adityareddy-dev:fix/esbuild-missing-default-export

Conversation

@adityareddy-dev

Copy link
Copy Markdown
Contributor

Why: The debug ID wrapper warns when an entry has no default export. I gave the wrapper a virtual dependency path so esbuild lowers that warning, while keeping static default access so downstream builds can remove unused exports. Maintainer go-ahead.

How to review: Start with the wrapper path in src/esbuild/index.ts, then test/esbuild/entry-exports.test.ts, both under packages/bundler-plugins.

Unsure about: This relies on esbuild's handling of dependency diagnostics. The wrapper's identity also changes in source maps and metadata, though the real entry keeps its path.

Closes #25885

@adityareddy-dev
adityareddy-dev requested review from a team as code owners November 5, 2026 11:15
@adityareddy-dev
adityareddy-dev requested review from Lms24, andreiborza, logaretm, mydea and s1gr1d and removed request for a team November 5, 2026 11:15
@github-actions github-actions Bot added the external PR from an external contributor label Nov 5, 2026

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Want reviews to match your repository better? Bugbot Learning can learn team-specific rules from PR activity. A team admin can enable Learning in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 5e08cb3. Configure here.

'esbuild-plugin',
path.basename(resolvedPath),
),
namespace: 'sentry-debug-id-proxy',

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Proxy namespace missing onLoad handler

High Severity

The debug ID wrapper is now resolved into the sentry-debug-id-proxy namespace, but the loader that emits that wrapper still listens on the default file namespace. esbuild will not load the proxy, so debug ID injection fails and the build errors when sourcemaps are enabled.

Additional Locations (1)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 5e08cb3. Configure here.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

onLoad({ filter: /.*/ }) has no namespace filter, so it handles sentry-debug-id-proxy too. esbuild only restricts the callback when a namespace is provided (docs).

@chargome

chargome commented Nov 5, 2026

Copy link
Copy Markdown
Member

Thanks for looking into this! Unfortunately moving the proxy into its own namespace with a fake node_modules path is visible to other plugins: onResolve hooks scoped to namespace: 'file' stop seeing the entry, plugins that skip node_modules importers skip the user's entry, and the absolute path ends up in source maps and the metafile. It also depends on an undocumented esbuild heuristic.

We went with a narrower fix in #26132 that sets logOverride['import-is-undefined'] instead. Closing this in favour of that, appreciate the investigation.

@chargome chargome closed this Nov 5, 2026
chargome added a commit that referenced this pull request Nov 5, 2026
… default export (#26132)

**Why:** The debug ID proxy statically re-exports the entry's default
export so downstream bundlers can tree-shake, which makes esbuild warn
with `import-is-undefined` whenever an entry has no default export.
esbuild can't suppress a diagnostic per file, so the plugin sets
`logOverride['import-is-undefined'] = 'silent'` in `initialOptions`,
same as it already forces `metafile`. The proxy's path, suffix and
namespace stay as they are, so other plugins, source maps and the
metafile are unaffected.

Tradeoff: this silences the warning for the whole build. A user-provided
`logOverride` for that id wins, so it can be turned back on.

Supersedes #26123, which relied on an undocumented esbuild heuristic and
changed the proxy's namespace and path in ways other plugins observe.

**How to review:** Four lines in
`packages/bundler-plugins/src/esbuild/index.ts`, plus
`test/esbuild/entry-without-default-export.test.ts`.

Closes #25885

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com>
43081j pushed a commit to 43081j/sentry-javascript that referenced this pull request Nov 9, 2026
… default export (getsentry#26132)

**Why:** The debug ID proxy statically re-exports the entry's default
export so downstream bundlers can tree-shake, which makes esbuild warn
with `import-is-undefined` whenever an entry has no default export.
esbuild can't suppress a diagnostic per file, so the plugin sets
`logOverride['import-is-undefined'] = 'silent'` in `initialOptions`,
same as it already forces `metafile`. The proxy's path, suffix and
namespace stay as they are, so other plugins, source maps and the
metafile are unaffected.

Tradeoff: this silences the warning for the whole build. A user-provided
`logOverride` for that id wins, so it can be turned back on.

Supersedes getsentry#26123, which relied on an undocumented esbuild heuristic and
changed the proxy's namespace and path in ways other plugins observe.

**How to review:** Four lines in
`packages/bundler-plugins/src/esbuild/index.ts`, plus
`test/esbuild/entry-without-default-export.test.ts`.

Closes getsentry#25885

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

external PR from an external contributor

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Esbuild: plugin throws a warning when the entry point doesn't have a default export

2 participants