whale2002 / svgr-rs

SVGR rewritten in Rust πŸ¦€

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

SVGR RS

Speedy SVGR rewritten in Rust πŸ¦€

⚠️ RVGR RS is in early development and should not be used in production, expect bugs! πŸ›

Node.js

Use SVGR RS in Node.js to complex transformations or tools.

Install

npm install --save-dev @svgr-rs/core
# or use yarn
yarn add --dev @svgr-rs/core

Usage

Import transform from @svgr-rs/core to transform a file. It takes three arguments:

  • source: the SVG source code to transform
  • options: the options used to transform the SVG
  • state: a state linked to the transformation
import { transform } from '@svgr-rs/core'

const svgCode = `
<svg xmlns="http://www.w3.org/2000/svg"
  xmlns:xlink="http://www.w3.org/1999/xlink">
  <rect x="10" y="10" height="100" width="100"
    style="stroke:#ff0000; fill: #0000ff"/>
</svg>
`

const jsCode = await transform(
  svgCode,
  { icon: true },
  { componentName: 'MyComponent' },
)

Benchmarks

Transform time without SVGO and Prettier in W3C SVG 1.1 TestSuite:

Transform time

Roadmap

  • jsxRuntime
  • jsxRuntimeImport
  • icon
  • native
  • typescript
  • dimensions
  • expandProps
  • prettier
  • prettierConfig
  • svgo (Speedy SVGO rewritten in Rust is working in progress)
  • svgoConfig
  • ref
  • memo
  • replaceAttrValues
  • svgProps
  • titleProp
  • descProp

License

MIT

About

SVGR rewritten in Rust πŸ¦€

License:MIT License


Languages

Language:Rust 92.5%Language:JavaScript 6.1%Language:TypeScript 1.4%