mirror of
https://github.com/fluencelabs/assemblyscript
synced 2025-06-14 23:41:30 +00:00
Utilities and an initial webpack loader
This commit is contained in:
13
lib/webpack/index.js
Normal file
13
lib/webpack/index.js
Normal file
@ -0,0 +1,13 @@
|
||||
var base64 = require("@protobufjs/base64");
|
||||
|
||||
(module.exports = function(buffer) {
|
||||
var data = base64.encode(buffer, 0, buffer.length);
|
||||
var code = [
|
||||
'var data = "' + data + '", wasm;',
|
||||
'module.exports = function(options) {',
|
||||
' if (!wasm) wasm = require("@assemblyscript/webpack/decode")(data);',
|
||||
' return new WebAssembly.Instance(new WebAssembly.Module(wasm), options && options.imports || {}).exports;',
|
||||
'};'
|
||||
];
|
||||
return code.join("\n");
|
||||
}).raw = true;
|
Reference in New Issue
Block a user