macro_rules! node_builtins_table {
(
compat: [ $( $c:literal ),* $(,)? ],
node_only: [ $( $n:literal ),* $(,)? ] $(,)?
) => {
pub const NODE_BUILTIN_PATTERNS_RAW: &[&[u8]] = &[
$( $c.as_bytes(), )*
$( $n.as_bytes(), )*
];
pub const NODE_BUILTIN_PATTERNS: &[&[u8]] = &[
$( $c.as_bytes(), )*
$( $n.as_bytes(), )*
$( concat!("node:", $c).as_bytes(), )*
$( concat!("node:", $n).as_bytes(), )*
];
pub const BUN_NODE_BUILTIN_PATTERNS_COMPAT: &[&[u8]] = &[
$( $c.as_bytes(), )*
];
};
}
node_builtins_table! {
compat: [
"_http_agent",
"_http_client",
"_http_common",
"_http_incoming",
"_http_outgoing",
"_http_server",
"_stream_duplex",
"_stream_passthrough",
"_stream_readable",
"_stream_transform",
"_stream_wrap",
"_stream_writable",
"_tls_common",
"_tls_wrap",
"assert",
"async_hooks",
"child_process",
"cluster",
"console",
"constants",
"crypto",
"dgram",
"diagnostics_channel",
"dns",
"domain",
"events",
"http",
"http2",
"https",
"inspector",
"module",
"net",
"os",
"perf_hooks",
"punycode",
"querystring",
"readline",
"repl",
"stream",
"string_decoder",
"sys",
"timers",
"tls",
"trace_events",
"tty",
"url",
"util",
"v8",
"vm",
"wasi",
"worker_threads",
"zlib",
],
node_only: [
"buffer",
"fs",
"path",
"process",
"test",
],
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn cardinalities_match_zig_spec() {
assert_eq!(NODE_BUILTIN_PATTERNS_RAW.len(), 57);
assert_eq!(NODE_BUILTIN_PATTERNS.len(), 57 * 2);
assert_eq!(BUN_NODE_BUILTIN_PATTERNS_COMPAT.len(), 52);
}
}