2023-02-10 10:26:39 -05:00
|
|
|
// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
|
|
|
|
|
|
|
|
pub fn find_builtin_node_module(
|
2023-02-22 14:15:25 -05:00
|
|
|
module_name: &str,
|
2023-02-10 10:26:39 -05:00
|
|
|
) -> Option<&NodeModulePolyfill> {
|
|
|
|
SUPPORTED_BUILTIN_NODE_MODULES
|
|
|
|
.iter()
|
2023-02-22 14:15:25 -05:00
|
|
|
.find(|m| m.name == module_name)
|
2023-02-10 10:26:39 -05:00
|
|
|
}
|
|
|
|
|
2023-02-22 14:15:25 -05:00
|
|
|
pub fn is_builtin_node_module(module_name: &str) -> bool {
|
|
|
|
find_builtin_node_module(module_name).is_some()
|
2023-02-10 10:26:39 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
pub struct NodeModulePolyfill {
|
|
|
|
/// Name of the module like "assert" or "timers/promises"
|
|
|
|
pub name: &'static str,
|
2023-02-15 13:44:52 -05:00
|
|
|
pub specifier: &'static str,
|
2023-02-10 10:26:39 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
pub static SUPPORTED_BUILTIN_NODE_MODULES: &[NodeModulePolyfill] = &[
|
|
|
|
NodeModulePolyfill {
|
|
|
|
name: "assert",
|
2023-02-15 13:44:52 -05:00
|
|
|
specifier: "internal:deno_node/polyfills/assert.ts",
|
2023-02-10 10:26:39 -05:00
|
|
|
},
|
|
|
|
NodeModulePolyfill {
|
|
|
|
name: "assert/strict",
|
2023-02-15 13:44:52 -05:00
|
|
|
specifier: "internal:deno_node/polyfills/assert/strict.ts",
|
2023-02-10 10:26:39 -05:00
|
|
|
},
|
|
|
|
NodeModulePolyfill {
|
|
|
|
name: "async_hooks",
|
2023-02-15 13:44:52 -05:00
|
|
|
specifier: "internal:deno_node/polyfills/async_hooks.ts",
|
2023-02-10 10:26:39 -05:00
|
|
|
},
|
|
|
|
NodeModulePolyfill {
|
|
|
|
name: "buffer",
|
2023-02-15 13:44:52 -05:00
|
|
|
specifier: "internal:deno_node/polyfills/buffer.ts",
|
2023-02-10 10:26:39 -05:00
|
|
|
},
|
|
|
|
NodeModulePolyfill {
|
|
|
|
name: "child_process",
|
2023-02-15 13:44:52 -05:00
|
|
|
specifier: "internal:deno_node/polyfills/child_process.ts",
|
2023-02-10 10:26:39 -05:00
|
|
|
},
|
|
|
|
NodeModulePolyfill {
|
|
|
|
name: "cluster",
|
2023-02-15 13:44:52 -05:00
|
|
|
specifier: "internal:deno_node/polyfills/cluster.ts",
|
2023-02-10 10:26:39 -05:00
|
|
|
},
|
|
|
|
NodeModulePolyfill {
|
|
|
|
name: "console",
|
2023-02-15 13:44:52 -05:00
|
|
|
specifier: "internal:deno_node/polyfills/console.ts",
|
2023-02-10 10:26:39 -05:00
|
|
|
},
|
|
|
|
NodeModulePolyfill {
|
|
|
|
name: "constants",
|
2023-02-15 13:44:52 -05:00
|
|
|
specifier: "internal:deno_node/polyfills/constants.ts",
|
2023-02-10 10:26:39 -05:00
|
|
|
},
|
|
|
|
NodeModulePolyfill {
|
|
|
|
name: "crypto",
|
2023-02-15 13:44:52 -05:00
|
|
|
specifier: "internal:deno_node/polyfills/crypto.ts",
|
2023-02-10 10:26:39 -05:00
|
|
|
},
|
|
|
|
NodeModulePolyfill {
|
|
|
|
name: "dgram",
|
2023-02-15 13:44:52 -05:00
|
|
|
specifier: "internal:deno_node/polyfills/dgram.ts",
|
2023-02-10 10:26:39 -05:00
|
|
|
},
|
|
|
|
NodeModulePolyfill {
|
|
|
|
name: "dns",
|
2023-02-15 13:44:52 -05:00
|
|
|
specifier: "internal:deno_node/polyfills/dns.ts",
|
2023-02-10 10:26:39 -05:00
|
|
|
},
|
|
|
|
NodeModulePolyfill {
|
|
|
|
name: "dns/promises",
|
2023-02-15 13:44:52 -05:00
|
|
|
specifier: "internal:deno_node/polyfills/dns/promises.ts",
|
2023-02-10 10:26:39 -05:00
|
|
|
},
|
|
|
|
NodeModulePolyfill {
|
|
|
|
name: "domain",
|
2023-02-15 13:44:52 -05:00
|
|
|
specifier: "internal:deno_node/polyfills/domain.ts",
|
2023-02-10 10:26:39 -05:00
|
|
|
},
|
|
|
|
NodeModulePolyfill {
|
|
|
|
name: "events",
|
2023-02-15 13:44:52 -05:00
|
|
|
specifier: "internal:deno_node/polyfills/events.ts",
|
2023-02-10 10:26:39 -05:00
|
|
|
},
|
|
|
|
NodeModulePolyfill {
|
|
|
|
name: "fs",
|
2023-02-15 13:44:52 -05:00
|
|
|
specifier: "internal:deno_node/polyfills/fs.ts",
|
2023-02-10 10:26:39 -05:00
|
|
|
},
|
|
|
|
NodeModulePolyfill {
|
|
|
|
name: "fs/promises",
|
2023-02-15 13:44:52 -05:00
|
|
|
specifier: "internal:deno_node/polyfills/fs/promises.ts",
|
2023-02-10 10:26:39 -05:00
|
|
|
},
|
|
|
|
NodeModulePolyfill {
|
|
|
|
name: "http",
|
2023-02-15 13:44:52 -05:00
|
|
|
specifier: "internal:deno_node/polyfills/http.ts",
|
2023-02-10 10:26:39 -05:00
|
|
|
},
|
|
|
|
NodeModulePolyfill {
|
|
|
|
name: "https",
|
2023-02-15 13:44:52 -05:00
|
|
|
specifier: "internal:deno_node/polyfills/https.ts",
|
2023-02-10 10:26:39 -05:00
|
|
|
},
|
|
|
|
NodeModulePolyfill {
|
|
|
|
name: "module",
|
2023-02-15 13:44:52 -05:00
|
|
|
specifier: "internal:deno_node_loading/module_es_shim.js",
|
2023-02-10 10:26:39 -05:00
|
|
|
},
|
|
|
|
NodeModulePolyfill {
|
|
|
|
name: "net",
|
2023-02-15 13:44:52 -05:00
|
|
|
specifier: "internal:deno_node/polyfills/net.ts",
|
2023-02-10 10:26:39 -05:00
|
|
|
},
|
|
|
|
NodeModulePolyfill {
|
|
|
|
name: "os",
|
2023-02-15 13:44:52 -05:00
|
|
|
specifier: "internal:deno_node/polyfills/os.ts",
|
2023-02-10 10:26:39 -05:00
|
|
|
},
|
|
|
|
NodeModulePolyfill {
|
|
|
|
name: "path",
|
2023-02-15 13:44:52 -05:00
|
|
|
specifier: "internal:deno_node/polyfills/path.ts",
|
2023-02-10 10:26:39 -05:00
|
|
|
},
|
|
|
|
NodeModulePolyfill {
|
|
|
|
name: "path/posix",
|
2023-02-15 13:44:52 -05:00
|
|
|
specifier: "internal:deno_node/polyfills/path/posix.ts",
|
2023-02-10 10:26:39 -05:00
|
|
|
},
|
|
|
|
NodeModulePolyfill {
|
|
|
|
name: "path/win32",
|
2023-02-15 13:44:52 -05:00
|
|
|
specifier: "internal:deno_node/polyfills/path/win32.ts",
|
2023-02-10 10:26:39 -05:00
|
|
|
},
|
|
|
|
NodeModulePolyfill {
|
|
|
|
name: "perf_hooks",
|
2023-02-15 13:44:52 -05:00
|
|
|
specifier: "internal:deno_node/polyfills/perf_hooks.ts",
|
2023-02-10 10:26:39 -05:00
|
|
|
},
|
|
|
|
NodeModulePolyfill {
|
|
|
|
name: "process",
|
2023-02-15 13:44:52 -05:00
|
|
|
specifier: "internal:deno_node/polyfills/process.ts",
|
2023-02-10 10:26:39 -05:00
|
|
|
},
|
|
|
|
NodeModulePolyfill {
|
|
|
|
name: "querystring",
|
2023-02-15 13:44:52 -05:00
|
|
|
specifier: "internal:deno_node/polyfills/querystring.ts",
|
2023-02-10 10:26:39 -05:00
|
|
|
},
|
|
|
|
NodeModulePolyfill {
|
|
|
|
name: "readline",
|
2023-02-15 13:44:52 -05:00
|
|
|
specifier: "internal:deno_node/polyfills/readline.ts",
|
2023-02-10 10:26:39 -05:00
|
|
|
},
|
|
|
|
NodeModulePolyfill {
|
|
|
|
name: "stream",
|
2023-02-15 13:44:52 -05:00
|
|
|
specifier: "internal:deno_node/polyfills/stream.ts",
|
2023-02-10 10:26:39 -05:00
|
|
|
},
|
|
|
|
NodeModulePolyfill {
|
|
|
|
name: "stream/consumers",
|
2023-02-15 13:44:52 -05:00
|
|
|
specifier: "internal:deno_node/polyfills/stream/consumers.mjs",
|
2023-02-10 10:26:39 -05:00
|
|
|
},
|
|
|
|
NodeModulePolyfill {
|
|
|
|
name: "stream/promises",
|
2023-02-15 13:44:52 -05:00
|
|
|
specifier: "internal:deno_node/polyfills/stream/promises.mjs",
|
2023-02-10 10:26:39 -05:00
|
|
|
},
|
|
|
|
NodeModulePolyfill {
|
|
|
|
name: "stream/web",
|
2023-02-15 13:44:52 -05:00
|
|
|
specifier: "internal:deno_node/polyfills/stream/web.ts",
|
2023-02-10 10:26:39 -05:00
|
|
|
},
|
|
|
|
NodeModulePolyfill {
|
|
|
|
name: "string_decoder",
|
2023-02-15 13:44:52 -05:00
|
|
|
specifier: "internal:deno_node/polyfills/string_decoder.ts",
|
2023-02-10 10:26:39 -05:00
|
|
|
},
|
|
|
|
NodeModulePolyfill {
|
|
|
|
name: "sys",
|
2023-02-15 13:44:52 -05:00
|
|
|
specifier: "internal:deno_node/polyfills/sys.ts",
|
2023-02-10 10:26:39 -05:00
|
|
|
},
|
|
|
|
NodeModulePolyfill {
|
|
|
|
name: "timers",
|
2023-02-15 13:44:52 -05:00
|
|
|
specifier: "internal:deno_node/polyfills/timers.ts",
|
2023-02-10 10:26:39 -05:00
|
|
|
},
|
|
|
|
NodeModulePolyfill {
|
|
|
|
name: "timers/promises",
|
2023-02-15 13:44:52 -05:00
|
|
|
specifier: "internal:deno_node/polyfills/timers/promises.ts",
|
2023-02-10 10:26:39 -05:00
|
|
|
},
|
|
|
|
NodeModulePolyfill {
|
|
|
|
name: "tls",
|
2023-02-15 13:44:52 -05:00
|
|
|
specifier: "internal:deno_node/polyfills/tls.ts",
|
2023-02-10 10:26:39 -05:00
|
|
|
},
|
|
|
|
NodeModulePolyfill {
|
|
|
|
name: "tty",
|
2023-02-15 13:44:52 -05:00
|
|
|
specifier: "internal:deno_node/polyfills/tty.ts",
|
2023-02-10 10:26:39 -05:00
|
|
|
},
|
|
|
|
NodeModulePolyfill {
|
|
|
|
name: "url",
|
2023-02-15 13:44:52 -05:00
|
|
|
specifier: "internal:deno_node/polyfills/url.ts",
|
2023-02-10 10:26:39 -05:00
|
|
|
},
|
|
|
|
NodeModulePolyfill {
|
|
|
|
name: "util",
|
2023-02-15 13:44:52 -05:00
|
|
|
specifier: "internal:deno_node/polyfills/util.ts",
|
2023-02-10 10:26:39 -05:00
|
|
|
},
|
|
|
|
NodeModulePolyfill {
|
|
|
|
name: "util/types",
|
2023-02-15 13:44:52 -05:00
|
|
|
specifier: "internal:deno_node/polyfills/util/types.ts",
|
2023-02-10 10:26:39 -05:00
|
|
|
},
|
|
|
|
NodeModulePolyfill {
|
|
|
|
name: "v8",
|
2023-02-15 13:44:52 -05:00
|
|
|
specifier: "internal:deno_node/polyfills/v8.ts",
|
2023-02-10 10:26:39 -05:00
|
|
|
},
|
|
|
|
NodeModulePolyfill {
|
|
|
|
name: "vm",
|
2023-02-15 13:44:52 -05:00
|
|
|
specifier: "internal:deno_node/polyfills/vm.ts",
|
2023-02-10 10:26:39 -05:00
|
|
|
},
|
|
|
|
NodeModulePolyfill {
|
|
|
|
name: "worker_threads",
|
2023-02-15 13:44:52 -05:00
|
|
|
specifier: "internal:deno_node/polyfills/worker_threads.ts",
|
2023-02-10 10:26:39 -05:00
|
|
|
},
|
|
|
|
NodeModulePolyfill {
|
|
|
|
name: "zlib",
|
2023-02-15 13:44:52 -05:00
|
|
|
specifier: "internal:deno_node/polyfills/zlib.ts",
|
2023-02-10 10:26:39 -05:00
|
|
|
},
|
|
|
|
];
|