pub struct Compressor<'a> { /* private fields */ }Implementations§
Source§impl<'a> Compressor<'a>
impl<'a> Compressor<'a>
pub fn new(allocator: &'a Allocator) -> Self
Sourcepub fn build(self, program: &mut Program<'a>, options: CompressOptions)
pub fn build(self, program: &mut Program<'a>, options: CompressOptions)
Full minify: removes dead code and applies size-reducing transforms.
For tree-shaking only, see Self::dead_code_elimination.
Sourcepub fn build_with_scoping(
self,
program: &mut Program<'a>,
scoping: Scoping,
options: CompressOptions,
) -> u8
pub fn build_with_scoping( self, program: &mut Program<'a>, scoping: Scoping, options: CompressOptions, ) -> u8
Returns total number of iterations ran.
§Precondition
scoping must be consistent with program in the resolved-reference
domain: every resolved IdentifierReference in program must be present
in its symbol’s resolved-references list, and no list may contain a
ReferenceId whose node is absent from program. The compressor refreshes
scoping incrementally — it only prunes references for nodes it drops, and
no longer rebuilds liveness from scratch each pass — so a caller that
mutated program after building scoping must reflect those edits in
scoping. Stale extra references cause missed optimizations (output stays
correct); an added reference that was never recorded can cause incorrect
output. In-repo callers satisfy this by rebuilding a fresh Scoping
immediately before calling this — e.g. crates/oxc/src/compiler.rs
rebuilds scoping before compress/DCE whenever ReplaceGlobalDefines
reports a change.
Sourcepub fn dead_code_elimination(
self,
program: &mut Program<'a>,
options: CompressOptions,
) -> u8
pub fn dead_code_elimination( self, program: &mut Program<'a>, options: CompressOptions, ) -> u8
Tree-shaking only: removes dead and unused code, but does not otherwise
shrink the output like Self::build. Rolldown runs this on its own.
Sourcepub fn dead_code_elimination_with_scoping(
self,
program: &mut Program<'a>,
scoping: Scoping,
options: CompressOptions,
) -> u8
pub fn dead_code_elimination_with_scoping( self, program: &mut Program<'a>, scoping: Scoping, options: CompressOptions, ) -> u8
Returns total number of iterations ran.
§Precondition
Same incoming-scoping consistency requirement as
Self::build_with_scoping — see its docs.
Auto Trait Implementations§
impl<'a> !RefUnwindSafe for Compressor<'a>
impl<'a> !Send for Compressor<'a>
impl<'a> !Sync for Compressor<'a>
impl<'a> !UnwindSafe for Compressor<'a>
impl<'a> Freeze for Compressor<'a>
impl<'a> Unpin for Compressor<'a>
impl<'a> UnsafeUnpin for Compressor<'a>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more