Skip to content

Conversation

@lobsterkatie
Copy link
Member

@lobsterkatie lobsterkatie commented Mar 11, 2022

Currently, the array ['log', 'info', 'warn', 'error', 'debug', 'assert'] appears three times in our code, and because it's an array of strings, it's can't be minified. This PR uses a constant in its place, for a small bundle size win.

Ref: https://getsentry.atlassian.net/browse/WEB-697

@github-actions
Copy link
Contributor

size-limit report

Path Base Size (af7081c) Current Size Change
@sentry/browser - ES5 CDN Bundle (gzipped + minified) 19.37 KB 19.37 KB -0.01% 🔽
@sentry/browser - ES5 CDN Bundle (minified) 61.92 KB 61.88 KB -0.06% 🔽
@sentry/browser - ES6 CDN Bundle (gzipped + minified) 18.04 KB 18.04 KB +0.01% 🔺
@sentry/browser - ES6 CDN Bundle (minified) 55.32 KB 55.29 KB -0.06% 🔽
@sentry/browser - Webpack (gzipped + minified) 22.3 KB 22.3 KB +0.03% 🔺
@sentry/browser - Webpack (minified) 76.58 KB 76.55 KB -0.04% 🔽
@sentry/react - Webpack (gzipped + minified) 22.33 KB 22.33 KB +0.03% 🔺
@sentry/nextjs Client - Webpack (gzipped + minified) 46.56 KB 46.54 KB -0.04% 🔽
@sentry/browser + @sentry/tracing - ES5 CDN Bundle (gzipped + minified) 25.25 KB 25.25 KB 0%
@sentry/browser + @sentry/tracing - ES6 CDN Bundle (gzipped + minified) 23.65 KB 23.66 KB +0.02% 🔺

Copy link
Member

@AbhiPrasad AbhiPrasad left a comment

Choose a reason for hiding this comment

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

Good change!

The reason it has weird results with gzip is because of compression algo preferring repetition, but this is cleaner.

Copy link
Member

@Lms24 Lms24 left a comment

Choose a reason for hiding this comment

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

Good change!

@lobsterkatie lobsterkatie merged commit e788c9e into master Mar 14, 2022
@lobsterkatie lobsterkatie deleted the kmclb-use-const-array-for-log-levels branch March 14, 2022 20:00
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.

5 participants