diff options
| author | DivisionByZero <[email protected]> | 2024-04-11 08:33:15 +0200 |
|---|---|---|
| committer | GitHub <[email protected]> | 2024-04-11 08:33:15 +0200 |
| commit | fb65976acb1003f441a35afafbd87204eca0e2d7 (patch) | |
| tree | 741cf63d0fe52947fce23e3f14e1e8ad8b3526fc /scripts/generate-locales.ts | |
| parent | 200a38e76efc27e32f716472bdc4f4d39eff60d1 (diff) | |
| download | faker-fb65976acb1003f441a35afafbd87204eca0e2d7.tar.xz faker-fb65976acb1003f441a35afafbd87204eca0e2d7.zip | |
fix: tree-shaking (#2790)
Co-authored-by: ST-DDT <[email protected]>
Diffstat (limited to 'scripts/generate-locales.ts')
| -rw-r--r-- | scripts/generate-locales.ts | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/scripts/generate-locales.ts b/scripts/generate-locales.ts index cba70edc..67b48553 100644 --- a/scripts/generate-locales.ts +++ b/scripts/generate-locales.ts @@ -375,7 +375,7 @@ removeIndexTs(locales); let localeIndexImports = ''; let localeIndexExportsIndividual = ''; let localeIndexExportsGrouped = ''; -let localesIndexExports = ''; +let localesIndexImports = ''; let localizationLocales = '| Locale | Name | Faker |\n| :--- | :--- | :--- |\n'; @@ -406,7 +406,7 @@ for (const locale of locales) { localeIndexImports += `import { faker as ${localizedFaker} } from './${locale}';\n`; localeIndexExportsIndividual += ` ${localizedFaker},\n`; localeIndexExportsGrouped += ` ${locale}: ${localizedFaker},\n`; - localesIndexExports += `export { default as ${locale} } from './${locale}';\n`; + localesIndexImports += `import { default as ${locale} } from './${locale}';\n`; localizationLocales += `| \`${locale}\` | ${localeTitle} | \`${localizedFaker}\` |\n`; // src/locale/<locale>.ts @@ -445,7 +445,11 @@ writeFileSync(pathLocaleIndex, localeIndexContent); let localesIndexContent = ` ${autoGeneratedCommentHeader} - ${localesIndexExports} + ${localesIndexImports} + + export { ${locales.join(',')} }; + + export const allLocales = { ${locales.join(',')} }; `; localesIndexContent = await formatTypescript(localesIndexContent); |
