API

The remaining types specified in `@parcel/types`

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

ConfigResultWithFilePath parcel/packages/core/types/index.js:17

Plugin-specific config result, any

type ConfigResultWithFilePathĀ = {|
  contents: ConfigResult,
  filePath: FilePath,
|}
Referenced by:
Config

EnvMap parcel/packages/core/types/index.js:22

process.env

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

QueryParameters parcel/packages/core/types/index.js:24

type QueryParametersĀ = {
}
Referenced by:
BaseAsset

JSONValue parcel/packages/core/types/index.js:26

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

JSONObject parcel/packages/core/types/index.js:36

A JSON object (as in "map")

type JSONObjectĀ = {
}
Referenced by:
JSONValue, Meta, ResolveResult

Glob parcel/packages/core/types/index.js:40

Type
type Glob = string;
Referenced by:
PackageJSON, RawParcelConfig

Semver parcel/packages/core/types/index.js:41

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

SemverRange parcel/packages/core/types/index.js:42

Type
type SemverRange = string;
Referenced by:
Engines

GlobMap parcel/packages/core/types/index.js:47

A pipeline as specified in the config mapping to T

type GlobMap<T>Ā = {
}

RawParcelConfigPipeline parcel/packages/core/types/index.js:49

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

HMROptions parcel/packages/core/types/index.js:51

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

RawParcelConfig parcel/packages/core/types/index.js:54

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 parcel/packages/core/types/index.js:68

A .parcelrc where all package names are resolved

type ResolvedParcelConfigFileĀ = {|
  ...RawParcelConfig,
  +filePath: FilePath,
  +resolveFrom?: FilePath,
|}

Engines parcel/packages/core/types/index.js:75

Corresponds to pkg#engines

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

TargetSourceMapOptions parcel/packages/core/types/index.js:84

Corresponds to pkg#targets.*.sourceMap

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

Target parcel/packages/core/types/index.js:93

A parsed version of PackageTargetDescriptor

interface TargetĀ {
  +distEntry: ?FilePath,
The output filename of the entry
  +distDir: FilePath,
The output folder
  +env: Environment,
  +name: string,
  +publicUrl: string,
  +loc: ?SourceLocation,
The location that created this Target, e.g. `package.json#main`
}
Referenced by:
Bundle, BundleGroup, CreateBundleOpts, Dependency, DependencyOptions, MutableBundleGraph, PackageTargetDescriptor

EnvironmentContext parcel/packages/core/types/index.js:106

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

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

OutputFormat parcel/packages/core/types/index.js:115

The JS module format for the bundle output

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

PackageTargetDescriptor parcel/packages/core/types/index.js:122

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:
PackageJSON, Target, TargetDescriptor

TargetDescriptor parcel/packages/core/types/index.js:143

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

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

EnvironmentOpts parcel/packages/core/types/index.js:152

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,
  +sourceMap?: ?TargetSourceMapOptions,
|}
Referenced by:
DependencyOptions, MutableAsset, TransformerResult

VersionMap parcel/packages/core/types/index.js:178

A resolved browserslist, e.g.:


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

type VersionMapĀ = {
}
Referenced by:
Environment

Environment parcel/packages/core/types/index.js:186

Defines the environment in for the output bundle

interface EnvironmentĀ {
  +context: EnvironmentContext,
  +engines: Engines,
  +includeNodeModules: boolean | Array<PackageName> | {
    [PackageName]: boolean,
    ...
  },
Whether to include all/none packages (true / false), an array of package names to include, or an object (of a package is not specified, it's included).
  +outputFormat: OutputFormat,
  +isLibrary: boolean,
Whether this is a library build (e.g. less loaders)
  +minify: boolean,
Whether the output should be minified.
  +scopeHoist: boolean,
Whether scope hoisting is enabled.
  +sourceMap: ?TargetSourceMapOptions,
  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:
BaseAsset, Bundle, Config, CreateBundleOpts, Dependency, EnvironmentOpts, PackageTargetDescriptor, Target

PackageDependencies parcel/packages/core/types/index.js:222

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

type PackageDependenciesĀ = {|
|}
Referenced by:
PackageJSON

PackageJSON parcel/packages/core/types/index.js:229

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>,
  bin?: string | {|
    [string]: FilePath
  |},
}
Referenced by:
BaseAsset, Config

LogLevel parcel/packages/core/types/index.js:249

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

BuildMode parcel/packages/core/types/index.js:250

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

InitialParcelOptions parcel/packages/core/types/index.js:252

type InitialParcelOptionsĀ = {|
  +entries?: FilePath | Array<FilePath>,
  +entryRoot?: FilePath,
  +config?: ModuleSpecifier,
  +defaultConfig?: ModuleSpecifier,
  +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,
  +contentHash?: boolean,
  +serve?: InitialServerOptions | false,
  +autoinstall?: boolean,
  +logLevel?: LogLevel,
  +profile?: boolean,
  +patchConsole?: boolean,
  +inputFS?: FileSystem,
  +outputFS?: FileSystem,
  +workerFarm?: WorkerFarm,
  +packageManager?: PackageManager,
  +defaultEngines?: Engines,
  +detailedReport?: number | boolean,
|}

InitialServerOptions parcel/packages/core/types/index.js:289

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

PluginOptions parcel/packages/core/types/index.js:296

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

ServerOptions parcel/packages/core/types/index.js:313

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

HTTPSOptions parcel/packages/core/types/index.js:321

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

SourceLocation parcel/packages/core/types/index.js:329

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

type SourceLocationĀ = {|
  +filePath: string,
  +start: {|
    +line: number,
    +column: number,
  |},
inclusive
  +end: {|
    +line: number,
    +column: number,
  |},
exclusive
|}
Referenced by:
AssetSymbols, Dependency, DependencyOptions, MutableAssetSymbols, MutableDependencySymbols, SymbolResolution, Target, TransformerResult

Meta parcel/packages/core/types/index.js:346

An object that plugins can write arbitatry data to.

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

AssetSymbols parcel/packages/core/types/index.js:356

A map from extert names to the corespinding asset's lcoal variable name.

interface AssetSymbols extends Iterable<[Symbol, {|
  local: Symbol,
  loc: ?SourceLocation,
|}]>Ā {
  +isCleared: boolean,
The exports of the asset are unknown, rather than just empty. This is the default state.
  get(exportSymbol: Symbol): ?{|
    local: Symbol,
    loc: ?SourceLocation,
  |},
  hasExportSymbol(exportSymbol: Symbol): boolean,
  hasLocalSymbol(local: Symbol): boolean,
  exportSymbols(): Iterable<Symbol>,
}
Referenced by:
BaseAsset, MutableAssetSymbols

MutableAssetSymbols parcel/packages/core/types/index.js:368

interface MutableAssetSymbols extends AssetSymbolsĀ {
  ensure(): void,
Initilizes the map, sets isCleared to false.
  set(exportSymbol: Symbol, local: Symbol, loc: ?SourceLocation): void,
  delete(exportSymbol: Symbol): void,
}
Referenced by:
MutableAsset

MutableDependencySymbols parcel/packages/core/types/index.js:379

isWeak means: the symbol is not used by the parent asset itself and is merely reexported

interface MutableDependencySymbols extends Iterable<[Symbol, {|
  local: Symbol,
  loc: ?SourceLocation,
  isWeak: boolean,
|}]>Ā {
  ensure(): void,
Initilizes the map, sets isCleared to false.
  +isCleared: boolean,
The symbols taht are imports are unknown, rather than just empty. This is the default state.
  get(exportSymbol: Symbol): ?{|
    local: Symbol,
    loc: ?SourceLocation,
    isWeak: boolean,
  |},
  hasExportSymbol(exportSymbol: Symbol): boolean,
  hasLocalSymbol(local: Symbol): boolean,
  exportSymbols(): Iterable<Symbol>,
  set(exportSymbol: Symbol, local: Symbol, loc: ?SourceLocation, isWeak: ?boolean): void,
  delete(exportSymbol: Symbol): void,
}
Referenced by:
Dependency

File parcel/packages/core/types/index.js:466

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

Stats parcel/packages/core/types/index.js:619

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

Blob parcel/packages/core/types/index.js:632

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

ConfigOutput parcel/packages/core/types/index.js:1083

type ConfigOutputĀ = {|
  config: ConfigResult,
  files: Array<File>,
|}
Referenced by:
Bundler, Packager

ErrorWithCode parcel/packages/core/types/index.js:1374

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

IDisposable parcel/packages/core/types/index.js:1378

interface IDisposableĀ {
  dispose(): mixed,
}

AsyncSubscription parcel/packages/core/types/index.js:1382

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