-
-
Notifications
You must be signed in to change notification settings - Fork 485
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(playground): add transform and minify (#993)
- Loading branch information
Showing
13 changed files
with
275 additions
and
170 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
#[allow(clippy::struct_excessive_bools)] | ||
#[derive(Debug, Clone, Copy)] | ||
pub struct CompressOptions { | ||
/// Various optimizations for boolean context, for example `!!a ? b : c` → `a ? b : c`. | ||
/// | ||
/// Default `true` | ||
pub booleans: bool, | ||
|
||
/// Remove `debugger;` statements. | ||
/// | ||
/// Default `true` | ||
pub drop_debugger: bool, | ||
|
||
/// Remove `console.*` statements. | ||
/// | ||
/// Default `false` | ||
pub drop_console: bool, | ||
|
||
/// Attempt to evaluate constant expressions | ||
/// | ||
/// Default `true` | ||
pub evaluate: bool, | ||
|
||
/// Join consecutive var statements. | ||
/// | ||
/// Default `true` | ||
pub join_vars: bool, | ||
|
||
/// Optimizations for do, while and for loops when we can statically determine the condition | ||
/// | ||
/// Default `true` | ||
pub loops: bool, | ||
|
||
/// Transforms `typeof foo == "undefined" into `foo === void 0` | ||
/// | ||
/// Default `true` | ||
pub typeofs: bool, | ||
} | ||
|
||
impl Default for CompressOptions { | ||
fn default() -> Self { | ||
Self { | ||
booleans: true, | ||
drop_debugger: true, | ||
drop_console: false, | ||
evaluate: true, | ||
join_vars: true, | ||
loops: true, | ||
typeofs: true, | ||
} | ||
} | ||
} | ||
|
||
impl CompressOptions { | ||
pub fn all_true() -> Self { | ||
Self { | ||
booleans: true, | ||
drop_debugger: true, | ||
drop_console: true, | ||
evaluate: true, | ||
join_vars: true, | ||
loops: true, | ||
typeofs: true, | ||
} | ||
} | ||
|
||
pub fn all_false() -> Self { | ||
Self { | ||
booleans: false, | ||
drop_debugger: false, | ||
drop_console: false, | ||
evaluate: false, | ||
join_vars: false, | ||
loops: false, | ||
typeofs: false, | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.