code: function build(importsObj, tree) {
    const modules = {};
  
    const instantiate = filepath => {
      if (modules[filepath] != null) {
        return modules[filepath];
      }
  
      const mod = tree.modules[filepath];
      const promise = Promise.all(
        Object.entries(mod.deps).map(([key, dep]) => {
          return instantiate(dep.filepath).then(result => [key, result]);
        })
      )
        .then(importsMap => {
          const imports = importsMap.reduce((acc, [key, module]) => {
            acc[key] = module.instance.exports;
            return acc;
          }, {});
  
          return WebAssembly.instantiate(
            tree.opcodes[filepath],
            Object.assign({}, imports, importsObj)
          );
        })
        .catch(e => {
          // TODO: do some logging here
          throw e;
        });
  
      modules[filepath] = promise;
  
      return promise;
    };
  
    modules[tree.root.filepath] = instantiate(tree.root.filepath);
  
    return modules[tree.root.filepath];
  }
docs: Build the final binary Module set