Skip to content

Commit 77e369f

Browse files
authored
Update compat language to make nodejs_compat with polyfills the defau… (#19323)
* Update compat language to make nodejs_compat with polyfills the default, with more advanced setups providing the option to opt out of polyfills * Update src/content/partials/workers/nodejs_compat.mdx
1 parent d059a50 commit 77e369f

File tree

3 files changed

+26
-27
lines changed

3 files changed

+26
-27
lines changed

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

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -45,17 +45,11 @@ 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`.
51-
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-
:::
55-
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`:
48+
import { Render } from "~/components";
5749

50+
<Render file="nodejs_compat" product="workers" />
5851

52+
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:
5953

6054
<WranglerConfig>
6155

@@ -69,8 +63,6 @@ As additional Node.js APIs are added, they will be made available under the `nod
6963

7064
The Node.js `AsyncLocalStorage` API is a particularly useful feature for Workers. To enable only the `AsyncLocalStorage` API, use the `nodejs_als` compatibility flag.
7165

72-
73-
7466
<WranglerConfig>
7567

7668
```toml title="wrangler.toml"

src/content/docs/workers/runtime-apis/nodejs/index.mdx

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -18,22 +18,9 @@ You can view which APIs are supported using the [Node.js compatability matrix](h
1818

1919
## Get Started
2020

21-
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.
21+
import { Render } from "~/components";
2222

23-
import { WranglerConfig } from "~/components";
24-
25-
<WranglerConfig>
26-
27-
```toml title="wrangler.toml"
28-
compatibility_flags = [ "nodejs_compat" ]
29-
compatibility_date = "2024-09-23"
30-
```
31-
32-
</WranglerConfig>
33-
34-
:::note
35-
As of September 23rd, 2024, the `nodejs_compat` compatibility flag enables the exact same behavior as the `nodejs_compat_v2` compatibility flag, as long as your compatibility date is set to September 23rd, 2024 or later.
36-
:::
23+
<Render file="nodejs_compat" product="workers" />
3724

3825
## Built-in Node.js Runtime APIs
3926

@@ -68,7 +55,7 @@ If an API you wish to use is missing and you want to suggest that Workers suppor
6855

6956
To enable only the Node.js `AsyncLocalStorage` API, use the `nodejs_als` compatibility flag.
7057

71-
58+
import { WranglerConfig } from "~/components";
7259

7360
<WranglerConfig>
7461

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
---
2+
{}
3+
---
4+
5+
import { WranglerConfig } from "~/components";
6+
7+
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. This will enable [Node.js compatibility](/workers/runtime-apis/nodejs/) for your Workers project.
8+
9+
<WranglerConfig>
10+
11+
```toml title="wrangler.toml"
12+
compatibility_flags = [ "nodejs_compat" ]
13+
compatibility_date = "2024-09-23"
14+
```
15+
16+
</WranglerConfig>
17+
18+
:::note
19+
As of September 23rd, 2024, the `nodejs_compat` compatibility flag enables the exact same behavior as the `nodejs_compat_v2` compatibility flag, as long as your compatibility date is set to September 23rd, 2024 or later.
20+
:::

0 commit comments

Comments
 (0)