@@ -67,7 +67,15 @@ bool isNodeJsCompatEnabled(auto featureFlags) {
67
67
return featureFlags.getNodeJsCompat () || featureFlags.getNodeJsCompatV2 ();
68
68
}
69
69
70
- bool isExperimentalNodeJsCompatModule (kj::StringPtr name);
70
+ constexpr bool isExperimentalNodeJsCompatModule (kj::StringPtr name) {
71
+ return name == " node:fs" _kj;
72
+ }
73
+
74
+ constexpr bool isNodeHttpModule (kj::StringPtr name) {
75
+ return name == " node:http" _kj || name == " node:_http_common" _kj ||
76
+ name == " node:_http_outgoing" _kj || name == " node:_http_client" _kj ||
77
+ name == " node:_http_incoming" _kj || name == " node:_http_agent" _kj || name == " node:https" _kj;
78
+ }
71
79
72
80
template <class Registry >
73
81
void registerNodeJsCompatModules (Registry& registry, auto featureFlags) {
@@ -85,7 +93,7 @@ void registerNodeJsCompatModules(Registry& registry, auto featureFlags) {
85
93
bool nodeJsCompatEnabled = isNodeJsCompatEnabled (featureFlags);
86
94
87
95
registry.addBuiltinBundleFiltered (NODE_BUNDLE, [&](jsg::Module::Reader module ) {
88
- // node:fs and node:http will be considered experimental until they are completed,
96
+ // node:fs will be considered experimental until it's completed,
89
97
// so unless the experimental flag is enabled, don't register them.
90
98
if (isExperimentalNodeJsCompatModule (module .getName ())) {
91
99
return featureFlags.getWorkerdExperimental ();
@@ -97,6 +105,12 @@ void registerNodeJsCompatModules(Registry& registry, auto featureFlags) {
97
105
return module .getType () == jsg::ModuleType::INTERNAL;
98
106
}
99
107
108
+ // We put node:http and node:https modules behind a compat flag
109
+ // for securing backward compatibility.
110
+ if (isNodeHttpModule (module .getName ())) {
111
+ return featureFlags.getEnableNodejsHttpModules ();
112
+ }
113
+
100
114
return true ;
101
115
});
102
116
0 commit comments