code: function saveAsIndexedFile(
    bundle: RamBundleInfo,
    options: OutputOptions,
    log: (...args: Array<string>) => void,
  ): Promise<mixed> {
    const {
      bundleOutput,
      bundleEncoding: encoding,
      sourcemapOutput,
      sourcemapSourcesRoot,
    } = options;
  
    log('start');
    const {startupModules, lazyModules, groups} = bundle;
    log('finish');
  
    const moduleGroups = createModuleGroups(groups, lazyModules);
    const startupCode = joinModules(startupModules);
  
    log('Writing unbundle output to:', bundleOutput);
    const writeUnbundle = writeBuffers(
      fs.createWriteStream(bundleOutput),
      buildTableAndContents(startupCode, lazyModules, moduleGroups, encoding),
    ).then(() => log('Done writing unbundle output'));
  
    if (sourcemapOutput) {
      const sourceMap = buildSourcemapWithMetadata({
        startupModules: startupModules.concat(),
        lazyModules: lazyModules.concat(),
        moduleGroups,
        fixWrapperOffset: true,
      });
      if (sourcemapSourcesRoot !== undefined) {
        relativizeSourceMapInline(sourceMap, sourcemapSourcesRoot);
      }
  
      const wroteSourceMap = writeSourceMap(
        sourcemapOutput,
        JSON.stringify(sourceMap),
        log,
      );
  
      return Promise.all([writeUnbundle, wroteSourceMap]);
    } else {
      return writeUnbundle;
    }
  }
docs: Saves all JS modules of an app as a single file, separated with null bytes.
  The file begins with an offset table that contains module ids and their
  lengths/offsets.
  The module id for the startup code (prelude, polyfills etc.) is the
  empty string.