esm-compiler
TypeScript icon, indicating that this package has built-in type declarations

0.5.6 • Public • Published

ESM Compiler

The compiler for esm.sh playground written in Rust, powered by swc and lightningcss.

Usage

import { init, transform } from "https://esm.sh/esm-compiler";

await init("https://esm.sh/esm-compiler/esm_compiler_bg.wasm");

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

export default App() {
  const [msg] = useState<string>("world")
  return <h1>Hello {msg}!</h1>
}
`

const importMap = {
  "imports": {
    "@jsxImportSource": "https://esm.sh/react@18"
    "react": "https://esm.sh/react@18",
  }
}

const ret = transform("./App.jsx", code, {
  importMap: json.stringify(importMap)
})

console.log(ret.code)

Development Setup

You will need rust 1.60+ and wasm-pack.

Build

wasm-pack build --target web

Run tests

cargo test --all
deno run -A test.ts

Readme

Keywords

none

Package Sidebar

Install

npm i esm-compiler

Weekly Downloads

1

Version

0.5.6

License

MIT

Unpacked Size

6.88 MB

Total Files

14

Last publish

Collaborators

  • ije