constructor(compiler) {
    this.compiler = compiler;

    pluginCompat.register(compiler, 'hardSourceCacheFactory', 'syncWaterfall', [
      'factory',
    ]);

    pluginCompat.tap(
      compiler,
      'hardSourceCacheFactory',
      'default factory',
      factory => info => {
        // It's best to have plugins to hard-source listed in the config after it
        // but to make hard-source easier to use we can call the factory of a
        // plugin passed into this default factory.
        if (factory) {
          serializer = factory(info);
          if (serializer) {
            return serializer;
          }
        }

        // Otherwise lets return the default serializers.
        switch (info.type) {
          case 'data':
            return CacheSerializerFactory.dataSerializer.createSerializer(info);
            break;
          case 'file':
            return CacheSerializerFactory.fileSerializer.createSerializer(info);
            break;
          default:
            throw new Error(
              `Unknown hard-source cache serializer type: ${info.type}`,
            );
            break;
        }
      },
    );
  }
@constructor CacheSerializerFactory
@memberof module:hard-source-webpack-plugin/cache-serializer-factory