fides-js: Reduce bundle size by removing dependencies and trimming locale data#8142
Open
eastandwestwind wants to merge 6 commits intomainfrom
Open
fides-js: Reduce bundle size by removing dependencies and trimming locale data#8142eastandwestwind wants to merge 6 commits intomainfrom
eastandwestwind wants to merge 6 commits intomainfrom
Conversation
Contributor
|
The latest updates on your projects. Learn more about Vercel for GitHub. 2 Skipped Deployments
|
de3c376 to
11a80ce
Compare
Dependency Review✅ No vulnerabilities found.Snapshot WarningsEnsure that dependencies are being submitted on PR branches and consider enabling retry-on-snapshot-warnings. See the documentation for more information and troubleshooting advice. Scanned Files
|
eastandwestwind
added a commit
that referenced
this pull request
May 8, 2026
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…ale data - Replace `base-64` npm package with native `btoa`/`atob` (already used elsewhere in the same file for newer compression helpers) - Replace `uuid` npm package with native `crypto.randomUUID()` (the uuid package itself already delegates to this when available) - Trim static i18n locale bundles to English-only: removes 41 non-English locale JSON imports (~27KB base, ~99KB TCF). The experience API provides all translations at runtime; static messages only serve as GPC text fallbacks, which already fall back to English when a locale is missing. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
TCF static messages contain UI labels (tab names like "Purposes", "Features", "Vendors", radio buttons like "Consent", "Legitimate interest", table headers, etc.) that are not provided by the experience API. Unlike the base GPC-only static messages, these have no alternative translation source and must remain bundled for all 42 locales. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
c91f95d to
29e11ca
Compare
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
The privacy-center tests import fides-js which now uses crypto.randomUUID() at module load time. The CI Jest/jsdom environment doesn't provide this API, so reuse the fides-js setup file to polyfill it. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Unticketed
Description Of Changes
Reduces the fides-js bundle size through three low-risk optimizations:
Remove
base-64dependency — replaced with nativebtoa/atob, which are already used elsewhere in the same file (cookie.ts) for newer compression helpers. Thebase-64package was CJS-only with no tree-shaking.Remove
uuiddependency — replaced with nativecrypto.randomUUID(). Theuuidpackage itself already delegates tocrypto.randomUUID()when available, making the fallback code dead weight on all modern browsers.Trim base i18n locale bundles to English-only — removes 41 non-English locale JSON imports (~27KB) for the base static messages. The experience API already provides all translations at runtime. The static messages only serve as GPC text fallbacks, and the existing code already falls back to English when a locale-specific static file is missing (
STATIC_MESSAGES[locale] ?? STATIC_MESSAGES[DEFAULT_LOCALE]). Note: TCF locale bundles are intentionally kept — their static messages contain UI chrome labels (tab names, radio buttons, table headers) that have no API fallback.Gzipped Size (what users download)
mainoptimizedfides.jsfides-tcf.jsfides-headless.jsCode Changes
src/lib/cookie.ts: Replacedbase-64imports with nativebtoa/atob, replaceduuidwithcrypto.randomUUID()src/lib/hooks/useUUID4.ts: Replaceduuidwithcrypto.randomUUID()src/lib/fides-lifecycle-manager.ts: Replaceduuidwithcrypto.randomUUID()src/lib/i18n/locales/index.ts: Removed 41 non-English locale JSON imports, keptLOCALE_LANGUAGE_MAPintactsrc/lib/i18n/i18n-utils.ts: Added null guard forPartial<Record>type change inloadMessagesFromFilespackage.json: Removedbase-64,@types/base-64,uuid,@types/uuidjest.config.js: Added setup file forcrypto.randomUUIDpolyfill in jsdom__tests__/setup.ts: New — polyfillscrypto.randomUUIDfor jsdom test environmentuuid/base-64mocksSteps to Confirm
npm testinclients/fides-js— all 599 tests should passnpm run typecheck— should pass with no errorsnpm run build— verify bundle sizes are within limits (should be smaller)Pre-Merge Checklist
CHANGELOG.mdupdated