@@ -10,6 +10,7 @@ import coffeescript from "rollup-plugin-coffee-script";
1010import json from "@rollup/plugin-json" ;
1111import cssOnly from "rollup-plugin-css-only" ;
1212import babel from "@rollup/plugin-babel" ;
13+ import { wasm } from "@rollup/plugin-wasm" ;
1314
1415export type Plugin =
1516 | "js"
@@ -18,11 +19,13 @@ export type Plugin =
1819 | "json"
1920 | "css"
2021 | "babel"
22+ | "wasm"
2123 | [ "ts" , typeof typescript ]
2224 | [ "babel" , typeof babel ]
2325 | [ "coffee" , typeof coffeescript ]
2426 | [ "json" , typeof json ]
25- | [ "css" , typeof cssOnly ] ;
27+ | [ "css" , typeof cssOnly ]
28+ | [ "wasm" , typeof wasm ] ;
2629
2730// function to check if the first array has any of the second array
2831// first array can have `[string, object]` as their input
@@ -70,7 +73,7 @@ export function createPlugins(
7073 plugins . push (
7174 typescript ( {
7275 noEmitOnError : false ,
73- module : "ESNext" // do not modify the imports
76+ module : "ESNext" , // do not modify the imports
7477 } )
7578 ) ;
7679 } else {
@@ -164,22 +167,33 @@ export function createPlugins(
164167 }
165168 }
166169
170+ // wasm
171+ const wasmIndex = includesAny ( inputPluginsNames , [ "wasm" , "WebAssembly" ] ) ;
172+ if ( wasmIndex !== null ) {
173+ const wasm = require ( "@rollup/plugin-wasm" ) ;
174+ if ( typeof inputPluginsNames [ wasmIndex ] === "string" ) {
175+ // plugin name only
176+ plugins . push ( wasm ( ) ) ;
177+ } else {
178+ // plugin with options
179+ plugins . push ( wasm ( inputPluginsNames [ wasmIndex ] [ 1 ] ) ) ;
180+ }
181+ }
182+
167183 // extra plugins
168184 if ( typeof extraPlugins !== "boolean" && extraPlugins !== undefined ) {
169185 try {
170186 plugins . push ( ...extraPlugins ) ;
171- }
172- catch ( e ) {
173- console . error ( "You should pass extraPlugins as an array" )
187+ } catch ( e ) {
188+ console . error ( "You should pass extraPlugins as an array" ) ;
174189 }
175190 }
176191
177192 if ( extraPluginsDeprecated ) {
178193 try {
179194 plugins . push ( ...extraPluginsDeprecated ) ;
180- }
181- catch ( e ) {
182- console . error ( "You should pass extraPluginsDeprecated as an array" )
195+ } catch ( e ) {
196+ console . error ( "You should pass extraPluginsDeprecated as an array" ) ;
183197 }
184198 }
185199
0 commit comments