diff --git a/.gitignore b/.gitignore index d5f19d8..5947815 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ node_modules package-lock.json +test/build \ No newline at end of file diff --git a/index.js b/index.js index 0b9be39..195391a 100644 --- a/index.js +++ b/index.js @@ -124,7 +124,8 @@ function asc(opts) { return `--${opt}`; } return `--${opt}=${val}`; - }) + }), + ...(opts.fileExtension ? [`--extension`, opts.fileExtension] : []) ]; asCompiler.main( params, diff --git a/package.json b/package.json index f8ba859..e2dabe0 100644 --- a/package.json +++ b/package.json @@ -1,18 +1,23 @@ { "name": "rollup-plugin-assemblyscript", - "version": "1.2.0", + "version": "1.2.1", "description": "", "main": "index.js", "keywords": [], "author": "Surma ", "license": "Apache-2.0", "dependencies": { - "assemblyscript": "^0.9.4" + "assemblyscript": "^0.17.1" }, "devDependencies": { "husky": "^4.2.3", "lint-staged": "^10.0.8", - "prettier": "^1.19.1" + "prettier": "^1.19.1", + "rollup": "^2.32.1" + }, + "scripts": { + "test": "cd test && rollup -c", + "test-serve": "npx servez test" }, "husky": { "hooks": { diff --git a/test/addition.as b/test/addition.as new file mode 100644 index 0000000..a549175 --- /dev/null +++ b/test/addition.as @@ -0,0 +1,4 @@ +//@ts-ignore +export function add(a: i32, b: i32): i32 { + return a + b; +} diff --git a/test/index.html b/test/index.html new file mode 100644 index 0000000..a9bf8f3 --- /dev/null +++ b/test/index.html @@ -0,0 +1,11 @@ + + + + + + Document + + + + + diff --git a/test/main.js b/test/main.js new file mode 100644 index 0000000..b9a8ba1 --- /dev/null +++ b/test/main.js @@ -0,0 +1,5 @@ +import { instancePromise } from "asc:./addition.as"; + +instancePromise.then(instance => { + alert(instance.exports.add(40, 2)); +}); diff --git a/test/rollup.config.js b/test/rollup.config.js new file mode 100644 index 0000000..8c0f42e --- /dev/null +++ b/test/rollup.config.js @@ -0,0 +1,21 @@ +let asc = require("../index.js").asc; + +export default { + input: "main.js", + output: { + file: "build/main.js", + name: "test", + format: "umd" + }, + plugins: [ + asc({ + fileExtension: ".as", + compilerOptions: { + optimizeLevel: 3, + runtime: "none" + //shrinkLevel: 1, + //importMemory: true + } + }) + ] +};