Title: Make sure field initializers don't add bundle size · Issue #5316 · getsentry/sentry-javascript · GitHub
Open Graph Title: Make sure field initializers don't add bundle size · Issue #5316 · getsentry/sentry-javascript
X Title: Make sure field initializers don't add bundle size · Issue #5316 · getsentry/sentry-javascript
Description: Problem Statement When using field initializers with typescript, our bundling process does something like so: constructor() { At.prototype.__init.call(this), At.prototype.__init2.call(this), At.prototype.__init3.call(this), At.prototype....
Open Graph Description: Problem Statement When using field initializers with typescript, our bundling process does something like so: constructor() { At.prototype.__init.call(this), At.prototype.__init2.call(this), At.pro...
X Description: Problem Statement When using field initializers with typescript, our bundling process does something like so: constructor() { At.prototype.__init.call(this), At.prototype.__init2.call(this), At.pro...
Opengraph URL: https://github.com/getsentry/sentry-javascript/issues/5316
X: @github
Domain: github.com
IPv4 address: 140.82.114.4
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Make sure field initializers don't add bundle size","articleBody":"### Problem Statement\n\nWhen using field initializers with typescript, our bundling process does something like so:\r\n\r\n```js\r\nconstructor() {\r\n At.prototype.__init.call(this), At.prototype.__init2.call(this), At.prototype.__init3.call(this), At.prototype.__init4.call(this), At.prototype.__init5.call(this), At.prototype.__init6.call(this), At.prototype.__init7.call(this), At.prototype.__init8.call(this), At.prototype.__init9.call(this), At.prototype.__init10.call(this)\r\n}\r\n__init() {\r\n this.m = !1\r\n}\r\n__init2() {\r\n this.g = []\r\n}\r\n__init3() {\r\n this._ = []\r\n}\r\n__init4() {\r\n this.S = []\r\n}\r\n__init5() {\r\n this.k = {}\r\n}\r\n__init6() {\r\n this.O = {}\r\n}\r\n__init7() {\r\n this.j = {}\r\n}\r\n__init8() {\r\n this.T = {}\r\n}\r\n__init9() {\r\n this.D = []\r\n}\r\n__init10() {\r\n this.R = {}\r\n}\r\n```\r\n\r\nEach `__initX()` call is generated from a field initializer of a class. This is a bunch of extra bytes. See an example here: https://sucrase.io/#selectedTransforms=typescript,imports&code=class%20Scope%20%7B%0A%20%20public%20a%20%3D%203%3B%0A%7D.\r\n\r\nThis is done to best match TS behaviour. See https://www.typescriptlang.org/docs/handbook/release-notes/typescript-3-7.html#the-usedefineforclassfields-flag-and-the-declare-property-modifier for more details. \r\n\r\n\n\n### Solution Brainstorm\n\nEvidence: https://github.com/getsentry/sentry-javascript/pull/5306\r\n\r\nIn the mean time, I think avoiding usage of field initializers in favour of initializing the field in a constructor is the best course of action to reduce bundle size.","author":{"url":"https://github.com/AbhiPrasad","@type":"Person","name":"AbhiPrasad"},"datePublished":"2022-06-24T19:39:00Z","url":"https://github.com/getsentry/sentry-javascript/issues/5316"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:a187d94b-ff73-b047-1c82-8bce7f5ced33 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | B2E2:90D70:14EC5AD:1B772B2:6B040992 |
| html-safe-nonce | f638002ecc57d9fb1d8426d6d4a27bbb21d10104e16b5b92775a72d7a6dfdac5 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCMkUyOjkwRDcwOjE0RUM1QUQ6MUI3NzJCMjo2QjA0MDk5MiIsInZpc2l0b3JfaWQiOiIyNzUwMzExMTIwNDI5NjQ4Mjc0IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | 19f7721764d984c536ede95c84b92669b25c08accc0a50530b63652819c76824 |
| hovercard-subject-tag | issue:1284121935 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/getsentry/sentry-javascript/5316/issue_layout |
| twitter:image | https://opengraph.githubassets.com/5e6f71c417d66caa79f39588a409aa9c1fbd098b447d54b4ab754388f5b0222e/getsentry/sentry-javascript/issues/5316 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/5e6f71c417d66caa79f39588a409aa9c1fbd098b447d54b4ab754388f5b0222e/getsentry/sentry-javascript/issues/5316 |
| og:image:alt | Problem Statement When using field initializers with typescript, our bundling process does something like so: constructor() { At.prototype.__init.call(this), At.prototype.__init2.call(this), At.pro... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | AbhiPrasad |
| hostname | github.com |
| expected-hostname | github.com |
| None | 87e774ee7c6b3bee0490394e4d3e57ec9dbc956f74b87ea685dc8996c1676456 |
| turbo-cache-control | no-preview |
| go-import | github.com/getsentry/sentry-javascript git https://github.com/getsentry/sentry-javascript.git |
| octolytics-dimension-user_id | 1396951 |
| octolytics-dimension-user_login | getsentry |
| octolytics-dimension-repository_id | 3328572 |
| octolytics-dimension-repository_nwo | getsentry/sentry-javascript |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 3328572 |
| octolytics-dimension-repository_network_root_nwo | getsentry/sentry-javascript |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 423dbb54c5e7bfecc838eb387c1435eb3d0e760d |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
| Server | github.com |
| Content-Type | text/html; charset=utf-8 |
| Cache-Control | max-age=0, private, must-revalidate |
Viewport: width=device-width