Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build: add redirect aliases for cjs #520

Merged
merged 1 commit into from
Feb 19, 2022
Merged

Conversation

Shinigami92
Copy link
Member

Our package.jsons exports field seems not to work for any case 🤔
This creates a locale/<locale>.js file for every locale when bundling for cjs so node/npm versions that does not support the exports field can use these redirects.

At least this should work for now and we can release a 6.0.0 soon

@codecov
Copy link

codecov bot commented Feb 19, 2022

Codecov Report

❗ No coverage uploaded for pull request base (main@41ec6f0). Click here to learn what that means.
The diff coverage is n/a.

@@           Coverage Diff           @@
##             main     #520   +/-   ##
=======================================
  Coverage        ?   99.34%           
=======================================
  Files           ?     1919           
  Lines           ?   176294           
  Branches        ?      904           
=======================================
  Hits            ?   175137           
  Misses          ?     1101           
  Partials        ?       56           

@Shinigami92
Copy link
Member Author

Tested successfully with my locale playground against esm and cjs + with json-schema-faker

@Shinigami92 Shinigami92 marked this pull request as ready for review February 19, 2022 21:56
@Shinigami92 Shinigami92 requested a review from a team as a code owner February 19, 2022 21:56
@ST-DDT
Copy link
Member

ST-DDT commented Feb 19, 2022

Should we do the same for locales?

@Shinigami92
Copy link
Member Author

Should we do the same for locales?

locales is not exported from the package.json

This is only for usage of

  1. require(@faker-js/faker) (package.json ->
    "main": "dist/cjs/index.js",
    )
  2. require(@faker-js/faker/locale/<locale>)

everything else is not supported (currently)

scripts/bundle.ts Show resolved Hide resolved
@ST-DDT ST-DDT requested a review from a team February 19, 2022 22:38
@Shinigami92 Shinigami92 merged commit 7d806d9 into main Feb 19, 2022
@Shinigami92 Shinigami92 deleted the redirect-aliases-for-cjs branch February 19, 2022 22:56
demipel8 pushed a commit to demipel8/faker that referenced this pull request Mar 11, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
p: 2-high Fix main branch
Projects
None yet
Development

Successfully merging this pull request may close these issues.

cjs: Importing specific locale in jest test fails with 'Cannot find module'
3 participants