mirror of https://github.com/webpack/webpack.git
Merge pull request #16339 from Liamolucko/wasm-i64
Add `i64` to the set of JS-compatible wasm types in `syncWebAssembly` mode
This commit is contained in:
commit
f7f36ad412
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
});
|
||||
});
|
||||
|
|
|
|||
Binary file not shown.
|
|
@ -1,5 +1,5 @@
|
|||
var supportsWebAssembly = require("../../../helpers/supportsWebAssembly");
|
||||
const supports = require("webassembly-feature");
|
||||
|
||||
module.exports = function(config) {
|
||||
return supportsWebAssembly();
|
||||
return supports["simd"]();
|
||||
};
|
||||
|
|
|
|||
Binary file not shown.
|
|
@ -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);
|
||||
})
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
const supports = require("webassembly-feature");
|
||||
|
||||
module.exports = function(config) {
|
||||
return supports["JS-BigInt-integration"]();
|
||||
};
|
||||
|
|
@ -0,0 +1,4 @@
|
|||
(module
|
||||
(func (export "getI64") (result i64)
|
||||
i64.const 42)
|
||||
(func (export "takeI64") (param i64)))
|
||||
|
|
@ -0,0 +1,16 @@
|
|||
/** @type {import("../../../../").Configuration} */
|
||||
module.exports = {
|
||||
entry: "./index",
|
||||
module: {
|
||||
rules: [
|
||||
{
|
||||
test: /\.wat$/,
|
||||
loader: "wast-loader",
|
||||
type: "webassembly/sync"
|
||||
}
|
||||
]
|
||||
},
|
||||
experiments: {
|
||||
syncWebAssembly: true
|
||||
}
|
||||
};
|
||||
Loading…
Reference in New Issue