From e92ca5dc9f9ed2fc0de04f465f7545ccdf161fbf Mon Sep 17 00:00:00 2001 From: xDivisionByZerox Date: Wed, 7 Aug 2024 19:59:50 +0200 Subject: [PATCH 1/3] wip --- .../2024-08-31-whats-new-in-9-0.md | 108 ++++++++++++++++++ docs/guide/upgrading.md | 42 +------ 2 files changed, 109 insertions(+), 41 deletions(-) create mode 100644 docs/about/announcements/2024-08-31-whats-new-in-9-0.md diff --git a/docs/about/announcements/2024-08-31-whats-new-in-9-0.md b/docs/about/announcements/2024-08-31-whats-new-in-9-0.md new file mode 100644 index 00000000000..f76cca0ac9f --- /dev/null +++ b/docs/about/announcements/2024-08-31-whats-new-in-9-0.md @@ -0,0 +1,108 @@ +# What's New In v9.0 + +::: info Looking for the migration guide? +This article is a focusing on changes happened in the development of v9 that are on the more interesting side. +If you are just looking for a way to migrate from v8 to v9 check out our [migration guide](https://v9.fakerjs.dev/guide/upgrading). +::: + +## Optimizing Bundle Size with Tree-Shaking + +In the upcoming release of Faker.js, we’ve tackled an important issue related to bundle size. The problem? Unnecessary modules were being included during tree-shaking, leading to bloated final bundles. But fear not! We’ve got a solution. + +The root problem was located in the way we handled locale imports and exports. Previously, the `allLocales` variable was defined using a named wild card export (`export * as from ''`). We refactored this into an named variable export. Additionally, we updated the package.json file to specify `"sideEffects": false`, signaling to bundlers that all files within this package are side-effect-free and can be safely tree-shaken. + +The results speak for themselves. + +| v8.4.1 | v9.0.0 | +| -------- | ------- | +| 2.77 MiB | 438 KiB | + +That’s a significant reduction of around 84.5% in file size! + +## Use High Precision RNG by Default + +In v9 we switch from a 32 bit random value to a 53 bit random value. +We don't change the underlying algorithm much, but we now consume two seed values each step instead of one. +This affects generated values in two ways: + +- In large lists or long numbers the values are spread more evenly. + This also reduces the number of duplicates it generates. + For `faker.number.int()` this reduces the number of duplicates from `1 / 10_000` to less than `1 / 8_000_000`. +- If you start with the same initial seed to generate a value, you might see some changes in the results you get. + This is because we're now working with a higher precision, which affects how numbers are rounded off. + As a result, the methods we use might produce slightly different outcomes. + And since we are now using two seed values each time subsequent results appear to skip a value each time. + +```ts +import { + SimpleFaker, + generateMersenne32Randomizer, + generateMersenne53Randomizer, +} from '@faker-js/faker'; + +// < v9 default +const oldFaker = new SimpleFaker({ + randomizer: generateMersenne32Randomizer(), +}); +oldFaker.seed(123); +const oldValue = oldFaker.helpers.multiple(() => oldFaker.number.int(10), { + count: 10, +}); +// > v9 default +const newFaker = new SimpleFaker({ + randomizer: generateMersenne53Randomizer(), +}); +newFaker.seed(123); +const newValue = newFaker.helpers.multiple(() => newFaker.number.int(10), { + count: 5, +}); + +diff(oldValue, newValue); +//[ +// 7, +// 7, // [!code --] +// 3, +// 4, // [!code --] +// 2, +// 7, // [!code --] +// 6, +// 7, // [!code --] +// 7, +// 5, // [!code --] +//] +``` + +## New Modules + +We are thrilled to announce the latest addition to FakerJS – the [FoodModule](https://v9.fakerjs.dev/api/food.html)! +Whether you’re building a restaurant app, a food blog, or just need some delicious data for testing, the Food Module has got you covered. +From spices to vegetables, meats, and fruits, you can generate a wide variety of ingredients to spice up your data. +Or make your applications more engaging with unique and mouth-watering dish names and descriptions. +Whether you need a single ingredient or a full menu, the Food Module offers the flexibility to meet your needs. + +Additionally, the [MusicModule](https://v9.fakerjs.dev/api/music.html) now featuring two brand-new methods: `album()` and `artist()`! +These additions will enhance your music-related projects by providing more detailed and diverse data. +Get the update and enjoy the latest tunes! + +## More Localized Data + +## Release Automation + +In our continuous effort to streamline and enhance the release process for Faker, we recently implemented the first steps required for our automated release pipeline. +This initiative aims to improve efficiency, reduce manual errors, and ensure a smoother release cycle. +Matter of fact this version was released using our new process. + +Our new process consists of 4 key steps: + +1. [Create a release Pull Request](https://github.com/faker-js/faker/pull/2981) +1. [Have an additional CI suite that tests against our playground](https://github.com/faker-js/faker/pull/2988) +1. [Create a GitHub Release](https://github.com/faker-js/faker/pull/2990) +1. [Release the latest version to npm](https://github.com/faker-js/faker/pull/2991) + +This allows us to kick off the process with a single manual schedule of the PR creation job. +This PR will then run an additional test CI (in parallel to our normal one) against our [playground repo](https://github.com/faker-js/playground). +If the PR is successfully merged another job is automatically started to create a draft GitHub Release. +This allows us to verify the correctness of the release one last time. +By publishing the GitHub release, the last job will kick in to publish this release to npm. +All these steps where done manually by the maintainers, previously. + diff --git a/docs/guide/upgrading.md b/docs/guide/upgrading.md index 4d9ae22dca4..b5096e2e58a 100644 --- a/docs/guide/upgrading.md +++ b/docs/guide/upgrading.md @@ -60,50 +60,10 @@ While this is not a breaking change according to semantic versioning guidelines, ### Use High Precision RNG by Default -TLDR: Many Faker methods return a different result in v9 compared to v8 for the same seed. - In v9 we switch from a 32 bit random value to a 53 bit random value. We don't change the underlying algorithm much, but we now consume two seed values each step instead of one. -This affects generated values in two ways: - -- In large lists or long numbers the values are spread more evenly. - This also reduces the number of duplicates it generates. - For `faker.number.int()` this reduces the number of duplicates from `1 / 10_000` to less than `1 / 8_000_000`. -- If you start with the same initial seed to generate a value, you might see some changes in the results you get. - This is because we're now working with a higher precision, which affects how numbers are rounded off. - As a result, the methods we use might produce slightly different outcomes. - And since we are now using two seed values each time subsequent results appear to skip a value each time. -```ts -import { - SimpleFaker, - generateMersenne32Randomizer, - generateMersenne53Randomizer, -} from '@faker-js/faker'; - -// < v9 default -const f32 = new SimpleFaker({ randomizer: generateMersenne32Randomizer() }); -f32.seed(123); -const r32 = f32.helpers.multiple(() => f32.number.int(10), { count: 10 }); -// > v9 default -const f53 = new SimpleFaker({ randomizer: generateMersenne53Randomizer() }); -f53.seed(123); -const r53 = f53.helpers.multiple(() => f53.number.int(10), { count: 5 }); - -diff(r32, r53); -//[ -// 7, -// 7, // [!code --] -// 3, -// 4, // [!code --] -// 2, -// 7, // [!code --] -// 6, -// 7, // [!code --] -// 7, -// 5, // [!code --] -//] -``` +You can read more in out Blog Post: [What's New In v9.0](/about/announcements/2024-08-31-whats-new-in-9-0.md) #### Adoption From 49c38fdc01e19640ffa457012f7a5631d3e4fe29 Mon Sep 17 00:00:00 2001 From: xDivisionByZerox Date: Fri, 4 Oct 2024 17:20:28 +0200 Subject: [PATCH 2/3] docs: remove new locales section --- docs/about/announcements/2024-08-31-whats-new-in-9-0.md | 2 -- 1 file changed, 2 deletions(-) diff --git a/docs/about/announcements/2024-08-31-whats-new-in-9-0.md b/docs/about/announcements/2024-08-31-whats-new-in-9-0.md index f76cca0ac9f..a4aec06e2e5 100644 --- a/docs/about/announcements/2024-08-31-whats-new-in-9-0.md +++ b/docs/about/announcements/2024-08-31-whats-new-in-9-0.md @@ -84,8 +84,6 @@ Additionally, the [MusicModule](https://v9.fakerjs.dev/api/music.html) now featu These additions will enhance your music-related projects by providing more detailed and diverse data. Get the update and enjoy the latest tunes! -## More Localized Data - ## Release Automation In our continuous effort to streamline and enhance the release process for Faker, we recently implemented the first steps required for our automated release pipeline. From 847d4974dfa5ddc36439e422213c863a7e207c58 Mon Sep 17 00:00:00 2001 From: xDivisionByZerox Date: Fri, 4 Oct 2024 17:30:34 +0200 Subject: [PATCH 3/3] docs: add section link to high precision section in upgrading --- docs/guide/upgrading.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/guide/upgrading.md b/docs/guide/upgrading.md index b5096e2e58a..849647bad3a 100644 --- a/docs/guide/upgrading.md +++ b/docs/guide/upgrading.md @@ -63,7 +63,7 @@ While this is not a breaking change according to semantic versioning guidelines, In v9 we switch from a 32 bit random value to a 53 bit random value. We don't change the underlying algorithm much, but we now consume two seed values each step instead of one. -You can read more in out Blog Post: [What's New In v9.0](/about/announcements/2024-08-31-whats-new-in-9-0.md) +You can read more in out Blog Post: [What's New In v9.0](/about/announcements/2024-08-31-whats-new-in-9-0#use-high-precision-rng-by-default) #### Adoption