{"_id":"@axew/swc-plugin-jsx-control-statements","_rev":"3-77bf2938100078d779e9f6a436708ba1","name":"@axew/swc-plugin-jsx-control-statements","dist-tags":{"latest":"0.8.0"},"versions":{"0.7.1000":{"name":"@axew/swc-plugin-jsx-control-statements","version":"0.7.1000","keywords":["react","jsx","if","else","swc","swc-core","swc-plugin","jsx-control-statements","react-component"],"author":{"name":"intpp"},"license":"MIT","_id":"@axew/swc-plugin-jsx-control-statements@0.7.1000","maintainers":[{"name":"daief","email":"defeng_mail@163.com"}],"homepage":"https://github.com/intpp/swc-plugin-jsx-control-statements#readme","bugs":{"url":"https://github.com/intpp/swc-plugin-jsx-control-statements/issues"},"dist":{"shasum":"a43aff28107cfa6c82deafcfff1e2b0462e02e56","tarball":"https://registry.npmjs.org/@axew/swc-plugin-jsx-control-statements/-/swc-plugin-jsx-control-statements-0.7.1000.tgz","fileCount":5,"integrity":"sha512-r5/1tFdoH5bs+ShxJc/9i3qKe0kY0qLW2WzeZ9VJfPbEbCbIsIbJEagNxtreHXQi8l8FEpJbvfbGyGOIq6ytyg==","signatures":[{"sig":"MEUCIDeGwH0KdBcB0iRugv3qP9GWDEt5pyAbOOiIYs0SM0ZuAiEA8fXat8ZFQ+v3PsLAze90ilLXwR0vzVSI4I2kXY3IArk=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":690858},"main":"swc_plugin_jsx_control_statements.wasm","types":"jsx-control-statements.d.ts","gitHead":"0e13a918ed809da3ebac6003b4381ae8e9198ce7","scripts":{"prepack":"cp ./target/wasm32-wasip1/release/swc_plugin_jsx_control_statements.wasm .","prepublishOnly":"cargo build-wasip1 --release"},"_npmUser":{"name":"daief","email":"defeng_mail@163.com"},"repository":{"url":"git+https://github.com/intpp/swc-plugin-jsx-control-statements.git","type":"git"},"_npmVersion":"10.8.2","description":"SWC plugin for jsx-control-statements","directories":{},"_nodeVersion":"20.19.5","publishConfig":{"access":"public","registry":"https://registry.npmjs.org/"},"_hasShrinkwrap":false,"preferUnplugged":true,"_npmOperationalInternal":{"tmp":"tmp/swc-plugin-jsx-control-statements_0.7.1000_1762433276399_0.39780274662314286","host":"s3://npm-registry-packages-npm-production"}},"0.7.1001":{"name":"@axew/swc-plugin-jsx-control-statements","version":"0.7.1001","keywords":["react","jsx","if","else","swc","swc-core","swc-plugin","jsx-control-statements","react-component"],"author":{"name":"intpp"},"license":"MIT","_id":"@axew/swc-plugin-jsx-control-statements@0.7.1001","maintainers":[{"name":"daief","email":"defeng_mail@163.com"}],"homepage":"https://github.com/daief/swc-plugin-jsx-control-statements#readme","bugs":{"url":"https://github.com/daief/swc-plugin-jsx-control-statements/issues"},"dist":{"shasum":"9e4e3dc333a3be1e273a6f16aebfae6c9b24f9be","tarball":"https://registry.npmjs.org/@axew/swc-plugin-jsx-control-statements/-/swc-plugin-jsx-control-statements-0.7.1001.tgz","fileCount":5,"integrity":"sha512-bRD0ab5l4JWwdZlugws9Uc1mSdyf8wgY0CvlpTLwGeQUq1fe+qbtcYFkWetyk9QwjTgRGiOYXCi6EJccXmkCZQ==","signatures":[{"sig":"MEUCIQDDZfBLu80RA1zUG+39tkkoQI1CTmd+fiR8Akj/D7vkQwIgf5Z1LNYCzWDKkpt+JYxF/GZJTJC8eSP8Losf/EsxUy4=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/@axew%2fswc-plugin-jsx-control-statements@0.7.1001","provenance":{"predicateType":"https://slsa.dev/provenance/v1"}},"unpackedSize":696324},"main":"swc_plugin_jsx_control_statements.wasm","types":"jsx-control-statements.d.ts","gitHead":"79a0323adbcfefe64e738c281ebf2f1fd39db242","scripts":{"prepack":"cp ./target/wasm32-wasip1/release/swc_plugin_jsx_control_statements.wasm .","prepublishOnly":"cargo build-wasip1 --release"},"_npmUser":{"name":"GitHub Actions","email":"npm-oidc-no-reply@github.com","trustedPublisher":{"id":"github","oidcConfigId":"oidc:73d2b126-4c03-4cce-bb57-6bcd53fb058a"}},"repository":{"url":"git+https://github.com/daief/swc-plugin-jsx-control-statements.git","type":"git"},"_npmVersion":"11.6.4","description":"SWC plugin for jsx-control-statements","directories":{},"_nodeVersion":"20.19.6","publishConfig":{"access":"public","registry":"https://registry.npmjs.org/"},"_hasShrinkwrap":false,"preferUnplugged":true,"_npmOperationalInternal":{"tmp":"tmp/swc-plugin-jsx-control-statements_0.7.1001_1764840606939_0.1823489713984885","host":"s3://npm-registry-packages-npm-production"}},"0.8.0":{"name":"@axew/swc-plugin-jsx-control-statements","version":"0.8.0","description":"SWC plugin for jsx-control-statements","repository":{"type":"git","url":"git+https://github.com/daief/swc-plugin-jsx-control-statements.git"},"bugs":{"url":"https://github.com/daief/swc-plugin-jsx-control-statements/issues"},"types":"jsx-control-statements.d.ts","keywords":["react","jsx","if","else","swc","swc-core","swc-plugin","jsx-control-statements","react-component"],"main":"swc_plugin_jsx_control_statements.wasm","scripts":{"prepublishOnly":"cargo build-wasip1 --release","prepack":"cp ./target/wasm32-wasip1/release/swc_plugin_jsx_control_statements.wasm ."},"author":{"name":"intpp"},"license":"MIT","preferUnplugged":true,"publishConfig":{"access":"public","registry":"https://registry.npmjs.org/"},"gitHead":"484d7d0c6efb23ebd01eb27552aef133982ae10b","_id":"@axew/swc-plugin-jsx-control-statements@0.8.0","homepage":"https://github.com/daief/swc-plugin-jsx-control-statements#readme","_nodeVersion":"20.20.2","_npmVersion":"11.12.1","dist":{"integrity":"sha512-vqb61wtXIbHbrfj8NEzqwXRko5Uidrx2H3s3EsGkIY1F3/wrhPr3igxhy4fBTVRPsEeOd2tw2EhmkuQePBUmWQ==","shasum":"0ee62cbbe5e4538d3a000cb02988cce23d4a9d3d","tarball":"https://registry.npmjs.org/@axew/swc-plugin-jsx-control-statements/-/swc-plugin-jsx-control-statements-0.8.0.tgz","fileCount":6,"unpackedSize":929452,"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/@axew%2fswc-plugin-jsx-control-statements@0.8.0","provenance":{"predicateType":"https://slsa.dev/provenance/v1"}},"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEQCIBmdh4ahmIFWOPXYdOWs2ONSXg77TyV/bKjnt3uel/0OAiBInd7Rshv8ahprhTHttED05fD/u5u0LX7UtEov6NScxQ=="}]},"_npmUser":{"name":"GitHub Actions","email":"npm-oidc-no-reply@github.com","trustedPublisher":{"id":"github","oidcConfigId":"oidc:73d2b126-4c03-4cce-bb57-6bcd53fb058a"}},"directories":{},"maintainers":[{"name":"daief","email":"defeng_mail@163.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/swc-plugin-jsx-control-statements_0.8.0_1776846263843_0.025277361089350636"},"_hasShrinkwrap":false}},"time":{"created":"2025-11-06T12:47:56.272Z","modified":"2026-04-22T08:24:24.401Z","0.7.1000":"2025-11-06T12:47:56.616Z","0.7.1001":"2025-12-04T09:30:07.138Z","0.8.0":"2026-04-22T08:24:24.119Z"},"bugs":{"url":"https://github.com/daief/swc-plugin-jsx-control-statements/issues"},"author":{"name":"intpp"},"license":"MIT","homepage":"https://github.com/daief/swc-plugin-jsx-control-statements#readme","keywords":["react","jsx","if","else","swc","swc-core","swc-plugin","jsx-control-statements","react-component"],"repository":{"type":"git","url":"git+https://github.com/daief/swc-plugin-jsx-control-statements.git"},"description":"SWC plugin for jsx-control-statements","maintainers":[{"name":"daief","email":"defeng_mail@163.com"}],"readme":"> 📢: This repository is a temporary release for this [PR](https://github.com/intpp/swc-plugin-jsx-control-statements/pull/9).\n>\n> 📢: This repository is a temporary release for this [PR](https://github.com/intpp/swc-plugin-jsx-control-statements/pull/9).\n>\n> 📢: This repository is a temporary release for this [PR](https://github.com/intpp/swc-plugin-jsx-control-statements/pull/9).\n\n# 🦀 JSX control statements for swc\n\nOriginal idea: [babel-plugin-jsx-control-statements](https://github.com/AlexGilleran/jsx-control-statements)\n\n## Installation\n\n**pnpm** (recommended):\n\n```shell\npnpm i -D @axew/swc-plugin-jsx-control-statements\n```\n\nor **yarn**\n\n```shell\nyarn add -D @axew/swc-plugin-jsx-control-statements\n```\n\n## Configure `swc`\n\nIn your SWC config, you have to add to [`jsc.experimental.plugins`](https://swc.rs/docs/configuration/compilation#jscexperimentalplugins) - `['@axew/swc-plugin-jsx-control-statements', {}]`, like in the following code:\n\n```javascript\njsc: {\n    experimental: {\n        plugins: [\n            ['@axew/swc-plugin-jsx-control-statements', {}],\n        ],\n    },\n},\n```\n\n## Usage\n\n### `<If>` tag\n\n```jsx\nimport React from 'react';\n\nconst Greeting = () => {\n    const [closed, setClosed] = useState(false);\n\n    return (\n        <>\n            <If condition={!closed}>\n                Hello,\n            </If>\n            World\n            <If condition={!closed}>\n                <button onClick={() => setClosed(true)}>Close</button>\n            </If>\n        </>\n    )\n};\n```\n\n### `<Choose>` tag (if - else if - else condition)\n\n```jsx\nimport React from 'react';\n\nconst Greeting = () => {\n    const [closed, setClosed] = useState(false);\n\n    return (\n        <>\n            <Choose>\n                <When condition={!closed}>\n                    Hello,\n                </When>\n                <Otherwise>\n                    Bye,\n                </Otherwise>\n            </Choose>\n            World\n            <If condition={!closed}>\n                <button onClick={() => setClosed(true)}>Close</button>\n            </If>\n        </>\n    )\n};\n```\n\n### `For` tag (like array map function)\n\n```jsx\nimport React from 'react';\n\nconst TodoList = ({ items }) => {\n    return (\n        <For each=\"item\" of={items}>\n            <span key={item.id}>{item.title}</span>\n        </For>\n    );\n};\n```\n\n> [!WARNING]\n> using the index as key attribute is not stable if the array changes\n>\n> ```tsx\n> <For each=\"item\" index=\"idx\" of={[1, 2, 3]}>\n>   <span key={idx}>{item}</span>\n>   <span key={`${idx}_2`}>Static Text</span>\n> </For>\n>```\n\n### `With` tag\n\n#### Simple\n\n```jsx\nimport React from 'react';\n\nconst SomeComponent = ({ items }) => {\n    return (\n        <With foo={47} bar=\"test\">\n            <span>{foo}</span>\n            <span>{bar}</span>\n        </With>\n    );\n};\n```\n\n#### Nested\n\n```jsx\nimport React from 'react';\n\nconst SomeComponent = ({ items }) => {\n    return (\n        <With foo={47}>\n            <With bar=\"test\">\n                <span>{foo}</span>\n                <span>{bar}</span>\n            </With>\n        </With>\n    );\n};\n```","readmeFilename":"README.md"}