Skip to main content

next_taskless/
constants.rs

1// SAFETY: This has to be sorted alphabetically since we are doing binary search on it
2pub const NODE_EXTERNALS: [&str; 68] = [
3    "_http_agent",
4    "_http_client",
5    "_http_common",
6    "_http_incoming",
7    "_http_outgoing",
8    "_http_server",
9    "_stream_duplex",
10    "_stream_passthrough",
11    "_stream_readable",
12    "_stream_transform",
13    "_stream_wrap",
14    "_stream_writable",
15    "_tls_common",
16    "_tls_wrap",
17    "assert",
18    "assert/strict",
19    "async_hooks",
20    "buffer",
21    "child_process",
22    "cluster",
23    "console",
24    "constants",
25    "crypto",
26    "dgram",
27    "diagnostics_channel",
28    "dns",
29    "dns/promises",
30    "domain",
31    "events",
32    "fs",
33    "fs/promises",
34    "http",
35    "http2",
36    "https",
37    "inspector",
38    "module",
39    "net",
40    "os",
41    "path",
42    "path/posix",
43    "path/win32",
44    "perf_hooks",
45    "pnpapi",
46    "process",
47    "punycode",
48    "querystring",
49    "readline",
50    "readline/promises",
51    "repl",
52    "stream",
53    "stream/consumers",
54    "stream/promises",
55    "stream/web",
56    "string_decoder",
57    "sys",
58    "timers",
59    "timers/promises",
60    "tls",
61    "trace_events",
62    "tty",
63    "url",
64    "util",
65    "util/types",
66    "v8",
67    "vm",
68    "wasi",
69    "worker_threads",
70    "zlib",
71];
72
73/// The Node.js built-in modules that are supported by edge runtime.
74///
75/// If any Node.js builtin module apart from these these imports are used and the user does not
76/// provide an alias for it (i.e. a polyfill), a runtime error will be thrown.
77///
78/// See <https://vercel.com/docs/functions/runtimes/edge-runtime#compatible-node.js-modules>
79//
80// SAFETY: This has to be sorted alphabetically since we are doing binary search on it
81pub const EDGE_NODE_EXTERNALS: [&str; 7] = [
82    "assert",
83    "assert/strict",
84    "async_hooks",
85    "buffer",
86    "events",
87    "util",
88    "util/types",
89];
90
91pub const BUN_EXTERNALS: [&str; 6] = [
92    "bun",
93    "bun:ffi",
94    "bun:jsc",
95    "bun:sqlite",
96    "bun:test",
97    "bun:wrap",
98];
99
100#[cfg(test)]
101mod tests {
102    use super::*;
103
104    #[test]
105    fn test_node_externals_sorted() {
106        assert!(NODE_EXTERNALS.is_sorted())
107    }
108
109    #[test]
110    fn test_edge_node_externals_sorted() {
111        assert!(EDGE_NODE_EXTERNALS.is_sorted())
112    }
113
114    #[test]
115    fn test_bun_externals_sorted() {
116        assert!(BUN_EXTERNALS.is_sorted())
117    }
118}