-
-
Notifications
You must be signed in to change notification settings - Fork 929
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
feat!: support tree-shaking #152
Conversation
✔️ Deploy Preview for vigilant-wescoff-04e480 ready! 🔨 Explore the source changes: 0dd1f74 🔍 Inspect the deploy log: https://app.netlify.com/sites/vigilant-wescoff-04e480/deploys/61e70a128887330007952264 😎 Browse the preview: https://deploy-preview-152--vigilant-wescoff-04e480.netlify.app |
when we merge this, we need to write a migration guide or at least provide a RegExp replace pattern for out users legacy js const faker = require('faker')
// to
const { faker } = require('@faker-js/faker')
// or
const faker = require('@faker-js/faker').faker modern js import faker from 'faker'
// or
import * as faker from 'faker'
// to
import { faker } from '@faker-js/faker' |
// Using the helper function arr, randomly sized collections of elements are produced in the document. | ||
|
||
var faker = require('../../lib').faker; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the important line in this file.
I didn't touched the rest of this file, just auto-prettier on save.
@@ -1,19 +1,26 @@ | |||
var fs = require('fs'); | |||
|
|||
var faker = require('../../index'); | |||
|
|||
var faker = require('../../lib').faker; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the important line in this file.
I didn't touched the rest of this file, just auto-prettier on save.
@@ -22,7 +22,7 @@ | |||
"url": "https://github.com/faker-js/faker.git" | |||
}, | |||
"license": "MIT", | |||
"main": "index.js", | |||
"main": "lib/index.js", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the most important line of this PR 🙂
This could affect how the browser version is used 🤔 if (typeof window === 'object') {
window.faker = faker;
} |
We need an integration test running in CI to validate both Node behavior and browser behavior of the legacy scenario before I think we can merge this. I also think that we move this to |
To me it's not such a critical change + I would like to do it now, cause the folks that migrate to us need to rewrite the import statements anyways. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me!
By semantic versioning, this would be a "next major version" change anyway, because it would be a possible breaking change. |
I'll mark this as |
v6 is currently the next major change, we just released alphas, so nothing wrong with that from my POV
Could you explain what you mean what test do we need? Currently all ~20k are passing and I'm very happy that we have so much. I may provide a regex-pattern and/or a sed-command so folks can easily update. Edit: created an issue for that #212 |
// since we are requiring the top level of faker, load all locales by default | ||
export const faker: Faker = new Faker({ | ||
locales: require('./locales'), | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need to add export default faker;
here
BREAKING CHANGE: importing of faker changes
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
After the export default line is in, this lgtm
0dd1f74
3f991ea
to
0dd1f74
Compare
BREAKING CHANGE: importing of faker changes