Skip to content
This repository has been archived by the owner on May 3, 2024. It is now read-only.

feat(conditionalIntl): added env var for Itnl #1258

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
cdfc459
feat(conditionalIntl): added env var for Itnl
timBarton96 Jan 25, 2024
7ef00ed
feat(conditionalIntl): fixed nonce
timBarton96 Jan 25, 2024
4a5db19
Merge branch 'main' into feat/conditionalIntlPolyfill
Matthew-Mallimo Jan 29, 2024
d76bbe5
feat(conditionalIntl): renamed env var, conditional I18n script
timBarton96 Feb 1, 2024
edb789a
feat(conditionalItnl): renderI18nScript return early
timBarton96 Feb 2, 2024
c3265dc
feat(conditionalIntl): renaming tests for env var script
timBarton96 Feb 2, 2024
a91730d
Merge branch 'main' into feat/conditionalIntlPolyfill
Matthew-Mallimo Feb 5, 2024
cc1706f
Merge branch 'main' into feat/conditionalIntlPolyfill
JAdshead Feb 5, 2024
43f9921
Merge branch 'main' into feat/conditionalIntlPolyfill
Matthew-Mallimo Feb 14, 2024
5c0aab4
feat(conditionalIntl): disable getLocalePack with env var
timBarton96 Feb 19, 2024
ce17ecb
Merge branch 'main' into feat/conditionalIntlPolyfill
Matthew-Mallimo Feb 20, 2024
74b64c2
Merge branch 'main' into feat/conditionalIntlPolyfill
Matthew-Mallimo Mar 6, 2024
2ceae45
feat(conditionalIntl): bump one-app-ducks
timBarton96 Mar 6, 2024
65a6992
feat(conditionalIntl): fix bullet in doc
timBarton96 Mar 6, 2024
617ec89
feat(conditionalPolyfill): uncomment logging
timBarton96 Mar 8, 2024
d89caab
Merge branch 'main' into feat/conditionalIntlPolyfill
10xLaCroixDrinker Mar 12, 2024
ca24808
chore(ducks): take latest ducks
code-forger Mar 26, 2024
a5a231b
Merge branch 'main' into feat/conditionalIntlPolyfill
code-forger Mar 26, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
feat(conditionalItnl): renderI18nScript return early
  • Loading branch information
timBarton96 committed Feb 2, 2024
commit edb789aa4e5e79e34d18e794e45fc2c3de99841f
11 changes: 11 additions & 0 deletions __tests__/server/plugins/reactHtml/index.spec.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,8 @@ describe('reactHtml', () => {
cdnUrl: '/cdnUrl/',
rootModuleName: 'test-root',
}));

process.env.ONE_CONFIG_USE_NATIVE_INTL = 'false';
});

function removeInitialState(body) {
Expand Down Expand Up @@ -431,6 +433,15 @@ describe('reactHtml', () => {
expect(reply.send.mock.calls[0][0]).not.toContain('src="/cdnUrl/app/1.2.3-rc.4-abc123/i18n/');
});

it('sends a rendered page without the locale data script tag when te ONE_CONFIG_USE_NATIVE_INTL environment variable is true', () => {
process.env.ONE_CONFIG_USE_NATIVE_INTL = 'true';
setFullMap();
sendHtml(request, reply);

expect(reply.send).toHaveBeenCalledTimes(1);
expect(reply.send.mock.calls[0][0]).not.toContain('src="/cdnUrl/app/1.2.3-rc.4-abc123/i18n/');
});

it('sends a rendered page with the module styles and scripts', () => {
sendHtml(request, reply);
expect(reply.send).toHaveBeenCalledTimes(1);
Expand Down
6 changes: 5 additions & 1 deletion src/server/plugins/reactHtml/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,12 @@ const legacyBrowserChunkAssets = getChunkAssets(readJsonFile('../../../.build-me
.map((chunkAsset) => `legacy/${chunkAsset}`);

function renderI18nScript(clientInitialState, appBundlesURLPrefix) {
if (process.env.ONE_CONFIG_USE_NATIVE_INTL === 'true') {
return '';
}

const i18nFile = getI18nFileFromState(clientInitialState);
if (!i18nFile || process.env.ONE_CONFIG_USE_NATIVE_INTL === 'true') {
if (!i18nFile) {
return '';
}

Expand Down
Loading