diff options
| author | Shinigami <[email protected]> | 2022-09-11 20:23:42 +0800 |
|---|---|---|
| committer | GitHub <[email protected]> | 2022-09-11 14:23:42 +0200 |
| commit | 8db9d6e8743d080431093b643b0a238d73c422e8 (patch) | |
| tree | da45e5432fbc232245922db569dc748af4c113f3 /docs/guide | |
| parent | 4efa530e5924e78712c220c9b4f4a0cf41cb5167 (diff) | |
| download | faker-8db9d6e8743d080431093b643b0a238d73c422e8.tar.xz faker-8db9d6e8743d080431093b643b0a238d73c422e8.zip | |
docs: upgrading guide (#1365)
Co-authored-by: Leyla Jähnig [email protected]
Co-authored-by: ST-DDT [email protected]
Diffstat (limited to 'docs/guide')
| -rw-r--r-- | docs/guide/migration-guide-v5.md | 83 | ||||
| -rw-r--r-- | docs/guide/upgrading.md (renamed from docs/guide/migration-guide-v6.md) | 11 |
2 files changed, 10 insertions, 84 deletions
diff --git a/docs/guide/migration-guide-v5.md b/docs/guide/migration-guide-v5.md deleted file mode 100644 index 13f23c3a..00000000 --- a/docs/guide/migration-guide-v5.md +++ /dev/null @@ -1,83 +0,0 @@ -# Migrating from Faker v5 to v6 - -## ESM Support - -**New Format**: We're now ESM compatible! We've dropped the Browser bundle in favor of ESM. - -So if you'd like to use `Faker` in the **browser**, simply include it using a [JavaScript module](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Modules#applying_the_module_to_your_html). - -```html -<script type="module"> - import { faker } from 'https://unpkg.com/@faker-js/faker'; - - console.log(`${faker.name.firstName()} ${faker.name.lastName()}`); -</script> -``` - -## Remove all references to `faker` from your project. The new package is located at `@faker-js/faker` - -:::warning -You **MUST** swap all references from the `faker` package to the new `@faker-js/faker` package. - -In addition to releasing all _future_ versions under the `@faker-js/faker` package namespace, we have also provided all _historical_ versions of Faker. - -If you depend on a specific version of Faker you still can reference the version directly. - -`npm i @faker-js/[email protected] -D` will work just fine 😄. -::: - -## TypeScript - -:::tip TypeScript Improvements -Faker now ships with its own types! Remove `@types/faker` from your `package.json` to avoid conflicts. -::: - -## Tree-shaking - -:::warning -Tree shaking is not yet fully supported due to some structural issues. But we plan to make Faker fully tree-shakable in the future. -::: - -For now Faker supports tree-shaking for some parts, and we highly recommend that you take advantage of your bundler's tree-shaking capabilities and change how you import Faker right now. - -Instead of using: - -```ts -// js -const faker = require('@faker-js/faker'); - -// ts -import faker from '@faker-js/faker'; -``` - -You should switch to: - -```ts -// js -const { faker } = require('@faker-js/faker'); - -// ts -import { faker } from '@faker-js/faker'; -``` - -If you only need one specific language, we highly recommend to make use of the locale specific imports like: - -```ts -// js -const fakerDe = require('@faker-js/faker/locale/de'); - -// ts -import fakerDe from '@faker-js/faker/locale/de'; -``` - -This is especially true if you're importing Faker in the browser. - -Faker is a giant package made up of many megabytes of strings. Only import what you need. - -_We plan to load the locales in another way in a future major release._ - ---- - -Happy Faking! - -- Shini, Jess, and the Faker Team diff --git a/docs/guide/migration-guide-v6.md b/docs/guide/upgrading.md index 6a91a143..ac95b6b5 100644 --- a/docs/guide/migration-guide-v6.md +++ b/docs/guide/upgrading.md @@ -1,4 +1,13 @@ -# Migrating from Faker v6 to v7 +# Upgrading to v7 + +This is the migration guide for upgrading from v6 to v7. + +::: info +Not the version you are looking for? + +- [v6.fakerjs.dev](https://v6.fakerjs.dev/migration-guide-v5/) + +::: ## Node 12 no longer supported |
