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/// List of node.js internals that are supported by edge runtime.
74/// If anything Node.js builtin module apart from these these imports are
75/// used and user does not provide alias for the polyfill, a runtime error will be thrown.
76/// See https://vercel.com/docs/functions/runtimes/edge-runtime#compatible-node.js-modules
77// SAFETY: This has to be sorted alphabetically since we are doing binary search on it
78pub const EDGE_NODE_EXTERNALS: [&str; 7] = [
79    "assert",
80    "assert/strict",
81    "async_hooks",
82    "buffer",
83    "events",
84    "util",
85    "util/types",
86];
87
88pub const BUN_EXTERNALS: [&str; 6] = [
89    "bun",
90    "bun:ffi",
91    "bun:jsc",
92    "bun:sqlite",
93    "bun:test",
94    "bun:wrap",
95];
96
97#[cfg(test)]
98mod tests {
99    use super::*;
100
101    #[test]
102    fn test_node_externals_sorted() {
103        assert!(NODE_EXTERNALS.is_sorted())
104    }
105
106    #[test]
107    fn test_edge_node_externals_sorted() {
108        assert!(EDGE_NODE_EXTERNALS.is_sorted())
109    }
110
111    #[test]
112    fn test_bun_externals_sorted() {
113        assert!(BUN_EXTERNALS.is_sorted())
114    }
115}