{"id":21916,"library":"rollup-plugin-assemblyscript","title":"rollup-plugin-assemblyscript","description":"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.","status":"active","version":"2.0.0","language":"javascript","source_language":"en","source_url":null,"tags":["javascript"],"install":[{"cmd":"npm install rollup-plugin-assemblyscript","lang":"bash","label":"npm"},{"cmd":"yarn add rollup-plugin-assemblyscript","lang":"bash","label":"yarn"},{"cmd":"pnpm add rollup-plugin-assemblyscript","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Peer dependency; required for compilation of .as files","package":"assemblyscript","optional":false},{"reason":"Optional peer dependency; enables high-level bindings when useAsBind is set","package":"as-bind","optional":true}],"imports":[{"note":"Default and named exports are merged; both `asc` and `default` work. v2.0.0 uses ESM.","symbol":"asc","correct":"import { asc } from 'rollup-plugin-assemblyscript'"},{"note":"Package is ESM-only in v2; CJS require will throw. Use dynamic import or transpiler.","wrong":"const ascPlugin = require('rollup-plugin-assemblyscript')","symbol":"Plugin (via default import)","correct":"import ascPlugin from 'rollup-plugin-assemblyscript'"},{"note":"Imports must use the `asc:` prefix (default matcher) to trigger compilation. Without prefix, Rollup treats it as a regular file.","wrong":"import wasm from './addition.as'","symbol":"Import specifier `asc:`","correct":"import wasmUrl from 'asc:./addition.as'"}],"quickstart":{"code":"// rollup.config.js\nimport { asc } from 'rollup-plugin-assemblyscript';\nimport { defineConfig } from 'rollup';\n\nexport default defineConfig({\n  input: 'src/main.js',\n  output: { dir: 'dist', format: 'esm' },\n  plugins: [\n    asc({\n      compilerOptions: { optimizeLevel: 3 },\n      matcher: /^asc:/,\n      useAsBind: false\n    })\n  ]\n});","lang":"typescript","description":"Shows minimal rollup config using asc plugin with compiler options, default matcher, and as-bind disabled."},"warnings":[{"fix":"Use ESM imports or dynamic import('rollup-plugin-assemblyscript').","message":"v2.0.0 migrated to ESM-only; CJS require() will fail.","severity":"breaking","affected_versions":">=2.0.0"},{"fix":"Change imports from `assemblyscript:./file.as` to `asc:./file.as`.","message":"Import specifier `assemblyscript:` prefix deprecated in v2; use `asc:` instead.","severity":"deprecated","affected_versions":">=2.0.0"},{"fix":"npm install assemblyscript as-bind","message":"Missing peer dependencies (assemblyscript or as-bind) cause runtime errors.","severity":"broken","affected_versions":"*"},{"fix":"Use the URL with WebAssembly.instantiateStreaming or fetch.","message":"The plugin compiles files matching the matcher into WASM URLs; imported value is a string URL, not a module instance.","severity":"gotcha","affected_versions":"*"},{"fix":"Ensure as-bind is installed and use `import * as wasm from 'asc:./file.as'` to get bindings.","message":"If `useAsBind: true`, as-bind library must be installed and import runtime requires `--exportRuntime` flag (automatically set by plugin).","severity":"gotcha","affected_versions":"*"}],"env_vars":null,"last_verified":"2026-04-27T00:00:00.000Z","next_check":"2026-07-26T00:00:00.000Z","problems":[{"fix":"Run: npm install rollup-plugin-assemblyscript\nUse: import { asc } from 'rollup-plugin-assemblyscript'","cause":"Package not installed or CJS require used in ESM-only version.","error":"Error: Cannot find module 'rollup-plugin-assemblyscript'"},{"fix":"If using v1: import asc from 'rollup-plugin-assemblyscript'\nIf using v2: import { asc } from 'rollup-plugin-assemblyscript'","cause":"Importing v1 style (named export 'asc' not available in older versions).","error":"[!] Error: The requested module 'rollup-plugin-assemblyscript' does not provide an export named 'asc'"},{"fix":"Correct usage: plugins: [asc()] (call the function), not plugins: [asc]","cause":"Wrong import or plugin not called.","error":"TypeError: asc is not a function"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}