You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/content/docs/workers/configuration/compatibility-flags.mdx
+18-8Lines changed: 18 additions & 8 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -45,17 +45,18 @@ Compatibility flags can be set when uploading a Worker using the [Workers Script
45
45
46
46
## Node.js compatibility flag
47
47
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.
51
49
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";
55
51
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>
57
53
54
+
```toml title="wrangler.toml"
55
+
compatibility_flags = [ "nodejs_compat" ]
56
+
compatibility_date = "2024-09-23"
57
+
```
58
58
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:
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.
69
70
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>
71
74
75
+
```toml title="wrangler.toml"
76
+
compatibility_flags = [ "nodejs_compat" ]
77
+
compatibility_date = "2024-09-23"
78
+
```
72
79
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.
0 commit comments