Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/littledivy/deno_swc

The SWC compiler for Deno.
https://github.com/littledivy/deno_swc

ast bundler deno hacktoberfest javascript parser rust spack swc typescript

Last synced: 12 days ago
JSON representation

The SWC compiler for Deno.

Awesome Lists containing this project

README

        





deno_swc logo

deno_swc


The SWC compiler for Deno.

![ci](https://github.com/littledivy/deno_swc/workflows/ci/badge.svg)
![](https://img.shields.io/github/v/release/littledivy/deno_swc?style=plastic)

# Usage

`parse()`

```typescript
import { parse, print } from "https://deno.land/x/[email protected]/mod.ts";

const code = `const x: string = "Hello, Deno SWC!"`;

const ast = parse(code, {
target: "es2019",
syntax: "typescript",
comments: false,
});

// {
// type: "Module",
// span: { start: 0, end: 36, ctxt: 0 },
// body: [
// {
// type: "VariableDeclaration",
// span: [Object],
// kind: "const",
// declare: false,
// declarations: [Array]
// }
// ],
// interpreter: null
// }
```

`print()`

```typescript
const { code } = print(ast, {
minify: true,
module: {
type: "commonjs",
},
});

// const x = "Hello, Deno SWC!"
```

...and `transform()`

```typescript
const { code } = transform("const x: number = 2;", {
jsc: {
target: "es2016",
parser: {
syntax: "typescript",
},
},
});

// const x = 2;
```

## Copyright

deno_swc is licensed under the MIT license. Please see the [LICENSE](LICENSE)
file.