Skip to content

Commit

Permalink
Fixed no-source-compression to compress at level 0 instead of no-comp…
Browse files Browse the repository at this point in the history
…ression

rel: #581
  • Loading branch information
orisano committed Jan 5, 2024
1 parent 585e495 commit 94010fb
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions crates/cli/src/js.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,13 +54,13 @@ impl JS {
bytecode::compile_source(self.source_code.as_bytes())
}

pub fn compress(&self) -> Result<Vec<u8>> {
pub fn compress(&self, quality: i32) -> Result<Vec<u8>> {
let mut compressed_source_code: Vec<u8> = vec![];
enc::BrotliCompress(
&mut Cursor::new(&self.source_code.as_bytes()),
&mut compressed_source_code,
&BrotliEncoderParams {
quality: 11,
quality,
..Default::default()
},
)?;
Expand Down
4 changes: 2 additions & 2 deletions crates/cli/src/wasm_generator/transform.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@ pub struct SourceCodeSection {
impl SourceCodeSection {
pub fn compressed(js: &JS) -> Result<SourceCodeSection> {
Ok(SourceCodeSection {
source_code: js.compress()?,
source_code: js.compress(11)?,
})
}

pub fn uncompressed(js: &JS) -> Result<SourceCodeSection> {
Ok(SourceCodeSection {
source_code: js.as_bytes().to_vec(),
source_code: js.compress(0)?,
})
}
}
Expand Down

0 comments on commit 94010fb

Please sign in to comment.