Skip to content
This repository has been archived by the owner on Sep 6, 2022. It is now read-only.

A Rollup plugin that allows you to import AssemblyScript files and compiles them on-the-fly.

License

Notifications You must be signed in to change notification settings

surma/rollup-plugin-assemblyscript

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

27 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

rollup-plugin-assemblyscript

A Rollup plugin that allows you to import AssemblyScript files and compiles them on-the-fly.

Usage

Installation

$ npm install --save rollup-plugin-assemblyscript

Configuration

// rollup.config.js
import { asc } from "rollup-plugin-assemblyscript";

export default {
  /* ... */
  plugins: [
    // ...
    asc(options)
    // ...
  ]
};

And in your JavaScript code you can now import AssemblyScript as usual:

// addition.as
export function add(a: i32, b: i32): i32 {
  return a + b;
}
// main.js
import wasmUrl from "asc:./addition.as";

WebAssembly.instantiateStreaming(fetch(wasmUrl), {}).then(({ instance }) =>
  console.log(instance.exports.add(40, 2))
);

Options

  • compilerOptions: Options bag that is passed straight to the AssemblyScript compiler library.
  • matcher: A RegExp that is used to decided what imports to handle. The default is PREFIX_MATCHER, which will match all imports that start with asc:.
  • useAsBind: Injects the as-bind package into the compilation process for high-level type bindings. See their README for details (implies --exportRuntime).

License Apache-2.0

About

A Rollup plugin that allows you to import AssemblyScript files and compiles them on-the-fly.

Resources

License

Stars

Watchers

Forks

Packages

No packages published