{"id":21930431,"url":"https://github.com/desdaemon/swc-plugin-static-jsx","last_synced_at":"2026-04-11T04:32:57.133Z","repository":{"id":183363696,"uuid":"670003248","full_name":"Desdaemon/swc-plugin-static-jsx","owner":"Desdaemon","description":"SWC plugin to transform JSX calls to static templates","archived":false,"fork":false,"pushed_at":"2024-04-23T04:19:08.000Z","size":155,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2026-02-03T03:42:07.212Z","etag":null,"topics":["jsx","swc-plugin","templating"],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Desdaemon.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE-APACHE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2023-07-24T04:48:44.000Z","updated_at":"2024-04-23T04:19:11.000Z","dependencies_parsed_at":"2024-11-28T23:09:30.199Z","dependency_job_id":"f708b7b6-6c40-4b49-bbea-a9f02c4b440e","html_url":"https://github.com/Desdaemon/swc-plugin-static-jsx","commit_stats":null,"previous_names":["desdaemon/transform-static-jsx","desdaemon/swc-plugin-static-jsx"],"tags_count":4,"template":false,"template_full_name":null,"purl":"pkg:github/Desdaemon/swc-plugin-static-jsx","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Desdaemon%2Fswc-plugin-static-jsx","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Desdaemon%2Fswc-plugin-static-jsx/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Desdaemon%2Fswc-plugin-static-jsx/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Desdaemon%2Fswc-plugin-static-jsx/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Desdaemon","download_url":"https://codeload.github.com/Desdaemon/swc-plugin-static-jsx/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Desdaemon%2Fswc-plugin-static-jsx/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31669115,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-10T17:19:37.612Z","status":"online","status_checked_at":"2026-04-11T02:00:05.776Z","response_time":54,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["jsx","swc-plugin","templating"],"created_at":"2024-11-28T23:09:23.987Z","updated_at":"2026-04-11T04:32:57.113Z","avatar_url":"https://github.com/Desdaemon.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# swc-plugin-static-jsx\n\n[![npm](https://img.shields.io/npm/v/swc-plugin-static-jsx)](https://www.npmjs.com/package/swc-plugin-static-jsx)\n[![Rust](https://github.com/Desdaemon/swc-plugin-static-jsx/actions/workflows/rust.yml/badge.svg)](https://github.com/Desdaemon/swc-plugin-static-jsx/actions/workflows/rust.yml)\n[![Node.js E2E](https://github.com/Desdaemon/swc-plugin-static-jsx/actions/workflows/e2e.yml/badge.svg)](https://github.com/Desdaemon/swc-plugin-static-jsx/actions/workflows/e2e.yml)\n\nSWC plugin to transform JSX calls to static templates\n\n## Install\n\n```shell\nnpm i -D @swc/core swc-plugin-static-jsx\n```\n\n### From source\n\n```shell\ngit clone https://github.com/Desdaemon/swc-plugin-static-jsx\ncd swc-plugin-static-jsx\nrustup target add wasm32-wasi\nnpm run dist\nnpm link\n```\n\n## Usage\n\n```jsonc\n// In .swcrc:\n{\n  \"jsc\": {\n    \"experimental\": {\n      \"plugins\": [\n        // All config values are optional.\n        [\n          \"swc-plugin-static-jsx\",\n          {\n            // If an identifier is supplied, it should not be an ambient global. Can be null.\n            \"template\": \"String.raw\",\n            // If supplied, template will be imported as `import { template } from 'my-library'`\n            \"importSource\": \"my-library\",\n            \"spread\": \"$$spread\",\n            \"child\": \"$$child\",\n            \"children\": \"$$children\"\n          }\n        ]\n      ]\n    }\n  }\n}\n```\n\nIn your tsconfig.json, `compilerOptions.jsx` should be set to 'preserve'. You will also need to\nprovide your own JSX-related types under `namespace JSX`.\n\n## Sample\n\n```jsx\nlet unsanitized = '\u003cscript\u003ealert(\"You\\'ve been pwned!\")\u003c/script\u003e';\n// input\nfunction MyComponent() {\n  return (\n    \u003cdiv foo=\"bar\" baz={true} {...spread} {...{ \"std::string\": \"value\" }}\u003e\n      The quick brown fox jumps over the \u003cstrong\u003elazy\u003c/strong\u003e dog.\n      {unsanitized}\n      {...children}\n    \u003c/div\u003e\n  );\n}\n\n// output (approximate)\nfunction MyComponent() {\n  return html`\u003cdiv foo=\"bar\" baz ${{ $$spread: spread }} std::string=\"value\"\u003e\n    The quick brown fox jumps over the\u003cstrong\u003elazy\u003c/strong\u003edog. ${{\n      $$child: unsanitized,\n    }} ${{ $$children: children }}\n  \u003c/div\u003e`;\n}\n```\n\nSample implementation of `html`:\n\n```tsx\nfunction html(raw, ...children: Record\u003cstring, unknown\u003e[]) {\n  all: for (const child of children) {\n    if (\"$$spread\" in child) {\n      // ..\n      continue all;\n    }\n    if (\"$$child\" in child) {\n      // ..\n      continue all;\n    }\n    if (\"$$children\" in child) {\n      // ..\n      continue all;\n    }\n    // ..\n  }\n}\n```\n\n## License\n\nSPDX Identifier: `MIT OR Apache-2`","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdesdaemon%2Fswc-plugin-static-jsx","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdesdaemon%2Fswc-plugin-static-jsx","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdesdaemon%2Fswc-plugin-static-jsx/lists"}