2024-01-01 14:58:21 -05:00
|
|
|
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
|
2023-02-10 10:26:39 -05:00
|
|
|
|
2023-05-28 14:44:41 -04:00
|
|
|
/// e.g. `is_builtin_node_module("assert")`
|
|
|
|
pub fn is_builtin_node_module(module_name: &str) -> bool {
|
2023-02-10 10:26:39 -05:00
|
|
|
SUPPORTED_BUILTIN_NODE_MODULES
|
|
|
|
.iter()
|
2023-07-02 14:19:30 -04:00
|
|
|
.any(|m| *m == module_name)
|
2023-02-10 10:26:39 -05:00
|
|
|
}
|
|
|
|
|
2023-07-02 14:19:30 -04:00
|
|
|
macro_rules! generate_builtin_node_module_lists {
|
|
|
|
($( $module_name:literal ,)+) => {
|
|
|
|
pub static SUPPORTED_BUILTIN_NODE_MODULES: &[&str] = &[
|
|
|
|
$(
|
|
|
|
$module_name,
|
|
|
|
)+
|
|
|
|
];
|
2023-05-28 14:44:41 -04:00
|
|
|
|
2023-07-02 14:19:30 -04:00
|
|
|
pub static SUPPORTED_BUILTIN_NODE_MODULES_WITH_PREFIX: &[&str] = &[
|
|
|
|
$(
|
|
|
|
concat!("node:", $module_name),
|
|
|
|
)+
|
|
|
|
];
|
|
|
|
};
|
2023-02-10 10:26:39 -05:00
|
|
|
}
|
|
|
|
|
2023-05-17 08:29:50 -04:00
|
|
|
// NOTE(bartlomieju): keep this list in sync with `ext/node/polyfills/01_require.js`
|
2023-07-02 14:19:30 -04:00
|
|
|
generate_builtin_node_module_lists! {
|
|
|
|
"assert",
|
|
|
|
"assert/strict",
|
|
|
|
"async_hooks",
|
|
|
|
"buffer",
|
|
|
|
"child_process",
|
|
|
|
"cluster",
|
|
|
|
"console",
|
|
|
|
"constants",
|
|
|
|
"crypto",
|
|
|
|
"dgram",
|
|
|
|
"diagnostics_channel",
|
|
|
|
"dns",
|
|
|
|
"dns/promises",
|
|
|
|
"domain",
|
|
|
|
"events",
|
|
|
|
"fs",
|
|
|
|
"fs/promises",
|
|
|
|
"http",
|
|
|
|
"http2",
|
|
|
|
"https",
|
2024-08-14 08:33:42 -04:00
|
|
|
"inspector",
|
2023-07-02 14:19:30 -04:00
|
|
|
"module",
|
|
|
|
"net",
|
|
|
|
"os",
|
|
|
|
"path",
|
|
|
|
"path/posix",
|
|
|
|
"path/win32",
|
|
|
|
"perf_hooks",
|
|
|
|
"process",
|
|
|
|
"punycode",
|
|
|
|
"querystring",
|
2023-08-04 08:30:48 -04:00
|
|
|
"repl",
|
2023-07-02 14:19:30 -04:00
|
|
|
"readline",
|
2024-06-25 19:15:54 -04:00
|
|
|
"readline/promises",
|
2023-07-02 14:19:30 -04:00
|
|
|
"stream",
|
|
|
|
"stream/consumers",
|
|
|
|
"stream/promises",
|
|
|
|
"stream/web",
|
|
|
|
"string_decoder",
|
|
|
|
"sys",
|
2023-08-01 19:17:38 -04:00
|
|
|
"test",
|
2023-07-02 14:19:30 -04:00
|
|
|
"timers",
|
|
|
|
"timers/promises",
|
|
|
|
"tls",
|
|
|
|
"tty",
|
|
|
|
"url",
|
|
|
|
"util",
|
|
|
|
"util/types",
|
|
|
|
"v8",
|
|
|
|
"vm",
|
2024-08-21 23:33:52 -04:00
|
|
|
"wasi",
|
2023-07-02 14:19:30 -04:00
|
|
|
"worker_threads",
|
|
|
|
"zlib",
|
|
|
|
}
|