API

The remaining types specified in `@parcel/types`

The most important data types are listed on the page of the relevant plugin type.

ConfigResult website/generate-api-docs/example.flow:16

Plugin-specific config result, any

Type
type ConfigResult = _ConfigResult;
Referenced by:
BaseAsset, Config, MultiThreadValidator, Transformer

EnvMap website/generate-api-docs/example.flow:18

process.env

Type
type EnvMap = typeof process.env;
Referenced by:
InitialParcelOptions, PluginOptions

JSONValue website/generate-api-docs/example.flow:21

A JSON value

Type
type JSONValue = null | void | boolean | number | string | Array<JSONValue> | JSONObject;

JSONObject website/generate-api-docs/example.flow:31

A JSON object (as in "map")

type JSONObject = {
}
Referenced by:
JSONValue, Meta

Semver website/generate-api-docs/example.flow:36

Type
type Semver = string;
Referenced by:
PackageJSON, Config

SemverRange website/generate-api-docs/example.flow:37

Type
type SemverRange = string;
Referenced by:
Engines

ModuleSpecifier website/generate-api-docs/example.flow:39

See Dependency

Type
type ModuleSpecifier = string;
Referenced by:
DependencyOptions, Dependency

GlobMap website/generate-api-docs/example.flow:41

type GlobMap<T> = {
}

RawParcelConfigPipeline website/generate-api-docs/example.flow:44

A pipeline as specified in the config -> T

Type
type RawParcelConfigPipeline = Array<PackageName>;
Referenced by:
RawParcelConfig

HMROptions website/generate-api-docs/example.flow:46

type HMROptions = {
  port?: number,
  host?: string,
}
Referenced by:
InitialParcelOptions, PluginOptions

RawParcelConfig website/generate-api-docs/example.flow:49

The format of .parcelrc

type RawParcelConfig = {|
  extends?: PackageName | FilePath | Array<PackageName | FilePath>,
  resolvers?: RawParcelConfigPipeline,
  transformers?: {
    [Glob]: RawParcelConfigPipeline,
    ...
  },
  bundler?: PackageName,
  namers?: RawParcelConfigPipeline,
  runtimes?: {
    [EnvironmentContext]: RawParcelConfigPipeline,
    ...
  },
  packagers?: {
    [Glob]: PackageName,
    ...
  },
  optimizers?: {
    [Glob]: RawParcelConfigPipeline,
    ...
  },
  reporters?: RawParcelConfigPipeline,
  validators?: {
    [Glob]: RawParcelConfigPipeline,
    ...
  },
|}
Referenced by:
ResolvedParcelConfigFile

ResolvedParcelConfigFile website/generate-api-docs/example.flow:63

A .parcelrc where all package names are resolved

type ResolvedParcelConfigFile = {|
  ...RawParcelConfig,
  +filePath: FilePath,
  +resolveFrom?: FilePath,
|}
Referenced by:
InitialParcelOptions

Engines website/generate-api-docs/example.flow:70

Corresponds to pkg#engines

type Engines = {
  +browsers?: string | Array<string>,
  +electron?: SemverRange,
  +node?: SemverRange,
  +parcel?: SemverRange,
}
Referenced by:
PackageTargetDescriptor, EnvironmentOpts, Environment, PackageJSON, InitialParcelOptions

TargetSourceMapOptions website/generate-api-docs/example.flow:79

Corresponds to pkg#targets.*.sourceMap

type TargetSourceMapOptions = {|
  +sourceRoot?: string,
  +inline?: boolean,
  +inlineSources?: boolean,
|}
Referenced by:
Target, PackageTargetDescriptor

Target website/generate-api-docs/example.flow:91

A parsed version of PackageTargetDescriptor

interface Target {
  +distEntry: ?FilePath,
  +distDir: FilePath,
  +env: Environment,
  +sourceMap: ?TargetSourceMapOptions,
  +name: string,
  +publicUrl: string,
  +loc: ?SourceLocation,
}
Referenced by:
PackageTargetDescriptor, DependencyOptions, Dependency, CreateBundleOpts, Bundle, BundleGroup, MutableBundleGraph

EnvironmentContext website/generate-api-docs/example.flow:102

In which environment the output should run (influces e.g. loaders)

Type
type EnvironmentContext = "browser" | "web-worker" | "service-worker" | "node" | "electron-main" | "electron-renderer";
Referenced by:
RawParcelConfig, PackageTargetDescriptor, EnvironmentOpts, Environment, BundleGraph

OutputFormat website/generate-api-docs/example.flow:111

The JS module format for the bundle output

Type
type OutputFormat = "esmodule" | "commonjs" | "global";
Referenced by:
PackageTargetDescriptor, EnvironmentOpts, Environment

PackageTargetDescriptor website/generate-api-docs/example.flow:118

The format of pkg#targets.*
See Environment and Target.

type PackageTargetDescriptor = {|
  +context?: EnvironmentContext,
  +engines?: Engines,
  +includeNodeModules?: boolean | Array<PackageName> | {
    [PackageName]: boolean,
    ...
  },
  +outputFormat?: OutputFormat,
  +publicUrl?: string,
  +distDir?: FilePath,
  +sourceMap?: boolean | TargetSourceMapOptions,
  +isLibrary?: boolean,
  +minify?: boolean,
  +scopeHoist?: boolean,
|}
Referenced by:
Target, TargetDescriptor, PackageJSON

TargetDescriptor website/generate-api-docs/example.flow:139

The target format when using the JS API.
(Same as PackageTargetDescriptor, but distDir is required.)

type TargetDescriptor = {|
  ...PackageTargetDescriptor,
  +distDir: FilePath,
|}
Referenced by:
InitialParcelOptions

EnvironmentOpts website/generate-api-docs/example.flow:147

This is used when creating an Environment (see that).

type EnvironmentOpts = {|
  +context?: EnvironmentContext,
  +engines?: Engines,
  +includeNodeModules?: boolean | Array<PackageName> | {
    [PackageName]: boolean,
    ...
  },
  +outputFormat?: OutputFormat,
  +isLibrary?: boolean,
  +minify?: boolean,
  +scopeHoist?: boolean,
|}
Referenced by:
DependencyOptions, MutableAsset, TransformerResult

VersionMap website/generate-api-docs/example.flow:172

Example:


{
  edge: '76',
  firefox: '67',
  chrome: '63',
  safari: '11.1',
  opera: '50',
}

type VersionMap = {
}
Referenced by:
Environment

Environment website/generate-api-docs/example.flow:180

Defines the environment in for the output bundle

interface Environment {
  +context: EnvironmentContext,
  +engines: Engines,
  +includeNodeModules: boolean | Array<PackageName> | {
    [PackageName]: boolean,
    ...
  },
  +outputFormat: OutputFormat,
  +isLibrary: boolean,
  +minify: boolean,
  +scopeHoist: boolean,
  isBrowser(): boolean,
Whether context specifies a browser context.
  isNode(): boolean,
Whether context specifies a node context.
  isElectron(): boolean,
Whether context specifies an electron context.
  isWorker(): boolean,
Whether context specifies a worker context.
  isIsolated(): boolean,
Whether context specifies an isolated context (can't access other loaded ancestor bundles).
  matchesEngines(minVersions: VersionMap): boolean,
}
Referenced by:
Target, PackageTargetDescriptor, EnvironmentOpts, Dependency, BaseAsset, Config, CreateBundleOpts, Bundle

PackageDependencies website/generate-api-docs/example.flow:215

Format of pkg#dependencies, pkg#devDependencies, pkg#peerDependencies

type PackageDependencies = {|
|}
Referenced by:
PackageJSON

PackageJSON website/generate-api-docs/example.flow:222

Format of package.json

type PackageJSON = {
  name: PackageName,
  version: Semver,
  main?: FilePath,
  module?: FilePath,
  types?: FilePath,
  browser?: FilePath | {
    [FilePath]: FilePath | boolean,
    ...
  },
  source?: FilePath | {
    [FilePath]: FilePath,
    ...
  },
  alias?: {
    [PackageName | FilePath | Glob]: PackageName | FilePath,
    ...
  },
  browserslist?: Array<string>,
  engines?: Engines,
  targets?: {
    [string]: PackageTargetDescriptor,
    ...
  },
  dependencies?: PackageDependencies,
  devDependencies?: PackageDependencies,
  peerDependencies?: PackageDependencies,
  sideEffects?: boolean | FilePath | Array<FilePath>,
}
Referenced by:
BaseAsset, Config

LogLevel website/generate-api-docs/example.flow:241

Type
type LogLevel = "none" | "error" | "warn" | "info" | "verbose";
Referenced by:
InitialParcelOptions, PluginOptions

BuildMode website/generate-api-docs/example.flow:242

Type
type BuildMode = "development" | "production" | string;
Referenced by:
InitialParcelOptions, PluginOptions

InitialParcelOptions website/generate-api-docs/example.flow:244

type InitialParcelOptions = {|
  +entries?: FilePath | Array<FilePath>,
  +rootDir?: FilePath,
  +config?: ResolvedParcelConfigFile,
  +defaultConfig?: ResolvedParcelConfigFile,
  +env?: EnvMap,
  +targets?: ?(Array<string> | {
    +[string]: TargetDescriptor,
    ...
  }),
  +disableCache?: boolean,
  +cacheDir?: FilePath,
  +killWorkers?: boolean,
  +mode?: BuildMode,
  +minify?: boolean,
  +scopeHoist?: boolean,
  +sourceMaps?: boolean,
  +publicUrl?: string,
  +distDir?: FilePath,
  +hot?: ?HMROptions,
  +serve?: ServerOptions | false,
  +autoinstall?: boolean,
  +logLevel?: LogLevel,
  +profile?: boolean,
  +patchConsole?: boolean,
  +inputFS?: FileSystem,
  +outputFS?: FileSystem,
  +workerFarm?: WorkerFarm,
  +packageManager?: PackageManager,
  +defaultEngines?: Engines,
  +detailedReport?: number | boolean,
|}

PluginOptions website/generate-api-docs/example.flow:280

interface PluginOptions {
  +mode: BuildMode,
  +sourceMaps: boolean,
  +env: EnvMap,
  +hot: ?HMROptions,
  +serve: ServerOptions | false,
  +autoinstall: boolean,
  +logLevel: LogLevel,
  +rootDir: FilePath,
  +distDir: FilePath,
  +projectRoot: FilePath,
  +cacheDir: FilePath,
  +inputFS: FileSystem,
  +outputFS: FileSystem,
  +packageManager: PackageManager,
  +instanceId: string,
  +detailedReport: number,
}
Referenced by:
DedicatedThreadValidator, MultiThreadValidator, Transformer, Bundler, Namer, Runtime, Packager, Optimizer, Resolver, Reporter

ServerOptions website/generate-api-docs/example.flow:299

type ServerOptions = {|
  +host?: string,
  +port: number,
  +https?: HTTPSOptions | boolean,
  +publicUrl?: string,
|}
Referenced by:
InitialParcelOptions, PluginOptions

HTTPSOptions website/generate-api-docs/example.flow:306

type HTTPSOptions = {|
  +cert: FilePath,
  +key: FilePath,
|}
Referenced by:
ServerOptions

SourceLocation website/generate-api-docs/example.flow:316

Source locations are 1-based, meaning lines and columns start at 1

type SourceLocation = {|
  +filePath: string,
  +start: {|
    +line: number,
    +column: number,
  |},
  +end: {|
    +line: number,
    +column: number,
  |},
|}
Referenced by:
Target, CodeSymbols, MutableCodeSymbols, DependencyOptions, Dependency, TransformerResult, SymbolResolution

Meta website/generate-api-docs/example.flow:331

An object that plugins can write arbitatry data to.

Type
type Meta = JSONObject;
Referenced by:
DependencyOptions, Dependency, BaseAsset, TransformerResult

CodeSymbol website/generate-api-docs/example.flow:336

An identifier in an asset (likely imported/exported).

Type
type CodeSymbol = string;
Referenced by:
CodeSymbols, MutableCodeSymbols, DependencyOptions, TransformerResult, SymbolResolution, ExportSymbolResolution, BundleGraph

CodeSymbols website/generate-api-docs/example.flow:337

interface CodeSymbols extends Iterable<[CodeSymbol, {|
  local: CodeSymbol,
  loc: ?SourceLocation,
|}]> {
  get(exportSymbol: CodeSymbol): ?{|
    local: CodeSymbol,
    loc: ?SourceLocation,
  |},
  hasExportSymbol(exportSymbol: CodeSymbol): boolean,
  hasLocalSymbol(local: CodeSymbol): boolean,
  +isCleared: boolean,
}
Referenced by:
BaseAsset

MutableCodeSymbols website/generate-api-docs/example.flow:347

interface MutableCodeSymbols extends CodeSymbols {
  clear(): void,
  set(exportSymbol: CodeSymbol, local: CodeSymbol, loc: ?SourceLocation): void,
}
Referenced by:
Dependency, MutableAsset

File website/generate-api-docs/example.flow:417

type File = {|
  +filePath: FilePath,
  +hash?: string,
|}
Referenced by:
BaseAsset, MutableAsset, TransformerResult

Stats website/generate-api-docs/example.flow:570

type Stats = {|
  time: number,
  size: number,
|}
Referenced by:
Asset, Bundle

Blob website/generate-api-docs/example.flow:583

Type
type Blob = string | Buffer | Readable;
Referenced by:
GenerateOutput, TransformerResult, BundleResult, Packager, Optimizer

ErrorWithCode website/generate-api-docs/example.flow:1295

interface ErrorWithCode extends Error {
  +code?: string,
}

IDisposable website/generate-api-docs/example.flow:1299

interface IDisposable {
  dispose(): mixed,
}

AsyncSubscription website/generate-api-docs/example.flow:1303

interface AsyncSubscription {
  unsubscribe(): Promise<mixed>,
}