Skip to content

Commit

Permalink
doc(es/minifier): Update examples code (#8652)
Browse files Browse the repository at this point in the history
**Related issue:**

- Closes #8651 

The core logic of SWC is correct, but there are incorrect code examples in our code repository.
  • Loading branch information
magic-akari committed Feb 21, 2024
1 parent 5cab610 commit 3bf3a62
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 3 deletions.
6 changes: 5 additions & 1 deletion crates/swc_ecma_minifier/examples/compress.rs
Expand Up @@ -15,7 +15,10 @@ use swc_ecma_minifier::{
option::{ExtraOptions, MinifyOptions},
};
use swc_ecma_parser::parse_file_as_module;
use swc_ecma_transforms_base::{fixer::fixer, resolver};
use swc_ecma_transforms_base::{
fixer::{fixer, paren_remover},
resolver,
};
use swc_ecma_visit::FoldWith;

fn main() {
Expand All @@ -40,6 +43,7 @@ fn main() {
err.into_diagnostic(&handler).emit();
})
.map(|module| module.fold_with(&mut resolver(unresolved_mark, top_level_mark, false)))
.map(|module| module.fold_with(&mut paren_remover(None)))
.unwrap();

let output = optimize(
Expand Down
6 changes: 5 additions & 1 deletion crates/swc_ecma_minifier/examples/minifier.rs
Expand Up @@ -11,7 +11,10 @@ use swc_ecma_minifier::{
option::{ExtraOptions, MangleOptions, MinifyOptions},
};
use swc_ecma_parser::parse_file_as_module;
use swc_ecma_transforms_base::{fixer::fixer, resolver};
use swc_ecma_transforms_base::{
fixer::{fixer, paren_remover},
resolver,
};
use swc_ecma_visit::FoldWith;

fn main() {
Expand All @@ -37,6 +40,7 @@ fn main() {
err.into_diagnostic(&handler).emit();
})
.map(|module| module.fold_with(&mut resolver(unresolved_mark, top_level_mark, false)))
.map(|module| module.fold_with(&mut paren_remover(None)))
.unwrap();

let output = optimize(
Expand Down
6 changes: 5 additions & 1 deletion crates/swc_ecma_minifier/examples/minify-all.rs
Expand Up @@ -13,7 +13,10 @@ use swc_ecma_minifier::{
option::{ExtraOptions, MangleOptions, MinifyOptions},
};
use swc_ecma_parser::parse_file_as_module;
use swc_ecma_transforms_base::{fixer::fixer, resolver};
use swc_ecma_transforms_base::{
fixer::{fixer, paren_remover},
resolver,
};
use swc_ecma_visit::FoldWith;
use walkdir::WalkDir;

Expand Down Expand Up @@ -52,6 +55,7 @@ fn main() {
false,
))
})
.map(|module| module.fold_with(&mut paren_remover(None)))
.unwrap();

let output = optimize(
Expand Down

0 comments on commit 3bf3a62

Please sign in to comment.