Skip to content

Commit

Permalink
Merge pull request #5 from atom-ide-community/wasm
Browse files Browse the repository at this point in the history
  • Loading branch information
aminya authored Jul 29, 2020
2 parents 69e350c + 9f139fe commit 748dd6f
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 8 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ babel
coffee
json
css
wasm
(js is considered by default)
```

Expand Down
5 changes: 5 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
"@rollup/plugin-babel": "^5.1.0",
"rollup-plugin-coffee-script": "2.0.0",
"@rollup/plugin-json": "4.1.0",
"@rollup/plugin-wasm": "^5.0.0",
"rollup-plugin-terser": "6.1.0",
"rollup-plugin-auto-external": "2.0.0",
"rollup-plugin-css-only": "^2.1.0",
Expand Down
30 changes: 22 additions & 8 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import coffeescript from "rollup-plugin-coffee-script";
import json from "@rollup/plugin-json";
import cssOnly from "rollup-plugin-css-only";
import babel from "@rollup/plugin-babel";
import { wasm } from "@rollup/plugin-wasm";

export type Plugin =
| "js"
Expand All @@ -18,11 +19,13 @@ export type Plugin =
| "json"
| "css"
| "babel"
| "wasm"
| ["ts", typeof typescript]
| ["babel", typeof babel]
| ["coffee", typeof coffeescript]
| ["json", typeof json]
| ["css", typeof cssOnly];
| ["css", typeof cssOnly]
| ["wasm", typeof wasm];

// function to check if the first array has any of the second array
// first array can have `[string, object]` as their input
Expand Down Expand Up @@ -70,7 +73,7 @@ export function createPlugins(
plugins.push(
typescript({
noEmitOnError: false,
module: "ESNext" // do not modify the imports
module: "ESNext", // do not modify the imports
})
);
} else {
Expand Down Expand Up @@ -164,22 +167,33 @@ export function createPlugins(
}
}

// wasm
const wasmIndex = includesAny(inputPluginsNames, ["wasm", "WebAssembly"]);
if (wasmIndex !== null) {
const wasm = require("@rollup/plugin-wasm");
if (typeof inputPluginsNames[wasmIndex] === "string") {
// plugin name only
plugins.push(wasm());
} else {
// plugin with options
plugins.push(wasm(inputPluginsNames[wasmIndex][1]));
}
}

// extra plugins
if (typeof extraPlugins !== "boolean" && extraPlugins !== undefined) {
try {
plugins.push(...extraPlugins);
}
catch (e) {
console.error("You should pass extraPlugins as an array")
} catch (e) {
console.error("You should pass extraPlugins as an array");
}
}

if (extraPluginsDeprecated) {
try {
plugins.push(...extraPluginsDeprecated);
}
catch (e) {
console.error("You should pass extraPluginsDeprecated as an array")
} catch (e) {
console.error("You should pass extraPluginsDeprecated as an array");
}
}

Expand Down

0 comments on commit 748dd6f

Please sign in to comment.