macro_rules! define_extension {
($base:ident, $file:ident, $ext:expr) => {
#[allow(dead_code)]
pub const $base: &str = $ext;
#[allow(dead_code)]
pub const $file: &str = concat!(".", $ext);
};
}
define_extension!(BYTECODE_EXT, BYTECODE_FILE_EXT, "lrt");
macro_rules! define_supported_extensions {
($constant_ext:ident, $($ext:literal),*) => {
pub const SUPPORTED_EXTENSIONS: &[&str] = &[$($ext),*, $constant_ext];
pub const JS_EXTENSIONS: &[&str] = &[$($ext),*];
pub fn is_supported_ext(ext: &str) -> bool {
matches!(ext, $($ext)|* | $constant_ext)
}
};
}
define_supported_extensions!(BYTECODE_FILE_EXT, ".js", ".mjs", ".cjs");