Skip to content

Commit

Permalink
Merge pull request #1117 from egfx-notifications/feature/support-deno…
Browse files Browse the repository at this point in the history
…-target

Make Deno target available
  • Loading branch information
drager authored Jun 13, 2022
2 parents 75c4d51 + dee3614 commit 38a9a41
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/bindgen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ fn build_target_arg_legacy(target: Target, cli_path: &Path) -> Result<String, fa
}
}
Target::Bundler => "--browser",
Target::Deno => "--deno",
};
Ok(target_arg.to_string())
}
5 changes: 5 additions & 0 deletions src/command/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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)
}
Expand All @@ -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),
}
}
Expand Down
2 changes: 2 additions & 0 deletions src/manifest/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)?;
Expand Down

0 comments on commit 38a9a41

Please sign in to comment.