mirror of
https://github.com/swc-project/swc.git
synced 2024-12-21 12:41:54 +03:00
c047e0e54d
swc_bundler: - Create variables for export while preparing a module. (denoland/deno#9560) - Fix order of statements. - Invoke dce multiple time if required. (denoland/deno#9546) swc_ecma_transforms_optimization: - dce: Track modifications correctly.
37 lines
908 B
Rust
37 lines
908 B
Rust
use std::path::PathBuf;
|
|
use swc_common::pass::Repeat;
|
|
use swc_ecma_parser::EsConfig;
|
|
use swc_ecma_parser::Syntax;
|
|
use swc_ecma_transforms_optimization::simplify::dce::dce;
|
|
use swc_ecma_transforms_testing::test_fixture;
|
|
|
|
#[testing::fixture("dce/**/input.js")]
|
|
fn dce_single_pass(input: PathBuf) {
|
|
let output = input.with_file_name("output.js");
|
|
|
|
test_fixture(
|
|
Syntax::Es(EsConfig {
|
|
dynamic_import: true,
|
|
..Default::default()
|
|
}),
|
|
&|_| dce(Default::default()),
|
|
&input,
|
|
&output,
|
|
);
|
|
}
|
|
|
|
#[testing::fixture("dce/**/input.js")]
|
|
fn dce_repeated(input: PathBuf) {
|
|
let output = input.with_file_name("output.full.js");
|
|
|
|
test_fixture(
|
|
Syntax::Es(EsConfig {
|
|
dynamic_import: true,
|
|
..Default::default()
|
|
}),
|
|
&|_| Repeat::new(dce(Default::default())),
|
|
&input,
|
|
&output,
|
|
);
|
|
}
|