{"id":18068769,"url":"https://github.com/sunny-117/rsdown","last_synced_at":"2025-04-11T23:42:36.592Z","repository":{"id":62945778,"uuid":"543422016","full_name":"Sunny-117/rsdown","owner":"Sunny-117","description":"一个高性能的 JavaScript/TypeScript 代码转换器，基于 Rust 和 SWC","archived":false,"fork":false,"pushed_at":"2025-02-27T14:31:35.000Z","size":1832,"stargazers_count":4,"open_issues_count":2,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-03-25T19:39:16.661Z","etag":null,"topics":["bundler","napi-rs","rust","swc","toolchain","transformer"],"latest_commit_sha":null,"homepage":"https://sunny-117.github.io/rsdown/","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Sunny-117.png","metadata":{"files":{"readme":"README-en.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","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}},"created_at":"2022-09-30T03:58:29.000Z","updated_at":"2025-02-27T14:31:06.000Z","dependencies_parsed_at":"2024-09-08T15:06:42.329Z","dependency_job_id":"5434feb7-1ee8-40ef-91e9-77af0a289120","html_url":"https://github.com/Sunny-117/rsdown","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Sunny-117%2Frsdown","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Sunny-117%2Frsdown/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Sunny-117%2Frsdown/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Sunny-117%2Frsdown/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Sunny-117","download_url":"https://codeload.github.com/Sunny-117/rsdown/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248497901,"owners_count":21113982,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":["bundler","napi-rs","rust","swc","toolchain","transformer"],"created_at":"2024-10-31T08:07:43.566Z","updated_at":"2025-04-11T23:42:36.562Z","avatar_url":"https://github.com/Sunny-117.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# rsdown\n\nEnglish|[简体中文](./README.md)\n\n[![npm version][npm-version-src]][npm-version-href]\n[![npm downloads][npm-downloads-src]][npm-downloads-href]\n[![bundle][bundle-src]][bundle-href]\n[![JSDocs][jsdocs-src]][jsdocs-href]\n[![License][license-src]][license-href]\n\nA high-performance JavaScript/TypeScript code transformer powered by Rust and SWC.\n\n## Features\n\n- 🚀 High performance - Built with Rust and SWC\n- 🔄 Transforms `const` and `let` declarations to `var`\n- 📦 Easy integration - Works as a Node.js module\n- 🛠️ TypeScript support out of the box\n\n## Installation\n\n```bash\nnpm install rsdown\npnpm add rsdown\nyarn add rsdown\nbun install rsdown\n```\n## Usage\n```js\nimport { transformToVar } from 'rsdown'\nconst code = `const x = 1;let y = 2;`\nconst result = transformToVar(code)\nconsole.log(result)\n// Output:\n// var x = 1;\n// var y = 2;\n```\n\n## API\n\n### `transformToVar(code: string): string`\n\nTransforms JavaScript/TypeScript code by converting `const` and `let` declarations to `var` declarations.\n\n- **Parameters:**\n  - `code` (string): The source code to transform\n- **Returns:**\n  - (string): The transformed code\n\n## Development\n\n### Prerequisites\n\n- [Rust](https://www.rust-lang.org/) (latest stable)\n- [Node.js](https://nodejs.org/) (\u003e= 14)\n- [pnpm](https://pnpm.io/) (recommended)\n\n### Setup\n\n1. Clone the repository\n\n```bash\ngit clone https://github.com/Sunny-117/rsdown.git\ncd rsdown\n```\n2. Install dependencies\n```bash\npnpm install\n```\n\n3. Build the project\n```bash\npnpm build\n```\n\n4. Run tests\n\n```bash\npnpm test\n```\n\n## Technical Details\n\nThis project uses:\n- [SWC](https://swc.rs/) for JavaScript/TypeScript parsing and transformation\n- [napi-rs](https://napi.rs/) for Node.js native module bindings\n- [Vitest](https://vitest.dev/) for testing\n\n## Contributing\n\nContributions are welcome! Please feel free to submit a Pull Request. For major changes, please open an issue first to discuss what you would like to change.\n\nPlease make sure to update tests as appropriate.\n\n## License\n\n[MIT](./LICENSE) License © 2024-PRESENT [Sunny-117](https://github.com/Sunny-117)\n\n\u003c!-- Badges --\u003e\n\n[npm-version-src]: https://img.shields.io/npm/v/rsdown?style=flat\u0026colorA=080f12\u0026colorB=1fa669\n[npm-version-href]: https://npmjs.com/package/rsdown\n[npm-downloads-src]: https://img.shields.io/npm/dm/rsdown?style=flat\u0026colorA=080f12\u0026colorB=1fa669\n[npm-downloads-href]: https://npmjs.com/package/rsdown\n[bundle-src]: https://img.shields.io/bundlephobia/minzip/rsdown?style=flat\u0026colorA=080f12\u0026colorB=1fa669\u0026label=minzip\n[bundle-href]: https://bundlephobia.com/result?p=rsdown\n[license-src]: https://img.shields.io/github/license/Sunny-117/rsdown.svg?style=flat\u0026colorA=080f12\u0026colorB=1fa669\n[license-href]: https://github.com/Sunny-117/rsdown/blob/main/LICENSE\n[jsdocs-src]: https://img.shields.io/badge/jsdocs-reference-080f12?style=flat\u0026colorA=080f12\u0026colorB=1fa669\n[jsdocs-href]: https://www.jsdocs.io/package/rsdown\n\n## Architecture Design\n\n```mermaid\ngraph TD\n    A[JavaScript/TypeScript Code] --\u003e B[SWC Parser]\n    B --\u003e C[AST]\n    C --\u003e D[VarTransformer]\n    D --\u003e E[Modified AST]\n    E --\u003e F[SWC Codegen]\n    F --\u003e G[Transformed Code]\n```\n\n## Implementation\n\nrsdown uses Rust and SWC for high-performance code transformation:\n\n1. **Parsing**: Parse source code to AST using SWC parser\n2. **Transform**: Modify declaration types using VarTransformer visitor\n3. **Generate**: Output result using SWC code generator\n\nFor detailed architecture documentation, visit [Architecture Guide](https://sunny-117.github.io/rsdown/en/guide/architecture)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsunny-117%2Frsdown","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsunny-117%2Frsdown","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsunny-117%2Frsdown/lists"}