@@ -10,6 +10,7 @@ import coffeescript from "rollup-plugin-coffee-script";
10
10
import json from "@rollup/plugin-json" ;
11
11
import cssOnly from "rollup-plugin-css-only" ;
12
12
import babel from "@rollup/plugin-babel" ;
13
+ import { wasm } from "@rollup/plugin-wasm" ;
13
14
14
15
export type Plugin =
15
16
| "js"
@@ -18,11 +19,13 @@ export type Plugin =
18
19
| "json"
19
20
| "css"
20
21
| "babel"
22
+ | "wasm"
21
23
| [ "ts" , typeof typescript ]
22
24
| [ "babel" , typeof babel ]
23
25
| [ "coffee" , typeof coffeescript ]
24
26
| [ "json" , typeof json ]
25
- | [ "css" , typeof cssOnly ] ;
27
+ | [ "css" , typeof cssOnly ]
28
+ | [ "wasm" , typeof wasm ] ;
26
29
27
30
// function to check if the first array has any of the second array
28
31
// first array can have `[string, object]` as their input
@@ -70,7 +73,7 @@ export function createPlugins(
70
73
plugins . push (
71
74
typescript ( {
72
75
noEmitOnError : false ,
73
- module : "ESNext" // do not modify the imports
76
+ module : "ESNext" , // do not modify the imports
74
77
} )
75
78
) ;
76
79
} else {
@@ -164,22 +167,33 @@ export function createPlugins(
164
167
}
165
168
}
166
169
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
+
167
183
// extra plugins
168
184
if ( typeof extraPlugins !== "boolean" && extraPlugins !== undefined ) {
169
185
try {
170
186
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" ) ;
174
189
}
175
190
}
176
191
177
192
if ( extraPluginsDeprecated ) {
178
193
try {
179
194
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" ) ;
183
197
}
184
198
}
185
199
0 commit comments