The compiler of Aleph.js written in Rust, powered by swc and lightningcss.
import { transform } from "https://deno.land/x/[email protected]/mod.ts";
const code = `
import { useState, useEffect } from "react"
export default function App() {
const [msg, setMsg] = useState("...")
useEffect(() => {
setTimeout(() => {
setMsg("world!")
}, 1000)
}, [])
return <h1>Hello {msg}</h1>
}
`
const ret = await transform("./app.tsx", code, {
importMap: JSON.stringify({
imports: {
"react": "https://esm.sh/react@18",
}
}),
jsxImportSource: "https://esm.sh/react@18",
sourceMap: true,
})
console.log(ret.code, ret.map)
You will need rust 1.60+ and wasm-pack.
deno run -A build.ts
cargo test --all