Skip to content

Commit

Permalink
feature: @putout/minify: add simpmlify-ternary
Browse files Browse the repository at this point in the history
  • Loading branch information
coderaiser committed Jan 8, 2024
1 parent 8619311 commit 289ae4a
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 1 deletion.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ Here is list of supported 🐊**Putout** transformations:
-[`remove-console`](https://github.com/coderaiser/putout/tree/v29.0.0/packages/plugin-remove-console#readme);
-[`remove-debugger`](https://github.com/coderaiser/putout/tree/v29.0.0/packages/plugin-remove-debugger#readme);
-[`remove-unreachable-code`](https://github.com/coderaiser/putout/tree/v29.0.0/packages/plugin-remove-unreachable-code#readme);
-[`simplify-ternary`](https://github.com/coderaiser/putout/tree/v34.0.0/packages/plugin-simplify-ternary#readme);
-[`types`](https://github.com/coderaiser/putout/tree/v29.7.1/packages/plugin-types#readme);
-[`for-of`](https://github.com/coderaiser/putout/tree/v29.7.1/packages/plugin-for-of#readme);

Expand Down
2 changes: 2 additions & 0 deletions lib/plugins.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import removeUselessElse from '@putout/plugin-remove-useless-else';
import removeUnusedExpressions from '@putout/plugin-remove-unused-expressions';
import removeUnreferencedVariables from '@putout/plugin-remove-unreferenced-variables';
import reuseDuplicateInit from '@putout/plugin-reuse-duplicate-init';
import simplifyTernary from '@putout/plugin-simplify-ternary';
import mergeDuplicateFunctions from '@putout/plugin-merge-duplicate-functions';
import forOf from '@putout/plugin-for-of';
import removeNestedBlocks from '@putout/plugin-remove-nested-blocks';
Expand Down Expand Up @@ -114,6 +115,7 @@ export const getPlugins = (options) => {
['merge-duplicate-functions', mergeDuplicateFunctions],
['minify/shorten-names', shortenNames],
['new', newPlugin],
['simplify-ternary', simplifyTernary],
['types', types],
].filter(Boolean);

Expand Down
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,9 @@
"build": "madrun build",
"minify": "madrun minify"
},
"dependencies": {},
"dependencies": {
"@putout/plugin-simplify-ternary": "^7.0.0"
},
"keywords": [
"putout",
"minify",
Expand Down
1 change: 1 addition & 0 deletions test/fixture/simplify-ternary-fix.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
x=y&&z;
1 change: 1 addition & 0 deletions test/fixture/simplify-ternary.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
x = y ? z : false;
5 changes: 5 additions & 0 deletions test/minify.js
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,11 @@ test('@putout/minify: mangle-names-overlap', (t) => {
t.end();
});

test('@putout/minify: simplify-ternary', (t) => {
t.minify('simplify-ternary');
t.end();
});

test('@putout/minify: mangle: disabled', (t) => {
t.minify('mangle-disabled', {
mangle: false,
Expand Down

0 comments on commit 289ae4a

Please sign in to comment.