Skip to content

Commit 7341223

Browse files
committed
[New] add support for node: prefix, in node 16+
1 parent cb466a6 commit 7341223

3 files changed

Lines changed: 90 additions & 1 deletion

File tree

core.json

Lines changed: 64 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,73 +1,132 @@
11
{
22
"assert": true,
3+
"node:assert": ">= 16",
34
"assert/strict": ">= 15",
5+
"node:assert/strict": ">= 16",
46
"async_hooks": ">= 8",
7+
"node:async_hooks": ">= 16",
58
"buffer_ieee754": "< 0.9.7",
69
"buffer": true,
10+
"node:buffer": ">= 16",
711
"child_process": true,
12+
"node:child_process": ">= 16",
813
"cluster": true,
14+
"node:cluster": ">= 16",
915
"console": true,
16+
"node:console": ">= 16",
1017
"constants": true,
18+
"node:constants": ">= 16",
1119
"crypto": true,
20+
"node:crypto": ">= 16",
1221
"_debug_agent": ">= 1 && < 8",
1322
"_debugger": "< 8",
1423
"dgram": true,
24+
"node:dgram": ">= 16",
1525
"diagnostics_channel": ">= 15.1",
26+
"node:diagnostics_channel": ">= 16",
1627
"dns": true,
28+
"node:dns": ">= 16",
1729
"dns/promises": ">= 15",
30+
"node:dns/promises": ">= 16",
1831
"domain": ">= 0.7.12",
32+
"node:domain": ">= 16",
1933
"events": true,
34+
"node:events": ">= 16",
2035
"freelist": "< 6",
2136
"fs": true,
37+
"node:fs": ">= 16",
2238
"fs/promises": [">= 10 && < 10.1", ">= 14"],
39+
"node:fs/promises": ">= 16",
2340
"_http_agent": ">= 0.11.1",
41+
"node:_http_agent": ">= 16",
2442
"_http_client": ">= 0.11.1",
43+
"node:_http_client": ">= 16",
2544
"_http_common": ">= 0.11.1",
45+
"node:_http_common": ">= 16",
2646
"_http_incoming": ">= 0.11.1",
47+
"node:_http_incoming": ">= 16",
2748
"_http_outgoing": ">= 0.11.1",
49+
"node:_http_outgoing": ">= 16",
2850
"_http_server": ">= 0.11.1",
51+
"node:_http_server": ">= 16",
2952
"http": true,
53+
"node:http": ">= 16",
3054
"http2": ">= 8.8",
55+
"node:http2": ">= 16",
3156
"https": true,
57+
"node:https": ">= 16",
3258
"inspector": ">= 8",
59+
"node:inspector": ">= 16",
3360
"_linklist": "< 8",
3461
"module": true,
62+
"node:module": ">= 16",
3563
"net": true,
64+
"node:net": ">= 16",
3665
"node-inspect/lib/_inspect": ">= 7.6 && < 12",
3766
"node-inspect/lib/internal/inspect_client": ">= 7.6 && < 12",
3867
"node-inspect/lib/internal/inspect_repl": ">= 7.6 && < 12",
3968
"os": true,
69+
"node:os": ">= 16",
4070
"path": true,
71+
"node:path": ">= 16",
4172
"path/posix": ">= 15.3",
73+
"node:path/posix": ">= 16",
4274
"path/win32": ">= 15.3",
75+
"node:path/win32": ">= 16",
4376
"perf_hooks": ">= 8.5",
77+
"node:perf_hooks": ">= 16",
4478
"process": ">= 1",
79+
"node:process": ">= 16",
4580
"punycode": true,
81+
"node:punycode": ">= 16",
4682
"querystring": true,
83+
"node:querystring": ">= 16",
4784
"readline": true,
85+
"node:readline": ">= 16",
4886
"repl": true,
87+
"node:repl": ">= 16",
4988
"smalloc": ">= 0.11.5 && < 3",
5089
"_stream_duplex": ">= 0.9.4",
90+
"node:_stream_duplex": ">= 16",
5191
"_stream_transform": ">= 0.9.4",
92+
"node:_stream_transform": ">= 16",
5293
"_stream_wrap": ">= 1.4.1",
94+
"node:_stream_wrap": ">= 16",
5395
"_stream_passthrough": ">= 0.9.4",
96+
"node:_stream_passthrough": ">= 16",
5497
"_stream_readable": ">= 0.9.4",
98+
"node:_stream_readable": ">= 16",
5599
"_stream_writable": ">= 0.9.4",
100+
"node:_stream_writable": ">= 16",
56101
"stream": true,
102+
"node:stream": ">= 16",
57103
"stream/promises": ">= 15",
104+
"node:stream/promises": ">= 16",
58105
"string_decoder": true,
106+
"node:string_decoder": ">= 16",
59107
"sys": [">= 0.6 && < 0.7", ">= 0.8"],
108+
"node:sys": ">= 16",
60109
"timers": true,
110+
"node:timers": ">= 16",
61111
"timers/promises": ">= 15",
112+
"node:timers/promises": ">= 16",
62113
"_tls_common": ">= 0.11.13",
114+
"node:_tls_common": ">= 16",
63115
"_tls_legacy": ">= 0.11.3 && < 10",
64116
"_tls_wrap": ">= 0.11.3",
117+
"node:_tls_wrap": ">= 16",
65118
"tls": true,
119+
"node:tls": ">= 16",
66120
"trace_events": ">= 10",
121+
"node:trace_events": ">= 16",
67122
"tty": true,
123+
"node:tty": ">= 16",
68124
"url": true,
125+
"node:url": ">= 16",
69126
"util": true,
127+
"node:util": ">= 16",
70128
"util/types": ">= 15.3",
129+
"node:util/types": ">= 16",
71130
"v8/tools/arguments": ">= 10 && < 12",
72131
"v8/tools/codemap": [">= 4.4 && < 5", ">= 5.2 && < 12"],
73132
"v8/tools/consarray": [">= 4.4 && < 5", ">= 5.2 && < 12"],
@@ -76,8 +135,12 @@
76135
"v8/tools/profile_view": [">= 4.4 && < 5", ">= 5.2 && < 12"],
77136
"v8/tools/splaytree": [">= 4.4 && < 5", ">= 5.2 && < 12"],
78137
"v8": ">= 1",
138+
"node:v8": ">= 16",
79139
"vm": true,
140+
"node:vm": ">= 16",
80141
"wasi": ">= 13.4 && < 13.5",
81142
"worker_threads": ">= 11.7",
82-
"zlib": true
143+
"node:worker_threads": ">= 16",
144+
"zlib": true,
145+
"node:zlib": ">= 16"
83146
}

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@
5353
"eslint": "^7.19.0",
5454
"nyc": "^10.3.2",
5555
"safe-publish-latest": "^1.1.4",
56+
"semver": "^6.3.0",
5657
"tape": "^5.1.1"
5758
},
5859
"auto-changelog": {

test/index.js

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,12 @@
22

33
var test = require('tape');
44
var keys = require('object-keys');
5+
var semver = require('semver');
56
var isCore = require('../');
67
var data = require('../core.json');
78

9+
var supportsNodePrefix = semver.satisfies(process.versions.node, '>= 16');
10+
811
test('core modules', function (t) {
912
t.test('isCore()', function (st) {
1013
st.ok(isCore('fs'));
@@ -48,6 +51,17 @@ test('core modules', function (t) {
4851
function () { require(mod); }, // eslint-disable-line no-loop-func
4952
'requiring ' + mod + ' does not throw'
5053
);
54+
if (supportsNodePrefix) {
55+
st.doesNotThrow(
56+
function () { require('node:' + mod); }, // eslint-disable-line no-loop-func
57+
'requiring node:' + mod + ' does not throw'
58+
);
59+
} else {
60+
st['throws'](
61+
function () { require('node:' + mod); }, // eslint-disable-line no-loop-func
62+
'requiring node:' + mod + ' throws'
63+
);
64+
}
5165
}
5266
}
5367
st.end();
@@ -73,6 +87,17 @@ test('core modules', function (t) {
7387
function () { require(mod); }, // eslint-disable-line no-loop-func
7488
'requiring ' + mod + ' does not throw'
7589
);
90+
if (supportsNodePrefix) {
91+
st.doesNotThrow(
92+
function () { require('node:' + mod); }, // eslint-disable-line no-loop-func
93+
'requiring node:' + mod + ' does not throw'
94+
);
95+
} else {
96+
st['throws'](
97+
function () { require('node:' + mod); }, // eslint-disable-line no-loop-func
98+
'requiring node:' + mod + ' throws'
99+
);
100+
}
76101
}
77102
}
78103
}

0 commit comments

Comments
 (0)