mirror of
https://github.com/systemjs/systemjs.git
synced 2026-02-01 15:59:54 +00:00
Fix Wasm limit and Safari instantiation (#1857)
test and fix wasm 4KB limit, as well as fixing Safari instantiation
This commit is contained in:
parent
989a04f1c0
commit
cb25b39f57
@ -12,7 +12,14 @@ systemJSPrototype.instantiate = function (url, parent) {
|
||||
.then(function (res) {
|
||||
if (!res.ok)
|
||||
throw new Error(res.status + ' ' + res.statusText + ' ' + res.url + (parent ? ' loading from ' + parent : ''));
|
||||
return WebAssembly.compileStreaming(res);
|
||||
|
||||
if (WebAssembly.compileStreaming)
|
||||
return WebAssembly.compileStreaming(res);
|
||||
|
||||
return res.arrayBuffer()
|
||||
.then(function (buf) {
|
||||
return WebAssembly.compile(buf);
|
||||
});
|
||||
})
|
||||
.then(function (module) {
|
||||
const deps = [];
|
||||
@ -34,7 +41,10 @@ systemJSPrototype.instantiate = function (url, parent) {
|
||||
return {
|
||||
setters: setters,
|
||||
execute: function () {
|
||||
_export(new WebAssembly.Instance(module, importObj).exports);
|
||||
return WebAssembly.instantiate(module, importObj)
|
||||
.then(function (instance) {
|
||||
_export(instance.exports);
|
||||
});
|
||||
}
|
||||
};
|
||||
}];
|
||||
|
||||
@ -125,4 +125,12 @@ suite('SystemJS Standard Tests', function() {
|
||||
assert.equal(m.exampleExport(1), 2);
|
||||
});
|
||||
});
|
||||
|
||||
if (typeof WebAssembly !== 'undefined' && typeof process === 'undefined')
|
||||
test('Loading WASM over 4KB limit', function () {
|
||||
return System.import('fixtures/wasm/addbloated.wasm')
|
||||
.then(function (m) {
|
||||
assert.equal(m.addTwo(1, 1), 2);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
BIN
test/fixtures/browser/wasm/addbloated.wasm
vendored
Normal file
BIN
test/fixtures/browser/wasm/addbloated.wasm
vendored
Normal file
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user