From 94010fbbd5d7042967f13a02bc95d7518ab9fcbd Mon Sep 17 00:00:00 2001 From: Nao Yonashiro Date: Sat, 6 Jan 2024 01:24:46 +0900 Subject: [PATCH] Fixed no-source-compression to compress at level 0 instead of no-compression rel: #581 --- crates/cli/src/js.rs | 4 ++-- crates/cli/src/wasm_generator/transform.rs | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/crates/cli/src/js.rs b/crates/cli/src/js.rs index c0f47fbf..8f7354a0 100644 --- a/crates/cli/src/js.rs +++ b/crates/cli/src/js.rs @@ -54,13 +54,13 @@ impl JS { bytecode::compile_source(self.source_code.as_bytes()) } - pub fn compress(&self) -> Result> { + pub fn compress(&self, quality: i32) -> Result> { let mut compressed_source_code: Vec = vec![]; enc::BrotliCompress( &mut Cursor::new(&self.source_code.as_bytes()), &mut compressed_source_code, &BrotliEncoderParams { - quality: 11, + quality, ..Default::default() }, )?; diff --git a/crates/cli/src/wasm_generator/transform.rs b/crates/cli/src/wasm_generator/transform.rs index 68023dcb..57af6212 100644 --- a/crates/cli/src/wasm_generator/transform.rs +++ b/crates/cli/src/wasm_generator/transform.rs @@ -13,13 +13,13 @@ pub struct SourceCodeSection { impl SourceCodeSection { pub fn compressed(js: &JS) -> Result { Ok(SourceCodeSection { - source_code: js.compress()?, + source_code: js.compress(11)?, }) } pub fn uncompressed(js: &JS) -> Result { Ok(SourceCodeSection { - source_code: js.as_bytes().to_vec(), + source_code: js.compress(0)?, }) } }