faker icon indicating copy to clipboard operation
faker copied to clipboard

Split the Faker class into smaller units

Open ST-DDT opened this issue 3 years ago • 0 comments

Clear and concise description of the problem

Currently the main Faker class contains many features most users don't need in their application.

Suggested solution

The main Faker class should be split into multiple units that build on top of each other:

  • CoreFaker (only seed and rng logic)
  • BaseFaker extends CoreFaker (all modules that don't depend on locales
  • LocalizedFaker extends BaseFaker (locale support, but no locale modules yet)
  • Faker extends LocalizedFaker (all default modules, same as now)

See also: https://github.com/faker-js/faker/discussions/805#discussioncomment-2690233

That way could users could just use baseFaker.string.uuid() and have a very minimal footprint after tree shaking.

The class names aren't final yet. This needs to be documented properly.

Alternative

No response

Additional context

No response

ST-DDT avatar Sep 06 '22 20:09 ST-DDT