aboutsummaryrefslogtreecommitdiff
path: root/docs/guide
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 /docs/guide
parent200a38e76efc27e32f716472bdc4f4d39eff60d1 (diff)
downloadfaker-fb65976acb1003f441a35afafbd87204eca0e2d7.tar.xz
faker-fb65976acb1003f441a35afafbd87204eca0e2d7.zip
fix: tree-shaking (#2790)
Co-authored-by: ST-DDT <[email protected]>
Diffstat (limited to 'docs/guide')
-rw-r--r--docs/guide/localization.md29
-rw-r--r--docs/guide/upgrading_v9/2790.md18
2 files changed, 23 insertions, 24 deletions
diff --git a/docs/guide/localization.md b/docs/guide/localization.md
index a351ef40..fe7c60a4 100644
--- a/docs/guide/localization.md
+++ b/docs/guide/localization.md
@@ -14,30 +14,6 @@ For example, you can import the German locale:
You can also build your own Faker instances, with custom locales/overwrites.
:::
-## Individual localized packages
-
-Currently, the imports from the main package have a [bug](https://github.com/faker-js/faker/issues/1791) and always cause the entire Faker lib to be imported.
-This might result in loading around 5 MB of data into memory and slow down startup times.
-
-_But we got your back!_
-When encountering such a problem in a test or production environment, you can use the individual localized packages.
-
-```ts
-import { faker } from '@faker-js/faker/locale/de';
-```
-
-This will then just load the German locales with additional English locales as fallback. The fallback is required due to not all locales containing data for all features. If you encounter a missing locale entry in your selected language, feel free to open a Pull Request fixing that issue.
-
-::: info Info
-The English locales are around 600 KB in size.
-All locales together are around 5 MB in size.
-:::
-
-::: tip Note
-Some locales have limited coverage and rely more heavily on the English locale as the source for features they currently do not have.
-However, in most cases, using a specific locale will be beneficial in the long term as specifying a locale reduces the time necessary for startup, which has a compounding effect on testing frameworks that reload the imports every execution.
-:::
-
## Custom locales and fallbacks
If our built-in faker instances don't satisfy your needs, you can build your own:
@@ -152,6 +128,11 @@ The `Locale` (data) and `Faker` columns refer to the respective `import` names:
import { de, fakerDE } from '@faker-js/faker';
```
+::: tip Note
+Some locales have limited coverage and rely more heavily on the English locale as the source for features they currently do not have.
+However, in most cases, using a specific locale will be beneficial in the long term as specifying a locale reduces the time necessary for startup, which has a compounding effect on testing frameworks that reload the imports every execution.
+:::
+
## Locale codes
Locales are named in a systematic way. The first two characters are a lowercase language code following the [ISO 639-1 standard](https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes) for example `ar` for Arabic or `en` for English.
diff --git a/docs/guide/upgrading_v9/2790.md b/docs/guide/upgrading_v9/2790.md
new file mode 100644
index 00000000..f4c99b02
--- /dev/null
+++ b/docs/guide/upgrading_v9/2790.md
@@ -0,0 +1,18 @@
+### Fix Tree Shaking
+
+Prior to this version, users had to resort to workarounds by importing specific faker instances from dedicated paths to overcome tree shaking issues.
+
+```ts
+import { faker } from '@faker-js/faker/locale/de';
+```
+
+With the implementation of this fix, such workarounds should no longer be necessary.
+That means that you should be able to import different localized faker instances from the root of your package.
+
+```ts
+import { fakerDE, fakerES, fakerFR } from '@faker-js/faker';
+```
+
+The dedicated import paths will still stay for now, to allow a gradual migration for our users.
+
+While the implementation of this change does not constitute as breaking according to semantic versioning guidelines, it does impact the behavior of users bundlers.