diff --git a/README.md b/README.md index 1750d77eede..d49d69c5fc3 100644 --- a/README.md +++ b/README.md @@ -175,7 +175,7 @@ Faker supports incremental loading of locales. ```js // loads only de locale -const faker = require('@faker-js/faker/locale/de'); +const { faker } = require('@faker-js/faker/locale/de'); ``` ## Setting a randomness seed diff --git a/docs/api/localization.md b/docs/api/localization.md index 97d5de50829..50e09665f9a 100644 --- a/docs/api/localization.md +++ b/docs/api/localization.md @@ -89,5 +89,5 @@ In a production environment, you may only want to include the locale data for a ```js // loads only de locale -const faker = require('@faker-js/faker/locale/de'); +const { faker } = require('@faker-js/faker/locale/de'); ``` diff --git a/scripts/generateLocales.ts b/scripts/generateLocales.ts index 38715b97a4a..fc2c7ebcb4a 100644 --- a/scripts/generateLocales.ts +++ b/scripts/generateLocales.ts @@ -88,7 +88,7 @@ function generateLocaleFile(locale: string): void { import ${locale} from '../locales/${locale}'; ${locale !== 'en' ? "import en from '../locales/en';" : ''} - const faker = new Faker({ + export const faker = new Faker({ locale: '${locale}', localeFallback: 'en', locales: { @@ -96,8 +96,6 @@ function generateLocaleFile(locale: string): void { ${locale !== 'en' ? 'en,' : ''} }, }); - - export = faker; `; content = format(content, prettierTsOptions); diff --git a/src/locale/af_ZA.ts b/src/locale/af_ZA.ts index c47297fdf28..93ac1bcf743 100644 --- a/src/locale/af_ZA.ts +++ b/src/locale/af_ZA.ts @@ -7,7 +7,7 @@ import { Faker } from '../faker'; import af_ZA from '../locales/af_ZA'; import en from '../locales/en'; -const faker = new Faker({ +export const faker = new Faker({ locale: 'af_ZA', localeFallback: 'en', locales: { @@ -15,5 +15,3 @@ const faker = new Faker({ en, }, }); - -export = faker; diff --git a/src/locale/ar.ts b/src/locale/ar.ts index e396c1739b8..83eb41683df 100644 --- a/src/locale/ar.ts +++ b/src/locale/ar.ts @@ -7,7 +7,7 @@ import { Faker } from '../faker'; import ar from '../locales/ar'; import en from '../locales/en'; -const faker = new Faker({ +export const faker = new Faker({ locale: 'ar', localeFallback: 'en', locales: { @@ -15,5 +15,3 @@ const faker = new Faker({ en, }, }); - -export = faker; diff --git a/src/locale/az.ts b/src/locale/az.ts index 3249a33c2a1..b7b1fd6fb57 100644 --- a/src/locale/az.ts +++ b/src/locale/az.ts @@ -7,7 +7,7 @@ import { Faker } from '../faker'; import az from '../locales/az'; import en from '../locales/en'; -const faker = new Faker({ +export const faker = new Faker({ locale: 'az', localeFallback: 'en', locales: { @@ -15,5 +15,3 @@ const faker = new Faker({ en, }, }); - -export = faker; diff --git a/src/locale/cz.ts b/src/locale/cz.ts index 1a2460118e9..f6932b0b1dc 100644 --- a/src/locale/cz.ts +++ b/src/locale/cz.ts @@ -7,7 +7,7 @@ import { Faker } from '../faker'; import cz from '../locales/cz'; import en from '../locales/en'; -const faker = new Faker({ +export const faker = new Faker({ locale: 'cz', localeFallback: 'en', locales: { @@ -15,5 +15,3 @@ const faker = new Faker({ en, }, }); - -export = faker; diff --git a/src/locale/de.ts b/src/locale/de.ts index 3968cb4af0f..47bd5794c37 100644 --- a/src/locale/de.ts +++ b/src/locale/de.ts @@ -7,7 +7,7 @@ import { Faker } from '../faker'; import de from '../locales/de'; import en from '../locales/en'; -const faker = new Faker({ +export const faker = new Faker({ locale: 'de', localeFallback: 'en', locales: { @@ -15,5 +15,3 @@ const faker = new Faker({ en, }, }); - -export = faker; diff --git a/src/locale/de_AT.ts b/src/locale/de_AT.ts index 9eefa8251dc..1060b041048 100644 --- a/src/locale/de_AT.ts +++ b/src/locale/de_AT.ts @@ -7,7 +7,7 @@ import { Faker } from '../faker'; import de_AT from '../locales/de_AT'; import en from '../locales/en'; -const faker = new Faker({ +export const faker = new Faker({ locale: 'de_AT', localeFallback: 'en', locales: { @@ -15,5 +15,3 @@ const faker = new Faker({ en, }, }); - -export = faker; diff --git a/src/locale/de_CH.ts b/src/locale/de_CH.ts index e3eadf9d920..2e6b84805a6 100644 --- a/src/locale/de_CH.ts +++ b/src/locale/de_CH.ts @@ -7,7 +7,7 @@ import { Faker } from '../faker'; import de_CH from '../locales/de_CH'; import en from '../locales/en'; -const faker = new Faker({ +export const faker = new Faker({ locale: 'de_CH', localeFallback: 'en', locales: { @@ -15,5 +15,3 @@ const faker = new Faker({ en, }, }); - -export = faker; diff --git a/src/locale/el.ts b/src/locale/el.ts index 39c0ec53bc8..0292c6015ba 100644 --- a/src/locale/el.ts +++ b/src/locale/el.ts @@ -7,7 +7,7 @@ import { Faker } from '../faker'; import el from '../locales/el'; import en from '../locales/en'; -const faker = new Faker({ +export const faker = new Faker({ locale: 'el', localeFallback: 'en', locales: { @@ -15,5 +15,3 @@ const faker = new Faker({ en, }, }); - -export = faker; diff --git a/src/locale/en.ts b/src/locale/en.ts index d003817e537..b857f0ae12e 100644 --- a/src/locale/en.ts +++ b/src/locale/en.ts @@ -6,12 +6,10 @@ import { Faker } from '../faker'; import en from '../locales/en'; -const faker = new Faker({ +export const faker = new Faker({ locale: 'en', localeFallback: 'en', locales: { en, }, }); - -export = faker; diff --git a/src/locale/en_AU.ts b/src/locale/en_AU.ts index 2e6afe5a259..33d41c4cdaa 100644 --- a/src/locale/en_AU.ts +++ b/src/locale/en_AU.ts @@ -7,7 +7,7 @@ import { Faker } from '../faker'; import en from '../locales/en'; import en_AU from '../locales/en_AU'; -const faker = new Faker({ +export const faker = new Faker({ locale: 'en_AU', localeFallback: 'en', locales: { @@ -15,5 +15,3 @@ const faker = new Faker({ en, }, }); - -export = faker; diff --git a/src/locale/en_AU_ocker.ts b/src/locale/en_AU_ocker.ts index 4330f6ed550..735c3e2c825 100644 --- a/src/locale/en_AU_ocker.ts +++ b/src/locale/en_AU_ocker.ts @@ -7,7 +7,7 @@ import { Faker } from '../faker'; import en from '../locales/en'; import en_AU_ocker from '../locales/en_AU_ocker'; -const faker = new Faker({ +export const faker = new Faker({ locale: 'en_AU_ocker', localeFallback: 'en', locales: { @@ -15,5 +15,3 @@ const faker = new Faker({ en, }, }); - -export = faker; diff --git a/src/locale/en_BORK.ts b/src/locale/en_BORK.ts index 3089a61d583..962f26196e6 100644 --- a/src/locale/en_BORK.ts +++ b/src/locale/en_BORK.ts @@ -7,7 +7,7 @@ import { Faker } from '../faker'; import en from '../locales/en'; import en_BORK from '../locales/en_BORK'; -const faker = new Faker({ +export const faker = new Faker({ locale: 'en_BORK', localeFallback: 'en', locales: { @@ -15,5 +15,3 @@ const faker = new Faker({ en, }, }); - -export = faker; diff --git a/src/locale/en_CA.ts b/src/locale/en_CA.ts index 6fbb6db25df..5b64a4eef2f 100644 --- a/src/locale/en_CA.ts +++ b/src/locale/en_CA.ts @@ -7,7 +7,7 @@ import { Faker } from '../faker'; import en from '../locales/en'; import en_CA from '../locales/en_CA'; -const faker = new Faker({ +export const faker = new Faker({ locale: 'en_CA', localeFallback: 'en', locales: { @@ -15,5 +15,3 @@ const faker = new Faker({ en, }, }); - -export = faker; diff --git a/src/locale/en_GB.ts b/src/locale/en_GB.ts index baed972d054..7cd2caba336 100644 --- a/src/locale/en_GB.ts +++ b/src/locale/en_GB.ts @@ -7,7 +7,7 @@ import { Faker } from '../faker'; import en from '../locales/en'; import en_GB from '../locales/en_GB'; -const faker = new Faker({ +export const faker = new Faker({ locale: 'en_GB', localeFallback: 'en', locales: { @@ -15,5 +15,3 @@ const faker = new Faker({ en, }, }); - -export = faker; diff --git a/src/locale/en_GH.ts b/src/locale/en_GH.ts index da396c5aea1..d6effe2a31c 100644 --- a/src/locale/en_GH.ts +++ b/src/locale/en_GH.ts @@ -7,7 +7,7 @@ import { Faker } from '../faker'; import en from '../locales/en'; import en_GH from '../locales/en_GH'; -const faker = new Faker({ +export const faker = new Faker({ locale: 'en_GH', localeFallback: 'en', locales: { @@ -15,5 +15,3 @@ const faker = new Faker({ en, }, }); - -export = faker; diff --git a/src/locale/en_IE.ts b/src/locale/en_IE.ts index 2b0f92b8a99..85afdb64dbe 100644 --- a/src/locale/en_IE.ts +++ b/src/locale/en_IE.ts @@ -7,7 +7,7 @@ import { Faker } from '../faker'; import en from '../locales/en'; import en_IE from '../locales/en_IE'; -const faker = new Faker({ +export const faker = new Faker({ locale: 'en_IE', localeFallback: 'en', locales: { @@ -15,5 +15,3 @@ const faker = new Faker({ en, }, }); - -export = faker; diff --git a/src/locale/en_IND.ts b/src/locale/en_IND.ts index 16a753be517..2b93bae9497 100644 --- a/src/locale/en_IND.ts +++ b/src/locale/en_IND.ts @@ -7,7 +7,7 @@ import { Faker } from '../faker'; import en from '../locales/en'; import en_IND from '../locales/en_IND'; -const faker = new Faker({ +export const faker = new Faker({ locale: 'en_IND', localeFallback: 'en', locales: { @@ -15,5 +15,3 @@ const faker = new Faker({ en, }, }); - -export = faker; diff --git a/src/locale/en_NG.ts b/src/locale/en_NG.ts index f9d49152865..32802c49716 100644 --- a/src/locale/en_NG.ts +++ b/src/locale/en_NG.ts @@ -7,7 +7,7 @@ import { Faker } from '../faker'; import en from '../locales/en'; import en_NG from '../locales/en_NG'; -const faker = new Faker({ +export const faker = new Faker({ locale: 'en_NG', localeFallback: 'en', locales: { @@ -15,5 +15,3 @@ const faker = new Faker({ en, }, }); - -export = faker; diff --git a/src/locale/en_US.ts b/src/locale/en_US.ts index ec6a6cc0bec..558bf4a3dc2 100644 --- a/src/locale/en_US.ts +++ b/src/locale/en_US.ts @@ -7,7 +7,7 @@ import { Faker } from '../faker'; import en from '../locales/en'; import en_US from '../locales/en_US'; -const faker = new Faker({ +export const faker = new Faker({ locale: 'en_US', localeFallback: 'en', locales: { @@ -15,5 +15,3 @@ const faker = new Faker({ en, }, }); - -export = faker; diff --git a/src/locale/en_ZA.ts b/src/locale/en_ZA.ts index 2eb13622429..94f6d76e84c 100644 --- a/src/locale/en_ZA.ts +++ b/src/locale/en_ZA.ts @@ -7,7 +7,7 @@ import { Faker } from '../faker'; import en from '../locales/en'; import en_ZA from '../locales/en_ZA'; -const faker = new Faker({ +export const faker = new Faker({ locale: 'en_ZA', localeFallback: 'en', locales: { @@ -15,5 +15,3 @@ const faker = new Faker({ en, }, }); - -export = faker; diff --git a/src/locale/es.ts b/src/locale/es.ts index b5485698ca6..cf4d26c2f66 100644 --- a/src/locale/es.ts +++ b/src/locale/es.ts @@ -7,7 +7,7 @@ import { Faker } from '../faker'; import en from '../locales/en'; import es from '../locales/es'; -const faker = new Faker({ +export const faker = new Faker({ locale: 'es', localeFallback: 'en', locales: { @@ -15,5 +15,3 @@ const faker = new Faker({ en, }, }); - -export = faker; diff --git a/src/locale/es_MX.ts b/src/locale/es_MX.ts index ff954d8c415..96492e5615b 100644 --- a/src/locale/es_MX.ts +++ b/src/locale/es_MX.ts @@ -7,7 +7,7 @@ import { Faker } from '../faker'; import en from '../locales/en'; import es_MX from '../locales/es_MX'; -const faker = new Faker({ +export const faker = new Faker({ locale: 'es_MX', localeFallback: 'en', locales: { @@ -15,5 +15,3 @@ const faker = new Faker({ en, }, }); - -export = faker; diff --git a/src/locale/fa.ts b/src/locale/fa.ts index 62e63d8ded6..6d5a0944948 100644 --- a/src/locale/fa.ts +++ b/src/locale/fa.ts @@ -7,7 +7,7 @@ import { Faker } from '../faker'; import en from '../locales/en'; import fa from '../locales/fa'; -const faker = new Faker({ +export const faker = new Faker({ locale: 'fa', localeFallback: 'en', locales: { @@ -15,5 +15,3 @@ const faker = new Faker({ en, }, }); - -export = faker; diff --git a/src/locale/fi.ts b/src/locale/fi.ts index ecdecb88b15..860ab5adf0f 100644 --- a/src/locale/fi.ts +++ b/src/locale/fi.ts @@ -7,7 +7,7 @@ import { Faker } from '../faker'; import en from '../locales/en'; import fi from '../locales/fi'; -const faker = new Faker({ +export const faker = new Faker({ locale: 'fi', localeFallback: 'en', locales: { @@ -15,5 +15,3 @@ const faker = new Faker({ en, }, }); - -export = faker; diff --git a/src/locale/fr.ts b/src/locale/fr.ts index e767c582397..d33c5d1c0b4 100644 --- a/src/locale/fr.ts +++ b/src/locale/fr.ts @@ -7,7 +7,7 @@ import { Faker } from '../faker'; import en from '../locales/en'; import fr from '../locales/fr'; -const faker = new Faker({ +export const faker = new Faker({ locale: 'fr', localeFallback: 'en', locales: { @@ -15,5 +15,3 @@ const faker = new Faker({ en, }, }); - -export = faker; diff --git a/src/locale/fr_BE.ts b/src/locale/fr_BE.ts index f98b7c8c5aa..c9de78dccf7 100644 --- a/src/locale/fr_BE.ts +++ b/src/locale/fr_BE.ts @@ -7,7 +7,7 @@ import { Faker } from '../faker'; import en from '../locales/en'; import fr_BE from '../locales/fr_BE'; -const faker = new Faker({ +export const faker = new Faker({ locale: 'fr_BE', localeFallback: 'en', locales: { @@ -15,5 +15,3 @@ const faker = new Faker({ en, }, }); - -export = faker; diff --git a/src/locale/fr_CA.ts b/src/locale/fr_CA.ts index 30e73bdbdbd..573181a3366 100644 --- a/src/locale/fr_CA.ts +++ b/src/locale/fr_CA.ts @@ -7,7 +7,7 @@ import { Faker } from '../faker'; import en from '../locales/en'; import fr_CA from '../locales/fr_CA'; -const faker = new Faker({ +export const faker = new Faker({ locale: 'fr_CA', localeFallback: 'en', locales: { @@ -15,5 +15,3 @@ const faker = new Faker({ en, }, }); - -export = faker; diff --git a/src/locale/fr_CH.ts b/src/locale/fr_CH.ts index f04588b54cd..3a914e43452 100644 --- a/src/locale/fr_CH.ts +++ b/src/locale/fr_CH.ts @@ -7,7 +7,7 @@ import { Faker } from '../faker'; import en from '../locales/en'; import fr_CH from '../locales/fr_CH'; -const faker = new Faker({ +export const faker = new Faker({ locale: 'fr_CH', localeFallback: 'en', locales: { @@ -15,5 +15,3 @@ const faker = new Faker({ en, }, }); - -export = faker; diff --git a/src/locale/ge.ts b/src/locale/ge.ts index 7734e2d33a1..e1f05865403 100644 --- a/src/locale/ge.ts +++ b/src/locale/ge.ts @@ -7,7 +7,7 @@ import { Faker } from '../faker'; import en from '../locales/en'; import ge from '../locales/ge'; -const faker = new Faker({ +export const faker = new Faker({ locale: 'ge', localeFallback: 'en', locales: { @@ -15,5 +15,3 @@ const faker = new Faker({ en, }, }); - -export = faker; diff --git a/src/locale/he.ts b/src/locale/he.ts index a029ea62114..b4c1b9c9b1d 100644 --- a/src/locale/he.ts +++ b/src/locale/he.ts @@ -7,7 +7,7 @@ import { Faker } from '../faker'; import en from '../locales/en'; import he from '../locales/he'; -const faker = new Faker({ +export const faker = new Faker({ locale: 'he', localeFallback: 'en', locales: { @@ -15,5 +15,3 @@ const faker = new Faker({ en, }, }); - -export = faker; diff --git a/src/locale/hr.ts b/src/locale/hr.ts index 1a8447155fb..d9aa1348012 100644 --- a/src/locale/hr.ts +++ b/src/locale/hr.ts @@ -7,7 +7,7 @@ import { Faker } from '../faker'; import en from '../locales/en'; import hr from '../locales/hr'; -const faker = new Faker({ +export const faker = new Faker({ locale: 'hr', localeFallback: 'en', locales: { @@ -15,5 +15,3 @@ const faker = new Faker({ en, }, }); - -export = faker; diff --git a/src/locale/hu.ts b/src/locale/hu.ts index 89bc3dda5a8..f9d9f55536a 100644 --- a/src/locale/hu.ts +++ b/src/locale/hu.ts @@ -7,7 +7,7 @@ import { Faker } from '../faker'; import en from '../locales/en'; import hu from '../locales/hu'; -const faker = new Faker({ +export const faker = new Faker({ locale: 'hu', localeFallback: 'en', locales: { @@ -15,5 +15,3 @@ const faker = new Faker({ en, }, }); - -export = faker; diff --git a/src/locale/hy.ts b/src/locale/hy.ts index ae584be3529..724c1406f68 100644 --- a/src/locale/hy.ts +++ b/src/locale/hy.ts @@ -7,7 +7,7 @@ import { Faker } from '../faker'; import en from '../locales/en'; import hy from '../locales/hy'; -const faker = new Faker({ +export const faker = new Faker({ locale: 'hy', localeFallback: 'en', locales: { @@ -15,5 +15,3 @@ const faker = new Faker({ en, }, }); - -export = faker; diff --git a/src/locale/id_ID.ts b/src/locale/id_ID.ts index 026086611df..eafc0c528e4 100644 --- a/src/locale/id_ID.ts +++ b/src/locale/id_ID.ts @@ -7,7 +7,7 @@ import { Faker } from '../faker'; import en from '../locales/en'; import id_ID from '../locales/id_ID'; -const faker = new Faker({ +export const faker = new Faker({ locale: 'id_ID', localeFallback: 'en', locales: { @@ -15,5 +15,3 @@ const faker = new Faker({ en, }, }); - -export = faker; diff --git a/src/locale/it.ts b/src/locale/it.ts index 40daaa65432..b6df80e82c0 100644 --- a/src/locale/it.ts +++ b/src/locale/it.ts @@ -7,7 +7,7 @@ import { Faker } from '../faker'; import en from '../locales/en'; import it from '../locales/it'; -const faker = new Faker({ +export const faker = new Faker({ locale: 'it', localeFallback: 'en', locales: { @@ -15,5 +15,3 @@ const faker = new Faker({ en, }, }); - -export = faker; diff --git a/src/locale/ja.ts b/src/locale/ja.ts index 4866ad92ead..f24109df83f 100644 --- a/src/locale/ja.ts +++ b/src/locale/ja.ts @@ -7,7 +7,7 @@ import { Faker } from '../faker'; import en from '../locales/en'; import ja from '../locales/ja'; -const faker = new Faker({ +export const faker = new Faker({ locale: 'ja', localeFallback: 'en', locales: { @@ -15,5 +15,3 @@ const faker = new Faker({ en, }, }); - -export = faker; diff --git a/src/locale/ko.ts b/src/locale/ko.ts index b6d975893b2..64b0b3e7834 100644 --- a/src/locale/ko.ts +++ b/src/locale/ko.ts @@ -7,7 +7,7 @@ import { Faker } from '../faker'; import en from '../locales/en'; import ko from '../locales/ko'; -const faker = new Faker({ +export const faker = new Faker({ locale: 'ko', localeFallback: 'en', locales: { @@ -15,5 +15,3 @@ const faker = new Faker({ en, }, }); - -export = faker; diff --git a/src/locale/lv.ts b/src/locale/lv.ts index 89349b51e96..80ed9156cfd 100644 --- a/src/locale/lv.ts +++ b/src/locale/lv.ts @@ -7,7 +7,7 @@ import { Faker } from '../faker'; import en from '../locales/en'; import lv from '../locales/lv'; -const faker = new Faker({ +export const faker = new Faker({ locale: 'lv', localeFallback: 'en', locales: { @@ -15,5 +15,3 @@ const faker = new Faker({ en, }, }); - -export = faker; diff --git a/src/locale/mk.ts b/src/locale/mk.ts index c5b9a584002..91199ba497c 100644 --- a/src/locale/mk.ts +++ b/src/locale/mk.ts @@ -7,7 +7,7 @@ import { Faker } from '../faker'; import en from '../locales/en'; import mk from '../locales/mk'; -const faker = new Faker({ +export const faker = new Faker({ locale: 'mk', localeFallback: 'en', locales: { @@ -15,5 +15,3 @@ const faker = new Faker({ en, }, }); - -export = faker; diff --git a/src/locale/nb_NO.ts b/src/locale/nb_NO.ts index 9c768999e40..ee4b561ced1 100644 --- a/src/locale/nb_NO.ts +++ b/src/locale/nb_NO.ts @@ -7,7 +7,7 @@ import { Faker } from '../faker'; import en from '../locales/en'; import nb_NO from '../locales/nb_NO'; -const faker = new Faker({ +export const faker = new Faker({ locale: 'nb_NO', localeFallback: 'en', locales: { @@ -15,5 +15,3 @@ const faker = new Faker({ en, }, }); - -export = faker; diff --git a/src/locale/ne.ts b/src/locale/ne.ts index 1527d4136ac..ebc47246bb0 100644 --- a/src/locale/ne.ts +++ b/src/locale/ne.ts @@ -7,7 +7,7 @@ import { Faker } from '../faker'; import en from '../locales/en'; import ne from '../locales/ne'; -const faker = new Faker({ +export const faker = new Faker({ locale: 'ne', localeFallback: 'en', locales: { @@ -15,5 +15,3 @@ const faker = new Faker({ en, }, }); - -export = faker; diff --git a/src/locale/nl.ts b/src/locale/nl.ts index c4adac22204..c8f6a649dbb 100644 --- a/src/locale/nl.ts +++ b/src/locale/nl.ts @@ -7,7 +7,7 @@ import { Faker } from '../faker'; import en from '../locales/en'; import nl from '../locales/nl'; -const faker = new Faker({ +export const faker = new Faker({ locale: 'nl', localeFallback: 'en', locales: { @@ -15,5 +15,3 @@ const faker = new Faker({ en, }, }); - -export = faker; diff --git a/src/locale/nl_BE.ts b/src/locale/nl_BE.ts index 57c23f2e08d..dd227f4e7f6 100644 --- a/src/locale/nl_BE.ts +++ b/src/locale/nl_BE.ts @@ -7,7 +7,7 @@ import { Faker } from '../faker'; import en from '../locales/en'; import nl_BE from '../locales/nl_BE'; -const faker = new Faker({ +export const faker = new Faker({ locale: 'nl_BE', localeFallback: 'en', locales: { @@ -15,5 +15,3 @@ const faker = new Faker({ en, }, }); - -export = faker; diff --git a/src/locale/pl.ts b/src/locale/pl.ts index 32489ea9484..44db8e40ab3 100644 --- a/src/locale/pl.ts +++ b/src/locale/pl.ts @@ -7,7 +7,7 @@ import { Faker } from '../faker'; import en from '../locales/en'; import pl from '../locales/pl'; -const faker = new Faker({ +export const faker = new Faker({ locale: 'pl', localeFallback: 'en', locales: { @@ -15,5 +15,3 @@ const faker = new Faker({ en, }, }); - -export = faker; diff --git a/src/locale/pt_BR.ts b/src/locale/pt_BR.ts index fd91879ec23..3711d3f6d7e 100644 --- a/src/locale/pt_BR.ts +++ b/src/locale/pt_BR.ts @@ -7,7 +7,7 @@ import { Faker } from '../faker'; import en from '../locales/en'; import pt_BR from '../locales/pt_BR'; -const faker = new Faker({ +export const faker = new Faker({ locale: 'pt_BR', localeFallback: 'en', locales: { @@ -15,5 +15,3 @@ const faker = new Faker({ en, }, }); - -export = faker; diff --git a/src/locale/pt_PT.ts b/src/locale/pt_PT.ts index 8233d8cd746..915092abd3a 100644 --- a/src/locale/pt_PT.ts +++ b/src/locale/pt_PT.ts @@ -7,7 +7,7 @@ import { Faker } from '../faker'; import en from '../locales/en'; import pt_PT from '../locales/pt_PT'; -const faker = new Faker({ +export const faker = new Faker({ locale: 'pt_PT', localeFallback: 'en', locales: { @@ -15,5 +15,3 @@ const faker = new Faker({ en, }, }); - -export = faker; diff --git a/src/locale/ro.ts b/src/locale/ro.ts index 45d97cbf990..2903e01dd2f 100644 --- a/src/locale/ro.ts +++ b/src/locale/ro.ts @@ -7,7 +7,7 @@ import { Faker } from '../faker'; import en from '../locales/en'; import ro from '../locales/ro'; -const faker = new Faker({ +export const faker = new Faker({ locale: 'ro', localeFallback: 'en', locales: { @@ -15,5 +15,3 @@ const faker = new Faker({ en, }, }); - -export = faker; diff --git a/src/locale/ru.ts b/src/locale/ru.ts index 753d218f7fa..433342216bc 100644 --- a/src/locale/ru.ts +++ b/src/locale/ru.ts @@ -7,7 +7,7 @@ import { Faker } from '../faker'; import en from '../locales/en'; import ru from '../locales/ru'; -const faker = new Faker({ +export const faker = new Faker({ locale: 'ru', localeFallback: 'en', locales: { @@ -15,5 +15,3 @@ const faker = new Faker({ en, }, }); - -export = faker; diff --git a/src/locale/sk.ts b/src/locale/sk.ts index ce8bc05a547..2816c16e6c9 100644 --- a/src/locale/sk.ts +++ b/src/locale/sk.ts @@ -7,7 +7,7 @@ import { Faker } from '../faker'; import en from '../locales/en'; import sk from '../locales/sk'; -const faker = new Faker({ +export const faker = new Faker({ locale: 'sk', localeFallback: 'en', locales: { @@ -15,5 +15,3 @@ const faker = new Faker({ en, }, }); - -export = faker; diff --git a/src/locale/sv.ts b/src/locale/sv.ts index 30706dfa8a1..41c8f4e3643 100644 --- a/src/locale/sv.ts +++ b/src/locale/sv.ts @@ -7,7 +7,7 @@ import { Faker } from '../faker'; import en from '../locales/en'; import sv from '../locales/sv'; -const faker = new Faker({ +export const faker = new Faker({ locale: 'sv', localeFallback: 'en', locales: { @@ -15,5 +15,3 @@ const faker = new Faker({ en, }, }); - -export = faker; diff --git a/src/locale/tr.ts b/src/locale/tr.ts index c68fe76f156..0aa4a51a561 100644 --- a/src/locale/tr.ts +++ b/src/locale/tr.ts @@ -7,7 +7,7 @@ import { Faker } from '../faker'; import en from '../locales/en'; import tr from '../locales/tr'; -const faker = new Faker({ +export const faker = new Faker({ locale: 'tr', localeFallback: 'en', locales: { @@ -15,5 +15,3 @@ const faker = new Faker({ en, }, }); - -export = faker; diff --git a/src/locale/uk.ts b/src/locale/uk.ts index a6b1c1bc1dd..ec40da8f4cc 100644 --- a/src/locale/uk.ts +++ b/src/locale/uk.ts @@ -7,7 +7,7 @@ import { Faker } from '../faker'; import en from '../locales/en'; import uk from '../locales/uk'; -const faker = new Faker({ +export const faker = new Faker({ locale: 'uk', localeFallback: 'en', locales: { @@ -15,5 +15,3 @@ const faker = new Faker({ en, }, }); - -export = faker; diff --git a/src/locale/ur.ts b/src/locale/ur.ts index 249c4011b9c..f08be161b5c 100644 --- a/src/locale/ur.ts +++ b/src/locale/ur.ts @@ -7,7 +7,7 @@ import { Faker } from '../faker'; import en from '../locales/en'; import ur from '../locales/ur'; -const faker = new Faker({ +export const faker = new Faker({ locale: 'ur', localeFallback: 'en', locales: { @@ -15,5 +15,3 @@ const faker = new Faker({ en, }, }); - -export = faker; diff --git a/src/locale/vi.ts b/src/locale/vi.ts index 62c1e367f96..96c888afea9 100644 --- a/src/locale/vi.ts +++ b/src/locale/vi.ts @@ -7,7 +7,7 @@ import { Faker } from '../faker'; import en from '../locales/en'; import vi from '../locales/vi'; -const faker = new Faker({ +export const faker = new Faker({ locale: 'vi', localeFallback: 'en', locales: { @@ -15,5 +15,3 @@ const faker = new Faker({ en, }, }); - -export = faker; diff --git a/src/locale/zh_CN.ts b/src/locale/zh_CN.ts index d7fddf293e5..207ede7716a 100644 --- a/src/locale/zh_CN.ts +++ b/src/locale/zh_CN.ts @@ -7,7 +7,7 @@ import { Faker } from '../faker'; import en from '../locales/en'; import zh_CN from '../locales/zh_CN'; -const faker = new Faker({ +export const faker = new Faker({ locale: 'zh_CN', localeFallback: 'en', locales: { @@ -15,5 +15,3 @@ const faker = new Faker({ en, }, }); - -export = faker; diff --git a/src/locale/zh_TW.ts b/src/locale/zh_TW.ts index 5a9b3e31583..dd36aa2e3d0 100644 --- a/src/locale/zh_TW.ts +++ b/src/locale/zh_TW.ts @@ -7,7 +7,7 @@ import { Faker } from '../faker'; import en from '../locales/en'; import zh_TW from '../locales/zh_TW'; -const faker = new Faker({ +export const faker = new Faker({ locale: 'zh_TW', localeFallback: 'en', locales: { @@ -15,5 +15,3 @@ const faker = new Faker({ en, }, }); - -export = faker; diff --git a/src/locale/zu_ZA.ts b/src/locale/zu_ZA.ts index f75bf2871f1..df595ff2d86 100644 --- a/src/locale/zu_ZA.ts +++ b/src/locale/zu_ZA.ts @@ -7,7 +7,7 @@ import { Faker } from '../faker'; import en from '../locales/en'; import zu_ZA from '../locales/zu_ZA'; -const faker = new Faker({ +export const faker = new Faker({ locale: 'zu_ZA', localeFallback: 'en', locales: { @@ -15,5 +15,3 @@ const faker = new Faker({ en, }, }); - -export = faker; diff --git a/test/locale-imports.spec.ts b/test/locale-imports.spec.ts index 6ac66fae3d0..3fdbeed1d75 100644 --- a/test/locale-imports.spec.ts +++ b/test/locale-imports.spec.ts @@ -5,19 +5,35 @@ describe('locale imports', () => { for (const locale in allLocales) { it(`should be possible to directly require('@faker-js/faker/locale/${locale}')`, () => { // eslint-disable-next-line @typescript-eslint/no-var-requires - const faker = require(`../dist/cjs/locale/${locale}`); + const { faker } = require(`../dist/cjs/locale/${locale}`); expect(faker).toBeDefined(); expect(faker.locale).toBe(locale); }); - // Internal test to cover `src/locale/*.ts` - it(`should be possible to directly require('../locale/${locale}')`, () => { - // eslint-disable-next-line @typescript-eslint/no-var-requires - const faker = require(`../locale/${locale}`); + it(`should be possible to directly import('@faker-js/faker/locale/${locale}')`, async () => { + const { faker } = await import(`../dist/esm/locale/${locale}`); expect(faker).toBeDefined(); expect(faker.locale).toBe(locale); }); + + describe('Internal tests to cover `src/locale/*.ts`', () => { + it(`should be possible to directly require('../locale/${locale}')`, () => { + // eslint-disable-next-line @typescript-eslint/no-var-requires + const { faker } = require(`../locale/${locale}`); + + expect(faker).toBeDefined(); + expect(faker.locale).toBe(locale); + }); + + it(`should be possible to directly import('../src/locale/${locale}')`, async () => { + // eslint-disable-next-line @typescript-eslint/no-var-requires + const { faker } = await import(`../src/locale/${locale}`); + + expect(faker).toBeDefined(); + expect(faker.locale).toBe(locale); + }); + }); } });