Skip to content

Commit 748dd6f

Browse files
authored
Merge pull request #5 from atom-ide-community/wasm
2 parents 69e350c + 9f139fe commit 748dd6f

File tree

4 files changed

+29
-8
lines changed

4 files changed

+29
-8
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-lock.json

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

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: 22 additions & 8 deletions
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
@@ -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

Comments
 (0)