Skip to content

wasm-fmt/dart_fmt

Repository files navigation

Test

Install

npm

npm install @wasm-fmt/dart_fmt

jsr.io

npx jsr add @fmt/dart-fmt

Usage

Node.js / Deno / Bun

import { format } from "@wasm-fmt/dart_fmt";

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

const formatted = format(source);
console.log(formatted);

Bundler

dart_fmt does not support ESM Integration entry yet. Try use other entry points like ./esm or ./web instead.

Web

For web environments, you need to initialize WASM module manually:

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

await init();

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

const formatted = format(source);
console.log(formatted);

Vite

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

await init();
// ...

Entry Points

  • . - Auto-detects environment (Node.js uses node, default is ESM)
  • ./node - Node.js module-sync compatible, include CommonJS (no init required)
  • ./esm - ESM environments like modern Node.js/Deno (no init required)
  • ./web - Web browsers (requires manual init)
  • ./vite - Vite bundler (requires manual init)

Build from source

# 1. install Dart https://dart.dev/get-dart

# 2. clone this repo
git clone https://github.com/wasm-fmt/dart_fmt.git

# 3. install dependencies
dart pub get

# 4. build
npm run build

# 5. test
npm run test:node

About

Dart Formatter powered by WASM ported from dart_style

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages