docs: function saveAsAssets(
    bundle: Bundle,
    options: OutputOptions,
    log: (x: string) => void,
  ): Promise<mixed> {
    const {
      bundleOutput,
      bundleEncoding: encoding,
      sourcemapOutput,
      sourcemapSourcesRoot,
    } = options;
  
    log('start');
    const {startupModules, lazyModules} = bundle.getUnbundle();
    log('finish');
    const startupCode = joinModules(startupModules);
  
    log('Writing bundle output to:', bundleOutput);
    const modulesDir = path.join(path.dirname(bundleOutput), MODULES_DIR);
    const writeUnbundle =
      createDir(modulesDir).then( // create the modules directory first
        () => Promise.all([
          writeModules(lazyModules, modulesDir, encoding),
          writeFile(bundleOutput, startupCode, encoding),
          writeMagicFlagFile(modulesDir),
        ])
      );
    writeUnbundle.then(() => log('Done writing unbundle output'));
  
    const sourceMap =
      relativizeSourceMap(
        buildSourceMapWithMetaData({
          startupModules: startupModules.concat(),
          lazyModules: lazyModules.concat(),
        }),
        sourcemapSourcesRoot
      );
  
  
    return Promise.all([
      writeUnbundle,
      sourcemapOutput && writeSourceMap(sourcemapOutput, JSON.stringify(sourceMap), log)
    ]);
  }