Unconditionally polyfill Intl.PluralRules for native (#4554)

* Revert "Fix Android startup perf regression (#4544)"

This reverts commit e6213d7aa5.

* Force polyfill
zio/stable
dan 2024-06-18 17:27:40 +03:00 committed by GitHub
parent f142339e06
commit 08cfb09589
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 1 additions and 60 deletions

View File

@ -33,7 +33,6 @@ module.exports = {
], ],
'bsky-internal/use-exact-imports': 'error', 'bsky-internal/use-exact-imports': 'error',
'bsky-internal/use-typed-gates': 'error', 'bsky-internal/use-typed-gates': 'error',
'bsky-internal/keep-i18n-patch-in-sync': 'error',
'simple-import-sort/imports': [ 'simple-import-sort/imports': [
'warn', 'warn',
{ {

View File

@ -2,7 +2,6 @@
module.exports = { module.exports = {
rules: { rules: {
'keep-i18n-patch-in-sync': require('./keep-i18n-patch-in-sync'),
'avoid-unwrapped-text': require('./avoid-unwrapped-text'), 'avoid-unwrapped-text': require('./avoid-unwrapped-text'),
'use-exact-imports': require('./use-exact-imports'), 'use-exact-imports': require('./use-exact-imports'),
'use-typed-gates': require('./use-typed-gates'), 'use-typed-gates': require('./use-typed-gates'),

View File

@ -1,28 +0,0 @@
/* eslint-disable bsky-internal/keep-i18n-patch-in-sync */
const LOCALE_DATA_FOLDER = '@formatjs/intl-pluralrules/locale-data/'
const GEN_MODULE_PATH =
'@formatjs/intl-pluralrules/supported-locales.generated.js'
exports.create = function create(context) {
delete require.cache[require.resolve(GEN_MODULE_PATH)]
const {supportedLocales} = require(GEN_MODULE_PATH)
return {
Literal(node) {
if (typeof node.value !== 'string') {
return
}
if (!node.value.startsWith(LOCALE_DATA_FOLDER)) {
return
}
const code = node.value.slice(LOCALE_DATA_FOLDER.length)
if (!supportedLocales.includes(code)) {
context.report({
node,
message:
'Edit .patches/@formatjs+intl-pluralrules+XXX.patch to include ' +
code,
})
}
},
}
}

View File

@ -1,29 +0,0 @@
diff --git a/node_modules/@formatjs/intl-pluralrules/supported-locales.generated.js b/node_modules/@formatjs/intl-pluralrules/supported-locales.generated.js
index 5e0692b..d11157a 100644
--- a/node_modules/@formatjs/intl-pluralrules/supported-locales.generated.js
+++ b/node_modules/@formatjs/intl-pluralrules/supported-locales.generated.js
@@ -2,3 +2,24 @@
Object.defineProperty(exports, "__esModule", { value: true });
exports.supportedLocales = void 0;
exports.supportedLocales = ["af", "ak", "am", "an", "ar", "ars", "as", "asa", "ast", "az", "bal", "be", "bem", "bez", "bg", "bho", "bm", "bn", "bo", "br", "brx", "bs", "ca", "ce", "ceb", "cgg", "chr", "ckb", "cs", "cy", "da", "de", "doi", "dsb", "dv", "dz", "ee", "el", "en", "eo", "es", "et", "eu", "fa", "ff", "fi", "fil", "fo", "fr", "fur", "fy", "ga", "gd", "gl", "gsw", "gu", "guw", "gv", "ha", "haw", "he", "hi", "hnj", "hr", "hsb", "hu", "hy", "ia", "id", "ig", "ii", "io", "is", "it", "iu", "ja", "jbo", "jgo", "jmc", "jv", "jw", "ka", "kab", "kaj", "kcg", "kde", "kea", "kk", "kkj", "kl", "km", "kn", "ko", "ks", "ksb", "ksh", "ku", "kw", "ky", "lag", "lb", "lg", "lij", "lkt", "ln", "lo", "lt", "lv", "mas", "mg", "mgo", "mk", "ml", "mn", "mo", "mr", "ms", "mt", "my", "nah", "naq", "nb", "nd", "ne", "nl", "nn", "nnh", "no", "nqo", "nr", "nso", "ny", "nyn", "om", "or", "os", "osa", "pa", "pap", "pcm", "pl", "prg", "ps", "pt", "pt-PT", "rm", "ro", "rof", "ru", "rwk", "sah", "saq", "sat", "sc", "scn", "sd", "sdh", "se", "seh", "ses", "sg", "sh", "shi", "si", "sk", "sl", "sma", "smi", "smj", "smn", "sms", "sn", "so", "sq", "sr", "ss", "ssy", "st", "su", "sv", "sw", "syr", "ta", "te", "teo", "th", "ti", "tig", "tk", "tl", "tn", "to", "tpi", "tr", "ts", "tzm", "ug", "uk", "und", "ur", "uz", "ve", "vi", "vo", "vun", "wa", "wae", "wo", "xh", "xog", "yi", "yo", "yue", "zh", "zu"];
+
+// PATCHED FOR ANDROID PERF. KEEP IN SYNC WITH i18n.ts -dan
+exports.supportedLocales = [
+ 'ca',
+ 'de',
+ 'en',
+ 'es',
+ 'fi',
+ 'fr',
+ 'ga',
+ 'hi',
+ 'id',
+ 'it',
+ 'ja',
+ 'ko',
+ 'pt',
+ 'tr',
+ 'uk',
+ 'zh'
+];
+

View File

@ -1,5 +1,5 @@
import '@formatjs/intl-locale/polyfill' import '@formatjs/intl-locale/polyfill'
import '@formatjs/intl-pluralrules/polyfill' import '@formatjs/intl-pluralrules/polyfill-force' // Don't remove -force because detection is very slow
import '@formatjs/intl-pluralrules/locale-data/en' import '@formatjs/intl-pluralrules/locale-data/en'
import {useEffect} from 'react' import {useEffect} from 'react'