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 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, { 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; +}