mirror of
https://github.com/swc-project/swc.git
synced 2024-12-25 06:36:08 +03:00
feat(es/bundler): Add an option to disable tree-shaking (#3102)
This commit is contained in:
parent
f4cc323e08
commit
d98a59339a
@ -86,6 +86,7 @@ fn do_test(_entry: &Path, entries: HashMap<String, FileName>, inline: bool, mini
|
||||
external_modules: Default::default(),
|
||||
disable_fixer: minify,
|
||||
disable_hygiene: minify,
|
||||
disable_dce: false,
|
||||
module: Default::default(),
|
||||
},
|
||||
Box::new(Hook),
|
||||
|
@ -36,6 +36,9 @@ pub struct Config {
|
||||
|
||||
pub disable_fixer: bool,
|
||||
|
||||
/// Disable tree-shaking optimization.
|
||||
pub disable_dce: bool,
|
||||
|
||||
/// List of modules which should be preserved.
|
||||
pub external_modules: Vec<JsWord>,
|
||||
|
||||
|
@ -18,12 +18,12 @@ where
|
||||
if !self.config.disable_inliner {
|
||||
node = node.fold_with(&mut constant_propagation())
|
||||
}
|
||||
|
||||
node = node.fold_with(&mut Repeat::new(dce::dce(dce::Config {
|
||||
// TODO(kdy1): Apply mark to wrapped esms and use it at here.
|
||||
module_mark: None,
|
||||
})));
|
||||
|
||||
if !self.config.disable_dce {
|
||||
node = node.fold_with(&mut Repeat::new(dce::dce(dce::Config {
|
||||
// TODO(kdy1): Apply mark to wrapped esms and use it at here.
|
||||
module_mark: None,
|
||||
})));
|
||||
}
|
||||
node
|
||||
})
|
||||
}
|
||||
|
@ -134,6 +134,7 @@ impl TestBuilder {
|
||||
disable_inliner: true,
|
||||
disable_hygiene: false,
|
||||
disable_fixer: false,
|
||||
disable_dce: false,
|
||||
external_modules: vec![],
|
||||
module: Default::default(),
|
||||
},
|
||||
|
Loading…
Reference in New Issue
Block a user