Skip to content

bluwy/fmu

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

61 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation


A collection of JS module utilities written in Rust

Usage

The package is published to npm as a WebAssembly module. Install with:

$ npm install fmu
import { init, guessJsSyntax } from 'fmu'

// initialize wasm (MUST call this before any other APIs)
await init()

const code = `exports.foo = 'bar'`
console.log(await guessJsSyntax(code)) // "CJS"

Note: For Vite, you have to pass a custom URL to init(). For example:

import { init } from 'fmu'
import wasmUrl from 'fmu/wasm?url'
await init(wasmUrl)

See examples for usage with different setups.

Development

Follow the official guide to install Rust. Also install wasm-pack to build Rust files into WebAssembly.

# Build wasm for dev (e.g. testing examples)
$ npm run dev

# Build wasm for publishing
$ npm run build

# Run unit and integration tests
$ cargo test

Sponsors

Sponsors

License

MIT

About

A collection of JS module utilities written in Rust

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Sponsor this project

 

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •