Skip to content

Commit

Permalink
Merge pull request #47 from atom-community/asc
Browse files Browse the repository at this point in the history
feat: add assemblyscript support
  • Loading branch information
aminya authored Jan 6, 2021
2 parents a964ab7 + 65e4553 commit 222592e
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 10 deletions.
7 changes: 5 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,17 +35,20 @@
"csso-cli": "^3.0.0",
"array-includes-any": "^2.7.3",
"rollup-plugin-sourcemaps": "^0.6.3",
"rollup-plugin-visualizer": "^4.2.0"
"rollup-plugin-visualizer": "^4.2.0",
"rollup-plugin-assemblyscript": "^1.3.0"
},
"peerDependencies": {
"rollup": "^2"
},
"optionalDependencies": {
"typescript": "^4",
"coffeescript": "^1",
"@babel/core": "^7"
"@babel/core": "^7",
"assemblyscript": "*"
},
"devDependencies": {
"assemblyscript": "*",
"typescript": "^4.0.3",
"rollup": "2.31.0",
"prettier": "^2.2.1",
Expand Down
24 changes: 16 additions & 8 deletions pnpm-lock.yaml

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

16 changes: 16 additions & 0 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ 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"
import { asc } from "rollup-plugin-assemblyscript"

export type Plugin =
| "js"
Expand All @@ -22,12 +23,14 @@ export type Plugin =
| "css"
| "babel"
| "wasm"
| "as"
| ["ts", typeof typescript]
| ["babel", typeof babel]
| ["coffee", typeof coffeescript]
| ["json", typeof json]
| ["css", typeof cssOnly]
| ["wasm", typeof wasm]
| ["as", typeof asc]

// 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 @@ -171,6 +174,19 @@ export function createPlugins(
}
}

// as
const ascIndex = includesAny(inputPluginsNames, ["as", "asc", "assemblyscript", "AssemblyScript"])
if (ascIndex !== null) {
const asc = require("rollup-plugin-assemblyscript")
if (typeof inputPluginsNames[ascIndex] === "string") {
// plugin name only
plugins.push(asc())
} else {
// plugin with options
plugins.push(asc(inputPluginsNames[ascIndex][1]))
}
}

// visualizer
const visualizerIndex = includesAny(inputPluginsNames, ["visualizer", "plot"])
if (visualizerIndex !== null) {
Expand Down

0 comments on commit 222592e

Please sign in to comment.