From dee3614a488c9b133ae2155fbb70bea8f370a2d6 Mon Sep 17 00:00:00 2001 From: Florian Schwalm Date: Wed, 2 Mar 2022 17:42:23 +0100 Subject: [PATCH] Make Deno target available --- src/bindgen.rs | 1 + src/command/build.rs | 5 +++++ src/manifest/mod.rs | 2 ++ 3 files changed, 8 insertions(+) diff --git a/src/bindgen.rs b/src/bindgen.rs index 535d6b87..e9d872ca 100644 --- a/src/bindgen.rs +++ b/src/bindgen.rs @@ -115,6 +115,7 @@ fn build_target_arg_legacy(target: Target, cli_path: &Path) -> Result "--browser", + Target::Deno => "--deno", }; Ok(target_arg.to_string()) } diff --git a/src/command/build.rs b/src/command/build.rs index b6802704..1f94471a 100644 --- a/src/command/build.rs +++ b/src/command/build.rs @@ -55,6 +55,9 @@ pub enum Target { /// in a browser but pollutes the global namespace and must be manually /// instantiated. NoModules, + /// Correspond to `--target deno` where the output is natively usable as + /// a Deno module loaded with `import`. + Deno, } impl Default for Target { @@ -70,6 +73,7 @@ impl fmt::Display for Target { Target::Web => "web", Target::Nodejs => "nodejs", Target::NoModules => "no-modules", + Target::Deno => "deno", }; write!(f, "{}", s) } @@ -83,6 +87,7 @@ impl FromStr for Target { "web" => Ok(Target::Web), "nodejs" => Ok(Target::Nodejs), "no-modules" => Ok(Target::NoModules), + "deno" => Ok(Target::Deno), _ => bail!("Unknown target: {}", s), } } diff --git a/src/manifest/mod.rs b/src/manifest/mod.rs index 25fb196a..6a483523 100644 --- a/src/manifest/mod.rs +++ b/src/manifest/mod.rs @@ -590,6 +590,8 @@ impl CrateData { Target::NoModules => self.to_nomodules(scope, disable_dts, existing_deps, out_dir), Target::Bundler => self.to_esmodules(scope, disable_dts, existing_deps, out_dir), Target::Web => self.to_web(scope, disable_dts, existing_deps, out_dir), + // Deno does not need package.json + Target::Deno => return Ok(()), }; let npm_json = serde_json::to_string_pretty(&npm_data)?;