async function runCompressor(
  compressor: LoadedPlugin<Compressor>,
  info: BundleInfo,
  stream: stream$Readable,
  options: ParcelOptions,
  outputFS: FileSystem,
  inputFilePath: ProjectPath,
  writeOptions: ?FileOptions,
  devDeps: Map<string, string>,
  api: RunAPI<PackagedBundleInfo[]>,
): Promise<PackagedBundleInfo | null> {
  let measurement;
  try {
    measurement = tracer.createMeasurement(
      compressor.name,
      'compress',
      fromProjectPathRelative(inputFilePath),
    );
    let res = await compressor.plugin.compress({
      stream,
      options: new PluginOptions(options),
      logger: new PluginLogger({origin: compressor.name}),
      tracer: new PluginTracer({origin: compressor.name, category: 'compress'}),
    });

    let filePath = inputFilePath;
    if (res != null) {
      if (res.type != null) {
        let type = res.type;
        filePath = toProjectPathUnsafe(
          fromProjectPathRelative(filePath) + '.' + type,
        );
      }

      let size = 0;
      let stream = res.stream.pipe(
        new TapStream(buf => {
          size += buf.length;
        }),
      );

      let fullPath = fromProjectPath(options.projectRoot, filePath);
      await new Promise((resolve, reject) =>
        pipeline(
          stream,
          outputFS.createWriteStream(fullPath, writeOptions),
          err => {
            if (err) reject(err);
            else resolve();
          },
        ),
      );

      return {
        filePath,
        type: info.type,
        stats: {
          size,
          time: info.time ?? 0,
        },
      };
    }

    return null;
  } catch (err) {
    throw new ThrowableDiagnostic({
      diagnostic: errorToDiagnostic(err, {
        origin: compressor.name,
      }),
    });
  } finally {
    measurement && measurement.end();
    // Add dev deps for compressor plugins AFTER running them, to account for lazy require().
    let devDepRequest = await createDevDependency(
      {
        specifier: compressor.name,
        resolveFrom: compressor.resolveFrom,
      },
      devDeps,
      options,
    );
    await runDevDepRequest(api, devDepRequest);
  }
}
Writes a bundle to the dist directory, replacing hash references with the final content hashes.