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').fakermodern js import faker from 'faker'
// or
import * as faker from 'faker'
// to
import { faker } from '@faker-js/faker' |
| // including name, address, company, date and commerce namespaces, moustache expressions and random element production | ||
| // 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.
This is the important line in this file.
I didn't touched the rest of this file, just auto-prettier on save.
|
|
||
| var faker = require('../../index'); | ||
|
|
||
| var faker = require('../../lib').faker; |
There was a problem hiding this comment.
This is the important line in this file.
I didn't touched the rest of this file, just auto-prettier on save.
| }, | ||
| "license": "MIT", | ||
| "main": "index.js", | ||
| "main": "lib/index.js", |
There was a problem hiding this comment.
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. |
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.
We need to add export default faker; here
BREAKING CHANGE: importing of faker changes
JessicaSachs
left a comment
There was a problem hiding this comment.
After the export default line is in, this lgtm
0dd1f74
3f991ea to
0dd1f74
Compare
BREAKING CHANGE: importing of faker changes