{"name":"@putout/plugin-minify","version":"11.2.2","keywords":["putout","putout-plugin","plugin","minify"],"author":{"url":"https://github.com/coderaiser","name":"coderaiser","email":"mnemonic.enemy@gmail.com"},"license":"MIT","_id":"@putout/plugin-minify@11.2.2","maintainers":[{"name":"coderaiser","email":"mnemonic.enemy@gmail.com"}],"homepage":"https://github.com/coderaiser/putout/tree/master/packages/plugin-minify#readme","bugs":{"url":"https://github.com/coderaiser/putout/issues"},"tag":false,"dist":{"shasum":"876aa90f0e62ff8de2bdb50b6af3461a748add33","tarball":"http://registry-npm.ywwl.com/@putout/plugin-minify/download/@putout/plugin-minify-11.2.2.tgz","fileCount":26,"integrity":"sha512-NkXDNk9FtiadTxse/uNKjqjDMHw/eeXhuTIzc0iaK7rwgl7PrPKBkp3DkrB3qhAkSsyAGTF+0BGn8x7zdy16iA==","signatures":[{"sig":"MEYCIQDjXvzVgaQKb1ezofNW1YOsE4HVI6L9uI4HQ+0UXilv2gIhAMi4fmbVUkUEsUbccYF+STm6pPbs40Qs+N3oMp3I4Jd5","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":38784,"size":10079,"noattachment":false,"key":"/@putout/plugin-minify/-/@putout/plugin-minify-11.2.2.tgz"},"main":"lib/index.js","type":"module","engines":{"node":">=20"},"gitHead":"96fd5214c32baa1a99f242da89be1c60432bbe2d","release":false,"scripts":{"lint":"madrun lint","test":"madrun test","report":"madrun report","wisdom":"madrun wisdom","coverage":"madrun coverage","fix:lint":"madrun fix:lint","fresh:lint":"madrun fresh:lint","lint:fresh":"madrun lint:fresh","watch:test":"madrun watch:test"},"_npmUser":{"name":"coderaiser","email":"mnemonic.enemy@gmail.com"},"changelog":false,"repository":{"url":"git+https://github.com/coderaiser/putout.git","type":"git"},"_npmVersion":"11.4.2","description":"🐊Putout plugin contains minifiers","directories":{},"_nodeVersion":"25.2.1","dependencies":{"fullstore":"^3.0.0","try-catch":"^4.0.0"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"c8":"^10.0.0","eslint":"^10.0.0-alpha.0","madrun":"^11.0.0","montag":"^1.2.1","nodemon":"^3.0.1","supertape":"^11.0.3","@putout/test":"^14.0.0","eslint-plugin-n":"^17.0.0","@putout/eslint-flat":"^3.0.0","eslint-plugin-putout":"^29.0.0","@putout/plugin-declare":"*","@putout/plugin-variables":"*","@putout/plugin-conditions":"*","@putout/plugin-destructuring":"*"},"peerDependencies":{"putout":">=40"},"_npmOperationalInternal":{"tmp":"tmp/plugin-minify_11.2.2_1767131464215_0.3010242035389623","host":"s3://npm-registry-packages-npm-production"},"readme":"# @putout/plugin-minify [![NPM version][NPMIMGURL]][NPMURL]\n\n[NPMIMGURL]: https://img.shields.io/npm/v/@putout/plugin-minify.svg?style=flat&longCache=true\n[NPMURL]: https://npmjs.org/package/@putout/plugin-minify \"npm\"\n\n🐊[**Putout**](https://github.com/coderaiser/putout) plugin adds support of minifiers used in [`@putout/minify`](https://github.com/putoutjs/minify) and [`minify`](https://github.com/coderaiser/minify).\n\n## Install\n\n```\nnpm i @putout/plugin-putout -D\n```\n\n## Rules\n\n- ✅ [apply-template-literal](#apply-template-literal);\n- ✅ [apply-ternary](#apply-ternary);\n- ✅ [convert-array-from-to-spread](#convert-array-from-to-spread);\n- ✅ [convert-const-to-let](#convert-const-to-let);\n- ✅ [convert-let-to-var](#convert-let-to-var);\n- ✅ [convert-if-to-logical](#convert-if-to-logical);\n- ✅ [convert-return-to-sequence-expression](#convert-return-to-sequence-expression);\n- ✅ [convert-strict-equal-to-equal](#convert-strict-equal-to-equal);\n- ✅ [expand-bindings](#expand-bindings);\n- ✅ [extract-body](#extract-body);\n- ✅ [join-continued-strings](#join-continued-strings);\n- ✅ [inline](#inline);\n- ✅ [mangle-names](#mangle-names);\n- ✅ [merge-assignment-expressions](#merge-assignment-expressions);\n- ✅ [merge-loops](#merge-loops);\n- ✅ [merge-variables](#merge-variables);\n- ✅ [remove-return-undefined](#remove-return-undefined);\n- ✅ [remove-var-undefined](#remove-var-undefined);\n- ✅ [shorten-names](#shorten-names);j\n- ✅ [simplify-floor](#simplify-floor);\n- ✅ [types](#types);\n\n## Config\n\n```json\n{\n    \"rules\": {\n        \"minify/apply-ternary\": \"on\",\n        \"minify/apply-template-literal\": \"on\",\n        \"minify/convert-const-to-let\": \"on\",\n        \"minify/convert-let-to-var\": \"on\",\n        \"minify/convert-if-to-logical\": \"on\",\n        \"minify/convert-strict-equal-to-equal\": \"on\",\n        \"minify/convert-array-from-to-spread\": \"on\",\n        \"minify/convert-return-to-sequence-expression\": \"on\",\n        \"minify/extract-body\": \"on\",\n        \"minify/expand-bindings\": \"on\",\n        \"minify/mangle-names\": [\"on\", {\n            \"mangleClassNames\": true\n        }],\n        \"minify/merge-assignment-expressions\": \"on\",\n        \"minify/merge-variables\": \"on\",\n        \"minify/merge-loops\": \"on\",\n        \"minify/remove-var-undefined\": \"on\",\n        \"minify/remove-return-undefined\": \"on\",\n        \"minify/simplify-floor\": \"on\",\n        \"minify/shorten-names\": \"on\",\n        \"minify/join-continued-strings\": \"on\",\n        \"minify/inline\": \"on\",\n        \"minify/types\": \"on\"\n    }\n}\n```\n\n## apply-ternary\n\nCheck out in 🐊[**Putout Editor**](https://putout.cloudcmd.io/#/gist/69329ca15ca7b13a91caa17bbfd64327/57d98ae86d557596dbab396be3cd2d093b625ec4).\n\n### ❌ Example of incorrect code\n\n```js\nif (a)\n    b();\nelse\n    c();\n```\n\n### ✅ Example of correct code\n\n```js\na ? b() : c();\n```\n\n## apply-template-literal\n\nNot only short, but also fast:\n\n```js\n// 34.795ms\nfor (let i = 0; i < 1_000_000; i++)\n    String(i);\n\n// 28.302ms\nfor (let i = 0; i < 1_000_000; i++)\n    i.toString();\n\n// 24.818ms\nfor (let i = 0; i < 1_000_000; i++)\n    `${i}`;\n```\n\n### ❌ Example of incorrect code\n\n```js\nx.toString();\nString(x);\n```\n\n### ✅ Example of correct code\n\n```js\nString(x);\n```\n\n## convert-if-to-logical\n\nCheck out in 🐊[**Putout Editor**](https://putout.cloudcmd.io/#/gist/7e7c679157ba7e3746c581c29f77c58d/3c726a73315c8511735b7cb2699d54ef1299aede).\n\n### ❌ Example of incorrect code\n\n```js\nif (a)\n    console.log('hello');\n\nif (b) {\n    console.log('hello');\n    console.log('world');\n}\n\nif (a) {\n    console.log(1);\n    console.log(2);\n} else {\n    console.log(3);\n    console.log(4);\n}\n```\n\n### ✅ Example of correct code\n\n```js\na && console.log('hello');\n\nb && (console.log('hello'), console.log('world'));\n\na ? (console.log(1), console.log(2)) : (console.log(3), console.log(4));\n```\n\n## convert-const-to-let\n\n### ❌ Example of incorrect code\n\n```js\nconst a = 5;\n```\n\n### ✅ Example of correct code\n\n```js\nlet a = 5;\n```\n\n## convert-let-to-var\n\n> `Lexical declaration cannot appear in a single-statement context`\n>\n> (c) [MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements#difference_between_statements_and_declarations)\n\nCheckout in 🐊[**Putout Editor**](https://putout.cloudcmd.io/#/gist/269edbd94999bc2ca919de7326a2c0fc/665350212e082c26d282e181da8506904322fd1b).\n\n### ❌ Example of incorrect code\n\n```\njavascript: let a = 3;\n\nif (5)\n    let b = 3;\n```\n\n### ✅ Example of correct code\n\n```js\njavascript: var a = 3;\n\nif (5)\n    var b = 3;\n```\n\n## convert-return-to-sequence-expression\n\nCheck out in 🐊[**Putout Editor**](https://putout.cloudcmd.io/#/gist/2ccbf7da6b22b32c0ba21a39b56ad20a/94664abd32cddc122458f43eb39ce8d776ad08cd).\n\n### ❌ Example of incorrect code\n\n```js\n() => {\n    d();\n    return 1;\n};\n```\n\n### ✅ Example of correct code\n\n```js\n() => {\n    d();\n    return 1;\n};\n```\n\n## convert-strict-equal-to-equal\n\nCheck out in 🐊[**Putout Editor**](https://putout.cloudcmd.io/#/gist/2ccbf7da6b22b32c0ba21a39b56ad20a/94664abd32cddc122458f43eb39ce8d776ad08cd).\n\n### ❌ Example of incorrect code\n\n```js\na === b;\n```\n\n### ✅ Example of correct code\n\n```js\na == b;\n```\n\n## convert-array-from-to-spread\n\n### ❌ Example of incorrect code\n\n```js\nArray\n    .from(a)\n    .map((x, i) => `${i}: ${x}`);\n```\n\n### ✅ Example of correct code\n\n```js\n[...a].map((x, i) => `${i}: ${x}`);\n```\n\n## extract-body\n\nCheck out in 🐊[**Putout Editor**](https://putout.cloudcmd.io/#/gist/fc3b90ac00754c99711c316fd632f4d9/443d4c1bc04e6416185d827c1483f1c2fafce88c).\n\n### ❌ Example of incorrect code\n\n```js\nif (x)\n    return;\n\nconst hello = () => {\n    return 'world';\n};\n```\n\n### ✅ Example of correct code\n\n```js\nif (x)\n    return;\n\nconst hello = () => 'world';\n```\n\n## expand-bindings\n\nCheck out in 🐊[**Putout Editor**](https://putout.cloudcmd.io/#/gist/f181577b923e9a9efca794d9abf1d6c8/1a70c7ebb4af18901ad250c34c8f78ec7519a732).\n\n### ❌ Example of incorrect code\n\n```js\nconst y = 'abc';\nconst x = y;\nconst fn = require(x);\n\nconst a = 5;\nconst b = a;\nconst c = b;\n\nfn(c);\n```\n\n### ✅ Example of correct code\n\n```js\nrequire('abc')(5);\n```\n\n## remove-var-undefined\n\nCheckout in 🐊[**Putout Editor**](https://putout.cloudcmd.io/#/gist/76ceb3f2604e887d7fe84e4b145db5f3/1be2301c0fa753f77090ca0d09df9a5ba1c0a819).\n\n### ❌ Example of incorrect code\n\n```js\nvar a = undefined;\n```\n\n### ✅ Example of correct code\n\n```js\nvar a;\n```\n\n## remove-return-undefined\n\n### ❌ Example of incorrect code\n\n```js\nconst fn = () => {\n    if (a)\n        return undefined;\n    \n    return undefined;\n};\n```\n\n### ✅ Example of correct code\n\n```js\nconst fn = () => {\n    if (a)\n        return;\n};\n```\n\n## mangle-names\n\nCheck out in 🐊[**Putout Editor**](https://putout.cloudcmd.io/#/gist/e6d28e60dcd6a6a84066136e8856d7d2/530e143bf2ece70938bd970065c28ed0acd6f5a4).\n\n### ❌ Example of incorrect code\n\n```js\nfunction generate() {\n    const hello = 'hi';\n    return hello;\n}\n```\n\n### ✅ Example of correct code\n\n```js\nfunction generate() {\n    const a = 'hi';\n    return a;\n}\n```\n\nWhen you want to preserve class names use\n\n```json\n{\n    \"rules\": {\n        \"minify/mangle-names\": [\"on\", {\n            \"mangleClassNames\": false\n        }]\n    }\n}\n```\n\nIn this case you will see:\n\n### ❌ Example of incorrect code\n\n```js\nclass Hello {\n    world() {\n        const hello = 'hello';\n        return hello;\n    }\n}\n```\n\n### ✅ Example of correct code\n\n```js\nclass Hello {\n    world() {\n        const a = 'hello';\n        return a;\n    }\n}\n```\n\n## merge-assignment-expressions\n\nCheck out in 🐊[**Putout Editor**](https://putout.cloudcmd.io/#/gist/31255c05343aa1b1c116a6a639a02d13/ba723cfb4abf475cd3f1bc2fe6908638cff92881).\n\n### ❌ Example of incorrect code\n\n```js\na = 'hello';\nb = 'hello';\nc = 'hello';\nd = 'hello';\n```\n\n### ✅ Example of correct code\n\n```js\na = b = c = d = 'hello';\n```\n\n## merge-variables\n\nCheck out in 🐊[**Putout Editor**](https://putout.cloudcmd.io/#/gist/31255c05343aa1b1c116a6a639a02d13/ba723cfb4abf475cd3f1bc2fe6908638cff92881).\n\n### ❌ Example of incorrect code\n\n```js\nvar a;\nvar b;\n```\n\n### ✅ Example of correct code\n\n```js\nvar a, b;\n```\n\n## merge-loops\n\nCheck out in 🐊[**Putout Editor**](https://putout.cloudcmd.io/#/gist/c9b77f37202389d30924135c2db3db9e/345edfc73c65b6cdf53c9b5e68bf689e4128291f).\n\n### ❌ Example of incorrect code\n\n```js\nfor (const aa of a)\n    d.push(aa);\n\nfor (const bb of b)\n    d.push(bb);\n```\n\n### ✅ Example of correct code\n\n```js\nfor (const aa of [...a, ...b])\n    d.push(aa);\n```\n\n## simplify-floor\n\nNot only shorter, but faster:\n\n```js\n// 5.027ms\nfor (let i = 0; i < 1_000_000; i++)\n    Math.floor(i + 0.5);\n\n// 3.493ms\nfor (let i = 0; i < 1_000_000; i++)\n    ~~(i + 0.5);\n```\n\n### ❌ Example of incorrect code\n\n```js\nMath.floor(x);\n```\n\n### ✅ Example of correct code\n\n```js\n~~x;\n```\n\n## shorten-names\n\nFeats good to [`@putout/plugin-declare`](https://github.com/coderaiser/putout/tree/master/packages/plugin-declare#readme).\nCheck out in 🐊[**Putout Editor**](https://putout.cloudcmd.io/#/gist/b1cbf117d57db1528bfad90bb4c3c07e/e85216221a1bd9595820ad64640859eec5fd0c3b).\n\n### ❌ Example of incorrect code\n\n```js\nconst a = (b) => {\n    Object.keys(b);\n};\n\nconst b = (keys) => {\n    Object.keys(keys);\n};\n\nObject.freeze(a);\nObject.defineProperty(b);\n```\n\n### ✅ Example of correct code\n\n```js\nconst a = (b) => {\n    keys(b);\n};\n\nconst b = (keys) => {\n    Object.keys(keys);\n};\n\nfreeze(a);\ndefineProperty(b);\n```\n\n## types\n\nCheck out in 🐊[**Putout Editor**](https://putout.cloudcmd.io/#/gist/208d2f64b68be114e1f9f93cf4b60734/bdae9887bbf05719e365920d60f3b0b7ca29702b).\n\n### ❌ Example of incorrect code\n\n```js\nconst a = undefined;\nconst b = true;\nconst c = false;\n```\n\n### ✅ Example of correct code\n\n```js\nconst a = void 0;\nconst b = !0;\nconst c = !1;\n```\n\n## join-continued-strings\n\nJoin continued strings to one line.\nCheck out in 🐊[**Putout Editor**](https://putout.cloudcmd.io/#/gist/1b0ad2900f604352697e8edc9f2be61b/d60caae865597b4cb99dce5f95158ff26ae74e20).\n\n### ❌ Example of incorrect code\n\n```js\nconsole.log(`\\\n  1\\\n  2\\\n  3`, '\\\n  a\\\n  b\\\n  c');\n```\n\n### ✅ Example of correct code\n\n```js\nconsole.log(`  1  2  3`, '  a  b  c');\n```\n\n## inline\n\nCheck out in 🐊[**Putout Editor**](https://putout.cloudcmd.io/#/gist/1b0ad2900f604352697e8edc9f2be61b/d60caae865597b4cb99dce5f95158ff26ae74e20).\n\n### ❌ Example of incorrect code\n\n```js\nlet x = 1;\n--x;\n\nif (!x)\n    console.log('hello');\n```\n\n### ✅ Example of correct code\n\n```js\nlet x = 1;\n\nif (!--x)\n    console.log('hello');\n```\n\n## License\n\nMIT\n","publish_time":1767131464367,"_cnpm_publish_time":1767131464367,"dist-tags":{"latest":"12.0.1"}}