docs: function saveAsIndexedFile(
    bundle: Bundle,
    options: OutputOptions,
    log: (x: string) => void,
  ): Promise<> {
    const {
      bundleOutput,
      bundleEncoding: encoding,
      sourcemapOutput,
      sourcemapSourcesRoot,
    } = options;
  
    log('start');
    const {startupModules, lazyModules, groups} = bundle.getUnbundle();
    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'));
  
    const sourceMap =
      relativizeSourceMap(
        buildSourceMapWithMetaData({
          startupModules: startupModules.concat(),
          lazyModules: lazyModules.concat(),
          moduleGroups,
        }),
        sourcemapSourcesRoot
      );
  
    return Promise.all([
      writeUnbundle,
      sourcemapOutput && writeSourceMap(sourcemapOutput, JSON.stringify(sourceMap), log),
    ]);
  }