<commit_before>var ChildCompiler = require('../ChildCompiler');
var SingleEntryPlugin = require('webpack/lib/SingleEntryPlugin');
var sharedDataLoader = require('./loader');

var DocsPlugin = require('../../plugin');
var Plugin = require('../../plugins/Plugin');

var stringifyLoaderConfig = require('../../utils/loader/stringifyLoaderConfig');
var format = require('util').format;

/**
 * @param {Compilation} compilation
 * @param {ChildCompilerOptions} compilerOptions
 * @param {ExampleFile} file
 * @param {string} resourcePath
 * @constructor
 */
function ExampleFileCompiler(compilation, compilerOptions, file, resourcePath) {
  if (typeof file.source != 'string')
    throw new Error('File.source not defined');

  ChildCompiler.call(this, compilation, compilerOptions);

  var compiler = this._compiler;
  var parentCompilerPlugins = compilation.compiler.options.plugins;

  // Apply parent compiler plugins to this compiler
  parentCompilerPlugins
    .filter(function (plugin) {
      return !(plugin instanceof DocsPlugin) && !(plugin instanceof Plugin)
    })
    .forEach(function (plugin) {
      compiler.apply(plugin)
    });

  // Create loaders request
  var request = ExampleFileCompiler.createEntryRequest(file, compiler.options, resourcePath);

  // ExampleFile optionally may have `context` property for proper dependencies resolving
  var entry = new SingleEntryPlugin(file.context || compiler.context, request);

  // Add entry to compiler
  compiler.apply(entry);

  // Return file.source by shared data loader
  sharedDataLoader.plugInCompiler(compiler, file.source);
}

ExampleFileCompiler.prototype = Object.create(ChildCompiler.prototype);<commit_msg>Add example file compiler output filename options handling<commit_after>var ChildCompiler = require('../ChildCompiler');
var SingleEntryPlugin = require('webpack/lib/SingleEntryPlugin');
var sharedDataLoader = require('./loader');

var DocsPlugin = require('../../plugin');
var Plugin = require('../../plugins/Plugin');

var stringifyLoaderConfig = require('../../utils/loader/stringifyLoaderConfig');
var format = require('util').format;

/**
 * @param {Compilation} compilation
 * @param {ChildCompilerOptions} compilerOptions
 * @param {ExampleFile} file
 * @param {string} resourcePath
 * @constructor
 */
function ExampleFileCompiler(compilation, compilerOptions, file, resourcePath) {
  if (typeof file.source != 'string')
    throw new Error('File.source not defined');

  ChildCompiler.call(this, compilation, compilerOptions);

  var compiler = this._compiler;
  var compilerOutputOptions = compiler.options.output;
  var parentCompilerPlugins = compilation.compiler.options.plugins;

  // Apply parent compiler plugins to this compiler
  parentCompilerPlugins
    .filter(function (plugin) {
      return !(plugin instanceof DocsPlugin) && !(plugin instanceof Plugin)
    })
    .forEach(function (plugin) {
      compiler.apply(plugin)
    });

  // Create loaders request
  var request = ExampleFileCompiler.createEntryRequest(file, compiler.options, resourcePath);

  // ExampleFile optionally may have `context` property for proper dependencies resolving
  var entry = new SingleEntryPlugin(file.context || compiler.context, request, compilerOutputOptions.filename);

  // Add entry to compiler
  compiler.apply(entry);

  // Return file.source by shared data loader
  sharedDataLoader.plugInCompiler(compiler, file.source);
}

ExampleFileCompiler.prototype = Object.create(ChildCompiler.prototype);
{'fraction_non_alphanumeric': 0.11848883800801374, 'fraction_numerical': 0.0, 'mean_word_length': 4.903716216216216, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2752623', 'n_tokens_mistral': 881, 'n_tokens_neox': 862, 'n_words': 242}