diff --git a/lib/wasm-sync/WebAssemblyParser.js b/lib/wasm-sync/WebAssemblyParser.js index c3078cf1c5b..e3ea0a814f2 100644 --- a/lib/wasm-sync/WebAssemblyParser.js +++ b/lib/wasm-sync/WebAssemblyParser.js @@ -17,7 +17,7 @@ const WebAssemblyImportDependency = require("../dependencies/WebAssemblyImportDe /** @typedef {import("../Parser").ParserState} ParserState */ /** @typedef {import("../Parser").PreparsedAst} PreparsedAst */ -const JS_COMPAT_TYPES = new Set(["i32", "f32", "f64"]); +const JS_COMPAT_TYPES = new Set(["i32", "i64", "f32", "f64"]); /** * @param {t.Signature} signature the func signature diff --git a/test/cases/wasm/imports-complex-types/index.js b/test/cases/wasm/imports-complex-types/index.js index c2e0b23fead..3d2b113b93f 100644 --- a/test/cases/wasm/imports-complex-types/index.js +++ b/test/cases/wasm/imports-complex-types/index.js @@ -1,6 +1,6 @@ it("should allow to run a WebAssembly module with non-js-compatible imports", function() { return import("./wasm.wasm").then(function(wasm) { - const result = wasm.testI64(); + const result = wasm.testV128(); expect(result).toEqual(42); }); }); diff --git a/test/cases/wasm/imports-complex-types/other.wasm b/test/cases/wasm/imports-complex-types/other.wasm index 70c5aee0fa3..6949d18dd24 100644 Binary files a/test/cases/wasm/imports-complex-types/other.wasm and b/test/cases/wasm/imports-complex-types/other.wasm differ diff --git a/test/cases/wasm/imports-complex-types/test.filter.js b/test/cases/wasm/imports-complex-types/test.filter.js index 23177349638..390fa4a4dfc 100644 --- a/test/cases/wasm/imports-complex-types/test.filter.js +++ b/test/cases/wasm/imports-complex-types/test.filter.js @@ -1,5 +1,5 @@ -var supportsWebAssembly = require("../../../helpers/supportsWebAssembly"); +const supports = require("webassembly-feature"); module.exports = function(config) { - return supportsWebAssembly(); + return supports["simd"](); }; diff --git a/test/cases/wasm/imports-complex-types/wasm.wasm b/test/cases/wasm/imports-complex-types/wasm.wasm index 8374df1439f..a94d0954e7b 100644 Binary files a/test/cases/wasm/imports-complex-types/wasm.wasm and b/test/cases/wasm/imports-complex-types/wasm.wasm differ diff --git a/test/configCases/wasm/bigints/index.js b/test/configCases/wasm/bigints/index.js new file mode 100644 index 00000000000..35b576ddeda --- /dev/null +++ b/test/configCases/wasm/bigints/index.js @@ -0,0 +1,9 @@ +it("should allow converting i64s to JS bigints", async () => { + const { getI64 } = await import("./wasm.wat"); + expect(getI64()).toEqual(42n); +}); + +it("should allow converting JS bigints to i64s", async () => { + const { takeI64 } = await import("./wasm.wat"); + takeI64(42n); +}) diff --git a/test/configCases/wasm/bigints/test.filter.js b/test/configCases/wasm/bigints/test.filter.js new file mode 100644 index 00000000000..fedc9379c36 --- /dev/null +++ b/test/configCases/wasm/bigints/test.filter.js @@ -0,0 +1,5 @@ +const supports = require("webassembly-feature"); + +module.exports = function(config) { + return supports["JS-BigInt-integration"](); +}; diff --git a/test/configCases/wasm/bigints/wasm.wat b/test/configCases/wasm/bigints/wasm.wat new file mode 100644 index 00000000000..94789d52d4b --- /dev/null +++ b/test/configCases/wasm/bigints/wasm.wat @@ -0,0 +1,4 @@ +(module + (func (export "getI64") (result i64) + i64.const 42) + (func (export "takeI64") (param i64))) diff --git a/test/configCases/wasm/bigints/webpack.config.js b/test/configCases/wasm/bigints/webpack.config.js new file mode 100644 index 00000000000..63567a47504 --- /dev/null +++ b/test/configCases/wasm/bigints/webpack.config.js @@ -0,0 +1,16 @@ +/** @type {import("../../../../").Configuration} */ +module.exports = { + entry: "./index", + module: { + rules: [ + { + test: /\.wat$/, + loader: "wast-loader", + type: "webassembly/sync" + } + ] + }, + experiments: { + syncWebAssembly: true + } +};