use std::path::Path;
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum RuntimeEnvironment {
Node,
EdgeWorker,
Browser,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum ExportConditions {
Node,
Edge,
Browser,
}
impl ExportConditions {
#[inline]
pub fn node() -> Self {
Self::Node
}
#[inline]
pub fn edge() -> Self {
Self::Edge
}
#[inline]
pub fn browser() -> Self {
Self::Browser
}
pub fn as_slice(&self) -> &'static [&'static str] {
match self {
Self::Node => &["node", "import", "module", "default"],
Self::Edge => &[
"edge-light",
"workerd",
"worker",
"browser",
"import",
"default",
],
Self::Browser => &["browser", "import", "module", "default"],
}
}
pub fn to_vec(&self) -> Vec<String> {
self.as_slice().iter().map(|s| (*s).to_string()).collect()
}
pub fn contains(&self, name: &str) -> bool {
self.as_slice().contains(&name)
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum NodeBuiltins {
External,
Error,
Polyfill,
}
pub trait DeploymentTarget: Send + Sync {
fn name(&self) -> &'static str;
fn runtime(&self) -> RuntimeEnvironment;
fn conditions(&self) -> ExportConditions;
fn node_builtins(&self) -> NodeBuiltins;
fn external_packages(&self) -> Vec<String> {
vec![]
}
fn generate_output(
&self,
_build_result: &crate::BuildResult,
_output_dir: &Path,
) -> crate::Result<()> {
Ok(())
}
}