# esm-compiler

> The compiler for esm.sh playground written in Rust.

Latest version **0.9.2** (published 2024-10-01) · MIT license · 0 weekly downloads

## Install

```sh
npm install esm-compiler
pnpm add esm-compiler
yarn add esm-compiler
bun add esm-compiler
```

## Health

**Score 50/100 (C)** — status: stable.

Positive: has types; esm support; no vulnerabilities; high quality score.

Warnings: low downloads; pre 1.0.

Negative: stale.

## Facts

| | |
|---|---|
| Version | 0.9.2 |
| Published | 2024-10-01 |
| First published | 2022-12-25 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM |
| Dependencies | 0 |
| Unpacked size | 6.4 MB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 33 |
| Maintainers | ije |

## Links

- npm: https://www.npmjs.com/package/esm-compiler
- Repository: https://github.com/esm-dev/esm-compiler
- Homepage: https://github.com/esm-dev/esm-compiler#readme
- Issues: https://github.com/esm-dev/esm-compiler/issues
- npm.io page: https://npm.io/package/esm-compiler

## Recent versions

- 0.9.2 (latest) — 2024-10-01
- 0.9.1 — 2024-09-07
- 0.9.0 — 2024-09-05
- 0.8.0 — 2024-09-02
- 0.7.2 — 2024-08-27
- 0.7.1 — 2024-08-27
- 0.7.0 — 2024-08-27
- 0.6.2 — 2024-08-11
- 0.6.1 — 2024-07-07
- 0.6.0 — 2024-06-20
- 0.5.7 — 2024-06-19
- 0.5.6 — 2024-04-07
- 0.5.5 — 2024-04-07
- 0.5.4 — 2024-04-06
- 0.5.3 — 2024-03-13
- … 24 more at https://npm.io/package/esm-compiler/versions

## README

# ESM Compiler

The compiler for esm.sh playground written in Rust, powered by
[swc](https://swc.rs) and [lightningcss](https://lightningcss.dev/).

## Usage

```js
import init, { transform } from "https://esm.sh/esm-compiler";
await init();

const appTsx = `
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.tsx", appTsx, { importMap })
console.log(ret.code)
```

## Development Setup

You will need [rust](https://www.rust-lang.org/tools/install) 1.60+ and
[wasm-pack](https://rustwasm.github.io/wasm-pack/installer/).

## Build

```bash
wasm-pack build --target web
```

## Run tests

```bash
cargo test --all
```

---
_Source: https://npm.io/package/esm-compiler · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
