<commit_before>// @flow
const os = require(`os`)

const autoprefixer = require(`autoprefixer`)
const flexbugs = require(`postcss-flexbugs-fixes`)
const UglifyPlugin = require(`uglifyjs-webpack-plugin`)
const MiniCssExtractPlugin = require(`mini-css-extract-plugin`)

const builtinPlugins = require(`./webpack-plugins`)
const { createBabelConfig } = require(`./babel-config`)
const eslintConfig = require(`./eslint-config`)

type LoaderSpec = string | { loader: string, options?: Object }
type LoaderResolver<T: Object> = (options?: T) => LoaderSpec

type Condition = string | RegExp | RegExp[]

type Rule = {
  test?: Condition,
  use: LoaderSpec[],
  exclude?: Condition,
  include?: Condition,
}

type RuleFactory<T: Object> = (options?: T) => Rule

type ContextualRuleFactory = RuleFactory<*> & {
  internal: RuleFactory<*>,
  external: RuleFactory<*>,
}

type PluginInstance = any
type PluginFactory = (...args?: any) => PluginInstance

type BuiltinPlugins = typeof builtinPlugins

type Stage = "develop" | "develop-html" | "build-javascript" | "build-html"

/**
 * Configuration options for `createUtils`
 */
export type WebpackUtilsOptions = { stage: Stage, program: any }

/**
 * Utils that produce webpack `loader` objects
 */
export type LoaderUtils = {
  json: LoaderResolver<*>,
  yaml: LoaderResolver<*>,
  null: LoaderResolver<*>,
  raw: LoaderResolver<*>,

  style: LoaderResolver<*>,
  css: LoaderResolver<*>,
  postcss: LoaderResolver<{
    browsers?: string[],
    plugins?: Array<any> | ((loader: any) => Array<any>),
  }>,

  file: LoaderResolver<*>,
  url: LoaderResolver<*>,
  js: LoaderResolver<*>,

  imports: LoaderResolver<*>,
  exports: LoaderResolver<*>,

  eslint: LaoderResolver<*>,
}

/**
 * Utils that prodcue webpack rule objects
 */
export type RuleUtils = {
  /**
   * Handles Javascript compilation via babel
   */
  js: RuleFactory<*>,
  yaml: RuleFactory<*>,
  fonts: RuleFactory<*>,
  images: RuleFactory<*>,
  audioVideo: RuleFactory<*>,

  css: ContextualRuleFactory,
  cssModules: RuleFactory<*>,
  postcss: ContextualRuleFactory,

  eslint: RuleFactory<*>,<commit_msg>Fix typo in type annotations (#6288)<commit_after>// @flow
const os = require(`os`)

const autoprefixer = require(`autoprefixer`)
const flexbugs = require(`postcss-flexbugs-fixes`)
const UglifyPlugin = require(`uglifyjs-webpack-plugin`)
const MiniCssExtractPlugin = require(`mini-css-extract-plugin`)

const builtinPlugins = require(`./webpack-plugins`)
const { createBabelConfig } = require(`./babel-config`)
const eslintConfig = require(`./eslint-config`)

type LoaderSpec = string | { loader: string, options?: Object }
type LoaderResolver<T: Object> = (options?: T) => LoaderSpec

type Condition = string | RegExp | RegExp[]

type Rule = {
  test?: Condition,
  use: LoaderSpec[],
  exclude?: Condition,
  include?: Condition,
}

type RuleFactory<T: Object> = (options?: T) => Rule

type ContextualRuleFactory = RuleFactory<*> & {
  internal: RuleFactory<*>,
  external: RuleFactory<*>,
}

type PluginInstance = any
type PluginFactory = (...args?: any) => PluginInstance

type BuiltinPlugins = typeof builtinPlugins

type Stage = "develop" | "develop-html" | "build-javascript" | "build-html"

/**
 * Configuration options for `createUtils`
 */
export type WebpackUtilsOptions = { stage: Stage, program: any }

/**
 * Utils that produce webpack `loader` objects
 */
export type LoaderUtils = {
  json: LoaderResolver<*>,
  yaml: LoaderResolver<*>,
  null: LoaderResolver<*>,
  raw: LoaderResolver<*>,

  style: LoaderResolver<*>,
  css: LoaderResolver<*>,
  postcss: LoaderResolver<{
    browsers?: string[],
    plugins?: Array<any> | ((loader: any) => Array<any>),
  }>,

  file: LoaderResolver<*>,
  url: LoaderResolver<*>,
  js: LoaderResolver<*>,

  imports: LoaderResolver<*>,
  exports: LoaderResolver<*>,

  eslint: LoaderResolver<*>,
}

/**
 * Utils that prodcue webpack rule objects
 */
export type RuleUtils = {
  /**
   * Handles Javascript compilation via babel
   */
  js: RuleFactory<*>,
  yaml: RuleFactory<*>,
  fonts: RuleFactory<*>,
  images: RuleFactory<*>,
  audioVideo: RuleFactory<*>,

  css: ContextualRuleFactory,
  cssModules: RuleFactory<*>,
  postcss: ContextualRuleFactory,

  eslint: RuleFactory<*>,
{'fraction_non_alphanumeric': 0.15201508366721658, 'fraction_numerical': 0.0009427292010370022, 'mean_word_length': 4.861878453038674, 'pattern_counts': {'":': 0, '<': 57, '<?xml version=': 0, '>': 65, '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': '5617590', 'n_tokens_mistral': 1396, 'n_tokens_neox': 1370, 'n_words': 344}