1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
|
#include "root.h"
static constexpr ASCIILiteral builtinModuleNamesSortedLength[] = {
"fs"_s,
"os"_s,
"v8"_s,
"vm"_s,
"ws"_s,
"bun"_s,
"dns"_s,
"net"_s,
"sys"_s,
"tls"_s,
"tty"_s,
"url"_s,
"http"_s,
"path"_s,
"repl"_s,
"util"_s,
"wasi"_s,
"zlib"_s,
"dgram"_s,
"http2"_s,
"https"_s,
"assert"_s,
"buffer"_s,
"crypto"_s,
"domain"_s,
"events"_s,
"module"_s,
"stream"_s,
"timers"_s,
"undici"_s,
"bun:ffi"_s,
"bun:jsc"_s,
"cluster"_s,
"console"_s,
"process"_s,
"bun:wrap"_s,
"punycode"_s,
"bun:test"_s,
"bun:main"_s,
"readline"_s,
"_tls_wrap"_s,
"constants"_s,
"inspector"_s,
"bun:sqlite"_s,
"path/posix"_s,
"path/win32"_s,
"perf_hooks"_s,
"stream/web"_s,
"util/types"_s,
"_http_agent"_s,
"_tls_common"_s,
"async_hooks"_s,
"detect-libc"_s,
"fs/promises"_s,
"querystring"_s,
"_http_client"_s,
"_http_common"_s,
"_http_server"_s,
"_stream_wrap"_s,
"dns/promises"_s,
"trace_events"_s,
"assert/strict"_s,
"child_process"_s,
"_http_incoming"_s,
"_http_outgoing"_s,
"_stream_duplex"_s,
"string_decoder"_s,
"worker_threads"_s,
"stream/promises"_s,
"timers/promises"_s,
"_stream_readable"_s,
"_stream_writable"_s,
"stream/consumers"_s,
"_stream_transform"_s,
"readline/promises"_s,
"inspector/promises"_s,
"_stream_passthrough"_s,
"diagnostics_channel"_s,
};
namespace Bun {
bool isBuiltinModule(const String &namePossiblyWithNodePrefix) {
String name = namePossiblyWithNodePrefix;
if (name.startsWith("node:"_s))
name = name.substringSharingImpl(5);
for (auto &builtinModule : builtinModuleNamesSortedLength) {
if (name == builtinModule)
return true;
}
return false;
}
} // namespace Bun
|