Skip to content

Commit 4851955

Browse files
authored
native node:fs and node:os are no more experimental (#10498)
1 parent 22c8ae6 commit 4851955

File tree

5 files changed

+35
-89
lines changed

5 files changed

+35
-89
lines changed

.changeset/spicy-sloths-divide.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
---
2+
"@cloudflare/unenv-preset": patch
3+
---
4+
5+
enabled native `node:fs` and `node:os` modules.
6+
7+
native `node:fs` is used when the `enable_nodejs_fs_module` is set or by default starting from 2025-09-15.
8+
9+
native `node:os` is used when the `enable_nodejs_os_module` is set or by default starting from 2025-09-15

packages/unenv-preset/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@
4949
},
5050
"peerDependencies": {
5151
"unenv": "2.0.0-rc.19",
52-
"workerd": "^1.20250823.0"
52+
"workerd": "^1.20250827.0"
5353
},
5454
"peerDependenciesMeta": {
5555
"workerd": {

packages/unenv-preset/src/preset.ts

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -132,11 +132,12 @@ export function getCloudflarePreset({
132132
* Returns the overrides for node http modules (unenv or workerd)
133133
*
134134
* The native http implementation (excluding server APIs):
135-
* - is enabled after 2025-08-15
135+
* - is enabled starting from 2025-08-15
136136
* - can be enabled with the "enable_nodejs_http_modules" flag
137137
* - can be disabled with the "disable_nodejs_http_modules" flag
138138
*
139139
* The native http server APIS implementation:
140+
* - is enabled starting from 2025-09-15
140141
* - can be enabled with the "enable_nodejs_http_server_modules" flag
141142
* - can be disabled with the "disable_nodejs_http_server_modules" flag
142143
*/
@@ -196,12 +197,12 @@ function getHttpOverrides({
196197
/**
197198
* Returns the overrides for `node:os` (unenv or workerd)
198199
*
199-
* The native http implementation:
200+
* The native os implementation:
201+
* - is enabled starting from 2025-09-15
200202
* - can be enabled with the "enable_nodejs_os_module" flag
201203
* - can be disabled with the "disable_nodejs_os_module" flag
202204
*/
203205
function getOsOverrides({
204-
// eslint-disable-next-line unused-imports/no-unused-vars
205206
compatibilityDate,
206207
compatibilityFlags,
207208
}: {
@@ -212,12 +213,10 @@ function getOsOverrides({
212213
"disable_nodejs_os_module"
213214
);
214215

215-
const enabledByFlag =
216-
compatibilityFlags.includes("enable_nodejs_os_module") &&
217-
compatibilityFlags.includes("experimental");
216+
const enabledByFlag = compatibilityFlags.includes("enable_nodejs_os_module");
217+
const enabledByDate = compatibilityDate >= "2025-09-15";
218218

219-
// TODO: add `enabledByDate` when a default date is set
220-
const enabled = enabledByFlag && !disabledByFlag;
219+
const enabled = (enabledByFlag || enabledByDate) && !disabledByFlag;
221220

222221
// The native os module implements all the APIs.
223222
// It can then be used as a native module.
@@ -236,11 +235,11 @@ function getOsOverrides({
236235
* Returns the overrides for `node:fs` and `node:fs/promises` (unenv or workerd)
237236
*
238237
* The native fs implementation:
238+
* - is enabled starting from 2025-09-15
239239
* - can be enabled with the "enable_nodejs_fs_module" flag
240240
* - can be disabled with the "disable_nodejs_fs_module" flag
241241
*/
242242
function getFsOverrides({
243-
// eslint-disable-next-line unused-imports/no-unused-vars
244243
compatibilityDate,
245244
compatibilityFlags,
246245
}: {
@@ -251,12 +250,10 @@ function getFsOverrides({
251250
"disable_nodejs_fs_module"
252251
);
253252

254-
const enabledByFlag =
255-
compatibilityFlags.includes("enable_nodejs_fs_module") &&
256-
compatibilityFlags.includes("experimental");
253+
const enabledByFlag = compatibilityFlags.includes("enable_nodejs_fs_module");
254+
const enabledByDate = compatibilityDate >= "2025-09-15";
257255

258-
// TODO: add `enabledByDate` when a default date is set
259-
const enabled = enabledByFlag && !disabledByFlag;
256+
const enabled = (enabledByFlag || enabledByDate) && !disabledByFlag;
260257

261258
// The native `fs` and `fs/promises` modules implement all the node APIs so we can use them directly
262259
return enabled

packages/wrangler/e2e/unenv-preset/preset.test.ts

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -98,26 +98,25 @@ const testConfigs: TestConfig[] = [
9898
[
9999
{
100100
name: "os disabled by date",
101-
compatibilityDate: "2025-07-26",
102-
compatibilityFlags: ["experimental"],
101+
compatibilityDate: "2024-09-23",
103102
expectRuntimeFlags: {
104103
enable_nodejs_os_module: false,
105104
},
106105
},
107-
// TODO: add a config when os is enabled by default (date no set yet)
106+
// TODO: add a config when os is enabled by default (>= 2025-09-15)
108107
{
109108
name: "os enabled by flag",
110-
compatibilityDate: "2025-07-26",
111-
compatibilityFlags: ["enable_nodejs_os_module", "experimental"],
109+
compatibilityDate: "2024-09-23",
110+
compatibilityFlags: ["enable_nodejs_os_module"],
112111
expectRuntimeFlags: {
113112
enable_nodejs_os_module: true,
114113
},
115114
},
116-
// TODO: change the date pass the default enabled date (date not set yet)
115+
// TODO: change the date pass the default enabled date (>= 2025-09-15)
117116
{
118117
name: "os disabled by flag",
119118
compatibilityDate: "2025-07-26",
120-
compatibilityFlags: ["disable_nodejs_os_module", "experimental"],
119+
compatibilityFlags: ["disable_nodejs_os_module"],
121120
expectRuntimeFlags: {
122121
enable_nodejs_os_module: false,
123122
},
@@ -127,26 +126,25 @@ const testConfigs: TestConfig[] = [
127126
[
128127
{
129128
name: "fs disabled by date",
130-
compatibilityDate: "2025-07-26",
131-
compatibilityFlags: ["experimental"],
129+
compatibilityDate: "2024-09-23",
132130
expectRuntimeFlags: {
133131
enable_nodejs_fs_module: false,
134132
},
135133
},
136-
// TODO: add a config when fs is enabled by default (date no set yet)
134+
// TODO: add a config when fs is enabled by default (>= 2025-09-15)
137135
{
138136
name: "fs enabled by flag",
139-
compatibilityDate: "2025-07-26",
140-
compatibilityFlags: ["enable_nodejs_fs_module", "experimental"],
137+
compatibilityDate: "2024-09-23",
138+
compatibilityFlags: ["enable_nodejs_fs_module"],
141139
expectRuntimeFlags: {
142140
enable_nodejs_fs_module: true,
143141
},
144142
},
145-
// TODO: change the date pass the default enabled date (date not set yet)
143+
// TODO: change the date pass the default enabled date (>= 2025-09-15)
146144
{
147145
name: "fs disabled by flag",
148146
compatibilityDate: "2025-07-26",
149-
compatibilityFlags: ["disable_nodejs_fs_module", "experimental"],
147+
compatibilityFlags: ["disable_nodejs_fs_module"],
150148
expectRuntimeFlags: {
151149
enable_nodejs_fs_module: false,
152150
},

pnpm-lock.yaml

Lines changed: 2 additions & 60 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)