Skip to content

Latest commit

 

History

History
47 lines (34 loc) · 845 Bytes

README.md

File metadata and controls

47 lines (34 loc) · 845 Bytes

tsx

A TSX transpiler for esm.sh services, powered by swc.

Usage

import init, { transform } from "https://esm.sh/@esm.sh/tsx";

// initialize the wasm module
await init();

const appTsx = `
import { useState } from "react"

export default App() {
  const [msg] = useState<string>("world")
  return <h1>Hello {msg}!</h1>
}
`
const importMap = {
  imports: {
    "react": "https://esm.sh/react@18",
  }
}
const ret = transform({ filename: "./App.tsx", code: appTsx, importMap })
console.log(ret.code)

More usage check types/index.d.ts.

Development Setup

You will need rust 1.60+ and wasm-pack.

Build

wasm-pack build --target web

Run tests

cargo test --all