|
|
|
@ -28,6 +28,8 @@ pub struct Build { |
|
|
|
|
pub crate_data: manifest::CrateData, |
|
|
|
|
pub scope: Option<String>, |
|
|
|
|
pub disable_dts: bool, |
|
|
|
|
pub weak_refs: bool, |
|
|
|
|
pub reference_types: bool, |
|
|
|
|
pub target: Target, |
|
|
|
|
pub profile: BuildProfile, |
|
|
|
|
pub mode: InstallMode, |
|
|
|
@ -132,6 +134,14 @@ pub struct BuildOptions { |
|
|
|
|
/// this flag will disable generating this TypeScript file.
|
|
|
|
|
pub disable_dts: bool, |
|
|
|
|
|
|
|
|
|
#[structopt(long = "weak-refs")] |
|
|
|
|
/// Enable usage of the JS weak references proposal.
|
|
|
|
|
pub weak_refs: bool, |
|
|
|
|
|
|
|
|
|
#[structopt(long = "reference-types")] |
|
|
|
|
/// Enable usage of WebAssembly reference types.
|
|
|
|
|
pub reference_types: bool, |
|
|
|
|
|
|
|
|
|
#[structopt(long = "target", short = "t", default_value = "bundler")] |
|
|
|
|
/// Sets the target environment. [possible values: bundler, nodejs, web, no-modules]
|
|
|
|
|
pub target: Target, |
|
|
|
@ -173,6 +183,8 @@ impl Default for BuildOptions { |
|
|
|
|
scope: None, |
|
|
|
|
mode: InstallMode::default(), |
|
|
|
|
disable_dts: false, |
|
|
|
|
weak_refs: false, |
|
|
|
|
reference_types: false, |
|
|
|
|
target: Target::default(), |
|
|
|
|
debug: false, |
|
|
|
|
dev: false, |
|
|
|
@ -217,6 +229,8 @@ impl Build { |
|
|
|
|
crate_data, |
|
|
|
|
scope: build_opts.scope, |
|
|
|
|
disable_dts: build_opts.disable_dts, |
|
|
|
|
weak_refs: build_opts.weak_refs, |
|
|
|
|
reference_types: build_opts.reference_types, |
|
|
|
|
target: build_opts.target, |
|
|
|
|
profile, |
|
|
|
|
mode: build_opts.mode, |
|
|
|
@ -391,6 +405,8 @@ impl Build { |
|
|
|
|
&self.out_dir, |
|
|
|
|
&self.out_name, |
|
|
|
|
self.disable_dts, |
|
|
|
|
self.weak_refs, |
|
|
|
|
self.reference_types, |
|
|
|
|
self.target, |
|
|
|
|
self.profile, |
|
|
|
|
&self.extra_options, |
|
|
|
@ -400,7 +416,7 @@ impl Build { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
fn step_run_wasm_opt(&mut self) -> Result<()> { |
|
|
|
|
let args = match self |
|
|
|
|
let mut args = match self |
|
|
|
|
.crate_data |
|
|
|
|
.configured_profile(self.profile) |
|
|
|
|
.wasm_opt_args() |
|
|
|
@ -408,6 +424,9 @@ impl Build { |
|
|
|
|
Some(args) => args, |
|
|
|
|
None => return Ok(()), |
|
|
|
|
}; |
|
|
|
|
if self.reference_types { |
|
|
|
|
args.push("--enable-reference-types".into()); |
|
|
|
|
} |
|
|
|
|
info!("executing wasm-opt with {:?}", args); |
|
|
|
|
wasm_opt::run( |
|
|
|
|
&self.cache, |
|
|
|
|