Title: [v9] Drop polyfills from build output · Issue #8795 · getsentry/sentry-javascript · GitHub
Open Graph Title: [v9] Drop polyfills from build output · Issue #8795 · getsentry/sentry-javascript
X Title: [v9] Drop polyfills from build output · Issue #8795 · getsentry/sentry-javascript
Description: Currently, we include a few polyfills in our build: _asyncNullishCoalesce _asyncOptionalChain _asyncOptionalChainDelete _createNamedExportFrom _createStarExport _interopDefault _interopNamespace _interopNamespaceDefaultOnly _interopRequi...
Open Graph Description: Currently, we include a few polyfills in our build: _asyncNullishCoalesce _asyncOptionalChain _asyncOptionalChainDelete _createNamedExportFrom _createStarExport _interopDefault _interopNamespace _i...
X Description: Currently, we include a few polyfills in our build: _asyncNullishCoalesce _asyncOptionalChain _asyncOptionalChainDelete _createNamedExportFrom _createStarExport _interopDefault _interopNamespace _i...
Opengraph URL: https://github.com/getsentry/sentry-javascript/issues/8795
X: @github
Domain: github.com
IPv4 address: 140.82.112.3
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"[v9] Drop polyfills from build output","articleBody":"Currently, we include a few polyfills in our build:\r\n\r\n```\r\n_asyncNullishCoalesce\r\n_asyncOptionalChain\r\n_asyncOptionalChainDelete\r\n_createNamedExportFrom\r\n_createStarExport\r\n_interopDefault\r\n_interopNamespace\r\n_interopNamespaceDefaultOnly\r\n_interopRequireDefault\r\n_interopRequireWildcard\r\n_nullishCoalesce\r\n_optionalChain\r\n_optionalChainDelete\r\n```\r\n\r\nThese are a bit tricky, increase complexity and build size.\r\n\r\nThese can be split into two categories:\r\n\r\n1. nullish coalesce & optional chaining polyfills\r\n2. Bundler-related polyfills\r\n\r\nThe first category is actually disallowed by eslint rules, as the polyfills increase bundle size considerably when used. We do not use any nullish coalesce/optional chaining in all core/browser SDKs, only in node & nextjs.\r\n\r\nI propose to remove these polyfills in v8, if we decide to bump the min. Node version to 14+. Node 14 supports both [nullish coalescing](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Nullish_coalescing#browser_compatibility) as well as [optional chaining](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Optional_chaining#browser_compatibility).\r\n\r\nI propose to leave the eslint rules for core/browser SDKs in place, but simply rely on them to ensure we don't use them outside of node context. We also have tests covering that the ES5 CDN bundles are valid ES5, which should cover any regressions there. This allows us to get rid of these polyfills:\r\n\r\n```\r\n_asyncNullishCoalesce\r\n_asyncOptionalChain\r\n_asyncOptionalChainDelete\r\n_nullishCoalesce\r\n_optionalChain\r\n_optionalChainDelete\r\n```\r\n\r\nThe other category of polyfills:\r\n\r\n```\r\n_createNamedExportFrom\r\n_createStarExport\r\n_interopDefault\r\n_interopNamespace\r\n_interopNamespaceDefaultOnly\r\n_interopRequireDefault\r\n_interopRequireWildcard\r\n```\r\n\r\nI propose we investigate if we can solve this with rollup instead.\r\n\r\n## Benefits of dropping the polyfills\r\n\r\n* Reduced complexity in our codebase & build\r\n* No need to have non-canonical exports (currently polyfills are imported directly from e.g. `@sentry/utils/esm/buildPolyfills/index.js` which is not ideal)\r\n* Reduced bundle size/increased performance for platforms that _do_ support these (e.g. newer node) - can use native instead of polyfilled code\r\n* Browser/core packages already don't use these features, so no migration work necessary there","author":{"url":"https://github.com/mydea","@type":"Person","name":"mydea"},"datePublished":"2023-08-11T07:22:39Z","url":"https://github.com/getsentry/sentry-javascript/issues/8795"}
| 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:73eb70cd-c6ac-6351-895f-9badf9019987 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | B920:FC8AF:36B36:495BB:6B04A2F0 |
| html-safe-nonce | 753bd1c79c9eac4a95960aa46697f91b23fbe673f7585652a15167c7a9e0ac91 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCOTIwOkZDOEFGOjM2QjM2OjQ5NUJCOjZCMDRBMkYwIiwidmlzaXRvcl9pZCI6IjMwMzcwMzI1ODg2NzA5Njg1NjAiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | e169282a7ab12786af6daa0b83b616503b0214eae35305dc94073c39b1ac1a11 |
| hovercard-subject-tag | issue:1846331095 |
| 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/8795/issue_layout |
| twitter:image | https://opengraph.githubassets.com/04df99e08ea8e903be2ee75d54d88db34b2b753777c15b257adb7daddc317d97/getsentry/sentry-javascript/issues/8795 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/04df99e08ea8e903be2ee75d54d88db34b2b753777c15b257adb7daddc317d97/getsentry/sentry-javascript/issues/8795 |
| og:image:alt | Currently, we include a few polyfills in our build: _asyncNullishCoalesce _asyncOptionalChain _asyncOptionalChainDelete _createNamedExportFrom _createStarExport _interopDefault _interopNamespace _i... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | mydea |
| hostname | github.com |
| expected-hostname | github.com |
| None | 9784b6f42e2d5eac4e394fa88cad134c0dc5b6662b4ff2787a1ed1ef5a96331d |
| 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 | 3fd14143b75b2af7b76bbd23b069867d091adfcc |
| 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