{"_id":"babel-plugin-remove-unused-reference","_rev":"4-59dae75067f0f089384b8141b7d1a6bf","name":"babel-plugin-remove-unused-reference","dist-tags":{"beta":"1.0.0-beta.0","latest":"1.0.3"},"versions":{"1.0.0-beta.0":{"name":"babel-plugin-remove-unused-reference","version":"1.0.0-beta.0","keywords":["babel-plugin-remove"],"author":{"name":"shiftj18"},"license":"MIT","_id":"babel-plugin-remove-unused-reference@1.0.0-beta.0","maintainers":[{"name":"shiftj","email":"stjkl@foxmail.com"}],"homepage":"https://github.com/shiftj18/babel-plugin-remove-unused-reference#readme","bugs":{"url":"https://github.com/shiftj18/babel-plugin-remove-unused-reference/issues"},"dist":{"shasum":"672b5c08eceab8ed2346f5e71b2609b5f748539b","tarball":"https://registry.npmjs.org/babel-plugin-remove-unused-reference/-/babel-plugin-remove-unused-reference-1.0.0-beta.0.tgz","fileCount":3,"integrity":"sha512-kkW8QxI23fjLHiebQocbC0NtB5HXWQ2bUd9N34ckZsqSwi3SsiZpvStwtSJoIJeGQc4E92Gp1o2CzhFb7v80BQ==","signatures":[{"sig":"MEUCIQDrtAftS5uUAxPcHxV+gOEtWxtUhOaQvmKe4mjCiH9DZQIgQK8yEOJZeCx18lUWxNh7wA6n9QfWZB0uV5P5OwEhvys=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":6849},"main":"index.js","gitHead":"bafbfc08abb14e17c0b5fddcb2534fde8bec692f","scripts":{"test":"echo \"Error: no test specified\" && exit 1","example":"node ./examples/index.js"},"_npmUser":{"name":"shiftj","email":"stjkl@foxmail.com"},"repository":{"url":"git+ssh://git@github.com/shiftj18/babel-plugin-remove-unused-reference.git","type":"git"},"_npmVersion":"10.5.2","directories":{},"_nodeVersion":"20.13.1","publishConfig":{"registry":"https://registry.npmjs.org"},"_hasShrinkwrap":false,"devDependencies":{"@babel/core":"^7.25.9"},"_npmOperationalInternal":{"tmp":"tmp/babel-plugin-remove-unused-reference_1.0.0-beta.0_1729833717111_0.9359795910086981","host":"s3://npm-registry-packages"}},"1.0.0":{"name":"babel-plugin-remove-unused-reference","version":"1.0.0","keywords":["babel-plugin-remove"],"author":{"name":"shiftj18"},"license":"MIT","_id":"babel-plugin-remove-unused-reference@1.0.0","maintainers":[{"name":"shiftj","email":"stjkl@foxmail.com"}],"homepage":"https://github.com/shiftj18/babel-plugin-remove-unused-reference#readme","bugs":{"url":"https://github.com/shiftj18/babel-plugin-remove-unused-reference/issues"},"dist":{"shasum":"4a3a243671b33dbbe48d623b2a7fe53023fdfd03","tarball":"https://registry.npmjs.org/babel-plugin-remove-unused-reference/-/babel-plugin-remove-unused-reference-1.0.0.tgz","fileCount":4,"integrity":"sha512-J0XMgfUKDF+gzPA7NmPjtC0esnaL55zyEssKD3Bt0PNoRn8q6pxrFza8dWYmfrxFS1Vu9fp2NUw4hTOwCtfpFg==","signatures":[{"sig":"MEYCIQCsKdhYRG6wLytQ0NXS7La+QMbkx+reU56uOL+K6jG8GwIhAPnoaO6RfwKT3ZmDPmP+MhRMTdZTSTMypaUikdmjg9he","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":9022},"main":"index.js","gitHead":"e6bdfe3fced6decbdf0fdfbcfae8137c25af7471","scripts":{"test":"echo \"Error: no test specified\" && exit 1","example":"node ./examples/index.js"},"_npmUser":{"name":"shiftj","email":"stjkl@foxmail.com"},"repository":{"url":"git+ssh://git@github.com/shiftj18/babel-plugin-remove-unused-reference.git","type":"git"},"_npmVersion":"10.5.2","description":"Babel plugin, remove unused references","directories":{},"_nodeVersion":"20.13.1","publishConfig":{"registry":"https://registry.npmjs.org"},"_hasShrinkwrap":false,"devDependencies":{"@babel/core":"^7.25.9"},"_npmOperationalInternal":{"tmp":"tmp/babel-plugin-remove-unused-reference_1.0.0_1729837709369_0.43850134415462194","host":"s3://npm-registry-packages"}},"1.0.1":{"name":"babel-plugin-remove-unused-reference","version":"1.0.1","keywords":["babel-plugin-remove"],"author":{"name":"shiftj18"},"license":"MIT","_id":"babel-plugin-remove-unused-reference@1.0.1","maintainers":[{"name":"shiftj","email":"stjkl@foxmail.com"}],"homepage":"https://github.com/shiftj18/babel-plugin-remove-unused-reference#readme","bugs":{"url":"https://github.com/shiftj18/babel-plugin-remove-unused-reference/issues"},"dist":{"shasum":"3e9a46d31cfa622a47bd074ab517ede3ed91f7b6","tarball":"https://registry.npmjs.org/babel-plugin-remove-unused-reference/-/babel-plugin-remove-unused-reference-1.0.1.tgz","fileCount":4,"integrity":"sha512-ZkXMwwmqshGPrVfTdYJ96Q2F8A0z99ZbXFNqyAr+yzBkj3agj2N44LD0rMKtzQkwuSG1/HB3sT+jdGwu/aXrBw==","signatures":[{"sig":"MEYCIQCas3SJ4ktkLIvM83mreqga0TMxHbi2Q7MHnlVVXpYmxQIhAI3WrocRpw2lOtQoquhQkkEyrTNBAbIlsnIgU/jFaXcf","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":8470},"main":"index.js","gitHead":"cb38071a1b59bc4540a26b74aa6f5c205447efdd","scripts":{"test":"echo \"Error: no test specified\" && exit 1","example":"node ./examples/index.js"},"_npmUser":{"name":"shiftj","email":"stjkl@foxmail.com"},"repository":{"url":"git+ssh://git@github.com/shiftj18/babel-plugin-remove-unused-reference.git","type":"git"},"_npmVersion":"10.5.2","description":"Babel plugin, remove unused references","directories":{},"_nodeVersion":"20.13.1","publishConfig":{"registry":"https://registry.npmjs.org"},"_hasShrinkwrap":false,"devDependencies":{"@babel/core":"^7.25.9"},"_npmOperationalInternal":{"tmp":"tmp/babel-plugin-remove-unused-reference_1.0.1_1729955910894_0.8023185352207896","host":"s3://npm-registry-packages"}},"1.0.2":{"name":"babel-plugin-remove-unused-reference","version":"1.0.2","keywords":["babel-plugin-remove"],"author":{"name":"shiftj18"},"license":"MIT","_id":"babel-plugin-remove-unused-reference@1.0.2","maintainers":[{"name":"shiftj","email":"stjkl@foxmail.com"}],"homepage":"https://github.com/shiftj18/babel-plugin-remove-unused-reference#readme","bugs":{"url":"https://github.com/shiftj18/babel-plugin-remove-unused-reference/issues"},"dist":{"shasum":"895dbf2a4594fe0c1c1843b8cf4d829b4a87d40b","tarball":"https://registry.npmjs.org/babel-plugin-remove-unused-reference/-/babel-plugin-remove-unused-reference-1.0.2.tgz","fileCount":4,"integrity":"sha512-3yfbNwU8OsjFlRDRyoXO758wHGLwTJO11GfrE+Iml2B/i3owU9q+eNqggSQp6b049OoyP56ztqPoW585rrCOZA==","signatures":[{"sig":"MEUCICFtkghDwvNH9rblhjoGeEV54AP1hQgnkqSjISKBaxvgAiEApdSFGO6IAW87QTz7zMVCL45PPzvBwacgHIheaKUwOH0=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13893},"main":"index.js","gitHead":"8e7e1bf66f53265e069a59d790785083c19f7567","scripts":{"test":"echo \"Error: no test specified\" && exit 1","example":"node ./examples/index.js"},"_npmUser":{"name":"shiftj","email":"stjkl@foxmail.com"},"repository":{"url":"git+ssh://git@github.com/shiftj18/babel-plugin-remove-unused-reference.git","type":"git"},"_npmVersion":"10.5.2","description":"Babel plugin, remove unused references","directories":{},"_nodeVersion":"20.13.1","publishConfig":{"registry":"https://registry.npmjs.org"},"_hasShrinkwrap":false,"devDependencies":{"@babel/core":"^7.25.9"},"_npmOperationalInternal":{"tmp":"tmp/babel-plugin-remove-unused-reference_1.0.2_1730306721223_0.04940455368025631","host":"s3://npm-registry-packages"}},"1.0.3":{"name":"babel-plugin-remove-unused-reference","version":"1.0.3","main":"index.js","scripts":{"test":"jest","clean":"rm -rf lib/*","babel":"babel src --out-dir lib -D","prepublishOnly":"npm test && npm run clean && npm run babel","example":"node ./examples/index.js"},"repository":{"type":"git","url":"git+ssh://git@github.com/shiftj18/babel-plugin-remove-unused-reference.git"},"keywords":["babel-plugin-remove"],"author":{"name":"shiftj18"},"license":"MIT","bugs":{"url":"https://github.com/shiftj18/babel-plugin-remove-unused-reference/issues"},"homepage":"https://github.com/shiftj18/babel-plugin-remove-unused-reference#readme","description":"Babel plugin, remove unused references","devDependencies":{"@babel/cli":"^7.25.9","@babel/core":"^7.25.9","@babel/preset-env":"^7.26.0","@babel/preset-react":"^7.25.9","@types/jest":"^29.5.14","jest":"^29.7.0"},"publishConfig":{"registry":"https://registry.npmjs.org"},"_id":"babel-plugin-remove-unused-reference@1.0.3","gitHead":"863f8e0cb65711feb43c9b62a96e508f7a9c3ce4","_nodeVersion":"20.13.1","_npmVersion":"10.5.2","dist":{"integrity":"sha512-HoFRlav21SugkxE/ZIoOi9nDZX2mvJ/g7neBtrxToZx43AOBPXZArzp+mL4wrw7whyi0REaZzvLK5gjR+s+joQ==","shasum":"a40fa798d73deed6dfc117706f1ff015c18b46a6","tarball":"https://registry.npmjs.org/babel-plugin-remove-unused-reference/-/babel-plugin-remove-unused-reference-1.0.3.tgz","fileCount":5,"unpackedSize":13888,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQDniLoa/c52ulngic6NYa6+vEmIMNVkJY7qf04qBZsj3wIgI0rR9v8VdqTGZ650DNC+uSm8/3CatWL719UW5TnMRAA="}]},"_npmUser":{"name":"shiftj","email":"stjkl@foxmail.com"},"directories":{},"maintainers":[{"name":"shiftj","email":"stjkl@foxmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/babel-plugin-remove-unused-reference_1.0.3_1731256367912_0.05942510258346534"},"_hasShrinkwrap":false}},"time":{"created":"2024-10-25T05:21:57.110Z","modified":"2024-11-10T16:32:48.278Z","1.0.0-beta.0":"2024-10-25T05:21:57.268Z","1.0.0":"2024-10-25T06:28:29.532Z","1.0.1":"2024-10-26T15:18:31.117Z","1.0.2":"2024-10-30T16:45:21.390Z","1.0.3":"2024-11-10T16:32:48.116Z"},"bugs":{"url":"https://github.com/shiftj18/babel-plugin-remove-unused-reference/issues"},"author":{"name":"shiftj18"},"license":"MIT","homepage":"https://github.com/shiftj18/babel-plugin-remove-unused-reference#readme","keywords":["babel-plugin-remove"],"repository":{"type":"git","url":"git+ssh://git@github.com/shiftj18/babel-plugin-remove-unused-reference.git"},"description":"Babel plugin, remove unused references","maintainers":[{"name":"shiftj","email":"stjkl@foxmail.com"}],"readme":"# babel-plugin-remove-unused-reference\n\n## Description\n\nBabel plugin, remove unused reference.\n\n\n#### Supports:\n\n- when `const isX = false;`, change `const x = isX ? A : B;` -> `const x = B;`\n- when `const isX = false;`, change `if (isX) { A } else { B }` -> `{ B }`\n- when `false`, support `(isX && ...)`, `(... && isX)` (left ...  is normal data type without slide effetcs)\n- support `const x = false ? A : B` ->  `const x = B` and `if (false) A else B` -> `B`\n\n\n- when `const isX = true;`, change `const x = isX ? A : B;` -> `const x = A;`\n- when `const isX = true;`, change `if (isX) { A } else { B }` -> `{ A }`\n- when `true`, support `(isX || ...)`, `(... || isX)` (left ...  is normal data type without slide effetcs)\n- support `const x = true ? A : B` ->  `const x = A` and `if (true) A else B` -> `A`\n\n#### Examples\n\nInput:\n```js\ntest(`\n  // 测试变量 const isX = false 时，条件表达式中 isX 相应逻辑的剔除\n  const isX = false;\n\n  const A = isX ? { a } : {};\n  const A2 = isX && x && 2 && true && fn() ? { a2 } : {};\n  const A3 = x && isX ? { a3 } : {};\n  const A4 = x && 2 && true && '2' && isX ? { a4 } : {};\n\n  const A0 = fn() && isX ? {} : { a0 };\n`);\n\n\ntest(`\n  // 测试条件表达式中含有 false 字面量时，条件表达式中相应逻辑的剔除\n  const A = false ? { a } : {};\n  const A2 = false && x && 2 && '2' && fn() ? { a2 } : {};\n  const A3 = x && 2 && true && false ? { a3 } : {};\n\n  const A0 = fn() && false ? { a0 } : {};\n`);\n\n\ntest(`\n  // 测试变量 const isX = false 时，if 语句中 isX 相应逻辑的剔除\n  const isX = false;\n\n  if (isX) { a } else {}\n  if (isX && x && 2 && true && fn()) { a2 } else {}\n  if (x && 2 && true && '2' && isX) { a3 } else {}\n\n  if (fn() && isX) { a0 } else {}\n`);\n\n\ntest(`\n  // 测试条件表达式中含有 false 字面量时，if 语句中相应逻辑的剔除\n\n  if (false) { a } else {}\n  if (false && x && 2 && true && fn()) { a2 } else {}\n  if (x && 2 && true && '2' && false) { a3 } else {}\n\n  if (fn() && false) { a0 } else {}\n`);\n\n\ntest(`\n  // 测试条件表达式中含有 const isX = true 时，条件表达式中 isX 相应逻辑的剔除\n  const isX = true;\n\n  const A = isX ? { } : { a };\n  const A2 = isX || x || 2 || false || fn() ? { } : { a2 };\n  const A3 = x || isX ? { } : { a3 };\n  const A4 = x || 2 || isX || false || '2' ? { } : { a4 };\n\n  const A0 = fn() || isX ? { } : { a0 };\n`);\n\n\ntest(`\n  // 测试条件表达式中含有 true 字面量时，条件表达式中相应逻辑的剔除\n  \n  const A = true ? { } : { a };\n  const A2 = true || x || 2 || '2' || fn() ? { } : { a2 };\n  const A3 = x || 2 || false || true || '2' || fn() ? { } : { a3 };\n\n  const A0 = fn() || true ? { } : { a0 };\n`);\n\n\ntest(`\n  // 测试条件表达式中含有 const isX = true 时，if 语句中 isX 相应逻辑的剔除\n  const isX = true;\n\n  if (isX) { } else { a }\n  if (isX || x || 2 || false || fn()) { } else { a2 }\n  if (x || 2 || false || '2' || isX) { } else { a3 }\n  if (false) { a4 } else if (true) { } else if (isWeb) { a41 } else { a42 }\n\n  if (fn() || isX) { } else { a0 }\n`);\n\n\ntest(`\n  // 测试条件表达式中含有 true 字面量时，if 语句中相应逻辑的剔除\n  \n  if (true) { } else { a }\n  if (true || x || 2 || false || fn()) { } else { a2 }\n  if (x || 2 || false || '2' || true) { } else { a3 }\n  if (false) { a4 } else if (true) { } else { a41 }\n  if (false) { a5 } else if (x || 2 || true || false || '2') { } else { a51 }\n\n  if (fn() || true) { } else { a0 }\n`);\n```\n\noutput:\n```bash\n> npm run example\n> node ./examples/index.js\n\n// 测试变量 const isX = false 时，条件表达式中 isX 相应逻辑的剔除\nconst isX = false;\nconst A = {};\nconst A2 = {};\nconst A3 = {};\nconst A4 = {};\nconst A0 = fn() && isX ? {} : {\n  a0\n};\n---------------------------------------\n\n// 测试条件表达式中含有 false 字面量时，条件表达式中相应逻辑的剔除\nconst A = {};\nconst A2 = {};\nconst A3 = {};\nconst A0 = fn() && false ? {\n  a0\n} : {};\n---------------------------------------\n\n// 测试变量 const isX = false 时，if 语句中 isX 相应逻辑的剔除\nconst isX = false;\n{}\n{}\n{}\nif (fn() && isX) {\n  a0;\n} else {}\n---------------------------------------\n\n// 测试条件表达式中含有 false 字面量时，if 语句中相应逻辑的剔除\n\n{}\n{}\n{}\nif (fn() && false) {\n  a0;\n} else {}\n---------------------------------------\n\n// 测试条件表达式中含有 const isX = true 时，if 语句中 isX 相应逻辑的剔除\nconst isX = true;\n{}\n{}\n{}\n{}\nif (fn() || isX) {} else {\n  a0;\n}\n---------------------------------------\n\n// 测试条件表达式中含有 true 字面量时，if 语句中相应逻辑的剔除\n\n{}\n{}\n{}\n{}\n{}\nif (fn() || true) {} else {\n  a0;\n}\n---------------------------------------\n\n// 测试条件表达式中含有 const isX = true 时，条件表达式中 isX 相应逻辑的剔除\nconst isX = true;\nconst A = {};\nconst A2 = {};\nconst A3 = {};\nconst A4 = {};\nconst A0 = fn() || isX ? {} : {\n  a0\n};\n---------------------------------------\n\n// 测试条件表达式中含有 true 字面量时，条件表达式中相应逻辑的剔除\n\nconst A = {};\nconst A2 = {};\nconst A3 = {};\nconst A0 = fn() || true ? {} : {\n  a0\n};\n---------------------------------------\n```\n\n## Usage\n```bash\nnpm i babel-plugin-remove-unused-reference\n// pnpm add babel-plugin-remove-unused-reference\n```","readmeFilename":"README.md"}