Skip to content

perf(settings): embed the l10n asset map in index.html - #21060

Open
vbudhram wants to merge 1 commit into
mainfrom
fxa-11871
Open

perf(settings): embed the l10n asset map in index.html#21060
vbudhram wants to merge 1 commit into
mainfrom
fxa-11871

Conversation

@vbudhram

@vbudhram vbudhram commented Aug 18, 2026

Copy link
Copy Markdown
Contributor

Because

  • The guard in readL10nHashedMappings accepted any non-null object with at least one key. A JSON array got through, and so did an object whose values were empty strings or nested objects.
  • fetchMessages then treated that map as real. Every lookup missed, each bundle came back empty, and the page ended up with no l10n resources at all rather than the unhashed-path fallback the comment promises.
  • The warning did not fire either, so nothing said why the strings were missing.

This pull request

  • Rejects arrays and requires every mapped value to be a non-empty string. Anything else falls through to the warning that is already there and returns undefined.
  • Adds three rows to the fallback table in AppLocalizationProvider.test.tsx: an array, an empty string value, and a non-string value. I reverted the guard and re-ran to check that all three fail without it.

Issue that this pull request solves

Closes: https://mozilla-hub.atlassian.net/browse/FXA-11871

Checklist

Put an x in the boxes that apply

  • My commit is GPG signed.
  • If applicable, I have modified or added tests which pass locally.
  • I have added necessary documentation (if appropriate).
  • I have verified that my changes render correctly in RTL (if appropriate).
  • I have manually reviewed all AI generated code.

How to review (Optional)

  • Key files/areas to focus on: the guard in packages/fxa-react/lib/AppLocalizationProvider.tsx and the three new rows in its spec.
  • Suggested review order: the source change first, then the test rows.
  • Risky or complex parts: a map that is valid today is still returned as it was, and every newly rejected shape takes the path an absent map already took.

Screenshots (Optional)

Other information (Optional)

fetchMessages, fetchAllMessages, and createFluentBundleGenerator are untouched. A per-path fallback instead of a per-map one is a different design and is not in this change.

@vbudhram
vbudhram requested a review from a team as a code owner August 18, 2026 23:50
@vbudhram vbudhram added the auto label Aug 18, 2026
Copilot AI balanced review requested due to automatic review settings August 18, 2026 23:50

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Embeds hashed localization paths in Settings HTML, removing a blocking manifest request and stale-CDN risk.

Changes:

  • Generates and embeds a filtered localization asset map.
  • Reads the map with graceful fallback behavior.
  • Updates Nx cache dependencies and localization tests.

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
packages/fxa-settings/scripts/start.js Embeds the map during development.
packages/fxa-settings/scripts/l10n-asset-map.js Filters and encodes manifest mappings.
packages/fxa-settings/scripts/build.js Embeds the map during builds.
packages/fxa-settings/public/index.html Adds the asset-map meta tag.
packages/fxa-settings/package.json Makes build caching manifest-aware.
packages/fxa-react/lib/AppLocalizationProvider.tsx Replaces manifest fetching with meta-tag parsing.
packages/fxa-react/lib/AppLocalizationProvider.test.tsx Tests mapped paths and fallback behavior.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment on lines +84 to +90
if (
typeof mappings === 'object' &&
mappings !== null &&
Object.keys(mappings).length > 0
) {
return mappings;
}
@chenba chenba removed their assignment Aug 19, 2026
## Because

- The guard in `readL10nHashedMappings` accepted any non-null object with at least one key. A JSON array got through, and so did an object whose values were empty strings or nested objects.
- `fetchMessages` then treated that map as real. Every lookup missed, each bundle came back empty, and the page ended up with no l10n resources at all rather than the unhashed-path fallback the comment promises.
- The warning did not fire either, so nothing said why the strings were missing.

## This pull request

- Rejects arrays and requires every mapped value to be a non-empty string. Anything else falls through to the warning that is already there and returns `undefined`.
- Adds three rows to the fallback table in `AppLocalizationProvider.test.tsx`: an array, an empty string value, and a non-string value. I reverted the guard and re-ran to check that all three fail without it.

## Issue that this pull request solves

Closes: https://mozilla-hub.atlassian.net/browse/FXA-11871
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants