From 17f0414f6cbe6543cc5e834d44ce593198e48a99 Mon Sep 17 00:00:00 2001 From: Amin Yahyaabadi Date: Thu, 7 Jan 2021 02:06:41 -0600 Subject: [PATCH 1/3] Use absolute path to the generate the wasmFilePath --- index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.js b/index.js index 195391a..8845616 100644 --- a/index.js +++ b/index.js @@ -111,7 +111,7 @@ function asc(opts) { const params = [ id, "-b", - relative(process.env.PWD, wasmFilePath), + wasmFilePath, ...(shouldGenerateSourceMaps(opts) ? [ `--sourceMap=${renderNamePattern(opts.sourceMapURLPattern, { From 78840b4adc3328db5c55439ff3f06d0f87567aa5 Mon Sep 17 00:00:00 2001 From: Amin Yahyaabadi Date: Thu, 7 Jan 2021 02:07:51 -0600 Subject: [PATCH 2/3] Sign --- CONTRIBUTORS | 1 + 1 file changed, 1 insertion(+) diff --git a/CONTRIBUTORS b/CONTRIBUTORS index adb9acb..6767dc5 100644 --- a/CONTRIBUTORS +++ b/CONTRIBUTORS @@ -9,3 +9,4 @@ # Names should be added to this file as: # Name Surma +Amin Ya From a7b60786a4e14d8c8ed5e1e9b821f5485f9261a8 Mon Sep 17 00:00:00 2001 From: Amin Yahyaabadi Date: Thu, 7 Jan 2021 02:24:30 -0600 Subject: [PATCH 3/3] Add subtraction test --- test/main2.js | 13 ++++++++++++ test/rollup.config.js | 47 ++++++++++++++++++++++++++----------------- test/subtraction.ts | 4 ++++ 3 files changed, 46 insertions(+), 18 deletions(-) create mode 100644 test/main2.js create mode 100644 test/subtraction.ts diff --git a/test/main2.js b/test/main2.js new file mode 100644 index 0000000..c7ecfab --- /dev/null +++ b/test/main2.js @@ -0,0 +1,13 @@ +import { modulePromise } from "asc:./subtraction.ts"; + +modulePromise + .then((module) => WebAssembly.instantiate(module, {})) + .then((instance) => { + assert(instance.exports.subtract(40, 2) === 38); + }); + +function assert(val) { + if (!val) { + throw Error(`Assertaion failed`); + } +} diff --git a/test/rollup.config.js b/test/rollup.config.js index 8c0f42e..bf19c8d 100644 --- a/test/rollup.config.js +++ b/test/rollup.config.js @@ -1,21 +1,32 @@ let asc = require("../index.js").asc; -export default { - input: "main.js", - output: { - file: "build/main.js", - name: "test", - format: "umd" +export default [ + { + input: "main.js", + output: { + file: "build/umd/main.js", + name: "test", + format: "umd", + }, + plugins: [ + asc({ + fileExtension: ".as", + compilerOptions: { + optimizeLevel: 3, + runtime: "none", + //shrinkLevel: 1, + //importMemory: true + }, + }), + ], }, - plugins: [ - asc({ - fileExtension: ".as", - compilerOptions: { - optimizeLevel: 3, - runtime: "none" - //shrinkLevel: 1, - //importMemory: true - } - }) - ] -}; + { + input: "main2.js", + output: { + file: "build/es/main.js", + name: "test", + format: "es", + }, + plugins: [asc()], + }, +]; diff --git a/test/subtraction.ts b/test/subtraction.ts new file mode 100644 index 0000000..b2bafcb --- /dev/null +++ b/test/subtraction.ts @@ -0,0 +1,4 @@ +//@ts-ignore +export function subctract(a: i32, b: i32): i32 { + return a - b; +}