aboutsummaryrefslogtreecommitdiff
path: root/docs
diff options
context:
space:
mode:
authorDivisionByZero <[email protected]>2025-08-16 03:02:45 +0200
committerGitHub <[email protected]>2025-08-16 01:02:45 +0000
commitb16dd9a2ef1373478e51b14b019843394c6db85d (patch)
tree83d3a189c62699d35c1df079ec1a284e2c060309 /docs
parent9783d95a8e43c45bc44c5c0c546b250b6c2ae140 (diff)
downloadfaker-b16dd9a2ef1373478e51b14b019843394c6db85d.tar.xz
faker-b16dd9a2ef1373478e51b14b019843394c6db85d.zip
docs: update migration guide with findings from playground update (#3587)
Diffstat (limited to 'docs')
-rw-r--r--docs/guide/upgrading.md10
-rw-r--r--docs/guide/usage.md17
2 files changed, 24 insertions, 3 deletions
diff --git a/docs/guide/upgrading.md b/docs/guide/upgrading.md
index b2e64e21..b717ec96 100644
--- a/docs/guide/upgrading.md
+++ b/docs/guide/upgrading.md
@@ -25,7 +25,9 @@ v10 has not yet been released. This page contains a work-in-progress list of bre
Support for Node.js v18 has been discontinued, as this version has reached its [end-of-life](https://github.com/nodejs/Release). Faker.js v10 requires a minimum of Node.js v20.19.0, v22.13.0, or v24.0.0.
-### CommonJS Still Supported, but Check Your Node Version
+### CommonJS Still Supported, but Check Your Versions
+
+#### Node
Technically, Faker v10 is now an ESM-only package. However, the good news is that you can still use it from your CommonJS projects without code changes, thanks to the [ESM Modules require feature](https://nodejs.org/api/modules.html#loading-ecmascript-modules-using-require) in recent versions of Node.js.
@@ -43,6 +45,12 @@ Error [ERR_REQUIRE_ESM]: require() of ES Module <path>/faker/dist/index.js not s
Instead, change the require of index.js in null to a dynamic import(), which is available in all CommonJS modules.
```
+#### TypeScript
+
+As mentioned in the previous section, CJS can still be used if you use a modern module resolution strategy. This directly impacts your `tsconfig.json` setup.
+
+Previously, you were able to provide the values `"Bundler"`, `"Node10"`, `"Node16"` or `"NodeNext"` for the configuration `"moduleResulution"`. Starting in v10 of Faker, only the values `"Bundler"`, `"Node20"` or `"NodeNext"` are supported for your CJS codebase. [To use `"Node20"` your **`typescript` version must be at least `5.9.0`**](https://devblogs.microsoft.com/typescript/announcing-typescript-5-9/#support-for---module-node20).
+
### Removal of Deprecated Code
A number of methods that were deprecated in v9 have been completely removed in v10. To prepare for the upgrade, it is recommended to first upgrade to the latest version of v9 (e.g., `npm install --save-dev faker@9`) and fix any deprecation warnings issued by your code.
diff --git a/docs/guide/usage.md b/docs/guide/usage.md
index c6dfb4d8..9168e752 100644
--- a/docs/guide/usage.md
+++ b/docs/guide/usage.md
@@ -99,15 +99,28 @@ You can use Faker without it, but we don't have dedicated error messages for wro
In order to have Faker working properly, you need to check if these `compilerOptions` are set correctly in your `tsconfig` file:
-```json
+::: code-group
+
+```json [esm]
{
"compilerOptions": {
- "moduleResolution": "Bundler", // "Node10", "Node16" or "NodeNext"
+ "moduleResolution": "Bundler", // or "Node10", "Node16", "Node20", "NodeNext"
"strict": true // Optional, but recommended
}
}
```
+```json [cjs]
+{
+ "compilerOptions": {
+ "moduleResolution": "Bundler", // or "Node20" or "NodeNext"
+ "strict": true // Optional, but recommended
+ }
+}
+```
+
+:::
+
## Reproducible results
Normally Faker will give you different random values each time it is used.