minifaker
minifaker copied to clipboard
Importing localsccurs
Hello,
When we try importing locals an error
import 'minifaker/locales/en';
An error occurs in this example I used parcel
@parcel/core: Failed to resolve 'minifaker/locales/en' from './src/index.js'
My solution was importing the locals directaly:
import '../node_modules/minifaker/dist/esm/locales/en';
I think is better to define a default local or add a method to set the locals
minifaker.setLocal('en');
Thank you man 🙏
I found in the type a setDefaultLocale()
but doesn't work, is better to update the documentation please.
hmmm I don't think parcel support conditionnal exports https://nodejs.org/api/packages.html#conditional-exports I could be wrong though
In the mean time you can use
import 'minifaker/dist/esm/locales/en'
You don't have to use setDefaultLocale()
Yeah, the import as you mention is working fine, I wish that if you found some time to update the documentation is gonna be great.
Thank you a lot man
I also found the similar problem when using minifaker
in jest
tests.

Solved by adding this line in jest.config.js
transformIgnorePatterns: ['node_modules/(?!minifaker)']
And this line into compilerOptions
in tsconfig.spec.json
"allowJs": true
Not sure if it was related to this issue or not?
I also have this problem when running e2e tests on NestJs and that didn't fix it for me.