Ecosyste.ms: Awesome

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

Awesome Lists | Featured Topics | Projects

https://github.com/wasm-fmt/dart_fmt

Dart Formatter powered by WASM ported from dart_style
https://github.com/wasm-fmt/dart_fmt

Last synced: 3 days ago
JSON representation

Dart Formatter powered by WASM ported from dart_style

Awesome Lists containing this project

README

        

[![Test](https://github.com/wasm-fmt/dart_fmt/actions/workflows/test.yml/badge.svg)](https://github.com/wasm-fmt/dart_fmt/actions/workflows/test.yml)

# Install

[![npm](https://img.shields.io/npm/v/@wasm-fmt/dart_fmt?color=00B4AB)](https://www.npmjs.com/package/@wasm-fmt/dart_fmt)

```bash
npm install @wasm-fmt/dart_fmt
```

[![jsr.io](https://jsr.io/badges/@fmt/dart-fmt?color=00B4AB)](https://jsr.io/@fmt/dart-fmt)

```bash
npx jsr add @fmt/dart-fmt
```

# Usage

```javascript
import init, { format } from "@wasm-fmt/dart_fmt";

await init();

const input = `void main() { print('Hello, World!'); }`;

const formatted = format(input, "main.dart");
console.log(formatted);
```

For Vite users:

Add `"@wasm-fmt/dart_fmt"` to `optimizeDeps.exclude` in your vite config:

```JSON
{
"optimizeDeps": {
"exclude": ["@wasm-fmt/dart_fmt"]
}
}
```

If you cannot change the vite config, you can use another import entry

```JavaScript
import init, { format } from "@wasm-fmt/dart_fmt/vite";

// ...
```