as-loader
Version:
AssemblyScript loader for webpack
23 lines (22 loc) • 908 B
JavaScript
Object.defineProperty(exports, "__esModule", { value: true });
exports.instantiate = void 0;
var AsBind = require("as-bind");
function instantiate(module, load, imports, fallback, supports) {
if (fallback === void 0) { fallback = true; }
if (supports === void 0) { supports = function () { return typeof WebAssembly === "object"; }; }
if (supports()) {
return AsBind.instantiate(load(module), imports || {}).then(function (result) {
result.type = "wasm-bound";
return result;
});
}
else if (fallback && module.fallback) {
return module.fallback().then(function (exports) { return ({
type: "js",
exports: exports,
}); });
}
return Promise.reject(new Error("Cannot load \"" + module + "\" module. WebAssembly is not supported in this environment."));
}
exports.instantiate = instantiate;
;