├── .github ├── FUNDING.yml ├── ISSUE_TEMPLATE.md ├── PULL_REQUEST_TEMPLATE.md └── workflows │ └── nodejs.yml ├── .gitignore ├── .madrun.js ├── .minify.json ├── .npmignore ├── .npmrc ├── .nycrc.json ├── .putout.json ├── .typos.toml ├── ChangeLog ├── LICENSE ├── README.md ├── benchmark ├── .gitignore ├── .putout.json ├── README.md ├── cli │ └── minify.js ├── index.js ├── package.json └── source │ └── example1.js ├── eslint.config.js ├── lib ├── minify.js └── plugins.js ├── package.json ├── rollup.config.js ├── stub ├── acorn-stage3.js ├── chalk.js ├── fullstore.js └── loader.js └── test ├── extension.js ├── fixture ├── apply-optional-chaining-fix.js ├── apply-optional-chaining.js ├── apply-template-literals-disabled-fix.js ├── apply-template-literals-disabled.js ├── apply-template-literals-fix.js ├── apply-template-literals.js ├── array-fix.js ├── array.js ├── arrow-fix.js ├── arrow.js ├── assign-fix.js ├── assign.js ├── before-init-fix.js ├── before-init.js ├── boolean-fix.js ├── boolean.js ├── class-fix.js ├── class.js ├── closure-fix.js ├── closure.js ├── comments-fix.js ├── comments.js ├── conditions-fix.js ├── conditions.js ├── const-fix.js ├── const.js ├── convert-arguments-to-rest-fix.js ├── convert-arguments-to-rest.js ├── convert-const-to-var-fix.js ├── convert-const-to-var.js ├── convert-return-to-sequence-expression-fix.js ├── convert-return-to-sequence-expression.js ├── convert-strict-equal-to-equal-fix.js ├── convert-strict-equal-to-equal-on-fix.js ├── convert-strict-equal-to-equal-on.js ├── convert-strict-equal-to-equal.js ├── dead-code-fix.js ├── dead-code.js ├── declaration-order-fix.js ├── declaration-order.js ├── declare-fix.js ├── declare.js ├── duplicate-declaration-fix.js ├── duplicate-declaration.js ├── else-fix.js ├── else.js ├── evaluate-fix.js ├── evaluate.js ├── fix-count-fix.js ├── fix-count.js ├── for-each-destructuring-fix.js ├── for-each-destructuring.js ├── for-each-ternary-fix.js ├── for-each-ternary.js ├── for-fix.js ├── for-of-nested-fix.js ├── for-of-nested.js ├── for-of-remove-useless-fix.js ├── for-of-remove-useless.js ├── for.js ├── function-fix.js ├── function.js ├── guard-fix.js ├── guard.js ├── if-fix.js ├── if-logical-fix.js ├── if-logical.js ├── if-no-ternary-fix.js ├── if-no-ternary.js ├── if.js ├── in-fix.js ├── in.js ├── increment-fix.js ├── increment.js ├── infinity-fix.js ├── infinity.js ├── join-continued-strings-fix.js ├── join-continued-strings.js ├── logical-expressions-fix.js ├── logical-expressions.js ├── mangle-class-names-fix.js ├── mangle-class-names.js ├── mangle-disabled-fix.js ├── mangle-disabled.js ├── mangle-names-fix.js ├── mangle-names-overlap-fix.js ├── mangle-names-overlap.js ├── mangle-names.js ├── merge-assignment-expressions-fix.js ├── merge-assignment-expressions.js ├── merge-destructuring-properties-fix.js ├── merge-destructuring-properties.js ├── merge-duplicate-functions-fix.js ├── merge-duplicate-functions.js ├── merge-duplicate-imports-fix.js ├── merge-duplicate-imports.js ├── merge-loops-fix.js ├── merge-loops.js ├── merge-variables-fix.js ├── merge-variables-off-fix.js ├── merge-variables-off.js ├── merge-variables.js ├── minify-fix.js ├── minify.js ├── new-fix.js ├── new.js ├── overlap-fix.js ├── overlap.js ├── parens-fix.js ├── parens.js ├── promises-fix.js ├── promises.js ├── quotes-fix.js ├── quotes.js ├── regexp-fix.js ├── regexp.js ├── remove-console-fix.js ├── remove-console.js ├── remove-unreachable-code-fix.js ├── remove-unreachable-code.js ├── remove-unreferenced-variables-fix.js ├── remove-unreferenced-variables.js ├── remove-unused-expressions-fix.js ├── remove-unused-expressions.js ├── remove-useless-return-fix.js ├── remove-useless-return.js ├── remove-useless-spread-disabled-fix.js ├── remove-useless-spread-disabled.js ├── remove-useless-spread-fix.js ├── remove-useless-spread.js ├── remove-useless-variables-fix.js ├── remove-useless-variables.js ├── return-arrow-fix.js ├── return-arrow.js ├── reuse-duplicate-init-fix.js ├── reuse-duplicate-init.js ├── sequence-expressions-fix.js ├── sequence-expressions.js ├── shebang-fix.js ├── shebang.js ├── simplify-ternary-fix.js ├── simplify-ternary.js ├── swap-fix.js ├── swap.js ├── switch-fix.js ├── switch.js ├── ternary-fix.js ├── ternary.js ├── try-catch-fix.js ├── try-catch.js ├── type-fix.js ├── type.js ├── types-fix.js ├── types.js ├── undefined-fix.js ├── undefined.js ├── unused-fix.js ├── unused.js ├── var-fix.js ├── var-overlap-fix.js ├── var-overlap.js ├── var.js ├── void-fix.js └── void.js └── minify.js /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | github: coderaiser 2 | patreon: coderaiser 3 | open_collective: cloudcmd 4 | ko_fi: coderaiser 5 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | 5 | 6 | - **Version** (`npm -v`): 7 | - **Node Version** `node -v`: 8 | - **OS** (`uname -a` on Linux): 9 | - **Browser name/version**: 10 | - **Used Command Line Parameters**: 11 | -------------------------------------------------------------------------------- /.github/PULL_REQUEST_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | 5 | 6 | - [ ] commit message named according to [Contributing Guide](https://github.com/coderaiser/cloudcmd/blob/master/CONTRIBUTING.md "Contributting Guide") 7 | - [ ] `npm run fix:lint` is OK 8 | - [ ] `npm test` is OK 9 | -------------------------------------------------------------------------------- /.github/workflows/nodejs.yml: -------------------------------------------------------------------------------- 1 | name: Node CI 2 | on: 3 | - push 4 | - pull_request 5 | jobs: 6 | build: 7 | runs-on: ubuntu-latest 8 | env: 9 | NAME: "@putout/print" 10 | strategy: 11 | matrix: 12 | node-version: 13 | - 20.x 14 | - 22.x 15 | - 24.x 16 | steps: 17 | - uses: actions/checkout@v4 18 | - uses: oven-sh/setup-bun@v1 19 | with: 20 | bun-version: latest 21 | - name: Use Node.js ${{ matrix.node-version }} 22 | uses: actions/setup-node@v4 23 | with: 24 | node-version: ${{ matrix.node-version }} 25 | - name: Install Redrun 26 | run: bun i redrun -g --no-save 27 | - name: Install 28 | run: bun i --no-save 29 | - name: Lint 30 | run: redrun fix:lint 31 | - name: Install Rust 32 | run: rustup update 33 | - uses: actions/cache@v4 34 | with: 35 | path: | 36 | ~/.cargo/bin/ 37 | ~/.cargo/registry/index/ 38 | ~/.cargo/registry/cache/ 39 | ~/.cargo/git/db/ 40 | target/ 41 | key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} 42 | - name: Typos Install 43 | run: cargo install typos-cli || echo 'already installed' 44 | - name: Typos 45 | run: typos --write-changes 46 | - name: Commit fixes 47 | uses: EndBug/add-and-commit@v9 48 | continue-on-error: true 49 | with: 50 | message: "chore: ${{ env.NAME }}: actions: lint ☘️" 51 | - name: Coverage 52 | run: redrun build coverage report 53 | - name: Coveralls 54 | uses: coverallsapp/github-action@v2 55 | continue-on-error: true 56 | with: 57 | github-token: ${{ secrets.GITHUB_TOKEN }} 58 | path-to-lcov: coverage/lcov.info 59 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | *.swp 3 | yarn-error.log 4 | 5 | coverage 6 | .idea 7 | bundle 8 | .DS_Store 9 | -------------------------------------------------------------------------------- /.madrun.js: -------------------------------------------------------------------------------- 1 | import {run, cutEnv} from 'madrun'; 2 | 3 | const env = {}; 4 | 5 | export default { 6 | 'wisdom': () => run([ 7 | 'lint', 8 | 'build', 9 | 'test', 10 | 'minify', 11 | ]), 12 | 'test': () => [env, `tape 'lib/**/*.spec.js' 'test/*.js'`], 13 | 'watch:test': async () => [env, `nodemon -w lib -w test -x ${await cutEnv('test')}`], 14 | 'lint': () => `putout .`, 15 | 'fresh:lint': () => run('lint', '--fresh'), 16 | 'lint:fresh': () => run('lint', '--fresh'), 17 | 'fix:lint': () => run('lint', '--fix'), 18 | 'coverage': async () => [env, `c8 ${await cutEnv('test')}`], 19 | 'coverage:html': async () => [env, `c8 --reporter=lcov ${await cutEnv('test')}`], 20 | 'report': () => 'c8 report --reporter=lcov', 21 | 'build': () => 'rollup -c', 22 | 'minify': () => 'minify bundle/minify.js > bundle/minify.min.js', 23 | }; 24 | -------------------------------------------------------------------------------- /.minify.json: -------------------------------------------------------------------------------- 1 | { 2 | "js": { 3 | "type": "swc" 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /.npmignore: -------------------------------------------------------------------------------- 1 | .* 2 | *.spec.js 3 | test 4 | yarn-error.log 5 | 6 | coverage 7 | fixture 8 | fixture.js 9 | rules 10 | rollup.config.js 11 | lib/*.js 12 | *.config.* 13 | benchmark 14 | -------------------------------------------------------------------------------- /.npmrc: -------------------------------------------------------------------------------- 1 | package-lock=false 2 | -------------------------------------------------------------------------------- /.nycrc.json: -------------------------------------------------------------------------------- 1 | { 2 | "check-coverage": true, 3 | "all": true, 4 | "exclude": [ 5 | "**/*.spec.*", 6 | "**/fixture", 7 | "test", 8 | "**/debug.js", 9 | "**/coverage", 10 | "**/.*.*", 11 | "**/fixture.js", 12 | "**/bundle", 13 | "**/stub", 14 | "rollup.config.js", 15 | "benchmark", 16 | "**/*.config.*" 17 | ], 18 | "branches": 100, 19 | "lines": 100, 20 | "functions": 100, 21 | "statements": 100 22 | } 23 | -------------------------------------------------------------------------------- /.putout.json: -------------------------------------------------------------------------------- 1 | { 2 | "match": { 3 | ".filesystem.json": { 4 | "eslint/convert-rc-to-flat": "on" 5 | } 6 | }, 7 | "ignore": [ 8 | "bundle", 9 | "benchmark/result", 10 | "benchmark/source" 11 | ] 12 | } 13 | -------------------------------------------------------------------------------- /.typos.toml: -------------------------------------------------------------------------------- 1 | [files] 2 | extend-exclude= ["ChangeLog"] 3 | -------------------------------------------------------------------------------- /ChangeLog: -------------------------------------------------------------------------------- 1 | 2025.05.26, v5.1.2 2 | 3 | fix: 4 | - 3a86b6d minify: rm replace 5 | 6 | 2025.05.26, v5.1.1 7 | 8 | fix: 9 | - abba7a5 bundle 10 | 11 | 2025.05.26, v5.1.0 12 | 13 | feature: 14 | - 42433b9 @putout/minify: @putout/printer v14.8.0 (coderaiser/minify#137) 15 | - 5880057 @putout/minify: eslint-plugin-putout v27.0.0 16 | - 8244643 @putout/minify: @putout/plugin-simplify-ternary v8.0.0 17 | - 62f7636 @putout/minify: @putout/plugin-reuse-duplicate-init v8.0.0 18 | - b5a322e @putout/minify: @putout/plugin-remove-useless-variables v14.0.0 19 | - b1a17e4 @putout/minify: @putout/plugin-remove-useless-spread v13.0.0 20 | - 0d19c5a @putout/minify: @putout/plugin-remove-useless-arguments v12.0.0 21 | - 202b4dc @putout/minify: @putout/plugin-remove-unused-variables v13.0.0 22 | - 0de609f @putout/minify: @putout/plugin-remove-unused-expressions v12.0.0 23 | - d583801 @putout/minify: @putout/plugin-remove-nested-blocks v9.0.0 24 | - e3bcafc @putout/minify: @putout/plugin-merge-duplicate-functions v4.0.0 25 | 26 | 2025.04.18, v5.0.1 27 | 28 | feature: 29 | - de16e19 @putout/minify: putout v40.0.9 30 | - 80fd948 @putout/minify: @putout/plugin-types v8.0.0 31 | - 3b96431 @putout/minify: @putout/plugin-return v2.0.0 32 | - 2dbc754 @putout/minify: @putout/plugin-regexp v11.0.0 33 | - d933e36 @putout/minify: @putout/plugin-promises v17.0.0 34 | - cd85293 @putout/minify: @putout/plugin-new v4.0.0 35 | - 51d91a7 @putout/minify: @putout/plugin-merge-duplicate-functions v3.0.0 36 | - 307dc26 @putout/minify: @putout/plugin-merge-destructuring-properties v11.0.0 37 | - 758a5eb @putout/minify: @putout/plugin-esm v4.2.2 38 | - 3aea02b @putout/minify: minify v14.0.0 39 | 40 | 2025.03.24, v5.0.0 41 | 42 | feature: 43 | - 226d386 @putout/minify: drop support of node < 20 44 | - 498c3a6 @putout/minify: supertape v11.0.3 45 | - 5b1b01b @putout/minify: redlint v4.0.0 46 | - 323a299 @putout/minify: putout v39.0.11 47 | - 62dfd1b @putout/minify: madrun v11.0.0 48 | - 5bf66b9 @putout/minify: eslint-plugin-putout v26.1.0 49 | - 62d8c40 @putout/minify: @putout/printer v14.1.1 50 | - 459bdec @putout/minify: @putout/plugin-reuse-duplicate-init v7.0.0 51 | - cfdb84a @putout/minify: @putout/plugin-remove-useless-variables v13.0.2 52 | - f76f24c @putout/minify: @putout/plugin-remove-unreferenced-variables v5.0.0 53 | - 50a7225 @putout/minify: @putout/plugin-regexp v10.0.0 54 | - acfa07c @putout/minify: @putout/plugin-for-of v9.0.0 55 | - fb17a08 @putout/minify: @putout/eslint-flat v3.0.0 56 | 57 | 2025.02.27, v4.12.3 58 | 59 | feature: 60 | - a026dd0 @putout/minify: @putout/plugin-minify v10.0.0 61 | - f67f780 @putout/minify: eslint-plugin-putout v25.0.2 62 | 63 | 2025.02.17, v4.12.2 64 | 65 | feature: 66 | - a987c3b @putout/minify: @putout/printer v13.0.0 67 | - eef1edf @putout/minify: @putout/plugin-remove-useless-arguments v11.0.0 68 | - cc744b1 @putout/minify: @putout/plugin-remove-nested-blocks v8.0.0 69 | - efe7b33 @putout/minify: @putout/plugin-declare v5.0.0 70 | - 98684ba @putout/minify: @putout/plugin-for-of v8.0.0 71 | - 8600ffb @putout/minify: @putout/plugin-types v7.0.0 72 | 73 | 2025.02.11, v4.12.1 74 | 75 | feature: 76 | - 7448925 @putout/minify: @putout/plugin-apply-template-literals v4.2.0 77 | 78 | 2025.02.11, v4.12.0 79 | 80 | feature: 81 | - bd28642 @putout/minify: minify v13.0.0 82 | - ea5dca5 @putout/minify: @putout/plugin-remove-unused-expressions v11.0.0 83 | - 97b9366 @putout/minify: @putout/plugin-remove-empty v14.0.0 84 | - 879cd5c @putout/minify: @putout/plugin-apply-template-literals v4.0.0 85 | - bcff09a @putout/minify: @putout/plugin-esm v2.0.0 86 | - a7a230b @putout/minify: @putout/plugin-remove-unused-variables v12.0.0 87 | - 70ffaba @putout/minify: @putout/plugin-remove-useless-spread v12.0.0 88 | 89 | 2025.01.29, v4.11.0 90 | 91 | feature: 92 | - feab63e @putout/minify: @putout/plugin-return v1.1.2 93 | - 51631d8 @putout/minify: eslint-plugin-putout v24.0.0 94 | - dd21173 @putout/minify: putout v38.0.0 95 | 96 | 2025.01.23, v4.10.0 97 | 98 | feature: 99 | - 415c3a7 @putout/minify: @putout/plugin-remove-unused-expressions v10.0.0 100 | - e42af03 @putout/minify: @putout/plugin-remove-unused-variables v11.0.0 101 | - f53d321 @putout/minify: @putout/plugin-remove-unreachable-code v2.0.0 102 | - c9728d7 @putout/minify: @putout/plugin-remove-nested-blocks v7.0.0 103 | - 9a18c48 @putout/minify: @putout/plugin-conditions v7.1.0 104 | 105 | 2025.01.14, v4.9.1 106 | 107 | feature: 108 | - fa58bb7 @putout/minify: @putout/printer v12.2.0 109 | 110 | 2025.01.10, v4.9.0 111 | 112 | feature: 113 | - 21407d1 @putout/minify: @putout/plugin-remove-useless-arguments v10.1.0 114 | - 699d026 @putout/minify: @putout/plugin-types v6.1.0 115 | - 8717a75 @putout/minify: @putout/plugin-for-of v7.1.0 116 | - 30da16f @putout/minify: @putout/plugin-conditions v6.6.0 117 | 118 | 2024.12.24, v4.8.4 119 | 120 | fix: 121 | - 9321477 @putout/plugin-esm: merge-duplicate-imports (#29) 122 | 123 | 2024.12.21, v4.8.3 124 | 125 | feature: 126 | - 20191a4 @putout/minify: merge-duplicate-imports -> esm/merge-duplicate-imports 127 | 128 | 2024.12.19, v4.8.2 129 | 130 | feature: 131 | - cef224a @putout/minify: @putout/plugin-promises v16.0.0 132 | 133 | 2024.12.15, v4.8.1 134 | 135 | feature: 136 | - bba3521 @putout/minify: @rollup/plugin-node-resolve v16.0.0 137 | - 979ce05 @putout/minify: putout v37.1.1 138 | - 4b1ded4 @putout/minify: rollup-plugin-node-externals v8.0.0 139 | 140 | 2024.12.10, v4.8.0 141 | 142 | feature: 143 | - c0f2a69 @putout/minify: @putout/plugin-merge-destructuring-properties v10.0.0 144 | - f29c277 @putout/minify: @putout/printer v11.0.0 145 | - 4c82b28 @putout/minify: @putout/plugin-reuse-duplicate-init v6.0.0 146 | - d1dea59 @putout/minify: @putout/plugin-logical-expressions v7.0.0 147 | - ecccfff @putout/minify: minify v12.0.0 148 | - 4003476 @putout/minify: @putout/plugin-remove-unused-variables v10.1.0 149 | - 8c0b8ea @putout/minify: @putout/plugin-minify v9.0.0 (coderaiser/minify#132) 150 | 151 | 2024.09.29, v4.7.2 152 | 153 | fix: 154 | - d9737c9 @putout/minify: call-expression: parens (#28) 155 | 156 | feature: 157 | - 18012b5 @putout/minify: @putout/plugin-convert-arguments-to-rest v3.1.0 (#28) 158 | - 25f253d @putout/minify: @putout/plugin-nodejs v12.0.0 159 | - 0e593b9 @putout/minify: convert-arguments-to-rest: improve support (#28) 160 | 161 | 2024.09.27, v4.7.1 162 | 163 | feature: 164 | - 1d8e67c @putout/minify: @putout/plugin-convert-arguments-to-rest v3.1.0 (#28) 165 | - 787cf00 @putout/minify: @putout/plugin-nodejs v12.0.0 166 | 167 | 2024.09.27, v4.7.0 168 | 169 | feature: 170 | - b2eacc9 @putout/minify: convert-arguments-to-reset: improve support (#28) 171 | - a92ab77 @putout/minify: @putout/plugin-convert-arguments-to-rest v3.0.0 172 | 173 | 2024.09.26, v4.6.1 174 | 175 | feature: 176 | - 0619c7c @putout/minify: @putout/plugin-remove-useless-variables v12.5.0 (coderaiser/minify#128) 177 | - 6d73c7e @putout/minify: @rollup/plugin-commonjs v28.0.0 178 | - 614be7c @putout/minify: @rollup/plugin-replace v6.0.1 179 | 180 | 2024.09.16, v4.6.0 181 | 182 | feature: 183 | - e9fcd9a @putout/minify: quotes: add ability to override (coderaiser/minify#127) 184 | 185 | 2024.09.12, v4.5.2 186 | 187 | fix: 188 | - 777c0f4 disable BABEL_TYPES_8_BREAKING (#126, babel/babel#16829) 189 | 190 | 2024.09.12, v4.5.1 191 | 192 | feature: 193 | - cd6bf82 @putout/minify: eslint-plugin-putout v23.1.0 194 | - 089c5c4 @putout/minify: @putout/plugin-remove-useless-arguments v9.0.0 195 | - 008d73b @putout/minify: @putout/plugin-types v5.0.0 196 | - a96c8ba @putout/minify: @putout/plugin-conditions v5.0.0 197 | 198 | 2024.07.18, v4.5.0 199 | 200 | feature: 201 | - f0f3d00 @putout/minify: swap (coderiaser/minify#125) 202 | - 0e98f4c @putout/minify: @putout/plugin-remove-useless-variables v12.0.0 203 | - 864ffa4 @putout/minify: putout v36.0.0 204 | 205 | 2024.07.11, v4.4.0 206 | 207 | feature: 208 | - 7105176 @putout/minify: @putout/printer v9.6.0 (coderaiser/minify#124) 209 | - 77689ae minify: esbuild 210 | 211 | 2024.06.27, v4.3.1 212 | 213 | feature: 214 | - fbe26eb @putout/minify: @putout/plugin-remove-unused-expressions v9.0.0 215 | - 6d32113 @putout/minify: @putout/plugin-remove-useless-return v7.0.0 216 | 217 | 2024.06.20, v4.3.0 218 | 219 | feature: 220 | - faa5bee @putout/minify: add fixCount 221 | - 2990f0b get back mangle 222 | - eccc805 @putout/minify: speed up, disable mangle, mergeVariables 223 | 224 | 2024.06.19, v4.2.0 225 | 226 | feature: 227 | - 29009d5 @putout/minify: speed up, disable mangle, mergeVariables 228 | - 53241b8 @putout/minify: @putout/plugin-regexp v9.0.0 229 | - b314369 @putout/minify: @putout/plugin-merge-destructuring-properties v9.0.0 230 | - 8d1855a @putout/minify: get rid of couple passes 231 | - b2c0190 add benchmark (#27) 232 | 233 | 2024.06.16, v4.1.0 234 | 235 | feature: 236 | - da367bd @putout/minify: add support of merge-assignment-expressions 237 | - 55457b8 @putout/minify: @putout/eslint-flat v2.0.0 238 | 239 | 2024.06.13, v4.0.1 240 | 241 | fix: 242 | - 80b6aff @putout/minify: merge-variables: for-of 243 | 244 | feature: 245 | - fec011a @putout/minify: c8 v10.1.2 246 | 247 | 2024.06.13, v4.0.0 248 | 249 | feature: 250 | - ae2dc32 @putout/minify: disable: convertStrictEqualToEqual: turn of 251 | - bcf5e5a convertStrictEqualToEqual: disabled (#26) 252 | 253 | 2024.06.12, v3.20.0 254 | 255 | feature: 256 | - 8e2431e @putout/minify: duplicate declaration (putout/minify#24) 257 | - f28692a @putout/minify: extension: add 258 | 259 | 2024.06.12, v3.19.7 260 | 261 | feature: 262 | - 7852690 @putout/minify: merge-variables (#18, #21) 263 | 264 | 2024.06.10, v3.19.6 265 | 266 | feature: 267 | - 4a093ed @putout/minify: remove-unused-variables, const (#20, #22) 268 | 269 | 2024.06.10, v3.19.5 270 | 271 | feature: 272 | - d5dae16 @putout/minify: @putout/plugin-remove-unreferenced-variables v4.0.0 (putoutjs/minify#23) 273 | 274 | 2024.06.10, v3.19.4 275 | 276 | feature: 277 | - e862ca5 @putout/minify: @rollup/plugin-commonjs v26.0.1 278 | - 1cdbec7 @putout/minify: @putout/plugin-apply-optional-chaining v6.0.0 (#19) 279 | 280 | 2024.06.09, v3.19.3 281 | 282 | fix: 283 | - be6c4ea @putout/minify: ternary, assign (#15) 284 | 285 | 2024.06.09, v3.19.2 286 | 287 | feature: 288 | - 233ff51 @putout/minify: merge-variables: void 0 (#17) 289 | 290 | 2024.06.09, v3.19.1 291 | 292 | feature: 293 | - b4440a7 @putout/minify: @putout/printer v9.0.3 (#15) 294 | 295 | 2024.06.07, v3.19.0 296 | 297 | feature: 298 | - f1b3a82 @putout/minify: get rid of extract-sequence-expressions (#15) 299 | 300 | 2024.06.07, v3.18.0 301 | 302 | feature: 303 | - a7d1f28 @putout/minify: options: mergeVariables (#18) 304 | 305 | 2024.06.07, v3.17.1 306 | 307 | feature: 308 | - 78daa88 @putout/minify: @putout/plugin-minify v8.9.1 (#13) 309 | 310 | 2024.06.07, v3.17.0 311 | 312 | feature: 313 | - a8210ab @putout/minify: @putout/printer v9.0.0 (#15) 314 | - 7053bad @putout/minify: convert-return-to-sequence-expression (#15) 315 | - b7d0f44 @putout/minify: @putout/printer v8.47.0 (#15) 316 | 317 | 2024.06.07, v3.16.0 318 | 319 | feature: 320 | - ef4c058 @putout/minify: convertStrictEqualToEqual: add option (#16) 321 | 322 | 2024.06.07, v3.15.0 323 | 324 | feature: 325 | - ae5220a @putout/minify: @putout/plugin-minify v8.8.1 (#17) 326 | 327 | 2024.06.06, v3.14.0 328 | 329 | feature: 330 | - 1ef8f21 @putout/minify: @putout/plugin-minify v8.7.0 (#13) 331 | 332 | 2024.06.05, v3.13.0 333 | 334 | feature: 335 | - dde4a35 @putout/minify: expand-bindings: add support of re-assign (#14) 336 | - 5c1d145 @putout/plugin-minify: if logical nested (putoutjs/minify#12) 337 | 338 | 2024.06.05, v3.12.1 339 | 340 | feature: 341 | - 069710f @putout/plugin-minify: if logical nested (coderaiser/minify#12) 342 | 343 | 2024.06.05, v3.12.0 344 | 345 | feature: 346 | - 2ab4111 @putout/minify: improve support of converting if to logical (#12) 347 | - 404c63a @putout/minify: @putout/plugin-remove-useless-variables v11.1.1 348 | 349 | 2024.05.28, v3.11.2 350 | 351 | feature: 352 | - 58caf38 @putout/minify: simplify 353 | 354 | 2024.05.28, v3.11.1 355 | 356 | feature: 357 | - 3561a0a minify: move promises to first transform 358 | 359 | 2024.05.28, v3.11.0 360 | 361 | feature: 362 | - 4dd3ea5 @putout/minify: @putout/plugin-logical-expressions v6.0.0 363 | 364 | 2024.05.21, v3.10.3 365 | 366 | fix: 367 | - 26e08b0 @putout/minify: node prefixes 368 | 369 | 2024.05.21, v3.10.2 370 | 371 | feature: 372 | - 39d969d @putout/plugin-minify: VariableDeclaration: LabeledStatement 373 | 374 | 2024.05.21, v3.10.1 375 | 376 | feature: 377 | - 1bdf816 @putout/minify: @putout/plugin-for-of v6.0.0 378 | 379 | 2024.05.21, v3.10.0 380 | 381 | feature: 382 | - a2d8ba1 @putout/minify: @putout/plugin-promises v15.0.0 383 | 384 | 2024.05.05, v3.9.0 385 | 386 | feature: 387 | - e2f2e78 @putout/minify: eslint v9.2.0 388 | - faed80c @putout/minify: (coderaiser/minifyfor-each: improve support ConditionalExpression (coderaiser/minify#122) 389 | - 6877de1 @putout/minify: @putout/plugin-remove-useless-spread v11.0.0 390 | - b2be291 @putout/minify: @putout/plugin-for-of v5.0.0 391 | - e74a8ad @putout/minify: @putout/plugin-declare v4.0.0 392 | - f396fad @putout/minify: eslint-plugin-n v17.4.0 393 | - 325b1c7 @putout/minify: @putout/plugin-types v4.0.0 394 | - 81fe0d9 @putout/minify: @putout/plugin-remove-unused-variables v9.0.0 395 | - cf5c0ca @putout/minify: @putout/plugin-remove-empty v12.1.0 396 | - b04aacf @putout/minify: @putout/plugin-remove-debugger v7.0.0 397 | 398 | 2024.03.04, v3.8.5 399 | 400 | fix: 401 | - 6cf3c1d @putout/minify: bundle 402 | 403 | 2024.03.04, v3.8.4 404 | 405 | fix: 406 | - 2227a1f @putout/minify: exports 407 | 408 | 2024.03.04, v3.8.3 409 | 410 | feature: 411 | - 2accb6a keywords: printer 412 | 413 | 2024.03.04, v3.8.2 414 | 415 | feature: 416 | - 24a4e1f @putout/minify: @putout/printer v8.8.0 417 | - 97ded07 @putout/minify: minify v11.1.0 418 | 419 | 2024.02.26, v3.8.1 420 | 421 | feature: 422 | - c22ee2b @putout/minify: @putout/plugin-minify v8.2.0 (coderaiser/minify#120) 423 | 424 | 2024.02.14, v3.8.0 425 | 426 | feature: 427 | - ea89537 @putout/minify: improve support of SwitchCase, ClassDeclaration (coderaiser/minify#119) 428 | - e41a47c @putout/minify: rollup-plugin-node-externals v7.0.1 429 | - 9379f46 @putout/minify: @putout/plugin-declare v3.0.0 430 | - cd8389c @putout/minify: supertape v10.0.0 431 | - e149f2b @putout/minify: @putout/plugin-apply-template-literals v3.0.0 432 | 433 | 2024.01.25, v3.7.0 434 | 435 | feature: 436 | - 3fe73f2 @putout/minify: @putout/plugin-minify v8.0.0 (coderaiser/minify#118) 437 | 438 | 2024.01.19, v3.6.1 439 | 440 | fix: 441 | - f83af84 get rid of build warning: (!) Plugin alias: rewrote acorn-stage3 to ./stub/acorn-stage3.js but was not an abolute path and was not handled by other plugins. This will lead to duplicated modules for the same path. To avoid duplicating modules, you should resolve to an absolute path. 442 | - 44e614d increment (#8) 443 | 444 | feature: 445 | - 12a961a @putout/minify: putout v35.0.0 446 | - d94d1b7 @putout/minify: add applyTemplateLiterals option (#10) 447 | - d55f400 @putout/minify: @putout/plugin-merge-duplicate-imports v11.0.0 448 | - eaa559b @putout/minify: @putout/printer v8.0.0 449 | - 765c2ea @putout/minify: @putout/plugin-remove-unused-expressions v8.0.0 450 | - d44e94a @putout/minify: @putout/plugin-remove-debugger v6.0.0 451 | - 2167a2a @putout/plugin-extract-sequence-expressions: add (#196) 452 | - ee06547 @putout/minify: @putout/plugin-extract-sequence-expressions v3.5.0 453 | - b4761dc @putout/minify: @putout/plugin-remove-useless-spread v10.0.1 454 | - 0b7520c @putout/minify: add simpmlify-ternary 455 | 456 | 2024.01.09, v3.6.0 457 | 458 | feature: 459 | - f21110d @putout/minify: add applyTemplateLiterals option (#10) 460 | 461 | 2024.01.09, v3.5.0 462 | 463 | feature: 464 | - 7498546 @putout/minify: @putout/plugin-merge-duplicate-imports v11.0.0 465 | 466 | 2024.01.09, v3.4.0 467 | 468 | feature: 469 | - 03a8058 @putout/minify: @putout/printer v8.0.0 470 | - f9b7460 @putout/minify: @putout/plugin-remove-unused-expressions v8.0.0 471 | 472 | 2024.01.09, v3.3.0 473 | 474 | feature: 475 | - 337768f @putout/minify: @putout/plugin-remove-debugger v6.0.0 476 | 477 | 2024.01.09, v3.2.0 478 | 479 | feature: 480 | - b772844 @putout/plugin-extract-sequence-expressions: add (#196) 481 | - cb1fa3b @putout/minify: @putout/plugin-extract-sequence-expressions v3.5.0 482 | 483 | 2024.01.08, v3.1.2 484 | 485 | feature: 486 | - 1c3ee33 @putout/minify: @putout/plugin-remove-useless-spread v10.0.1 487 | 488 | 2024.01.08, v3.1.1 489 | 490 | fix: 491 | - 28d15ea get rid of build warning: (!) Plugin alias: rewrote acorn-stage3 to ./stub/acorn-stage3.js but was not an abolute path and was not handled by other plugins. This will lead to duplicated modules for the same path. To avoid duplicating modules, you should resolve to an absolute path. 492 | 493 | 2024.01.08, v3.1.0 494 | 495 | fix: 496 | - 8619311 increment (#8) 497 | 498 | feature: 499 | - 289ae4a @putout/minify: add simpmlify-ternary 500 | 501 | 2024.01.08, v3.0.1 502 | 503 | feature: 504 | - 3aca048 @putout/minify: c8 v9.0.0 505 | - 0444c21 @putout/minify: @putout/plugin-remove-unused-variables v8.1.0 506 | - d28ccd4 @putout/minify: @putout/plugin-for-of v4.0.0 507 | - 5fb5121 @putout/minify: @putout/plugin-promises v14.0.0 508 | - 54de228 @putout/minify: @putout/printer v7.4.0 509 | - 0747497 @putout/minify: eslint-plugin-putout v22.2.1 510 | - c4379a6 @putout/minify: supertape v9.0.0 511 | 512 | 2023.12.10, v3.0.0 513 | 514 | feature: 515 | - 80a18bc drop support of node < 18 516 | - ff882d8 @putout/minify: madrun v10.0.0 517 | - 2e44adf @putout/minify: putout v34.0.0 518 | 519 | 2023.12.05, v2.11.0 520 | 521 | feature: 522 | - 2c82a4f @putout/minify: @putout/plugin-minify v6.2.0 (#6) 523 | 524 | 2023.12.05, v2.10.2 525 | 526 | feature: 527 | - d62d3d8 @putout/minify: @putout/plugin-minify v6.1.2 528 | 529 | 2023.12.04, v2.10.1 530 | 531 | feature: 532 | - e25d858 @putout/minify: simplify mangle-names 533 | 534 | 2023.12.04, v2.10.0 535 | 536 | feature: 537 | - a702856 @putout/minify: mangle-names (#6) 538 | 539 | 2023.12.03, v2.9.0 540 | 541 | feature: 542 | - c38a63c package: @putout/plugin-minify v6.0.0 (putoutjs/minify#6) 543 | 544 | 2023.11.21, v2.8.0 545 | 546 | fix: 547 | - d519b69 @putout/minify: single quotes escape (#117) 548 | 549 | feature: 550 | - 6ddd198 @putout/minify: rollup-plugin-polyfill-node v0.13.0 551 | - 48fd00b @putout/minify: rollup v4.5.0 552 | - 315c204 @putout/minify: @putout/plugin-remove-useless-return v6.0.0 553 | - 6de62df @putout/minify: @putout/plugin-conditions v4.0.1 554 | - 177ff87 @putout/minify: @putout/printer v6.4.1 555 | 556 | 2023.11.12, v2.7.0 557 | 558 | feature: 559 | - 152edc3 @putout/minify: @putout/plugin-remove-empty v11.0.0 560 | - 5594fd4 @putout/minify: @putout/plugin-new v3.0.1 561 | - 57eead5 @putout/minify: putout v33.0.0 562 | 563 | 2023.10.28, v2.6.1 564 | 565 | feature: 566 | - f1fa351 package: @putout/plugin-logical-expressions v5.0.0 567 | 568 | 2023.10.28, v2.6.0 569 | 570 | feature: 571 | - e10afca package: @putout/plugin-regexp v8.0.0 572 | - 4d00faa package: @putout/printer v6.0.0 573 | - 8b8d9e4 package: eslint-plugin-putout v21.0.1 574 | 575 | 2023.10.20, v2.5.0 576 | 577 | feature: 578 | - efda1d2 package: @putout/plugin-minify v5.1.0 (putoutjs/minify#5) 579 | 580 | 2023.10.17, v2.4.1 581 | 582 | fix: 583 | - ed0eef1 @putout/minify: mangle (coderaiser/minify#114) 584 | 585 | feature: 586 | - 369e39b package: rollup v4.1.4 587 | - 2d8d902 package: rendy v4.1.3 588 | 589 | 2023.10.11, v2.4.0 590 | 591 | feature: 592 | - f12c1e0 @putout/minify: add ability to disable mangle (coderaiser/minify#114) 593 | 594 | 2023.10.11, v2.3.0 595 | 596 | feature: 597 | - df03b71 package: @putout/plugin-remove-useless-spread v9.0.0 598 | - e24609c package: @putout/plugin-apply-optional-chaining v5.0.1 599 | - e15a528 package: @putout/plugin-minify v5.0.0 (coderaiser/minify#114) 600 | 601 | 2023.09.27, v2.2.2 602 | 603 | feature: 604 | - a959154 package: @putout/printer v5.12.0 605 | - 27afc84 package: eslint-plugin-putout v20.0.0 606 | 607 | 2023.09.15, v2.2.1 608 | 609 | feature: 610 | - 195015d package: @putout/plugin-apply-shorthand-properties v5.1.0 611 | - a2d39d6 package: @putout/plugin-promises v13.0.0 612 | - 9712268 package: @putout/plugin-merge-duplicate-functions v2.0.0 613 | - 8178867 package: @putout/plugin-remove-useless-variables v10.0.0 614 | 615 | 2023.09.14, v2.2.0 616 | 617 | feature: 618 | - 94672a3 package: @putout/plugin-remove-unused-variables v7.0.0 619 | - ae3bcfb package: putout v32.0.1 620 | - 2086a40 package: @putout/plugin-conditions v3.0.0 621 | 622 | 2023.09.13, v2.1.1 623 | 624 | feature: 625 | - ab3a8c7 package: @putout/printer v4.1.0 626 | 627 | 2023.09.12, v2.1.0 628 | 629 | feature: 630 | - fc3e8ac package: @putout/plugin-minify v4.1.0 (coderaiser/minify#111) 631 | - 4c809a2 package: @putout/plugin-apply-shorthand-properties v4.0.0 632 | - 08e4458 package: @putout/plugin-for-of v3.0.0 633 | - f5847b3 package: @putout/plugin-remove-useless-arguments v8.0.0 634 | 635 | 2023.08.29, v2.0.1 636 | 637 | feature: 638 | - dc10b4e @putout/minify: get back sync 639 | 640 | 2023.08.28, v2.0.0 641 | 642 | feature: 643 | - 0a9b934 @putout/minify: async 644 | - 7acabad package: @putout/plugin-minify v4.0.0 645 | 646 | 2023.08.22, v1.50.2 647 | 648 | feature: 649 | - b8da22a package: @putout/plugin-types v3.0.0 650 | 651 | 2023.08.22, v1.50.1 652 | 653 | feature: 654 | - b5ebf45 package: @putout/plugin-promises v12.0.0 655 | 656 | 2023.08.21, v1.50.0 657 | 658 | feature: 659 | - 3018f9a package: eslint-plugin-putout v19.1.0 660 | - 062cc96 package: @putout/plugin-logical-expressions v4.0.0 661 | - 2cc7952 package: @putout/plugin-remove-unused-variables v6.0.2 662 | - 211072a package: @putout/plugin-apply-optional-chaining v4.0.0 663 | - 2aeaa1d package: @putout/plugin-declare v2.0.1 664 | - 18332ca package: @putout/printer v3.6.0 665 | - 12b0ea9 package: putout v31.2.2 666 | - dc7c768 package: @putout/plugin-minify v3.0.0 667 | 668 | 2023.08.03, v1.49.0 669 | 670 | feature: 671 | - bac0226 package: @putout/plugin-minify v2.4.0 (coderaiser/minify#111) 672 | 673 | 2023.08.03, v1.48.0 674 | 675 | feature: 676 | - bf49789 package: @putout/printer v2.96.0 (coderaiser/minify#112) 677 | 678 | 2023.07.28, v1.47.0 679 | 680 | feature: 681 | - e244c70 @putout/plugin-minify: add @putout/plugin-remove-useless-variables 682 | - 474968d package: @putout/plugin-remove-useless-variables v9.0.0 683 | 684 | 2023.07.25, v1.46.0 685 | 686 | feature: 687 | - b8221bd package: @putout/plugin-remove-useless-spread v8.0.1 688 | - a1c3f75 package: @putout/plugin-logical-expressions v3.1.0 689 | - 5d0126d package: @putout/plugin-conditions v2.2.0 690 | - 0608d8a package: eslint-plugin-putout v18.2.0 691 | - 802b9ee package: @putout/plugin-minify v2.0.0 692 | 693 | 2023.07.13, v1.45.0 694 | 695 | feature: 696 | - 94c9900 package: @putout/plugin-types v2.0.0 697 | - fe8d64e package: @putout/plugin-remove-unused-expressions v7.0.0 698 | - 166623a package: @putout/plugin-for-of v2.0.0 699 | - b9a163e package: @putout/plugin-remove-unreferenced-variables v3.0.0 700 | - e4a6285 package: nodemon v3.0.1 701 | - 68bfe2f package: putout v30.4.0 702 | 703 | 2023.07.03, v1.44.1 704 | 705 | feature: 706 | - a94d71e package: @putout/printer v2.42.1 (coderaiser/minify#109) 707 | 708 | 2023.06.20, v1.44.0 709 | 710 | feature: 711 | - 06c0154 package: @putout/plugin-minify v1.40.0 (coderaiser/minify#107) 712 | 713 | 2023.06.19, v1.43.0 714 | 715 | feature: 716 | - a4d6ed7 package: @putout/printer v2.27.0 (coderaiser/minify#106) 717 | 718 | 2023.06.19, v1.42.0 719 | 720 | feature: 721 | - 8d09a93 package: @putout/plugin-minify v1.39.0 (coderaiser/minify#108) 722 | - 1c63ebe package: @putout/printer v2.25.0 (coderaiser/minify#108) 723 | 724 | 2023.06.19, v1.41.0 725 | 726 | feature: 727 | - f6f3681 @putout/plugin-minify: shorten names (coderaiser/minify#109) 728 | - fb6539f package: @rollup/plugin-commonjs v25.0.1 729 | - 13dd48e package: c8 v8.0.0 730 | 731 | 2023.06.16, v1.40.0 732 | 733 | feature: 734 | - a3b3f4c package: @putout/printer v2.21.0 (coderaiser/minify#106) 735 | 736 | 2023.06.16, v1.39.1 737 | 738 | feature: 739 | - f25bbc2 package: @putout/printer v2.20.0 740 | 741 | 2023.06.16, v1.39.0 742 | 743 | feature: 744 | - 63f4009 @putout/minify: add ability to disable removeUselessSpread (coderaiser/minify#107) 745 | 746 | 2023.06.16, v1.38.0 747 | 748 | feature: 749 | - f2f0a1a package: @putout/plugin-remove-useless-spread v7.0.0 750 | - 17ed136 package: @putout/plugin-reuse-duplicate-init v5.0.0 751 | - 1e5d8a7 package: eslint-plugin-n v16.0.0 752 | - d29a632 package: rollup-plugin-node-externals v6.1.1 753 | - 6675c28 package: @putout/plugin-merge-destructuring-properties v8.0.0 754 | 755 | 2023.06.12, v1.37.1 756 | 757 | feature: 758 | - 8747987 package: @putout/printer v2.0.0 759 | 760 | 2023.06.05, v1.37.0 761 | 762 | feature: 763 | - acd7780 @putout/minify: add support of mangleClassNames (coderaiser/minify#104) 764 | - da8b113 package: @putout/plugin-remove-useless-arguments v7.0.0 765 | 766 | 2023.06.05, v1.36.1 767 | 768 | feature: 769 | - 6e2cc03 package: @putout/plugin-apply-shorthand-properties v3.0.2 770 | - 1fa3d13 package: @putout/plugin-minify v1.37.0 771 | 772 | 2023.06.05, v1.36.0 773 | 774 | feature: 775 | - 93b3cf8 package: @putout/plugin-minify v1.36.0 776 | 777 | 2023.06.04, v1.35.3 778 | 779 | feature: 780 | - be06a34 package: @putout/plugin-minify v1.35.1 781 | 782 | 2023.06.04, v1.35.2 783 | 784 | feature: 785 | - 83513ed package: @putout/plugin-minify v1.35.0 786 | 787 | 2023.06.04, v1.35.1 788 | 789 | feature: 790 | - d6a5d62 package: @putout/plugin-minify v1.34.0 791 | 792 | 2023.06.04, v1.35.0 793 | 794 | feature: 795 | - 5b1b020 package: @putout/plugin-minify v1.33.0 796 | 797 | 2023.06.02, v1.34.1 798 | 799 | feature: 800 | - 0c7575c package: @putout/plugin-minify v1.31.1 801 | 802 | 2023.06.02, v1.34.0 803 | 804 | feature: 805 | - 86991ce package: @putout/plugin-minify v1.31.0 806 | 807 | 2023.06.01, v1.33.0 808 | 809 | feature: 810 | - 0142edd package: @putout/plugin-minify v1.30.0 811 | 812 | 2023.06.01, v1.32.1 813 | 814 | feature: 815 | - 83b23a1 package: @putout/printer v1.128.1 816 | 817 | 2023.06.01, v1.32.0 818 | 819 | feature: 820 | - 4f21e6a package: @putout/plugin-reuse-duplicate-init v4.0.0 821 | 822 | 2023.06.01, v1.31.0 823 | 824 | feature: 825 | - 7b4ea06 package: @putout/plugin-merge-destructuring-properties v7.0.0 826 | 827 | 2023.06.01, v1.30.0 828 | 829 | feature: 830 | - c6a44f7 package: @putout/plugin-minify v1.28.0 831 | 832 | 2023.06.01, v1.29.1 833 | 834 | feature: 835 | - ad95da6 @putout/minify: drop tenko 836 | 837 | 2023.06.01, v1.29.0 838 | 839 | feature: 840 | - 64461b0 package: @putout/printer v1.128.0 841 | 842 | 2023.06.01, v1.28.1 843 | 844 | feature: 845 | - 9a24be6 package: @putout/plugin-minify v1.26.0 846 | 847 | 2023.06.01, v1.28.0 848 | 849 | feature: 850 | - 89e31f9 package: @putout/plugin-minify v1.24.0 851 | 852 | 2023.06.01, v1.27.2 853 | 854 | feature: 855 | - 26c0bae package: @putout/printer v1.126.0 856 | 857 | 2023.06.01, v1.27.1 858 | 859 | feature: 860 | - 6205458 package: @putout/printer v1.125.0 861 | 862 | 2023.05.31, v1.27.0 863 | 864 | feature: 865 | - d0f0135 @putout/minify: apply-optiona-chaining 866 | 867 | 2023.05.31, v1.26.0 868 | 869 | feature: 870 | - a72ab25 @putout/minify: add ability to merge variables 871 | - 9a68d10 package: @putout/plugin-minify v1.23.0 872 | 873 | 2023.05.30, v1.25.0 874 | 875 | feature: 876 | - 66b1fe4 package: @putout/printer v1.122.0 877 | 878 | 2023.05.30, v1.24.0 879 | 880 | feature: 881 | - 5565688 @putout/minify: add declare 882 | - 01de27e package: @putout/plugin-minify v1.20.0 883 | - fd61633 @putout/minify: add types 884 | 885 | 2023.05.30, v1.23.0 886 | 887 | feature: 888 | - ded7ad3 @putout/minify: add convert-arguments-to-rest 889 | 890 | 2023.05.30, v1.22.3 891 | 892 | feature: 893 | - 4386656 package: @putout/plugin-minify v1.19.0 894 | 895 | 2023.05.30, v1.22.2 896 | 897 | feature: 898 | - bbbdaba package: putout v29.10.0 899 | 900 | 2023.05.29, v1.22.1 901 | 902 | feature: 903 | - 712f363 package: @putout/plugin-minify v1.18.0 904 | 905 | 2023.05.25, v1.22.0 906 | 907 | feature: 908 | - b8a4a5b package: @putout/printer v1.118.0 909 | 910 | 2023.05.25, v1.21.0 911 | 912 | feature: 913 | - 3f4a931 package: @putout/plugin-minify v1.16.0 914 | 915 | 2023.05.25, v1.20.3 916 | 917 | feature: 918 | - 40255a3 package: @putout/plugin-minify v1.15.0 919 | 920 | 2023.05.25, v1.20.2 921 | 922 | fix: 923 | - 8d4dc97 @putout/minify: add ability to rename ObjectProperty inside ObjectPattern (babel/babel#15648) 924 | 925 | 2023.05.25, v1.20.1 926 | 927 | feature: 928 | - 71d5f7a @putout/minify: decrease dependencies count -> minified build 929 | 930 | 2023.05.24, v1.20.0 931 | 932 | feature: 933 | - a56e4f6 @putout/minify: improve shebang support 934 | 935 | 2023.05.24, v1.19.1 936 | 937 | feature: 938 | - 566605c package: @putout/printer v1.114.0 939 | 940 | 2023.05.24, v1.19.0 941 | 942 | feature: 943 | - 8ee7cf5 @putout/minify: add remove-useless-else 944 | 945 | 2023.05.23, v1.18.1 946 | 947 | feature: 948 | - 9c4a525 package: @putout/printer v1.110.0 949 | 950 | 2023.05.23, v1.18.0 951 | 952 | feature: 953 | - 45f4178 package: @putout/plugin-minify v1.10.0 954 | 955 | 2023.05.23, v1.17.4 956 | 957 | feature: 958 | - 88d6f0b package: @putout/printer v1.109.0 959 | - 85cf5c5 package: @putout/plugin-minify v1.9.0 960 | 961 | 2023.05.23, v1.17.3 962 | 963 | feature: 964 | - 0ba0f40 package: @putout/printer v1.107.0 965 | 966 | 2023.05.22, v1.17.2 967 | 968 | feature: 969 | - ff174a3 package: @putout/printer v1.106.2 970 | 971 | 2023.05.22, v1.17.1 972 | 973 | feature: 974 | - e8805a5 package: @putout/printer v1.106.1 975 | 976 | 2023.05.22, v1.17.0 977 | 978 | feature: 979 | - a3d7716 package: @putout/printer v1.104.0 980 | 981 | 2023.05.18, v1.16.5 982 | 983 | feature: 984 | - 19c162d package: @putout/printer v1.103.0 (#2) 985 | 986 | 2023.05.18, v1.16.4 987 | 988 | feature: 989 | - 5de5d12 @putout/printer: add small optimization 990 | 991 | 2023.05.18, v1.16.3 992 | 993 | feature: 994 | - 6ffa279 package: @putout/printer v1.101.3 995 | 996 | 2023.05.18, v1.16.2 997 | 998 | feature: 999 | - bbdbe69 package: @putout/printer v1.101.2 1000 | 1001 | 2023.05.18, v1.16.1 1002 | 1003 | feature: 1004 | - 32f26a3 package: @putout/plugin-conditions v1.1.0 1005 | 1006 | 2023.05.18, v1.16.0 1007 | 1008 | feature: 1009 | - f9e7cc4 @putout/minify: add ability to convert FunctionExpression to ArrowFunctionExpression 1010 | 1011 | 2023.05.18, v1.15.0 1012 | 1013 | feature: 1014 | - 7a3d913 @putout/minify: add ability to minify RegExp 1015 | 1016 | 2023.05.18, v1.14.0 1017 | 1018 | fix: 1019 | - 43c0f34 @putout/minify: exports (#1) 1020 | 1021 | feature: 1022 | - 03a8604 @putout/minify: add ability to minify type constructors 1023 | 1024 | 2023.05.18, v1.13.1 1025 | 1026 | fix: 1027 | - e66f869 @putout/minify: exports 1028 | 1029 | 2023.05.17, v1.13.0 1030 | 1031 | feature: 1032 | - e90ab4a @putout/minify: add support of logical-expressions, conditions 1033 | - f1a7d70 package: @putout/plugin-logical-expressions v2.1.0 1034 | - b983025 package: @putout/plugin-remove-unused-expressions v6.0.1 1035 | 1036 | 2023.05.17, v1.12.0 1037 | 1038 | feature: 1039 | - 246ddf3 @putout/minify: add support of couple elements inside BlockStatement body of IfStatement consequent 1040 | 1041 | 2023.05.17, v1.11.0 1042 | 1043 | feature: 1044 | - 45b4c05 @putout/minify: add ability to minify IfStatement 1045 | 1046 | 2023.05.17, v1.10.0 1047 | 1048 | feature: 1049 | - f7f2d95 @putout/minify: add ability to shorten types 1050 | 1051 | 2023.05.16, v1.9.0 1052 | 1053 | feature: 1054 | - 047bfec @putout/minify: use full for-of plugin 1055 | 1056 | 2023.05.16, v1.8.0 1057 | 1058 | feature: 1059 | - affc8a0 @putout/minify: @putout/plugin-minify v1.1.0: add ability to mangle names 1060 | 1061 | 2023.05.15, v1.7.0 1062 | 1063 | feature: 1064 | - 623967e @putout/plugin-minify: remove-nested-blocks: add 1065 | 1066 | 2023.05.15, v1.6.1 1067 | 1068 | feature: 1069 | - 9876f0c @putout/minify: minimize bundle 1070 | 1071 | 2023.05.15, v1.6.0 1072 | 1073 | feature: 1074 | - 6b6ce25 @putout/minify: speed up 1075 | 1076 | 2023.05.11, v1.5.0 1077 | 1078 | feature: 1079 | - 557d427 @putout/minify: add @putout/plugin-minify 1080 | 1081 | 2023.05.10, v1.4.0 1082 | 1083 | feature: 1084 | - fb06389 @putout/minify: add remove-unreferenced-variables 1085 | 1086 | 2023.05.10, v1.3.0 1087 | 1088 | feature: 1089 | - 264e26f @putout/minify: add remove-unused-expressions 1090 | 1091 | 2023.05.10, v1.2.0 1092 | 1093 | feature: 1094 | - 3054d26 @putout/minify: add remove-unreachable-code 1095 | 1096 | 2023.05.10, v1.1.2 1097 | 1098 | feature: 1099 | - 1fe2abd @putout/minify: add remove-console 1100 | - 58cc93c @putout/minify: add apply-template-literals 1101 | 1102 | 2023.05.10, v1.1.1 1103 | 1104 | feature: 1105 | - 18306d3 @putout/printer: remove-useless-return 1106 | 1107 | 2023.05.10, v1.1.0 1108 | 1109 | feature: 1110 | - c1d12d2 @putout/minify: add remove-useless-spread 1111 | 1112 | 2023.05.09, v1.0.4 1113 | 1114 | feature: 1115 | - 37d349c @putout/printer: add merge-duplicate-function 1116 | 1117 | 2023.05.09, v1.0.3 1118 | 1119 | feature: 1120 | - 91ce4cf @putout/minify: add minify-dead-code 1121 | - e1d081a @putout/minify: add minify type constructors 1122 | 1123 | 2023.05.09, v1.0.2 1124 | 1125 | feature: 1126 | - 6e90935 @putout/minify: add remove-unused-variables 1127 | 1128 | 2023.05.09, v1.0.1 1129 | 1130 | feature: 1131 | - 59cd0a4 minify: remove-return-undefined: exclude nesting 1132 | - 8798f5f add ability to remove undefined 1133 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) coderaiser 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # @putout/minify [![NPM version][NPMIMGURL]][NPMURL] [![Coverage Status][CoverageIMGURL]][CoverageURL] 2 | 3 | [NPMIMGURL]: https://img.shields.io/npm/v/@putout/minify.svg?style=flat&longCache=true 4 | [NPMURL]: https://npmjs.org/package/@putout/minify "npm" 5 | [CoverageURL]: https://coveralls.io/github/putoutjs/minify?branch=master 6 | [CoverageIMGURL]: https://coveralls.io/repos/putoutjs/minify/badge.svg?branch=master&service=github 7 | 8 | 🐊[**Putout**](https://github.com/coderaiser/putout)-based JavaScript minifier. 9 | 10 | ## Install 11 | 12 | ```sh 13 | npm i @putout/minify 14 | ``` 15 | 16 | ## Supported minifier transforms 17 | 18 | Here is list of supported 🐊**Putout** transformations: 19 | 20 | - ✅ [`apply-template-literals`](https://github.com/coderaiser/putout/tree/v29.0.0/packages/plugin-apply-template-literals#readme); 21 | - ✅ [`apply-optional-chaining`](https://github.com/coderaiser/putout/tree/v29.0.0/packages/plugin-apply-optional-chaining#readme); 22 | - ✅ [`conditions`](https://github.com/coderaiser/putout/tree/v29.10.0/packages/plugin-conditions#readme); 23 | - ✅ [`convert-to-arrow-function`](https://github.com/coderaiser/putout/tree/v29.0.0/packages/plugin-convert-to-arrow-functions#readme); 24 | - ✅ [`convert-arguments-to-rest`](https://github.com/coderaiser/putout/tree/v29.10.1/packages/plugin-convert-arguments-to-rest#readme); 25 | - ✅ [`declare`](https://github.com/coderaiser/putout/tree/v29.0.0/packages/plugin-declare#readme); 26 | - ✅ [`for-of`](https://github.com/coderaiser/putout/tree/v34.0.0/packages/plugin-for-of#readme); 27 | - ✅ [`logical-expressions`](https://github.com/coderaiser/putout/tree/v29.0.0/packages/plugin-logical-expressions#readme); 28 | - ✅ [`merge-duplicate-functions`](https://github.com/coderaiser/putout/tree/v29.0.0/packages/plugin-merge-duplicate-functions#readme); 29 | - ✅ [`merge-duplicate-imports`](https://github.com/coderaiser/putout/tree/v29.0.0/packages/plugin-merge-duplicate-imports#readme); 30 | - ✅ [`merge-destructuring-properties`](https://github.com/coderaiser/putout/tree/v29.0.0/packages/plugin-merge-destructuring-properties#readme); 31 | - ✅ [`minify`](https://github.com/coderaiser/putout/tree/v29.0.0/packages/plugin-minify#readme); 32 | - ✅ [`new`](https://github.com/coderaiser/putout/tree/v29.0.0/packages/plugin-new#readme); 33 | - ✅ [`regexp`](https://github.com/coderaiser/putout/tree/v29.0.0/packages/plugin-regexp#readme); 34 | - ✅ [`reuse-duplicate-init`](https://github.com/coderaiser/putout/tree/v29.0.0/packages/plugin-reuse-duplicate-init#readme); 35 | - ✅ [`remove-empty`](https://github.com/coderaiser/putout/tree/v29.0.0/packages/plugin-remove-empty#readme); 36 | - ✅ [`remove-nested-blocks`](https://github.com/coderaiser/putout/tree/v29.0.0/packages/plugin-remove-nested-blocks#readme); 37 | - ✅ [`remove-unused-variables`](https://github.com/coderaiser/putout/tree/v29.0.0/packages/plugin-remove-unused-variables#readme); 38 | - ✅ [`remove-unused-expressions`](https://github.com/coderaiser/putout/tree/v29.0.0/packages/plugin-remove-unused-expressions#readme); 39 | - ✅ [`remove-unreferenced-variables`](https://github.com/coderaiser/putout/tree/v29.0.0/packages/plugin-remove-unreferenced-variables#readme); 40 | - ✅ [`remove-useless-arguments`](https://github.com/coderaiser/putout/tree/master/packages/plugin-remove-useless-arguments#readme); 41 | - ✅ [`remove-useless-else`](https://github.com/coderaiser/putout/tree/master/packages/plugin-remove-useless-else#readme); 42 | - ✅ [`remove-useless-return`](https://github.com/coderaiser/putout/tree/v29.0.0/packages/plugin-remove-useless-return#readme); 43 | - ✅ [`remove-useless-spread`](https://github.com/coderaiser/putout/tree/v29.0.0/packages/plugin-remove-useless-spread/#readme); 44 | - ✅ [`remove-useless-variables`](https://github.com/coderaiser/putout/tree/v29.0.0/packages/plugin-remove-useless-variables#readme); 45 | - ✅ [`remove-console`](https://github.com/coderaiser/putout/tree/v29.0.0/packages/plugin-remove-console#readme); 46 | - ✅ [`remove-debugger`](https://github.com/coderaiser/putout/tree/v29.0.0/packages/plugin-remove-debugger#readme); 47 | - ✅ [`remove-unreachable-code`](https://github.com/coderaiser/putout/tree/v29.0.0/packages/plugin-remove-unreachable-code#readme); 48 | - ✅ [`simplify-ternary`](https://github.com/coderaiser/putout/tree/v34.0.0/packages/plugin-simplify-ternary#readme); 49 | - ✅ [`types`](https://github.com/coderaiser/putout/tree/v29.7.1/packages/plugin-types#readme); 50 | 51 | ## API 52 | 53 | ```js 54 | import {minify} from '@putout/minify'; 55 | 56 | minify(` 57 | const a = 5; 58 | const b = 6; 59 | 60 | fn(a, b); 61 | `); 62 | ``` 63 | 64 | ``` 65 | // returns 66 | var a=5,b=6;fn(a,b); 67 | ``` 68 | 69 | ### Options 70 | 71 | You can also pass options to `minify`. Here is list of default options: 72 | 73 | ```js 74 | ({ 75 | quotes: `'`, 76 | fixCount: 1, // the more fixCount - less output size 77 | conditions: false, 78 | mangleClassNames: true, 79 | mangle: true, 80 | mergeVariables: true, 81 | removeUnusedVariables: false, 82 | removeConsole: false, 83 | removeUselessSpread: true, 84 | applyTemplateLiterals: true, 85 | convertStrictEqualToEqual: false, 86 | }); 87 | ``` 88 | 89 | And usage example: 90 | 91 | ```js 92 | import {minify} from '@putout/minify'; 93 | 94 | const source = ` 95 | const a = 5; 96 | const b = 6; 97 | `; 98 | 99 | minify(source, { 100 | removeUnusedVariables: false, 101 | }); 102 | ``` 103 | 104 | ### How it's compared to X(your benchmark)? 105 | 106 | [Benchmark](https://github.com/putoutjs/minify/tree/master/benchmark) 107 | 108 | ## License 109 | 110 | MIT 111 | -------------------------------------------------------------------------------- /benchmark/.gitignore: -------------------------------------------------------------------------------- 1 | source/* 2 | !source/example* 3 | result 4 | .idea 5 | *.swp 6 | yarn-error.log 7 | coverage 8 | -------------------------------------------------------------------------------- /benchmark/.putout.json: -------------------------------------------------------------------------------- 1 | { 2 | "rules": { 3 | "remove-console": "off", 4 | "remove-useless-arguments/arguments": "off" 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /benchmark/README.md: -------------------------------------------------------------------------------- 1 | # Benchmark 2 | 3 | This is a performance benchmark of the following bundlers: 4 | 5 | - Bun 6 | - esbuild 7 | - Terser 8 | - @putoutjs/minify 9 | 10 | To run the benchmark: 11 | 12 | - Need to install bun globally (https://bun.sh/docs/installation) 13 | 14 | ```sh 15 | $ npm install 16 | $ node index.js 17 | ``` 18 | 19 | ## Results 20 | 21 | The `real` results, as run on a on M1 Macbook: 22 | 23 | ``` 24 | Time in ms 25 | ┌──────────┬─────┬─────────┬────────┬────────────────┐ 26 | │ (index) │ bun │ esbuild │ terser │ @putout/minify │ 27 | ├──────────┼─────┼─────────┼────────┼────────────────┤ 28 | │ react │ 8 │ 40 │ 123 │ 593 │ 29 | │ solidjs │ 9 │ 40 │ 155 │ 3817 │ 30 | │ lodash │ 13 │ 50 │ 330 │ 33121 │ 31 | │ vue │ 17 │ 55 │ 525 │ 160834 │ 32 | │ angular │ 15 │ 57 │ 523 │ 111926 │ 33 | │ jquery │ 11 │ 45 │ 290 │ 24202 │ 34 | │ example1 │ 7 │ 42 │ 68 │ 143 │ 35 | └──────────┴─────┴─────────┴────────┴────────────────┘ 36 | Size in bytes 37 | ┌──────────┬───────────────────┬───────────────────┬───────────────────┬──────────────────┬──────────────────┐ 38 | │ (index) │ original │ bun │ esbuild │ terser │ @putout/minify │ 39 | ├──────────┼───────────────────┼───────────────────┼───────────────────┼──────────────────┼──────────────────┤ 40 | │ react │ '10751 (100.0%)' │ '10553 (98.2%)' │ '10644 (99.0%)' │ '10391 (96.7%)' │ '10096 (93.9%)' │ 41 | │ solidjs │ '28537 (100.0%)' │ '21888 (76.7%)' │ '20553 (72.0%)' │ '28202 (98.8%)' │ '21962 (77.0%)' │ 42 | │ lodash │ '73015 (100.0%)' │ '72551 (99.4%)' │ '72189 (98.9%)' │ '70751 (96.9%)' │ '70794 (97.0%)' │ 43 | │ vue │ '196075 (100.0%)' │ '196443 (100.2%)' │ '193091 (98.5%)' │ '195200 (99.6%)' │ '192231 (98.0%)' │ 44 | │ angular │ '177368 (100.0%)' │ '178187 (100.5%)' │ '177834 (100.3%)' │ '176388 (99.4%)' │ '173584 (97.9%)' │ 45 | │ jquery │ '87533 (100.0%)' │ '87451 (99.9%)' │ '87119 (99.5%)' │ '86958 (99.3%)' │ '85968 (98.2%)' │ 46 | │ example1 │ '861 (100.0%)' │ '512 (59.5%)' │ '502 (58.3%)' │ '501 (58.2%)' │ '496 (57.6%)' │ 47 | └──────────┴───────────────────┴───────────────────┴───────────────────┴──────────────────┴──────────────────┘ 48 | ``` 49 | -------------------------------------------------------------------------------- /benchmark/cli/minify.js: -------------------------------------------------------------------------------- 1 | import {readFileSync, writeFileSync} from 'node:fs'; 2 | import {minify} from '@putout/minify'; 3 | 4 | export const runMinify = (dist, out) => { 5 | const body = readFileSync(dist, 'utf8'); 6 | writeFileSync(out, minify(body)); 7 | }; 8 | -------------------------------------------------------------------------------- /benchmark/index.js: -------------------------------------------------------------------------------- 1 | import {get} from 'node:https'; 2 | import {execSync} from 'node:child_process'; 3 | import { 4 | statSync, 5 | createWriteStream, 6 | rmSync, 7 | } from 'node:fs'; 8 | import {runMinify} from './cli/minify.js'; 9 | 10 | const listFiles = { 11 | react: { 12 | url: 'https://cdn.jsdelivr.net/npm/react@18.3.1/umd/react.production.min.js', 13 | }, 14 | solidjs: { 15 | url: 'https://cdn.jsdelivr.net/npm/solid-js@1.8.17/dist/solid.min.js', 16 | }, 17 | lodash: { 18 | url: 'https://cdn.jsdelivr.net/npm/lodash@4.17.21/lodash.min.js', 19 | }, 20 | vue: { 21 | url: 'https://cdn.jsdelivr.net/npm/vue@3.4.29/dist/vue.global.min.js', 22 | }, 23 | angular: { 24 | url: 'https://cdn.jsdelivr.net/npm/angular@1.8.3/angular.min.js', 25 | }, 26 | jquery: { 27 | url: 'https://cdn.jsdelivr.net/npm/jquery@3.7.1/dist/jquery.min.js', 28 | }, 29 | example1: { 30 | file: './source/example1.js', 31 | }, 32 | }; 33 | 34 | const compressors = { 35 | 'bun': 'bun build --minify {dist} --outfile {out}', 36 | 'esbuild': './node_modules/.bin/esbuild {dist} --bundle --minify --outfile={out}', 37 | 'terser': './node_modules/.bin/terser {dist} --compress --mangle --comments false -o {out}', 38 | '@putout/minify': 'node ./cli/minify.js {dist} {out}', 39 | }; 40 | 41 | const debug = () => {}; 42 | 43 | // debug = console.log; 44 | function fileExists(path) { 45 | try { 46 | const s = statSync(path); 47 | debug(`File ${path} exists ${s.size} bytes`); 48 | 49 | return s.size > 0; 50 | } catch { 51 | debug(`File ${path} does not exist`); 52 | return false; 53 | } 54 | } 55 | 56 | function downloadFile(url, dest) { 57 | if (fileExists(dest)) { 58 | debug(`File ${dest} already exists`); 59 | return; 60 | } 61 | 62 | return new Promise((resolve) => { 63 | debug(`Downloading ${url} to ${dest}`); 64 | get(url, (res) => { 65 | const file = createWriteStream(dest, ''); 66 | res.pipe(file); 67 | res.on('end', () => { 68 | debug(`Downloaded ${url} to ${dest}`); 69 | resolve(); 70 | }); 71 | }); 72 | }); 73 | } 74 | 75 | const fileFromUrl = (url) => `./source/${url}.js`; 76 | 77 | async function download() { 78 | for (const [key, value] of Object.entries(listFiles)) { 79 | if (!value.url) 80 | continue; 81 | 82 | const {url} = value; 83 | const dest = fileFromUrl(key); 84 | 85 | await downloadFile(url, dest); 86 | } 87 | } 88 | 89 | function getPathFromFile(file) { 90 | return listFiles[file].file || fileFromUrl(file); 91 | } 92 | 93 | function removeFile(filePath) { 94 | rmSync(filePath, { 95 | force: true, 96 | }); 97 | } 98 | 99 | function execute(value, dist, out) { 100 | if (value.startsWith('node ./cli/minify.js')) { 101 | debug(`Running: minify`); 102 | runMinify(dist, out); 103 | } 104 | 105 | const cmd = value 106 | .replace('{dist}', dist) 107 | .replace('{out}', out); 108 | 109 | debug(`Running: ${cmd}`); 110 | execSync(cmd, { 111 | stdio: 'pipe', 112 | encoding: 'utf8', 113 | }); 114 | } 115 | 116 | function compareTask(file) { 117 | const dist = getPathFromFile(file); 118 | const result = {}; 119 | 120 | for (const [key, value] of Object.entries(compressors)) { 121 | const out = `./result/${file}-${key.replace('/', '-')}.js`; 122 | 123 | removeFile(out); 124 | 125 | let endTime = 0; 126 | 127 | try { 128 | const startTime = Date.now(); 129 | execute(value, dist, out); 130 | endTime = Date.now() - startTime; 131 | } catch(e) { 132 | console.error(`Error running ${key}: ${e.message} ${e.stderr}`); 133 | continue; 134 | } 135 | 136 | const fileSize = statSync(out).size; 137 | 138 | result[key] = { 139 | time: endTime, 140 | size: fileSize, 141 | }; 142 | console.log(`File: ${file} Compressor: ${key} Time: ${endTime}ms Size: ${fileSize} bytes`); 143 | } 144 | 145 | return result; 146 | } 147 | 148 | const convertMap = (fn, obj) => Object.fromEntries(Object 149 | .entries(obj) 150 | .map(([k, v]) => [k, fn(v, k, obj)]) 151 | .filter(([k, v]) => v)); 152 | 153 | function convertTable(obj, key) { 154 | return convertMap(convertMap.bind(null, (v) => v[key]), obj); 155 | } 156 | 157 | function compare() { 158 | const result = {}; 159 | 160 | for (const key of Object.keys(listFiles)) { 161 | result[key] = compareTask(key); 162 | const originalSize = statSync(getPathFromFile(key)).size; 163 | 164 | result[key] = { 165 | original: { 166 | size: originalSize, 167 | }, 168 | ...result[key], 169 | }; 170 | } 171 | 172 | return result; 173 | } 174 | 175 | async function main() { 176 | await download(); 177 | const result = compare(); 178 | 179 | debug(result); 180 | const resultTime = convertTable(result, 'time'); 181 | 182 | debug(resultTime); 183 | console.log('Time in ms'); 184 | console.table(resultTime); 185 | const resultSize = convertMap(convertMap.bind(null, (v, k, obj) => `${v} (${(100 * v / obj.original).toFixed(1)}%)`), convertTable(result, 'size')); 186 | 187 | debug(resultSize); 188 | console.log('Size in bytes'); 189 | console.table(resultSize); 190 | } 191 | 192 | main(); 193 | -------------------------------------------------------------------------------- /benchmark/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@putout/minify-benchmark", 3 | "version": "1.0.0", 4 | "main": "index.js", 5 | "type": "module", 6 | "scripts": { 7 | "test": "echo \"Error: no test specified\" && exit 1" 8 | }, 9 | "homepage": "https://github.com/putoutjs/minify/tree/master/benchmark#readme", 10 | "license": "MIT", 11 | "repository": { 12 | "type": "git", 13 | "url": "git+https://github.com/putoutjs/minify.git" 14 | }, 15 | "dependencies": { 16 | "@putout/minify": "^4.1.0", 17 | "esbuild": "^0.21.5", 18 | "terser": "^5.31.1" 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /benchmark/source/example1.js: -------------------------------------------------------------------------------- 1 | /* global jQuery */ 2 | const isUndefined = (a) => typeof a === 'undefined'; 3 | 4 | jQuery(($) => { 5 | let dp; 6 | 7 | if (!isUndefined($.datepicker)) { 8 | $('#ep_ipo_date').datepicker({ 9 | dateFormat: 'yy-mm-dd', 10 | changeYear: true, 11 | changeMonth: true, 12 | }); 13 | $('#ep_ipo_date_dp').click(function() { 14 | if ($('#ui-datepicker-div').is(':visible') && dp === $(this).attr('id')) { 15 | $('#ep_ipo_date').datepicker('hide'); 16 | const dp = null; 17 | } else { 18 | $('#ep_ipo_date').datepicker('show'); 19 | const dp = $(this).attr('id'); 20 | } 21 | }); 22 | 23 | $('#ep_ipo_date').focusout(function() { 24 | if (!/^(?:\d{2}\/){2}\d{4}$/.test($(this).val()) && $(this).val().length) 25 | $(this).val(''); 26 | }); 27 | } 28 | }); 29 | -------------------------------------------------------------------------------- /eslint.config.js: -------------------------------------------------------------------------------- 1 | import {safeAlign} from 'eslint-plugin-putout'; 2 | import {matchToFlat} from '@putout/eslint-flat'; 3 | import {defineConfig} from 'eslint/config'; 4 | 5 | export default defineConfig([safeAlign, matchToFlat({ 6 | '**/fixture/*.js': { 7 | 'arrow-parens': ['error', 'as-needed'], 8 | '@stylistic/js/no-extra-parens': 'off', 9 | 'prefer-arrow-callback': 'off', 10 | }, 11 | '**/*-fix.*': { 12 | '@stylistic/js/quotes': 'off', 13 | '@stylistic/js/eol-last': 'off', 14 | '@stylistic/js/space-infix-ops': 'off', 15 | }, 16 | })]); 17 | -------------------------------------------------------------------------------- /lib/minify.js: -------------------------------------------------------------------------------- 1 | import {print} from '@putout/printer'; 2 | import {parse, transform} from 'putout'; 3 | import {getFirstPassOptions} from './plugins.js'; 4 | 5 | export const minify = (source, options = {}) => { 6 | const ast = parse(source); 7 | const {quote = `'`} = options; 8 | 9 | transform(ast, source, getFirstPassOptions(options)); 10 | 11 | const code = print(ast, { 12 | format: { 13 | newline: '', 14 | space: '', 15 | indent: '', 16 | splitter: ' ', 17 | endOfFile: '', 18 | quote, 19 | }, 20 | semantics: { 21 | comments: false, 22 | roundBraces: false, 23 | trailingComma: false, 24 | encodeDoubleQuotes: true, 25 | encodeSingleQuotes: true, 26 | }, 27 | }); 28 | 29 | return code.replaceAll(';}', '}'); 30 | }; 31 | -------------------------------------------------------------------------------- /lib/plugins.js: -------------------------------------------------------------------------------- 1 | import * as minifyPlugin from '@putout/plugin-minify'; 2 | import * as mergeDestructuringProperties from '@putout/plugin-merge-destructuring-properties'; 3 | import * as declare from '@putout/plugin-declare'; 4 | import * as applyOptionalChaining from '@putout/plugin-apply-optional-chaining'; 5 | import * as applyTemplateLiteralsPlugins from '@putout/plugin-apply-template-literals'; 6 | import * as conditionsPlugins from '@putout/plugin-conditions'; 7 | import * as convertToArrowFunction from '@putout/plugin-convert-to-arrow-function'; 8 | import * as convertArgumentsToRest from '@putout/plugin-convert-arguments-to-rest'; 9 | import * as removeConsolePlugin from '@putout/plugin-remove-console'; 10 | import * as removeUnusedVariablesPlugin from '@putout/plugin-remove-unused-variables'; 11 | import * as removeUnreachableCode from '@putout/plugin-remove-unreachable-code'; 12 | import * as removeDebugger from '@putout/plugin-remove-debugger'; 13 | import * as removeEmpty from '@putout/plugin-remove-empty'; 14 | import * as removeUselessSpreadPlugin from '@putout/plugin-remove-useless-spread'; 15 | import * as removeUselessVariables from '@putout/plugin-remove-useless-variables'; 16 | import * as pluginReturn from '@putout/plugin-return'; 17 | import * as removeUselessElse from '@putout/plugin-remove-useless-else'; 18 | import * as removeUnusedExpressions from '@putout/plugin-remove-unused-expressions'; 19 | import * as removeUnreferencedVariables from '@putout/plugin-remove-unreferenced-variables'; 20 | import * as reuseDuplicateInit from '@putout/plugin-reuse-duplicate-init'; 21 | import * as simplifyTernary from '@putout/plugin-simplify-ternary'; 22 | import * as mergeDuplicateFunctions from '@putout/plugin-merge-duplicate-functions'; 23 | import * as mergeDuplicateImports from '@putout/plugin-esm/merge-duplicate-imports'; 24 | import * as forOf from '@putout/plugin-for-of'; 25 | import * as removeNestedBlocks from '@putout/plugin-remove-nested-blocks'; 26 | import * as logicalExpressions from '@putout/plugin-logical-expressions'; 27 | import * as newPlugin from '@putout/plugin-new'; 28 | import * as regexp from '@putout/plugin-regexp'; 29 | import * as promises from '@putout/plugin-promises'; 30 | import * as types from '@putout/plugin-types'; 31 | 32 | export const parseOptions = (options) => ({ 33 | applyTemplateLiterals: true, 34 | conditions: false, 35 | removeUnusedVariables: false, 36 | removeConsole: false, 37 | removeUselessSpread: true, 38 | mangleClassNames: true, 39 | mangle: true, 40 | mergeVariables: true, 41 | convertStrictEqualToEqual: false, 42 | fixCount: 1, 43 | ...options, 44 | }); 45 | 46 | export const getFirstPassOptions = (options) => { 47 | const { 48 | fixCount, 49 | conditions, 50 | removeUnusedVariables, 51 | removeConsole, 52 | removeUselessSpread, 53 | applyTemplateLiterals, 54 | convertStrictEqualToEqual, 55 | mangle, 56 | mangleClassNames, 57 | mergeVariables, 58 | } = parseOptions(options); 59 | 60 | const plugins = [ 61 | applyTemplateLiterals && ['apply-template-literals', applyTemplateLiteralsPlugins], 62 | ['apply-optional-chaining', applyOptionalChaining], 63 | conditions && ['conditions', conditionsPlugins], 64 | ['convert-to-arrow-function', convertToArrowFunction], 65 | ['convert-arguments-to-rest', convertArgumentsToRest], 66 | ['declare', declare], 67 | ['for-of', forOf], 68 | ['regexp', regexp], 69 | removeUnusedVariables && ['remove-unused-variables', removeUnusedVariablesPlugin], 70 | ['remove-unreachable-code', removeUnreachableCode], 71 | ['remove-debugger', removeDebugger], 72 | ['remove-empty', removeEmpty], 73 | removeUselessSpread && ['remove-useless-spread', removeUselessSpreadPlugin], 74 | ['return/remove-useless', pluginReturn.rules['remove-useless']], 75 | ['remove-useless-else', removeUselessElse], 76 | ['remove-useless-variables', removeUselessVariables], 77 | ['remove-unused-expressions', removeUnusedExpressions], 78 | ['remove-unreferenced-variables', removeUnreferencedVariables], 79 | ['remove-nested-blocks', removeNestedBlocks], 80 | removeConsole && ['remove-console', removeConsolePlugin], 81 | ['reuse-duplicate-init', reuseDuplicateInit], 82 | ['logical-expressions', logicalExpressions], 83 | ['merge-destructuring-properties', mergeDestructuringProperties], 84 | ['merge-duplicate-functions', mergeDuplicateFunctions], 85 | ['merge-duplicate-import * as s', mergeDuplicateImports], 86 | ['new', newPlugin], 87 | ['simplify-ternary', simplifyTernary], 88 | ['types', types], 89 | ['promises', promises], 90 | ['minify', minifyPlugin], 91 | ].filter(Boolean); 92 | 93 | return { 94 | fixCount, 95 | rules: { 96 | ...conditions && { 97 | 'conditions/apply-if': 'off', 98 | 'conditions/convert-equal-to-strict-equal': 'off', 99 | }, 100 | 'promises/add-missing-await': 'off', 101 | 'minify/mangle-names': [ 102 | mangle, { 103 | mangleClassNames, 104 | }, 105 | ], 106 | 'minify/merge-variables': mergeVariables, 107 | 'minify/convert-strict-equal-to-equal': convertStrictEqualToEqual, 108 | }, 109 | plugins, 110 | }; 111 | }; 112 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@putout/minify", 3 | "version": "5.1.2", 4 | "type": "module", 5 | "author": "coderaiser (https://github.com/coderaiser)", 6 | "description": "🐊Putout-based minifier", 7 | "homepage": "https://github.com/putoutjs/minify#readme", 8 | "files": [ 9 | "bundle/minify.min.js", 10 | "README.md" 11 | ], 12 | "exports": { 13 | ".": "./bundle/minify.min.js", 14 | "./dev": "./lib/minify.js" 15 | }, 16 | "repository": { 17 | "type": "git", 18 | "url": "git+https://github.com/putoutjs/minify.git" 19 | }, 20 | "scripts": { 21 | "wisdom": "madrun wisdom", 22 | "test": "madrun test", 23 | "watch:test": "madrun watch:test", 24 | "lint": "madrun lint", 25 | "fresh:lint": "madrun fresh:lint", 26 | "lint:fresh": "madrun lint:fresh", 27 | "fix:lint": "madrun fix:lint", 28 | "coverage": "madrun coverage", 29 | "coverage:html": "madrun coverage:html", 30 | "report": "madrun report", 31 | "build": "madrun build", 32 | "minify": "madrun minify" 33 | }, 34 | "keywords": [ 35 | "putout", 36 | "minify", 37 | "AST", 38 | "babel", 39 | "printer", 40 | "api", 41 | "traverse", 42 | "generate" 43 | ], 44 | "devDependencies": { 45 | "@putout/eslint-flat": "^3.0.0", 46 | "@putout/plugin-apply-optional-chaining": "^6.0.0", 47 | "@putout/plugin-apply-shorthand-properties": "^6.1.0", 48 | "@putout/plugin-apply-template-literals": "^4.2.0", 49 | "@putout/plugin-conditions": "^7.1.0", 50 | "@putout/plugin-convert-arguments-to-rest": "^3.1.0", 51 | "@putout/plugin-convert-to-arrow-function": "^4.0.0", 52 | "@putout/plugin-declare": "^5.0.0", 53 | "@putout/plugin-esm": "^4.2.2", 54 | "@putout/plugin-for-of": "^9.0.0", 55 | "@putout/plugin-logical-expressions": "^7.0.0", 56 | "@putout/plugin-merge-destructuring-properties": "^11.0.0", 57 | "@putout/plugin-merge-duplicate-functions": "^4.0.0", 58 | "@putout/plugin-minify": "^10.0.0", 59 | "@putout/plugin-new": "^4.0.0", 60 | "@putout/plugin-promises": "^17.0.0", 61 | "@putout/plugin-regexp": "^11.0.0", 62 | "@putout/plugin-remove-console": "^6.0.0", 63 | "@putout/plugin-remove-debugger": "^7.0.0", 64 | "@putout/plugin-remove-empty": "^14.0.0", 65 | "@putout/plugin-remove-nested-blocks": "^9.0.0", 66 | "@putout/plugin-remove-unreachable-code": "^2.0.0", 67 | "@putout/plugin-remove-unreferenced-variables": "^5.0.0", 68 | "@putout/plugin-remove-unused-expressions": "^12.0.0", 69 | "@putout/plugin-remove-unused-variables": "^13.0.0", 70 | "@putout/plugin-remove-useless-arguments": "^12.0.0", 71 | "@putout/plugin-remove-useless-else": "^2.0.0", 72 | "@putout/plugin-remove-useless-spread": "^13.0.0", 73 | "@putout/plugin-remove-useless-variables": "^14.0.0", 74 | "@putout/plugin-return": "^2.0.0", 75 | "@putout/plugin-reuse-duplicate-init": "^8.0.0", 76 | "@putout/plugin-simplify-ternary": "^8.0.0", 77 | "@putout/plugin-types": "^8.0.0", 78 | "@putout/printer": "^14.8.0", 79 | "@rollup/plugin-alias": "^5.0.0", 80 | "@rollup/plugin-commonjs": "^28.0.0", 81 | "@rollup/plugin-json": "^6.0.0", 82 | "@rollup/plugin-node-resolve": "^16.0.0", 83 | "@rollup/plugin-replace": "^6.0.1", 84 | "c8": "^10.1.2", 85 | "eslint": "^9.2.0", 86 | "eslint-plugin-putout": "^27.0.0", 87 | "fullstore": "^3.0.0", 88 | "just-kebab-case": "^4.2.0", 89 | "just-snake-case": "^3.2.0", 90 | "madrun": "^11.0.0", 91 | "minify": "^14.0.0", 92 | "mock-require": "^3.0.3", 93 | "montag": "^1.0.0", 94 | "nodemon": "^3.0.1", 95 | "putout": "^40.0.9", 96 | "redlint": "^4.0.0", 97 | "rendy": "^4.1.3", 98 | "rollup": "^4.5.0", 99 | "rollup-plugin-node-externals": "^8.0.0", 100 | "rollup-plugin-polyfill-node": "^0.13.0", 101 | "supertape": "^11.0.3", 102 | "try-catch": "^3.0.0" 103 | }, 104 | "license": "MIT", 105 | "engines": { 106 | "node": ">=20" 107 | }, 108 | "publishConfig": { 109 | "access": "public" 110 | }, 111 | "dependencies": {} 112 | } 113 | -------------------------------------------------------------------------------- /rollup.config.js: -------------------------------------------------------------------------------- 1 | import {resolve} from 'node:path'; 2 | import commonjs from '@rollup/plugin-commonjs'; 3 | import {nodeResolve} from '@rollup/plugin-node-resolve'; 4 | import json from '@rollup/plugin-json'; 5 | import nodePolyfills from 'rollup-plugin-polyfill-node'; 6 | import replace from '@rollup/plugin-replace'; 7 | import alias from '@rollup/plugin-alias'; 8 | 9 | const createReplacement = (a) => ({ 10 | find: `node:${a}`, 11 | replacement: a, 12 | }); 13 | 14 | export default { 15 | input: 'lib/minify.js', 16 | output: { 17 | file: 'bundle/minify.js', 18 | format: 'es', 19 | }, 20 | plugins: [ 21 | alias({ 22 | entries: [{ 23 | find: 'fullstore', 24 | replacement: resolve('./stub/fullstore.js'), 25 | }, { 26 | find: './loader.mjs', 27 | replacement: './stub/loader.js', 28 | }, { 29 | find: 'chalk', 30 | replacement: './stub/chalk.js', 31 | }, { 32 | find: 'acorn-stage3', 33 | replacement: new URL('./stub/acorn-stage3.js', import.meta.url).pathname, 34 | }, 35 | ...[ 36 | 'process', 37 | 'module', 38 | 'path', 39 | ].map(createReplacement)], 40 | }), 41 | commonjs({ 42 | strictRequires: 'auto', 43 | defaultIsModuleExports: false, 44 | exclude: [ 45 | 'os', 46 | 'path', 47 | 'fs', 48 | 'module', 49 | 'buffer', 50 | '**/parse-options/**', 51 | ], 52 | ignore: [ 53 | 'tenko', 54 | 'hermes-parser', 55 | 'esprima', 56 | 'espree', 57 | 'acorn', 58 | 'hermes-parser/*', 59 | 'core-js/**', 60 | '**/lib/loader.*', 61 | 'caniuse', 62 | 'hermes*', 63 | 'electron*', 64 | 'node-releases', 65 | ], 66 | }), 67 | nodeResolve({ 68 | preferBuiltins: false, 69 | browser: true, 70 | }), 71 | nodePolyfills(), 72 | json(), 73 | replace({ 74 | preventAssignment: true, 75 | values: { 76 | 'process.env.BABEL_TYPES_8_BREAKING': true, 77 | 'Buffer.isBuffer': 'Array.isArray', 78 | 'process.platform': '"unix"', 79 | 'process.env.BABEL_TYPES_8_BREAKING = true': '', 80 | 'process.env': '{}', 81 | 'export {load} from "./loader.mjs"': '', 82 | }, 83 | }), 84 | ], 85 | }; 86 | -------------------------------------------------------------------------------- /stub/acorn-stage3.js: -------------------------------------------------------------------------------- 1 | export default {}; 2 | -------------------------------------------------------------------------------- /stub/chalk.js: -------------------------------------------------------------------------------- 1 | const noop = () => {}; 2 | 3 | export default noop; 4 | -------------------------------------------------------------------------------- /stub/fullstore.js: -------------------------------------------------------------------------------- 1 | export default (value) => { 2 | const data = { 3 | value, 4 | }; 5 | 6 | return (...args) => { 7 | const [value] = args; 8 | 9 | if (!args.length) 10 | return data.value; 11 | 12 | data.value = value; 13 | 14 | return value; 15 | }; 16 | }; 17 | -------------------------------------------------------------------------------- /stub/loader.js: -------------------------------------------------------------------------------- 1 | export const load = () => {}; 2 | -------------------------------------------------------------------------------- /test/extension.js: -------------------------------------------------------------------------------- 1 | import {dirname, join} from 'node:path'; 2 | import {fileURLToPath} from 'node:url'; 3 | import {readFileSync, writeFileSync} from 'node:fs'; 4 | import process from 'node:process'; 5 | import {minify as bundledMinify} from '../bundle/minify.js'; 6 | import {minify} from '../lib/minify.js'; 7 | 8 | const {isArray} = Array; 9 | const maybeArray = (a) => isArray(a) ? a : [a]; 10 | 11 | const __filename = fileURLToPath(import.meta.url); 12 | const __dirname = dirname(__filename); 13 | 14 | const {UPDATE} = process.env; 15 | 16 | const chooseMinify = (bundle) => bundle ? bundledMinify : minify; 17 | 18 | export const minifyExtension = ({pass, equal, deepEqual}) => (fixtureName, testOptions = {}) => { 19 | const { 20 | run = true, 21 | bundle, 22 | expected = [], 23 | ...options 24 | } = testOptions; 25 | 26 | const nameFrom = join(__dirname, 'fixture', `${fixtureName}.js`); 27 | const nameTo = join(__dirname, 'fixture', `${fixtureName}-fix.js`); 28 | 29 | const fixtureFrom = readFileSync(nameFrom, 'utf8'); 30 | const result = chooseMinify(bundle)(fixtureFrom, options); 31 | 32 | if (UPDATE) { 33 | writeFileSync(nameTo, result); 34 | return pass('fixture updated'); 35 | } 36 | 37 | const fixtureTo = readFileSync(nameTo, 'utf8'); 38 | 39 | if (run) { 40 | const resultRun = runCode(result, expected, { 41 | deepEqual, 42 | }); 43 | 44 | const {is} = resultRun; 45 | 46 | if (!is) 47 | return resultRun; 48 | } 49 | 50 | return equal(result, fixtureTo); 51 | }; 52 | 53 | function runCode(code, expected, {deepEqual}) { 54 | const fn = Function('console', code); 55 | 56 | const list = []; 57 | const push = list.push.bind(list); 58 | 59 | fn({ 60 | log: push, 61 | }); 62 | 63 | return deepEqual(list, maybeArray(expected)); 64 | } 65 | -------------------------------------------------------------------------------- /test/fixture/apply-optional-chaining-fix.js: -------------------------------------------------------------------------------- 1 | var a={b:{c:1}};a?.b?.c&&console.log(a.b.c);var b={};b&&(b.running=!1); -------------------------------------------------------------------------------- /test/fixture/apply-optional-chaining.js: -------------------------------------------------------------------------------- 1 | const a = { 2 | b: { 3 | c: 1, 4 | }, 5 | }; 6 | 7 | if (a && a.b && a.b.c) 8 | console.log(a.b.c); 9 | 10 | const Transition = {}; 11 | Transition && (Transition.running = !1); 12 | -------------------------------------------------------------------------------- /test/fixture/apply-template-literals-disabled-fix.js: -------------------------------------------------------------------------------- 1 | var a='hello',b='("'+a+'")'; -------------------------------------------------------------------------------- /test/fixture/apply-template-literals-disabled.js: -------------------------------------------------------------------------------- 1 | const name = 'hello'; 2 | const line = '("' + name + '")'; -------------------------------------------------------------------------------- /test/fixture/apply-template-literals-fix.js: -------------------------------------------------------------------------------- 1 | var a='hello';console.log(`("${a}")`); -------------------------------------------------------------------------------- /test/fixture/apply-template-literals.js: -------------------------------------------------------------------------------- 1 | const name = 'hello'; 2 | const line = '("' + name + '")'; 3 | 4 | console.log(line); 5 | -------------------------------------------------------------------------------- /test/fixture/array-fix.js: -------------------------------------------------------------------------------- 1 | var a=[1,2,3,4,5,6];console.log(a.reduce(((a,b)=>a+b),0)); -------------------------------------------------------------------------------- /test/fixture/array.js: -------------------------------------------------------------------------------- 1 | const a = [ 2 | 1, 3 | 2, 4 | 3, 5 | 4, 6 | 5, 7 | 6, 8 | ]; 9 | 10 | const sum = (a, b) => a + b; 11 | console.log(a.reduce(sum, 0)); 12 | -------------------------------------------------------------------------------- /test/fixture/arrow-fix.js: -------------------------------------------------------------------------------- 1 | (f=>console.log(f()))(()=>'start');((b,c)=>console.log(b,c))('hello','world'); -------------------------------------------------------------------------------- /test/fixture/arrow.js: -------------------------------------------------------------------------------- 1 | const m = f => console.log(f()); 2 | const b = 'hello'; 3 | const c = 'world'; 4 | 5 | m(function() { 6 | return 'start'; 7 | }); 8 | 9 | const a = (b, c) => { 10 | console.log(b, c); 11 | }; 12 | a(b, c); 13 | -------------------------------------------------------------------------------- /test/fixture/assign-fix.js: -------------------------------------------------------------------------------- 1 | var l=[{l:2}],w=console.log;for(const e of l)e.o,e.l=w(e.l); -------------------------------------------------------------------------------- /test/fixture/assign.js: -------------------------------------------------------------------------------- 1 | const l = [{l: 2}]; 2 | const w = console.log; 3 | 4 | for (const e of l) 5 | (e.o = (e.o)), (e.l = w(e.l)); 6 | -------------------------------------------------------------------------------- /test/fixture/before-init-fix.js: -------------------------------------------------------------------------------- 1 | const{assign:a}=Object;const q=1,A={};function d(e,n){return a({},A,n)}var _=d(!q),w=c=>c;console.log(_[q]&&_||0);var c=e=>e.w;function f(e){const{n}=e;e.w=n;const q=c(e);return q&&w(q)}console.log(f({n:1})); -------------------------------------------------------------------------------- /test/fixture/before-init.js: -------------------------------------------------------------------------------- 1 | const q = 1, 2 | signalOptions = {}; 3 | 4 | function createSignal(e, n) { 5 | return Object.assign({}, signalOptions, n); 6 | } 7 | const transPending = createSignal(!q); 8 | 9 | console.log(transPending[q] && transPending || 0); 10 | 11 | const c = (e) => e.w; 12 | const w = (c) => c; 13 | 14 | function f(e) { 15 | const {n} = e; 16 | e.w = n; 17 | const q = c(e); 18 | 19 | return q && w(q); 20 | } 21 | console.log(f({n: 1})); 22 | -------------------------------------------------------------------------------- /test/fixture/boolean-fix.js: -------------------------------------------------------------------------------- 1 | console.log(!0,!1);const c=!!'hello'; -------------------------------------------------------------------------------- /test/fixture/boolean.js: -------------------------------------------------------------------------------- 1 | const a = true; 2 | const b = false; 3 | 4 | console.log(a, b); 5 | 6 | const c = new Boolean('hello'); 7 | -------------------------------------------------------------------------------- /test/fixture/class-fix.js: -------------------------------------------------------------------------------- 1 | var a='foo',b=123.4;class C{f(){}constructor(){this.d=a;this.e=b}}globalThis.h=globalThis.i=new C; -------------------------------------------------------------------------------- /test/fixture/class.js: -------------------------------------------------------------------------------- 1 | var a = "foo"; 2 | var b = 123.4; 3 | class C { 4 | f() { 5 | } 6 | constructor() { 7 | this.d = a; 8 | this.e = b; 9 | } 10 | } 11 | var g = new C(); 12 | globalThis.h = g; 13 | globalThis.i = g; -------------------------------------------------------------------------------- /test/fixture/closure-fix.js: -------------------------------------------------------------------------------- 1 | let A=5;(f=>f())(a=>{console.log(A);console.log(a)}); -------------------------------------------------------------------------------- /test/fixture/closure.js: -------------------------------------------------------------------------------- 1 | let aaaaa = 5; 2 | const fn = (f) => f(); 3 | fn((a)=>{ 4 | console.log(aaaaa); 5 | console.log(a); 6 | }); 7 | -------------------------------------------------------------------------------- /test/fixture/comments-fix.js: -------------------------------------------------------------------------------- 1 | var a=5; -------------------------------------------------------------------------------- /test/fixture/comments.js: -------------------------------------------------------------------------------- 1 | // hello 2 | const a = 5; -------------------------------------------------------------------------------- /test/fixture/conditions-fix.js: -------------------------------------------------------------------------------- 1 | let a;!a&&console.log(2); -------------------------------------------------------------------------------- /test/fixture/conditions.js: -------------------------------------------------------------------------------- 1 | let a; 2 | 3 | if (a === 0) 4 | console.log(2); 5 | -------------------------------------------------------------------------------- /test/fixture/const-fix.js: -------------------------------------------------------------------------------- 1 | var a=[],z=a.forEach(aa=>d.push(aa)); -------------------------------------------------------------------------------- /test/fixture/const.js: -------------------------------------------------------------------------------- 1 | const a = []; 2 | const z=a.forEach(aa=>d.push(aa)) -------------------------------------------------------------------------------- /test/fixture/convert-arguments-to-rest-fix.js: -------------------------------------------------------------------------------- 1 | (function(){'use strict';function a(...args){for(let i=0;i(d(),1); -------------------------------------------------------------------------------- /test/fixture/convert-return-to-sequence-expression.js: -------------------------------------------------------------------------------- 1 | () => { 2 | d(); return 1; 3 | }; 4 | -------------------------------------------------------------------------------- /test/fixture/convert-strict-equal-to-equal-fix.js: -------------------------------------------------------------------------------- 1 | console.log(o=((a,b)=>a===b)(1,'1')?1:2); -------------------------------------------------------------------------------- /test/fixture/convert-strict-equal-to-equal-on-fix.js: -------------------------------------------------------------------------------- 1 | console.log(((a,b)=>a==b)(1,`${1}`)?1:2); -------------------------------------------------------------------------------- /test/fixture/convert-strict-equal-to-equal-on.js: -------------------------------------------------------------------------------- 1 | const eq = (a, b) => a === b; 2 | const t = 1;const c = `${1}`;console.log(eq(t, c) ? 1 : 2); 3 | -------------------------------------------------------------------------------- /test/fixture/convert-strict-equal-to-equal.js: -------------------------------------------------------------------------------- 1 | const t = 1; 2 | const c = '1'; 3 | const eq = (a, b) => a === b; 4 | 5 | console.log(o = eq(t, c) ? 1 : 2); 6 | -------------------------------------------------------------------------------- /test/fixture/dead-code-fix.js: -------------------------------------------------------------------------------- 1 | 'use strict';function a(){var x=1}function b(){var x=f()}function c(){console.log(1);function A(){return 5}}export{a as foo,b as bar,c as baz}; -------------------------------------------------------------------------------- /test/fixture/dead-code.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | function foo() {var x = 1;} 4 | function bar() { var x = f(); } 5 | function baz() { 6 | debugger; 7 | var x = 1; 8 | console.log(x); 9 | function unused() { 10 | return 5; 11 | } 12 | } 13 | export { 14 | foo, 15 | bar, 16 | baz, 17 | } -------------------------------------------------------------------------------- /test/fixture/declaration-order-fix.js: -------------------------------------------------------------------------------- 1 | var c=e=>e.w,w=c=>c;function f(e){const{n}=e;e.w=n;var q=c(e);return q&&w(q)}console.log(f({n:1})); -------------------------------------------------------------------------------- /test/fixture/declaration-order.js: -------------------------------------------------------------------------------- 1 | const c = (e) => e.w; 2 | const w = (c) => c; 3 | 4 | function f(e) { 5 | const {n} = e; 6 | e.w = n; 7 | const q = c(e); 8 | 9 | return q && w(q); 10 | } 11 | console.log(f({n: 1})); 12 | -------------------------------------------------------------------------------- /test/fixture/declare-fix.js: -------------------------------------------------------------------------------- 1 | const{keys:A}=Object;A({});A({});A({});A({}); -------------------------------------------------------------------------------- /test/fixture/declare.js: -------------------------------------------------------------------------------- 1 | let a = {}, b = {}, c = {}, d = {}; 2 | 3 | Object.keys(a); 4 | Object.keys(b); 5 | Object.keys(c); 6 | Object.keys(d); 7 | -------------------------------------------------------------------------------- /test/fixture/duplicate-declaration-fix.js: -------------------------------------------------------------------------------- 1 | const{assign:a}=Object;function b(){}function c(){return b()}function d(){return c}var A={context:void 0,registry:void 0},[j]=h(!1);function f(e){A.context=e}var g=null;function h(e){return[e,a({}).equals]}function i(){return g}function k(){return[j,i]}function l(e){f()}global.useTransition=k; -------------------------------------------------------------------------------- /test/fixture/duplicate-declaration.js: -------------------------------------------------------------------------------- 1 | function workLoop() {} 2 | function flushWork() { 3 | return workLoop(); 4 | } 5 | function requestCallback() { 6 | return flushWork; 7 | } 8 | const sharedConfig = { context: void 0, registry: void 0 }; 9 | function setHydrateContext(e) { 10 | sharedConfig.context = e; 11 | } 12 | var Owner = null; 13 | function createSignal(e) { 14 | return [e, Object.assign({}).equals]; 15 | } 16 | function startTransition() { 17 | return Owner; 18 | } 19 | const [transPending] = createSignal(!1); 20 | function useTransition() { 21 | return [transPending, startTransition]; 22 | } 23 | function runUserEffects(e) { 24 | setHydrateContext(); 25 | } 26 | global.useTransition = useTransition -------------------------------------------------------------------------------- /test/fixture/else-fix.js: -------------------------------------------------------------------------------- 1 | let a=1;(()=>{})();if(a){console.log('hello');return'hello'}console.log('world'); -------------------------------------------------------------------------------- /test/fixture/else.js: -------------------------------------------------------------------------------- 1 | let a = 1; 2 | let b = () => {}; 3 | let c = () => {}; 4 | 5 | if (a) 6 | b(); 7 | else 8 | c(); 9 | 10 | 11 | if (a) { 12 | console.log('hello') 13 | return 'hello'; 14 | } else { 15 | console.log('world'); 16 | } 17 | -------------------------------------------------------------------------------- /test/fixture/evaluate-fix.js: -------------------------------------------------------------------------------- 1 | var a=5;console.log('hello'); -------------------------------------------------------------------------------- /test/fixture/evaluate.js: -------------------------------------------------------------------------------- 1 | const a = 5; 2 | 3 | if (a) 4 | console.log('hello'); 5 | -------------------------------------------------------------------------------- /test/fixture/fix-count-fix.js: -------------------------------------------------------------------------------- 1 | function A(){var n=a();n&&n();if(!0){const n=b();n&&n()}} -------------------------------------------------------------------------------- /test/fixture/fix-count.js: -------------------------------------------------------------------------------- 1 | function mergeProps() { 2 | const n = a(); 3 | 4 | if (n) { 5 | n(); 6 | } 7 | 8 | if (true) { 9 | const n = b(); 10 | 11 | if (n) 12 | n(); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /test/fixture/for-each-destructuring-fix.js: -------------------------------------------------------------------------------- 1 | var a=[{b:'b',c:'c'},{b:'bb',c:'cc'}];for(const{b,c} of a)console.log(b,c); -------------------------------------------------------------------------------- /test/fixture/for-each-destructuring.js: -------------------------------------------------------------------------------- 1 | const a = [{b: 'b', c: 'c'}, {b: 'bb', c: 'cc'}]; 2 | 3 | a.forEach(({b, c}) => { 4 | console.log(b, c); 5 | }); 6 | -------------------------------------------------------------------------------- /test/fixture/for-each-ternary-fix.js: -------------------------------------------------------------------------------- 1 | const{keys:a}=Object;function t(e){var n=[];return e instanceof Map?e.forEach((i,o)=>{'object'===r(i)&&(i=t(i)),n.push([o,i])}):a(e).forEach(o=>{})}; -------------------------------------------------------------------------------- /test/fixture/for-each-ternary.js: -------------------------------------------------------------------------------- 1 | function t(e) { 2 | var n = []; 3 | 4 | return e instanceof Map ? e.forEach(function(e, o) { 5 | var i = e; 6 | ('object' === r(i) && (i = t(i)), n.push([o, i])); 7 | }) : Object 8 | .keys(e) 9 | .forEach(function(o) {}); 10 | }; -------------------------------------------------------------------------------- /test/fixture/for-fix.js: -------------------------------------------------------------------------------- 1 | var a=[1],n=a.length;for(let i=0;i{var c=o.sizer;for(const[w,v] of g.entries())if(v&&v.length>1)var t=c.appendChild(document.createElement('span'));else m[w]=y}),l.forEach(o=>{for(let c=o.sizer;y { 3 | const c = o.sizer; 4 | 5 | g.forEach((v, w) => { 6 | if (v && v.length > 1) { 7 | const t = c.appendChild(document.createElement('span')); 8 | } else 9 | m[w] = y; 10 | }); 11 | }), 12 | l.forEach((o) => { 13 | for ( 14 | let c = o.sizer; 15 | y < g.length; 16 | y++ 17 | ) 18 | g[y] = c.children[m++]; 19 | });console.log('hello'); 20 | -------------------------------------------------------------------------------- /test/fixture/for-of-remove-useless-fix.js: -------------------------------------------------------------------------------- 1 | console.log('hello'); -------------------------------------------------------------------------------- /test/fixture/for-of-remove-useless.js: -------------------------------------------------------------------------------- 1 | for (const a of ['hello']) { 2 | console.log(a); 3 | } -------------------------------------------------------------------------------- /test/fixture/for.js: -------------------------------------------------------------------------------- 1 | const items = [1]; 2 | const n = items.length; 3 | 4 | for (let i = 0; i < n; i++) { 5 | const item = items[i]; 6 | console.log(item); 7 | } 8 | -------------------------------------------------------------------------------- /test/fixture/function-fix.js: -------------------------------------------------------------------------------- 1 | function A(){}function _(a,b){if(a)return;return b}console.log(A(_(1,2))); -------------------------------------------------------------------------------- /test/fixture/function.js: -------------------------------------------------------------------------------- 1 | function hello() { 2 | return undefined; 3 | } 4 | 5 | function getWorld(a, b) { 6 | if (a) 7 | return undefined; 8 | 9 | return b; 10 | } 11 | 12 | console.log(hello(getWorld(1, 2))); 13 | -------------------------------------------------------------------------------- /test/fixture/guard-fix.js: -------------------------------------------------------------------------------- 1 | var x=1;!x&&(()=>{})(); -------------------------------------------------------------------------------- /test/fixture/guard.js: -------------------------------------------------------------------------------- 1 | const x = 1; 2 | const foo = () => {}; 3 | !x && foo(); 4 | -------------------------------------------------------------------------------- /test/fixture/if-fix.js: -------------------------------------------------------------------------------- 1 | let a;a&&console.log('hello');a&&(console.log('hello'),console.log('world')); -------------------------------------------------------------------------------- /test/fixture/if-logical-fix.js: -------------------------------------------------------------------------------- 1 | let a,b,c;var d=()=>{};(a||b&&c)&&console.log('test');if(a||b&&c){d();var4&&fn2()} -------------------------------------------------------------------------------- /test/fixture/if-logical.js: -------------------------------------------------------------------------------- 1 | let var1, var2, var3; 2 | const fn1 = () => {}; 3 | 4 | if (var1 || var2 && var3) { 5 | console.log('test'); 6 | } 7 | 8 | if (var1 || var2 && var3) { 9 | fn1(); 10 | 11 | if (var4) { 12 | fn2(); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /test/fixture/if-no-ternary-fix.js: -------------------------------------------------------------------------------- 1 | var a=new Date;a.setDate(1);let b=0;a.getMonth()<11?(a.setMonth(a.getMonth()+1),b=1):(a.setMonth(0),a.setFullYear(a.getFullYear()+1));var c=new Date;c.setFullYear(c.getFullYear()+1);var d=a.getFullYear(),e=c.getFullYear();console.log(d+b===e); -------------------------------------------------------------------------------- /test/fixture/if-no-ternary.js: -------------------------------------------------------------------------------- 1 | const now = new Date(); 2 | now.setDate(1); 3 | let delta = 0; 4 | 5 | if (now.getMonth() < 11) { 6 | // increase month by 1 if it is not currently December 7 | now.setMonth(now.getMonth() + 1); 8 | delta = 1; 9 | } else { 10 | // else, consider year rollover and go to next January 11 | now.setMonth(0); 12 | now.setFullYear(now.getFullYear() + 1); 13 | } 14 | 15 | const then = new Date(); 16 | then.setFullYear(then.getFullYear() + 1); 17 | 18 | const first = now.getFullYear(); 19 | const second = then.getFullYear(); 20 | 21 | console.log(first + delta === second); 22 | -------------------------------------------------------------------------------- /test/fixture/if.js: -------------------------------------------------------------------------------- 1 | let a; 2 | 3 | if (a) 4 | console.log('hello'); 5 | 6 | if (a) { 7 | console.log('hello'); 8 | console.log('world'); 9 | } 10 | -------------------------------------------------------------------------------- /test/fixture/in-fix.js: -------------------------------------------------------------------------------- 1 | var a={};'xxx' in a; -------------------------------------------------------------------------------- /test/fixture/in.js: -------------------------------------------------------------------------------- 1 | const history = {}; 2 | 'xxx' in history; -------------------------------------------------------------------------------- /test/fixture/increment-fix.js: -------------------------------------------------------------------------------- 1 | let a=0;Math.random()>0.5?a++:a--; -------------------------------------------------------------------------------- /test/fixture/increment.js: -------------------------------------------------------------------------------- 1 | let a = 0; 2 | if(Math.random() > 0.5){ 3 | a++; 4 | }else{ 5 | a--; 6 | } -------------------------------------------------------------------------------- /test/fixture/infinity-fix.js: -------------------------------------------------------------------------------- 1 | console.log(Infinity); -------------------------------------------------------------------------------- /test/fixture/infinity.js: -------------------------------------------------------------------------------- 1 | console.log(Infinity); 2 | -------------------------------------------------------------------------------- /test/fixture/join-continued-strings-fix.js: -------------------------------------------------------------------------------- 1 | console.log(` ${1} ${2} ${3}`,' a b c');console.log(` ${1} ${2} ${3}\n`,' a b c\n'); -------------------------------------------------------------------------------- /test/fixture/join-continued-strings.js: -------------------------------------------------------------------------------- 1 | console.log( 2 | `\ 3 | ${1}\ 4 | ${2}\ 5 | ${3}`, 6 | '\ 7 | a\ 8 | b\ 9 | c', 10 | ); 11 | 12 | console.log( 13 | `\ 14 | ${1}\ 15 | ${2}\ 16 | ${3}\n`, 17 | '\ 18 | a\ 19 | b\ 20 | c\n', 21 | ); 22 | -------------------------------------------------------------------------------- /test/fixture/logical-expressions-fix.js: -------------------------------------------------------------------------------- 1 | var a=()=>{};a();a();a===!0&&a(); -------------------------------------------------------------------------------- /test/fixture/logical-expressions.js: -------------------------------------------------------------------------------- 1 | const a = () => {}; 2 | const b = () => {}; 3 | a() && b; 4 | true && a(); 5 | a === true && b(); 6 | -------------------------------------------------------------------------------- /test/fixture/mangle-class-names-fix.js: -------------------------------------------------------------------------------- 1 | class Hello{world(){return'hello'}} -------------------------------------------------------------------------------- /test/fixture/mangle-class-names.js: -------------------------------------------------------------------------------- 1 | class Hello { 2 | world() { 3 | const hello = 'hello'; 4 | return hello; 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /test/fixture/mangle-disabled-fix.js: -------------------------------------------------------------------------------- 1 | function everywhere(){}function cool(){var list=[1];for(const item of list)everywhere(item)} -------------------------------------------------------------------------------- /test/fixture/mangle-disabled.js: -------------------------------------------------------------------------------- 1 | function everywhere() {} 2 | function cool() { const list = [1]; for (const item of list) { everywhere(item) } } -------------------------------------------------------------------------------- /test/fixture/mangle-names-fix.js: -------------------------------------------------------------------------------- 1 | const{hello:a}={};(()=>{})(a); -------------------------------------------------------------------------------- /test/fixture/mangle-names-overlap-fix.js: -------------------------------------------------------------------------------- 1 | let A=5;(a=>a())((a,b)=>console.log(b,A)); -------------------------------------------------------------------------------- /test/fixture/mangle-names-overlap.js: -------------------------------------------------------------------------------- 1 | let aaa = 5; 2 | const fn = (a) => a(); 3 | fn((a, b)=>{ 4 | console.log(b, aaa); 5 | }); 6 | -------------------------------------------------------------------------------- /test/fixture/mangle-names.js: -------------------------------------------------------------------------------- 1 | const world = {}; 2 | const fn = () => {}; 3 | const {hello} = world; 4 | 5 | fn(hello); 6 | -------------------------------------------------------------------------------- /test/fixture/merge-assignment-expressions-fix.js: -------------------------------------------------------------------------------- 1 | a=b=c=5; -------------------------------------------------------------------------------- /test/fixture/merge-assignment-expressions.js: -------------------------------------------------------------------------------- 1 | a = 5; 2 | b = 5; 3 | c = 5; 4 | -------------------------------------------------------------------------------- /test/fixture/merge-destructuring-properties-fix.js: -------------------------------------------------------------------------------- 1 | const{assign:A}=Object;const{keys:_}=Object;_({});A({},{}); -------------------------------------------------------------------------------- /test/fixture/merge-destructuring-properties.js: -------------------------------------------------------------------------------- 1 | let a = {}, b ={}; 2 | const x = {}; 3 | Object.keys(x); 4 | Object.assign(a, b) -------------------------------------------------------------------------------- /test/fixture/merge-duplicate-functions-fix.js: -------------------------------------------------------------------------------- 1 | var A=a=>typeof a==='function';A(1);A(2); -------------------------------------------------------------------------------- /test/fixture/merge-duplicate-functions.js: -------------------------------------------------------------------------------- 1 | const isFn = (a) => typeof a === 'function'; 2 | const isFn1 = (a) => typeof a === 'function'; 3 | const isFn2 = (a) => typeof a === 'function'; 4 | 5 | isFn(1); 6 | isFn1(2); 7 | -------------------------------------------------------------------------------- /test/fixture/merge-duplicate-imports-fix.js: -------------------------------------------------------------------------------- 1 | import a from'./putout.js';console.log(a);console.log(a); -------------------------------------------------------------------------------- /test/fixture/merge-duplicate-imports.js: -------------------------------------------------------------------------------- 1 | import putout from './putout.js'; 2 | import all from './putout.js'; 3 | import x from './putout.js'; 4 | 5 | console.log(all); 6 | console.log(x); 7 | -------------------------------------------------------------------------------- /test/fixture/merge-loops-fix.js: -------------------------------------------------------------------------------- 1 | var a=[1],b=[2];for(const A of [...a,...b,...a])console.log(A);for(const B of b)console.log(B); -------------------------------------------------------------------------------- /test/fixture/merge-loops.js: -------------------------------------------------------------------------------- 1 | const a = [1]; 2 | const b = [2]; 3 | 4 | a.forEach(aa => console.log(aa)), 5 | b.forEach(bb => console.log(bb)); 6 | 7 | for (const aa of a) 8 | console.log(aa); 9 | 10 | for (const bb of b) 11 | console.log(bb); 12 | -------------------------------------------------------------------------------- /test/fixture/merge-variables-fix.js: -------------------------------------------------------------------------------- 1 | var a='a';console.log(`${a}`);let b='b1';b='b2';var c=`${b}`;console.log(`${c}`); -------------------------------------------------------------------------------- /test/fixture/merge-variables-off-fix.js: -------------------------------------------------------------------------------- 1 | var c=e=>e.w;var w=c=>c;function f(e){const{n}=e;e.w=n;var q=c(e);return q&&w(q)}console.log(f({n:1})); -------------------------------------------------------------------------------- /test/fixture/merge-variables-off.js: -------------------------------------------------------------------------------- 1 | const c = (e) => e.w; 2 | const w = (c) => c; 3 | 4 | function f(e) { 5 | const {n} = e; 6 | e.w = n; 7 | const q = c(e); 8 | 9 | return q && w(q); 10 | } 11 | console.log(f({n: 1})); 12 | -------------------------------------------------------------------------------- /test/fixture/merge-variables.js: -------------------------------------------------------------------------------- 1 | const a = 'a'; 2 | console.log(`${a}`); 3 | let b = 'b1'; 4 | b = 'b2'; 5 | const c = `${b}`; 6 | console.log(`${c}`); -------------------------------------------------------------------------------- /test/fixture/minify-fix.js: -------------------------------------------------------------------------------- 1 | console.log('hello','world'); -------------------------------------------------------------------------------- /test/fixture/minify.js: -------------------------------------------------------------------------------- 1 | const a = 'hello'; 2 | const b = 'world'; 3 | 4 | console.log(a, b); 5 | -------------------------------------------------------------------------------- /test/fixture/new-fix.js: -------------------------------------------------------------------------------- 1 | var a=new Date().getFullYear()/100;console.log(~~a); -------------------------------------------------------------------------------- /test/fixture/new.js: -------------------------------------------------------------------------------- 1 | const date = new Date().getFullYear() / 100; 2 | const value = Math.floor(date); 3 | 4 | console.log(value); 5 | -------------------------------------------------------------------------------- /test/fixture/overlap-fix.js: -------------------------------------------------------------------------------- 1 | var a={buttonClickHandlers:{}},b=Object.keys(a.buttonClickHandlers); -------------------------------------------------------------------------------- /test/fixture/overlap.js: -------------------------------------------------------------------------------- 1 | var LISTENERS = {buttonClickHandlers: {}}; 2 | var keys = Object.keys(LISTENERS.buttonClickHandlers); -------------------------------------------------------------------------------- /test/fixture/parens-fix.js: -------------------------------------------------------------------------------- 1 | url='https://cdnjs.cloudflare.com/ajax/libs/d3/7.9.0/d3.min.js';let p;var b={createElement:()=>({})};(p=b.createElement('script')).type='application/javascript',p.src=url;console.log(p.type);(function(){console.log('hello')}.call(this)); -------------------------------------------------------------------------------- /test/fixture/parens.js: -------------------------------------------------------------------------------- 1 | url = 'https://cdnjs.cloudflare.com/ajax/libs/d3/7.9.0/d3.min.js'; 2 | let p; 3 | const document = { 4 | createElement: () => ({}), 5 | }; 6 | (p = document.createElement('script')).type = 'application/javascript', p.src = url; 7 | console.log(p.type); 8 | 9 | (function() { 10 | console.log('hello'); 11 | }.call(this)); 12 | -------------------------------------------------------------------------------- /test/fixture/promises-fix.js: -------------------------------------------------------------------------------- 1 | async ()=>{return transformer.transform(realTransformer,transformCode,code,parser)};var x=()=>b();async function b(){} -------------------------------------------------------------------------------- /test/fixture/promises.js: -------------------------------------------------------------------------------- 1 | async () => { 2 | const result = transformer.transform(realTransformer, transformCode, code, parser); 3 | 4 | const result2 = await Promise.resolve(result); 5 | 6 | return result2; 7 | }; 8 | 9 | const x = () => { 10 | return runCli(); 11 | } 12 | 13 | async function runCli() {} 14 | -------------------------------------------------------------------------------- /test/fixture/quotes-fix.js: -------------------------------------------------------------------------------- 1 | console.log("hello\'x");console.log("Can't start parsing from rule \""+"hello"+"\"."); -------------------------------------------------------------------------------- /test/fixture/quotes.js: -------------------------------------------------------------------------------- 1 | const a = 'hello\'x'; 2 | console.log(a); 3 | // eslint-disable-next-line @stylistic/js/quotes 4 | console.log("Can't start parsing from rule \"" + "hello" + "\"."); 5 | 6 | -------------------------------------------------------------------------------- /test/fixture/regexp-fix.js: -------------------------------------------------------------------------------- 1 | /^(?:\d{2}\/){2}\d{4}$/&&(()=>{})();var a=/^[a-z]{2,}$/i; -------------------------------------------------------------------------------- /test/fixture/regexp.js: -------------------------------------------------------------------------------- 1 | const fn = () => {}; 2 | /^[\d]{2}\/[\d]{2}\/[\d]{4}$/ && fn(); 3 | 4 | const a = /^[a-z]{2,}$/i; 5 | -------------------------------------------------------------------------------- /test/fixture/remove-console-fix.js: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/putoutjs/minify/a9c12851da198d5d8f0326edd7b57d1cc01986f7/test/fixture/remove-console-fix.js -------------------------------------------------------------------------------- /test/fixture/remove-console.js: -------------------------------------------------------------------------------- 1 | console.log('hello world'); -------------------------------------------------------------------------------- /test/fixture/remove-unreachable-code-fix.js: -------------------------------------------------------------------------------- 1 | function a(){return'world'}function b(){throw Error('error')} -------------------------------------------------------------------------------- /test/fixture/remove-unreachable-code.js: -------------------------------------------------------------------------------- 1 | function hi() { 2 | return 'world'; 3 | console.log('hello'); 4 | } 5 | 6 | function log() { 7 | throw Error('error'); 8 | console.log('hello'); 9 | } -------------------------------------------------------------------------------- /test/fixture/remove-unreferenced-variables-fix.js: -------------------------------------------------------------------------------- 1 | let a;a=5;console.log(a);function b(){let t=1;1&&(t=0);return t}console.log(b()); -------------------------------------------------------------------------------- /test/fixture/remove-unreferenced-variables.js: -------------------------------------------------------------------------------- 1 | let a; 2 | let b; 3 | 4 | a = 5; 5 | b = 6; 6 | 7 | console.log(a); 8 | 9 | function runUpdates() { 10 | let t = 1; 11 | 1 ? t = 0 : 1; 12 | 13 | return t; 14 | } 15 | console.log(runUpdates()); 16 | -------------------------------------------------------------------------------- /test/fixture/remove-unused-expressions-fix.js: -------------------------------------------------------------------------------- 1 | function a(A){} -------------------------------------------------------------------------------- /test/fixture/remove-unused-expressions.js: -------------------------------------------------------------------------------- 1 | function show(error) { 2 | showError; 3 | } -------------------------------------------------------------------------------- /test/fixture/remove-useless-return-fix.js: -------------------------------------------------------------------------------- 1 | var a=({push})=>({ObjectExpression(A){push(A)}}); -------------------------------------------------------------------------------- /test/fixture/remove-useless-return.js: -------------------------------------------------------------------------------- 1 | const traverse = ({push}) => { 2 | return { 3 | ObjectExpression(path) { 4 | push(path); 5 | }, 6 | }; 7 | }; 8 | -------------------------------------------------------------------------------- /test/fixture/remove-useless-spread-disabled-fix.js: -------------------------------------------------------------------------------- 1 | const{keys:a}=Object;var b=[1,2];console.log(...b);var c=[...(()=>[3,4])()];console.log(...c);console.log(a({...(()=>({}))()}).length); -------------------------------------------------------------------------------- /test/fixture/remove-useless-spread-disabled.js: -------------------------------------------------------------------------------- 1 | const getPlaces = () => [3, 4]; 2 | const fn = () => ({}); 3 | const b = [1, 2]; 4 | 5 | for (const a of [...b]) 6 | console.log(a); 7 | 8 | const places = [...getPlaces()]; 9 | const a = { 10 | ...fn(), 11 | }; 12 | 13 | console.log(...places); 14 | console.log(Object.keys(a).length); 15 | -------------------------------------------------------------------------------- /test/fixture/remove-useless-spread-fix.js: -------------------------------------------------------------------------------- 1 | var A=()=>{},b=A(),a=A(); -------------------------------------------------------------------------------- /test/fixture/remove-useless-spread.js: -------------------------------------------------------------------------------- 1 | const noop = () => {}; 2 | const getPlaces = noop; 3 | const fn = noop; 4 | 5 | for (const a of [...b]) {} 6 | 7 | const places = [...getPlaces()]; 8 | const a = { 9 | ...fn(), 10 | }; 11 | -------------------------------------------------------------------------------- /test/fixture/remove-useless-variables-fix.js: -------------------------------------------------------------------------------- 1 | function hi({a,b}){console.log(fn(a,b))}hi({a:1,b:2});function fn(a,b){return a+b} -------------------------------------------------------------------------------- /test/fixture/remove-useless-variables.js: -------------------------------------------------------------------------------- 1 | function hi(c) { 2 | const {a, b} = c; 3 | console.log(fn(a, b)); 4 | } 5 | 6 | hi({ 7 | a: 1, 8 | b: 2, 9 | }); 10 | 11 | function fn(a, b) { 12 | return a + b; 13 | } 14 | -------------------------------------------------------------------------------- /test/fixture/return-arrow-fix.js: -------------------------------------------------------------------------------- 1 | function c(n){return s=>s.b*n} -------------------------------------------------------------------------------- /test/fixture/return-arrow.js: -------------------------------------------------------------------------------- 1 | function c(n) {return (s)=>s.b*n} -------------------------------------------------------------------------------- /test/fixture/reuse-duplicate-init-fix.js: -------------------------------------------------------------------------------- 1 | const{a,b,operator:c}=(a=>({operator:{}}))('putout'),{replaceWith:d}=c; -------------------------------------------------------------------------------- /test/fixture/reuse-duplicate-init.js: -------------------------------------------------------------------------------- 1 | const require = (a) => ({ 2 | operator: {} 3 | }); 4 | const putout = require('putout'); 5 | const { 6 | a, 7 | b, 8 | operator, 9 | } = require('putout'); 10 | 11 | const {replaceWith} = operator; -------------------------------------------------------------------------------- /test/fixture/sequence-expressions-fix.js: -------------------------------------------------------------------------------- 1 | var l=[];for(const e of l){e.o=w(e.o);e.l=w(e.l)}()=>{try{return 1}catch(e){return console.log(e),2}};for(const e of l)e.o=w(e.o),e.l=w(e.l); -------------------------------------------------------------------------------- /test/fixture/sequence-expressions.js: -------------------------------------------------------------------------------- 1 | const l = []; 2 | for (const e of l) { 3 | e.o = w(e.o);e.l = w(e.l); 4 | } 5 | 6 | () => { 7 | try{ 8 | return 1; 9 | } catch(e) { 10 | return console.log(e), 2; 11 | } 12 | }; 13 | 14 | for (const e of l) 15 | e.o = w(e.o), e.l = w(e.l); 16 | -------------------------------------------------------------------------------- /test/fixture/shebang-fix.js: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | import a from'b'; -------------------------------------------------------------------------------- /test/fixture/shebang.js: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | 3 | import a from 'b'; 4 | -------------------------------------------------------------------------------- /test/fixture/simplify-ternary-fix.js: -------------------------------------------------------------------------------- 1 | var y,z; -------------------------------------------------------------------------------- /test/fixture/simplify-ternary.js: -------------------------------------------------------------------------------- 1 | var x, y, z; 2 | x = y ? z : false; -------------------------------------------------------------------------------- /test/fixture/swap-fix.js: -------------------------------------------------------------------------------- 1 | var a=[1,2],[,b]=a;a[1]=a[0];a[0]=b;console.log(a); -------------------------------------------------------------------------------- /test/fixture/swap.js: -------------------------------------------------------------------------------- 1 | const a = [1, 2]; 2 | const [, tmp] = a; 3 | 4 | a[1] = a[0]; 5 | a[0] = tmp; 6 | 7 | console.log(a); 8 | -------------------------------------------------------------------------------- /test/fixture/switch-fix.js: -------------------------------------------------------------------------------- 1 | var a='x';switch(a) {case 'a':var b='foo';console.log(b);break;case 'x':var c='bar';console.log(c);break} -------------------------------------------------------------------------------- /test/fixture/switch.js: -------------------------------------------------------------------------------- 1 | var a = "x"; 2 | switch (a) { 3 | case "a": 4 | var b = "foo"; 5 | console.log(b); 6 | break; 7 | case "x": 8 | var c = "bar"; 9 | console.log(c); 10 | break; 11 | } -------------------------------------------------------------------------------- /test/fixture/ternary-fix.js: -------------------------------------------------------------------------------- 1 | var s=()=>a?(p(),i):2; -------------------------------------------------------------------------------- /test/fixture/ternary.js: -------------------------------------------------------------------------------- 1 | const s = () => a ? (p(),i) : 2 -------------------------------------------------------------------------------- /test/fixture/try-catch-fix.js: -------------------------------------------------------------------------------- 1 | javascript:var A=a=>a,b;var a=A('Base64 Encode');try{b=atob(a)}catch(_){b=_}A(`\n${b}\n`); -------------------------------------------------------------------------------- /test/fixture/try-catch.js: -------------------------------------------------------------------------------- 1 | javascript: 2 | const alert = (a) => a; 3 | const prompt = (a) => a; 4 | var a = prompt('Base64 Encode'); 5 | var b; 6 | try { 7 | b = atob(a) 8 | } catch(error) { 9 | b = error; 10 | } 11 | var c = '\n' + b + '\n'; 12 | alert(c); -------------------------------------------------------------------------------- /test/fixture/type-fix.js: -------------------------------------------------------------------------------- 1 | var x=1;(()=>{})(!!x); -------------------------------------------------------------------------------- /test/fixture/type.js: -------------------------------------------------------------------------------- 1 | const fn = () => {}; 2 | const x = 1; 3 | const a = Boolean(x); 4 | 5 | fn(a); 6 | -------------------------------------------------------------------------------- /test/fixture/types-fix.js: -------------------------------------------------------------------------------- 1 | if((a=>typeof a==='string')((()=>'x')()))return; -------------------------------------------------------------------------------- /test/fixture/types.js: -------------------------------------------------------------------------------- 1 | const get = () => 'x'; 2 | const a = get(); 3 | 4 | if (typeof a === 'string') 5 | return; -------------------------------------------------------------------------------- /test/fixture/undefined-fix.js: -------------------------------------------------------------------------------- 1 | var a=()=>{};typeof Promise!=='undefined'&&a();Promise.a!==void 0&&a(); -------------------------------------------------------------------------------- /test/fixture/undefined.js: -------------------------------------------------------------------------------- 1 | const fn = () => {}; 2 | 3 | if (typeof Promise !== 'undefined') 4 | fn(); 5 | 6 | if (typeof Promise.a !== 'undefined') 7 | fn(); 8 | -------------------------------------------------------------------------------- /test/fixture/unused-fix.js: -------------------------------------------------------------------------------- 1 | console.log(5); -------------------------------------------------------------------------------- /test/fixture/unused.js: -------------------------------------------------------------------------------- 1 | const a = 5; 2 | const b = 6; 3 | 4 | console.log(a); 5 | -------------------------------------------------------------------------------- /test/fixture/var-fix.js: -------------------------------------------------------------------------------- 1 | !function(){let a='1';a+='2';console.log(a)}(); -------------------------------------------------------------------------------- /test/fixture/var-overlap-fix.js: -------------------------------------------------------------------------------- 1 | function A(){var n=a();n&&n();if(!0){const n=b();n&&n()}} -------------------------------------------------------------------------------- /test/fixture/var-overlap.js: -------------------------------------------------------------------------------- 1 | function mergeProps() { 2 | const n = a(); 3 | 4 | if (n) { 5 | n(); 6 | } 7 | 8 | if (true) { 9 | const n = b(); 10 | 11 | if (n) 12 | n(); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /test/fixture/var.js: -------------------------------------------------------------------------------- 1 | !function() { 2 | let string_var = '1'; 3 | string_var += '2'; 4 | console.log(string_var); 5 | }(); 6 | -------------------------------------------------------------------------------- /test/fixture/void-fix.js: -------------------------------------------------------------------------------- 1 | var a='x',b;console.log({DEV:b,on:a}); -------------------------------------------------------------------------------- /test/fixture/void.js: -------------------------------------------------------------------------------- 1 | const on = 'x'; 2 | const DEV = void 0; 3 | 4 | console.log({DEV, on}); 5 | -------------------------------------------------------------------------------- /test/minify.js: -------------------------------------------------------------------------------- 1 | import {extend} from 'supertape'; 2 | import {minifyExtension} from './extension.js'; 3 | 4 | const test = extend({ 5 | minify: minifyExtension, 6 | }); 7 | 8 | test('@putout/minify: arrow', (t) => { 9 | t.minify('arrow', { 10 | expected: [ 11 | 'start', 12 | 'hello', 13 | 'world', 14 | ], 15 | }); 16 | t.end(); 17 | }); 18 | 19 | test('@putout/minify: assign', (t) => { 20 | t.minify('assign', { 21 | expected: 2, 22 | }); 23 | t.end(); 24 | }); 25 | 26 | test('@putout/minify: array', (t) => { 27 | t.minify('array', { 28 | expected: 21, 29 | }); 30 | t.end(); 31 | }); 32 | 33 | test('@putout/minify: apply-optional-chainig', (t) => { 34 | t.minify('apply-optional-chaining', { 35 | expected: 1, 36 | }); 37 | t.end(); 38 | }); 39 | 40 | test('@putout/minify: conditions', (t) => { 41 | t.minify('conditions', { 42 | expected: 2, 43 | conditions: true, 44 | }); 45 | t.end(); 46 | }); 47 | 48 | test('@putout/minify: comments', (t) => { 49 | t.minify('comments'); 50 | t.end(); 51 | }); 52 | 53 | test('@putout/minify: parens', (t) => { 54 | t.minify('parens', { 55 | expected: ['application/javascript', 'hello'], 56 | }); 57 | t.end(); 58 | }); 59 | 60 | test('@putout/minify: evaluate', (t) => { 61 | t.minify('evaluate', { 62 | expected: 'hello', 63 | conditions: true, 64 | }); 65 | t.end(); 66 | }); 67 | 68 | test('@putout/minify: else', (t) => { 69 | t.minify('else', { 70 | expected: 'hello', 71 | }); 72 | t.end(); 73 | }); 74 | 75 | test('@putout/minify: minify', (t) => { 76 | t.minify('minify', { 77 | expected: [ 78 | 'hello', 79 | 'world', 80 | ], 81 | }); 82 | t.end(); 83 | }); 84 | 85 | test('@putout/minify: function', (t) => { 86 | t.minify('function', { 87 | expected: [undefined], 88 | }); 89 | t.end(); 90 | }); 91 | 92 | test('@putout/minify: boolean', (t) => { 93 | t.minify('boolean', { 94 | expected: [true, false], 95 | }); 96 | t.end(); 97 | }); 98 | 99 | test('@putout/minify: swap', (t) => { 100 | t.minify('swap', { 101 | expected: [[2, 1]], 102 | }); 103 | t.end(); 104 | }); 105 | 106 | test('@putout/minify: infinity', (t) => { 107 | t.minify('infinity', { 108 | expected: Infinity, 109 | }); 110 | t.end(); 111 | }); 112 | 113 | test('@putout/minify: unused', (t) => { 114 | t.minify('unused', { 115 | expected: 5, 116 | removeUnusedVariables: true, 117 | }); 118 | t.end(); 119 | }); 120 | 121 | test('@putout/minify: type', (t) => { 122 | t.minify('type'); 123 | t.end(); 124 | }); 125 | 126 | test('@putout/minify: guard', (t) => { 127 | t.minify('guard'); 128 | t.end(); 129 | }); 130 | 131 | test('@putout/minify: dead-code', (t) => { 132 | t.minify('dead-code', { 133 | run: false, 134 | }); 135 | t.end(); 136 | }); 137 | 138 | test('@putout/minify: merge-duplicate-functions', (t) => { 139 | t.minify('merge-duplicate-functions'); 140 | t.end(); 141 | }); 142 | 143 | test('@putout/minify: merge-assignment-expressions', (t) => { 144 | t.minify('merge-assignment-expressions'); 145 | t.end(); 146 | }); 147 | 148 | test('@putout/minify: merge-duplicate-imports', (t) => { 149 | t.minify('merge-duplicate-imports', { 150 | run: false, 151 | }); 152 | t.end(); 153 | }); 154 | 155 | test('@putout/minify: merge-loops', (t) => { 156 | t.minify('merge-loops', { 157 | expected: [ 158 | 1, 159 | 2, 160 | 1, 161 | 2, 162 | ], 163 | }); 164 | t.end(); 165 | }); 166 | 167 | test('@putout/minify: remove-useless-variables', (t) => { 168 | t.minify('remove-useless-variables', { 169 | removeUnusedVariables: true, 170 | expected: [3], 171 | }); 172 | t.end(); 173 | }); 174 | 175 | test('@putout/minify: remove-useless-spread', (t) => { 176 | t.minify('remove-useless-spread'); 177 | t.end(); 178 | }); 179 | 180 | test('@putout/minify: remove-useless-spread: disabled', (t) => { 181 | t.minify('remove-useless-spread-disabled', { 182 | removeUselessSpread: false, 183 | expected: [ 184 | 1, 185 | 2, 186 | 3, 187 | 4, 188 | 0, 189 | ], 190 | }); 191 | t.end(); 192 | }); 193 | 194 | test('@putout/minify: remove-useless-return', (t) => { 195 | t.minify('remove-useless-return'); 196 | t.end(); 197 | }); 198 | 199 | test('@putout/minify: if', (t) => { 200 | t.minify('if'); 201 | t.end(); 202 | }); 203 | 204 | test('@putout/minify: if: logical', (t) => { 205 | t.minify('if-logical'); 206 | t.end(); 207 | }); 208 | 209 | test('@putout/minify: if: no ternary', (t) => { 210 | t.minify('if-no-ternary', { 211 | expected: [true], 212 | }); 213 | t.end(); 214 | }); 215 | 216 | test('@putout/minify: apply-template-literals', (t) => { 217 | t.minify('apply-template-literals', { 218 | expected: ['("hello")'], 219 | }); 220 | t.end(); 221 | }); 222 | 223 | test('@putout/minify: for', (t) => { 224 | t.minify('for', { 225 | expected: [1], 226 | }); 227 | t.end(); 228 | }); 229 | 230 | test('@putout/minify: logical-expressions', (t) => { 231 | t.minify('logical-expressions'); 232 | t.end(); 233 | }); 234 | 235 | test('@putout/minify: regexp', (t) => { 236 | t.minify('regexp'); 237 | t.end(); 238 | }); 239 | 240 | test('@putout/minify: remove-unreachable-code', (t) => { 241 | t.minify('remove-unreachable-code'); 242 | t.end(); 243 | }); 244 | 245 | test('@putout/minify: remove-unused-expressions', (t) => { 246 | t.minify('remove-unused-expressions'); 247 | t.end(); 248 | }); 249 | 250 | test('@putout/minify: remove-unreferenced-variables', (t) => { 251 | t.minify('remove-unreferenced-variables', { 252 | expected: [5, 0], 253 | }); 254 | t.end(); 255 | }); 256 | 257 | test('@putout/minify: for-of: remove-useless', (t) => { 258 | t.minify('for-of-remove-useless', { 259 | expected: ['hello'], 260 | }); 261 | t.end(); 262 | }); 263 | 264 | test('@putout/minify: for-of: nested', (t) => { 265 | t.minify('for-of-nested', { 266 | expected: ['hello'], 267 | }); 268 | t.end(); 269 | }); 270 | 271 | test('@putout/minify: mangle-names: enabled', (t) => { 272 | t.minify('mangle-names', { 273 | mangle: true, 274 | }); 275 | t.end(); 276 | }); 277 | 278 | test('@putout/minify: mangle-class-names', (t) => { 279 | t.minify('mangle-class-names'); 280 | t.end(); 281 | }); 282 | 283 | test('@putout/minify: merge-destructuring-properties', (t) => { 284 | t.minify('merge-destructuring-properties'); 285 | t.end(); 286 | }); 287 | 288 | test('@putout/minify: new', (t) => { 289 | t.minify('new', { 290 | expected: [20], 291 | }); 292 | t.end(); 293 | }); 294 | 295 | test('@putout/minify: void', (t) => { 296 | t.minify('void', { 297 | expected: [{ 298 | DEV: undefined, 299 | on: 'x', 300 | }], 301 | }); 302 | t.end(); 303 | }); 304 | 305 | test('@putout/minify: undefined', (t) => { 306 | t.minify('undefined'); 307 | t.end(); 308 | }); 309 | 310 | test('@putout/minify: before-init', (t) => { 311 | t.minify('before-init', { 312 | expected: [0, 1], 313 | }); 314 | t.end(); 315 | }); 316 | 317 | test('@putout/minify: convert-arguments-to-rest', (t) => { 318 | t.minify('convert-arguments-to-rest', { 319 | expected: [1, 2, 3], 320 | }); 321 | t.end(); 322 | }); 323 | 324 | test('@putout/minify: convert-const-to-var', (t) => { 325 | t.minify('convert-const-to-var'); 326 | t.end(); 327 | }); 328 | 329 | test('@putout/minify: types', (t) => { 330 | t.minify('types'); 331 | t.end(); 332 | }); 333 | 334 | test('@putout/minify: shebang', (t) => { 335 | t.minify('shebang', { 336 | run: false, 337 | }); 338 | t.end(); 339 | }); 340 | 341 | test('@putout/minify: declare', (t) => { 342 | t.minify('declare'); 343 | t.end(); 344 | }); 345 | 346 | test('@putout/minify: promises', (t) => { 347 | t.minify('promises'); 348 | t.end(); 349 | }); 350 | 351 | test('@putout/minify: remove-console', (t) => { 352 | t.minify('remove-console', { 353 | removeConsole: true, 354 | }); 355 | t.end(); 356 | }); 357 | 358 | test('@putout/minify: convert-strict-equal-equal', (t) => { 359 | t.minify('convert-strict-equal-to-equal', { 360 | expected: [2], 361 | }); 362 | t.end(); 363 | }); 364 | 365 | test('@putout/minify: convert-strict-equal-equal: on', (t) => { 366 | t.minify('convert-strict-equal-to-equal-on', { 367 | convertStrictEqualToEqual: true, 368 | expected: [1], 369 | }); 370 | t.end(); 371 | }); 372 | 373 | test('@putout/minify: convert-return-to-sequence-expression', (t) => { 374 | t.minify('convert-return-to-sequence-expression'); 375 | t.end(); 376 | }); 377 | 378 | test('@putout/minify: remove-unreferenced-variables: bundle', (t) => { 379 | t.minify('remove-unreferenced-variables', { 380 | bundle: true, 381 | expected: [5, 0], 382 | }); 383 | t.end(); 384 | }); 385 | 386 | test('@putout/minify: reuse-duplicate-init', (t) => { 387 | t.minify('reuse-duplicate-init'); 388 | t.end(); 389 | }); 390 | 391 | test('@putout/minify: sequence-expressions', (t) => { 392 | t.minify('sequence-expressions'); 393 | t.end(); 394 | }); 395 | 396 | test('@putout/minify: ternary', (t) => { 397 | t.minify('ternary'); 398 | t.end(); 399 | }); 400 | 401 | test('@putout/minify: overlap', (t) => { 402 | t.minify('overlap'); 403 | t.end(); 404 | }); 405 | 406 | test('@putout/minify: in', (t) => { 407 | t.minify('in'); 408 | t.end(); 409 | }); 410 | 411 | test('@putout/minify: increment', (t) => { 412 | t.minify('increment'); 413 | t.end(); 414 | }); 415 | 416 | test('@putout/minify: quotes', (t) => { 417 | t.minify('quotes', { 418 | quote: '"', 419 | expected: [ 420 | `hello'x`, 421 | `Can't start parsing from rule "hello".`, 422 | ], 423 | }); 424 | t.end(); 425 | }); 426 | 427 | test('@putout/minify: closure', (t) => { 428 | t.minify('closure', { 429 | expected: [ 430 | 5, 431 | undefined, 432 | ], 433 | }); 434 | t.end(); 435 | }); 436 | 437 | test('@putout/minify: mangle-names-overlap', (t) => { 438 | t.minify('mangle-names-overlap', { 439 | expected: [ 440 | undefined, 441 | 5, 442 | ], 443 | }); 444 | t.end(); 445 | }); 446 | 447 | test('@putout/minify: simplify-ternary', (t) => { 448 | t.minify('simplify-ternary'); 449 | t.end(); 450 | }); 451 | 452 | test('@putout/minify: const', (t) => { 453 | t.minify('const'); 454 | t.end(); 455 | }); 456 | 457 | test('@putout/minify: declaration-order', (t) => { 458 | t.minify('declaration-order', { 459 | expected: [1], 460 | }); 461 | t.end(); 462 | }); 463 | 464 | test('@putout/minify: return-arrow', (t) => { 465 | t.minify('return-arrow'); 466 | t.end(); 467 | }); 468 | 469 | test('@putout/minify: switch', (t) => { 470 | t.minify('switch', { 471 | expected: ['bar'], 472 | }); 473 | t.end(); 474 | }); 475 | 476 | test('@putout/minify: class', (t) => { 477 | t.minify('class'); 478 | t.end(); 479 | }); 480 | 481 | test('@putout/minify: merge-variables', (t) => { 482 | t.minify('merge-variables', { 483 | expected: [ 484 | 'a', 485 | 'b2', 486 | ], 487 | }); 488 | t.end(); 489 | }); 490 | 491 | test('@putout/minify: for-each-ternary', (t) => { 492 | t.minify('for-each-ternary'); 493 | t.end(); 494 | }); 495 | 496 | test('@putout/minify: duplicate-declaration', (t) => { 497 | t.minify('duplicate-declaration'); 498 | t.end(); 499 | }); 500 | 501 | test('@putout/minify: join-continued-strings', (t) => { 502 | t.minify('join-continued-strings', { 503 | expected: [ 504 | ' 1 2 3', 505 | ' a b c', 506 | ' 1 2 3\n', 507 | ' a b c\n', 508 | ], 509 | }); 510 | t.end(); 511 | }); 512 | 513 | test('@putout/minify: try-catch', (t) => { 514 | t.minify('try-catch'); 515 | t.end(); 516 | }); 517 | 518 | test('@putout/minify: var', (t) => { 519 | t.minify('var', { 520 | expected: ['12'], 521 | }); 522 | t.end(); 523 | }); 524 | 525 | test('@putout/minify: var: overlap', (t) => { 526 | t.minify('var-overlap'); 527 | t.end(); 528 | }); 529 | 530 | test('@putout/minify: fixCount', (t) => { 531 | t.minify('fix-count', { 532 | fixCount: 2, 533 | }); 534 | t.end(); 535 | }); 536 | 537 | test('@putout/minify: mangle: disabled', (t) => { 538 | t.minify('mangle-disabled', { 539 | mangle: false, 540 | }); 541 | t.end(); 542 | }); 543 | 544 | test('@putout/minify: apply-template-literals: disabled', (t) => { 545 | t.minify('apply-template-literals-disabled', { 546 | applyTemplateLiterals: false, 547 | }); 548 | t.end(); 549 | }); 550 | 551 | test('@putout/minify: merge-variables: off', (t) => { 552 | t.minify('merge-variables-off', { 553 | expected: [1], 554 | mergeVariables: false, 555 | }); 556 | t.end(); 557 | }); 558 | 559 | test('@putout/minify: for-each-destructuring', (t) => { 560 | t.minify('for-each-destructuring', { 561 | expected: [ 562 | 'b', 563 | 'c', 564 | 'bb', 565 | 'cc', 566 | ], 567 | bundle: true, 568 | }); 569 | t.end(); 570 | }); 571 | --------------------------------------------------------------------------------