Vite plugin for MoonBit that allows importing MoonBit modules with the mbt: prefix. Current stable version is 0.2.1. It supports JS and WASM-GC backends, auto-starts moon build --watch, provides HMR on file changes, source maps for .mbt files, and supports MoonBit workspaces/monorepos. Key differentiators include a MoonBit-native DSL parser for moon.pkg/moon.work, query suffixes (?worker, ?url, ?raw), experimental TypeScript bridge generation via mizchi/ts.mbt, and the ability to mix multiple backends in one project. It requires vite >=5.0.0 and ships TypeScript types.
npm install vite-plugin-moonbitVerified import paths — ran on the pinned version, not inferred.
Basic setup with JS backend: configure Vite plugin, then import MoonBit modules using the mbt: prefix.
Use named import: import { moonbit } from 'vite-plugin-moonbit'Use 'wasm-gc' explicitly instead of 'wasm'.
Add to tsconfig.json: {"compilerOptions": {"paths": {"mbt:*": ["./node_modules/vite-plugin-moonbit/types/mbt.d.ts"]}}}Review generated bridge code and pin plugin version if stability is critical.
Change to: import { moonbit } from 'vite-plugin-moonbit'Add to tsconfig.json compilerOptions.paths: { "mbt:*": ["./node_modules/vite-plugin-moonbit/types/mbt.d.ts"] }Ensure 'moon' is installed and run 'moon build --target js' manually to see detailed errors.