Skip to content

Commit 20d4433

Browse files
committed
feat: add wasm support
1 parent 69e350c commit 20d4433

File tree

3 files changed

+19
-1
lines changed

3 files changed

+19
-1
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ babel
6565
coffee
6666
json
6767
css
68+
wasm
6869
(js is considered by default)
6970
```
7071

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
"@rollup/plugin-babel": "^5.1.0",
2727
"rollup-plugin-coffee-script": "2.0.0",
2828
"@rollup/plugin-json": "4.1.0",
29+
"@rollup/plugin-wasm": "^5.0.0",
2930
"rollup-plugin-terser": "6.1.0",
3031
"rollup-plugin-auto-external": "2.0.0",
3132
"rollup-plugin-css-only": "^2.1.0",

src/main.ts

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import coffeescript from "rollup-plugin-coffee-script";
1010
import json from "@rollup/plugin-json";
1111
import cssOnly from "rollup-plugin-css-only";
1212
import babel from "@rollup/plugin-babel";
13+
import { wasm } from '@rollup/plugin-wasm';
1314

1415
export 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
@@ -164,6 +167,19 @@ 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 {

0 commit comments

Comments
 (0)