Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Expose partial locale data for smaller bundle size #3590

@ST-DDT

Description

@ST-DDT

Clear and concise description of the problem

Currently anything inside a locale object such as en is never tree shaken even if you only need one submodule/language file from it. This applies also if you manually deconstruct and reassemble it.

Suggested solution

Add imports/exports for localization files.

E.g.

import { person } from '@faker-js/faker/locales/en';
import { firstName } from '@faker-js/faker/locales/en/person';

For my usecase it would be sufficient to get access on the module level e.g. person, but others may want to narrow it down more.

This might require some changes on how locale files are joined at least if the imports should be most convinient.

// module.ts
export first_name from './first_name';
// locale.ts
export * as person from './person';

Alternative

Alt1) Provide other ways to access subsets of locales.

Alt2) Combine #2667 with pre-built per locale nano instances.

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions