@wasm-fmt/dart_fmt
v0.4.0
Published
Dart Formatter powered by WASM ported from dart_style
Downloads
120
Readme
Install
npm install @wasm-fmt/dart_fmtnpx jsr add @fmt/dart-fmtUsage
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.jsmodule-synccompatible, 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