Repository: parcel-bundler/parcel
File: packages/core/types/index.js (JavaScript)

Code before:

export interface PluginLogger {
  /** Logs a diagnostic at the verbose log level. */
  verbose(
    diagnostic: DiagnosticWithoutOrigin | Array<DiagnosticWithoutOrigin>,
  ): void;

  /** Logs a diagnostic at the info log level. */
  info(
    diagnostic: DiagnosticWithoutOrigin | Array<DiagnosticWithoutOrigin>,
  ): void;

  /** Synonym for logger.info. */
  log(
    diagnostic: DiagnosticWithoutOrigin | Array<DiagnosticWithoutOrigin>,
  ): void;

  /** Logs a diagnostic at the verbose warning log level. */
  warn(
    diagnostic: DiagnosticWithoutOrigin | Array<DiagnosticWithoutOrigin>,
  ): void;

  /** Logs a diagnostic at the verbose error log level. */
  error(
    input:
      | Diagnostifiable
      | DiagnosticWithoutOrigin
      | Array<DiagnosticWithoutOrigin>,
  ): void;
}

/**
 * @section transformer
 */
export type ResolveFn = (from: FilePath, to: string) => Promise<FilePath>;

/**
 * @section validator
 * @experimental
 */
type ResolveConfigFn = (configNames: Array<FilePath>) => Promise<?FilePath>;

/**
 * @section validator
 * @experimental
 */
type ResolveConfigWithPathFn = (
  configNames: Array<FilePath>,
  assetFilePath: string,
) => Promise<?FilePath>;


Review comment (suggestion):
Moved this type here to avoid another circular dependency. Plus, better to expose an interface to plugins rather than an implementation.

Code after:
   * If the asset is used as a bundle entry, this controls whether that bundle can be split
   * into multiple, or whether all of the dependencies must be placed in a single bundle.
   */
  +isBundleSplittable?: boolean,
  /** Plugin-specific metadata for the asset. */
  +meta?: Meta,
  /** The pipeline defined in .parcelrc that the asset should be processed with. */
  +pipeline?: ?string,
  /**
   * Whether this asset can be omitted if none of its exports are being used.
   * This is initially set by the resolver, but can be overridden by transformers.
   */
  +sideEffects?: boolean,
  /** The symbols that the asset exports. */
  +symbols?: $ReadOnlyMap<Symbol, {|local: Symbol, loc: ?SourceLocation|}>,
  /**
   * When a transformer returns multiple assets, it can give them unique keys to identify them.
   * This can be used to find assets during packaging, or to create dependencies between multiple
   * assets returned by a transformer by using the unique key as the dependency specifier.
   */
  +uniqueKey?: ?string,
|};

export type Async<T> = T | Promise<T>;

export interface PluginLogger {
  /** Logs a diagnostic at the verbose log level. */
  verbose(
    diagnostic: DiagnosticWithoutOrigin | Array<DiagnosticWithoutOrigin>,
  ): void;

  /** Logs a diagnostic at the info log level. */
  info(
    diagnostic: DiagnosticWithoutOrigin | Array<DiagnosticWithoutOrigin>,
  ): void;

  /** Synonym for logger.info. */
  log(
    diagnostic: DiagnosticWithoutOrigin | Array<DiagnosticWithoutOrigin>,
  ): void;

  /** Logs a diagnostic at the verbose warning log level. */
  warn(
    diagnostic: DiagnosticWithoutOrigin | Array<DiagnosticWithoutOrigin>,
  ): void;

  /** Logs a diagnostic at the verbose error log level. */
  error(
    input:
      | Diagnostifiable
      | DiagnosticWithoutOrigin