getsentry / getsentry/sentry-javascript

Move bundler flags to specifically named files to increase bundler plugin perf.

Offen
#17,048 3 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen
Browser Improvement
Vorherrschende Sprache
TypeScript
Sterne
8.7k
Forks
1.8k
Ø Merge
1 T. 17 Std.
Gemergte PRs (30 T.)
523

Beschreibung

### Description

In the bundler plugins we use a range of feature flags that we replace at bundle time so that certain large features can be stripped during minification and don't end up in users bundles if they're not using them:

```ts
export interface SentrySDKBuildFlags {
__SENTRY_DEBUG__?: boolean;
__SENTRY_TRACING__?: boolean;
__RRWEB_EXCLUDE_CANVAS__?: boolean;
__RRWEB_EXCLUDE_IFRAME__?: boolean;
__RRWEB_EXCLUDE_SHADOW_DOM__?: boolean;
__SENTRY_EXCLUDE_REPLAY_WORKER__?: boolean;
}
```
To replace these we currently need to find and replace in **every** file that runs through the bundler. This can potentially be tens of thousands of files.

`__SENTRY_DEBUG__` almost always ends up in a file called `debug-build.js` and we can use this knowledge to only try and find and replace in those specific files.

Rather than have these globals everywhere, we should move these to consts in files with a specific filename so that we can be more selective in the bundler plugins. This could impact bundler performance significantly.

Beitragsleitfaden

Beitragsleitfaden öffnen

Bewertung

Dieses Issue wurde noch nicht bewertet.

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.