aboutsummaryrefslogtreecommitdiff
path: root/scripts/generate-locales.ts
diff options
context:
space:
mode:
authorDivisionByZero <[email protected]>2024-04-11 08:33:15 +0200
committerGitHub <[email protected]>2024-04-11 08:33:15 +0200
commitfb65976acb1003f441a35afafbd87204eca0e2d7 (patch)
tree741cf63d0fe52947fce23e3f14e1e8ad8b3526fc /scripts/generate-locales.ts
parent200a38e76efc27e32f716472bdc4f4d39eff60d1 (diff)
downloadfaker-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.ts10
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);