Merge pull request #1117 from egfx-notifications/feature/support-deno-target

Make Deno target available
master
Jesper Håkansson 3 years ago committed by GitHub
commit 38a9a41225
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 1
      src/bindgen.rs
  2. 5
      src/command/build.rs
  3. 2
      src/manifest/mod.rs

@ -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())
}

@ -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),
}
}

@ -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)?;

Loading…
Cancel
Save