Skip to content

Commit 3ed48a6

Browse files
authored
Update compatibility-flags.mdx
1 parent 071a65a commit 3ed48a6

File tree

1 file changed

+18
-8
lines changed

1 file changed

+18
-8
lines changed

src/content/docs/workers/configuration/compatibility-flags.mdx

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -45,17 +45,18 @@ Compatibility flags can be set when uploading a Worker using the [Workers Script
4545

4646
## Node.js compatibility flag
4747

48-
:::note
49-
You can opt into improved Node.js compatibility by using `nodejs_compat_v2` instead of `nodejs_compat`. This provides the functionality of `nodejs_compat`, but
50-
additionally you can import Node.js modules without the `node:` prefix and use polyfilled Node.js modules and globals that are not available with `nodejs_compat`.
48+
To enable both built-in runtime APIs and polyfills for your Worker or Pages project, add the [`nodejs_compat`](/workers/configuration/compatibility-flags/#nodejs-compatibility-flag) [compatibility flag](/workers/configuration/compatibility-flags/#nodejs-compatibility-flag) to your `wrangler.toml`, and set your compatibility date to September 23rd, 2024 or later.
5149

52-
On September 23, 2024, `nodejs_compat` will use the improved Node.js compatibility currently enabled with `nodejs_compat_v2`. This will require updating your
53-
compatibility_date to 2024-09-23 or later.
54-
:::
50+
import { WranglerConfig } from "~/components";
5551

56-
A [growing subset](/workers/runtime-apis/nodejs/) of Node.js APIs are available directly as [Runtime APIs](/workers/runtime-apis/nodejs), with no need to add polyfills to your own code. To enable these APIs in your Worker, add the `nodejs_compat` compatibility flag to your `wrangler.toml`:
52+
<WranglerConfig>
5753

54+
```toml title="wrangler.toml"
55+
compatibility_flags = [ "nodejs_compat" ]
56+
compatibility_date = "2024-09-23"
57+
```
5858

59+
A [growing subset](/workers/runtime-apis/nodejs/) of Node.js APIs are available directly as [Runtime APIs](/workers/runtime-apis/nodejs), with no need to add polyfills to your own code. To enable these APIs in your Worker, only the `nodejs_compat` compatibility flag is required:
5960

6061
<WranglerConfig>
6162

@@ -67,9 +68,18 @@ compatibility_flags = [ "nodejs_compat" ]
6768

6869
As additional Node.js APIs are added, they will be made available under the `nodejs_compat` compatibility flag. Unlike most other compatibility flags, we do not expect the `nodejs_compat` to become active by default at a future date.
6970

70-
The Node.js `AsyncLocalStorage` API is a particularly useful feature for Workers. To enable only the `AsyncLocalStorage` API, use the `nodejs_als` compatibility flag.
71+
To enable Node.js compatibility with the ability to import Node.js modules without the `node:` prefix and with additional polyfilling for Node.js modules that are not available with `nodejs_compat`, specify a compatibility date of `2024-09-23` or later.
72+
73+
<WranglerConfig>
7174

75+
```toml title="wrangler.toml"
76+
compatibility_flags = [ "nodejs_compat" ]
77+
compatibility_date = "2024-09-23"
78+
```
7279

80+
</WranglerConfig>
81+
82+
The Node.js `AsyncLocalStorage` API is a particularly useful feature for Workers. To enable only the `AsyncLocalStorage` API, use the `nodejs_als` compatibility flag.
7383

7484
<WranglerConfig>
7585

0 commit comments

Comments
 (0)