Skip to content

fix(build): Do not reference const in object#457

Merged
Lms24 merged 1 commit into
mainfrom
jp/tree-shake-esbuild
Jun 30, 2026
Merged

fix(build): Do not reference const in object#457
Lms24 merged 1 commit into
mainfrom
jp/tree-shake-esbuild

Conversation

@JPeer264

Copy link
Copy Markdown
Member

Description

The only thing which changes is the way how the constants are used within an object:

export const ATTRIBUTE_TYPE: Record<string, AttributeType> = {
-  [AI_CITATIONS]: 'string[]',
+  'ai.citations': 'string[]',
};

When having following code ESBuild is not able to tree-shake ATTRIBUTE_TYPE:

import { ANY_CONSTANT } from '@sentry/conventions';

console.log(ANY_CONSTANT);

When removing the references in the objects ESBuild is now able to tree-shake ATTRIBUTE_TYPE, as the constants are not referenced anymore 🤷

seems like this is the reason: evanw/esbuild#4373

PR Checklist

  • I have run yarn test and verified that the tests pass.
  • I have run yarn generate to generate and format code and docs.

If an attribute was added:

  • The attribute is in a namespace (e.g. nextjs.function_id, not function_id)
  • I have used the correct value for apply_scrubbing (i.e. manual or auto. Use never only for values that should never be scrubbed such as IDs)

If an attribute was deprecated:

@JPeer264 JPeer264 self-assigned this Jun 30, 2026
@JPeer264
JPeer264 requested review from a team, Lms24, cleptric, mjq and nsdeschenes as code owners June 30, 2026 12:03
@github-actions

github-actions Bot commented Jun 30, 2026

Copy link
Copy Markdown

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).


New Features ✨

  • (attributes) Add sentry.status and sentry.trace.status by mjq in #453

Bug Fixes 🐛

  • (build) Do not reference const in object by JPeer264 in #457

🤖 This preview updates automatically when you update the PR.

@JPeer264
JPeer264 force-pushed the jp/tree-shake-esbuild branch from e41fa94 to 764580a Compare June 30, 2026 12:06

@Lms24 Lms24 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks for looking into and fixing this!

(I'm gonna cut a conventions release after we merge this so that we can properly use the package in the JS SDK)

@Lms24
Lms24 merged commit fdc5831 into main Jun 30, 2026
17 checks passed
@Lms24
Lms24 deleted the jp/tree-shake-esbuild branch June 30, 2026 12:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants