rollup-plugin-assemblyscript

raw JSON →
2.0.0 verified Mon Apr 27 auth: no javascript

A Rollup plugin (v2.0.0) that imports AssemblyScript (.as) files and compiles them on-the-fly into WebAssembly modules. It supports custom compiler options, a configurable import matcher (default `asc:` prefix), and optional integration with as-bind for high-level type bindings. Distinct from other WASM plugins by targeting AssemblyScript specifically and offering tight rollup integration. Requires AssemblyScript and as-bind as peer dependencies. Maintained by the AssemblyScript team.

error Error: Cannot find module 'rollup-plugin-assemblyscript'
cause Package not installed or CJS require used in ESM-only version.
fix
Run: npm install rollup-plugin-assemblyscript Use: import { asc } from 'rollup-plugin-assemblyscript'
error [!] Error: The requested module 'rollup-plugin-assemblyscript' does not provide an export named 'asc'
cause Importing v1 style (named export 'asc' not available in older versions).
fix
If using v1: import asc from 'rollup-plugin-assemblyscript' If using v2: import { asc } from 'rollup-plugin-assemblyscript'
error TypeError: asc is not a function
cause Wrong import or plugin not called.
fix
Correct usage: plugins: [asc()] (call the function), not plugins: [asc]
breaking v2.0.0 migrated to ESM-only; CJS require() will fail.
fix Use ESM imports or dynamic import('rollup-plugin-assemblyscript').
deprecated Import specifier `assemblyscript:` prefix deprecated in v2; use `asc:` instead.
fix Change imports from `assemblyscript:./file.as` to `asc:./file.as`.
broken Missing peer dependencies (assemblyscript or as-bind) cause runtime errors.
fix npm install assemblyscript as-bind
gotcha The plugin compiles files matching the matcher into WASM URLs; imported value is a string URL, not a module instance.
fix Use the URL with WebAssembly.instantiateStreaming or fetch.
gotcha If `useAsBind: true`, as-bind library must be installed and import runtime requires `--exportRuntime` flag (automatically set by plugin).
fix Ensure as-bind is installed and use `import * as wasm from 'asc:./file.as'` to get bindings.
npm install rollup-plugin-assemblyscript
yarn add rollup-plugin-assemblyscript
pnpm add rollup-plugin-assemblyscript

Shows minimal rollup config using asc plugin with compiler options, default matcher, and as-bind disabled.

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

export default defineConfig({
  input: 'src/main.js',
  output: { dir: 'dist', format: 'esm' },
  plugins: [
    asc({
      compilerOptions: { optimizeLevel: 3 },
      matcher: /^asc:/,
      useAsBind: false
    })
  ]
});