API

`@parcel/types`で指定されている残りの型

最も重要なデータ型は、関連するプラグインタイプのページに記載されています。

AST parcel/packages/core/types/index.js:18

プラグイン固有の ASTany

type AST = _AST;
参照元
BaseAssetBundleResultMutableAssetTransformerTransformerResult

ConfigResult parcel/packages/core/types/index.js:19

type ConfigResult = _ConfigResult;
参照元
MultiThreadValidator

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

プラグイン固有の設定結果、any

type ConfigResultWithFilePath<T> = {|
  contents: T,
  filePath: FilePath,
|}
参照元
設定

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

process.env

type EnvMap = typeof process.env;
参照元
InitialParcelOptionsPluginOptions

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

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

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

JSONオブジェクト(マップとして)

type JSONObject = {
}
参照元
JSONValueMetaResolveResult

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

設定でTにマッピングされているように指定されたパイプライン

type GlobMap<T> = {
}

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

type RawParcelConfigPipeline = Array<PackageName>;
参照元
RawParcelConfig

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

type HMROptions = {
  port?: number,
  host?: string,
}
参照元
InitialParcelOptionsPluginOptions

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

.parcelrcの形式

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

ResolvedParcelConfigFile parcel/packages/core/types/index.js:71

すべてのpackage名が解決された.parcelrc

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

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

pkg#enginesに対応

type Engines = {
  +browsers?: string | Array<string>,
  +electron?: SemverRange,
  +node?: SemverRange,
  +parcel?: SemverRange,
}
参照元
EnvironmentEnvironmentOptionsInitialParcelOptionsPackageJSONPackageTargetDescriptor

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

pkg#targets.*.sourceMapに対応

type TargetSourceMapOptions = {|
  +sourceRoot?: string,
  +inline?: boolean,
  +inlineSources?: boolean,
|}
参照元
EnvironmentEnvironmentOptionsPackageTargetDescriptor

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

PackageTargetDescriptorの解析済みバージョン

interface Target {
  +distEntry: ?FilePath,

エントリの出力ファイル名

  +distDir: FilePath,

出力フォルダ

  +env: Environment,
  +name: string,
  +publicUrl: string,
  +loc: ?SourceLocation,

このTargetを作成した場所、例:package.json#main

}
参照元
BundleBundleGraphBundleGroupCreateBundleOptsDependencyMutableBundleGraphPackageTargetDescriptor

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

出力が実行される環境(バンドルローダーなどに影響を与える)

type EnvironmentContext = 'browser' | 'web-worker' | 'service-worker' | 'worklet' | 'node' | 'electron-main' | 'electron-renderer';
参照元
EnvironmentEnvironmentOptionsPackageTargetDescriptor

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

バンドル出力のJSモジュール形式

type OutputFormat = 'esmodule' | 'commonjs' | 'global';
参照元
EnvironmentEnvironmentOptionsInitialParcelOptionsPackageTargetDescriptor

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

pkg#targets.*の形式
EnvironmentTargetを参照。

type PackageTargetDescriptor = {|
  +context?: EnvironmentContext,
  +engines?: Engines,
  +includeNodeModules?: boolean | Array<PackageName> | {
    [PackageName]: boolean,
    ...
  },
  +outputFormat?: OutputFormat,
  +publicUrl?: string,
  +distDir?: FilePath,
  +sourceMap?: boolean | TargetSourceMapOptions,
  +isLibrary?: boolean,
  +optimize?: boolean,
  +scopeHoist?: boolean,
  +source?: FilePath | Array<FilePath>,
|}
参照元
PackageJSONTargetTargetDescriptor

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

JS APIを使用する場合のターゲット形式。
(PackageTargetDescriptorと同じだが、distDirが必要。)

type TargetDescriptor = {|
  ...PackageTargetDescriptor,
  +distDir: FilePath,
  +distEntry?: FilePath,
|}
参照元
InitialParcelOptions

SourceType parcel/packages/core/types/index.js:154

type SourceType = 'script' | 'module';
参照元
EnvironmentEnvironmentOptions

EnvironmentOptions parcel/packages/core/types/index.js:159

Environmentの作成時に使用されます(そちらを参照)。

type EnvironmentOptions = {|
  +context?: EnvironmentContext,
  +engines?: Engines,
  +includeNodeModules?: boolean | Array<PackageName> | {
    [PackageName]: boolean,
    ...
  },
  +outputFormat?: OutputFormat,
  +sourceType?: SourceType,
  +isLibrary?: boolean,
  +shouldOptimize?: boolean,
  +shouldScopeHoist?: boolean,
  +sourceMap?: ?TargetSourceMapOptions,
  +loc?: ?SourceLocation,
|}
参照元
DependencyOptionsMutableAssetRuntimeAssetTransformerResult

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

解決済みのbrowserslist、例:


{
  edge: '76',
  firefox: '67',
  chrome: '63',
  safari: '11.1',
  opera: '50',
}
type VersionMap = {
}
参照元
環境

EnvironmentFeature parcel/packages/core/types/index.js:192

type EnvironmentFeature = 'esmodules' | 'dynamic-import' | 'worker-module' | 'service-worker-module' | 'import-meta-url' | 'arrow-functions';
参照元
環境

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

出力バンドルの環境を定義します

interface Environment {
  +id: string,
  +context: EnvironmentContext,
  +engines: Engines,
  +includeNodeModules: boolean | Array<PackageName> | {
    [PackageName]: boolean,
    ...
  },

すべての/いずれのpackageを含めるか(`true/false`)、含めるpackage名の配列、またはオブジェクト(packageが指定されていない場合、含まれる)。

  +outputFormat: OutputFormat,
  +sourceType: SourceType,
  +isLibrary: boolean,

これがライブラリビルドかどうか(例:少ないローダー)

  +shouldOptimize: boolean,

出力を縮小するかどうか。

  +shouldScopeHoist: boolean,

スコープホーイスティングが有効かどうか。

  +sourceMap: ?TargetSourceMapOptions,
  +loc: ?SourceLocation,
  isBrowser(): boolean,

contextがブラウザコンテキストを指定しているかどうか。

  isNode(): boolean,

contextがノードコンテキストを指定しているかどうか。

  isElectron(): boolean,

contextがエレクトロンコンテキストを指定しているかどうか。

  isWorker(): boolean,

contextがワーカーコンテキストを指定しているかどうか。

  isWorklet(): boolean,

contextがワークレットコンテキストを指定しているかどうか。

  isIsolated(): boolean,

contextが独立したコンテキストを指定しているかどうか(ロードされた祖先バンドルにアクセスできない)。

  matchesEngines(minVersions: VersionMap, defaultValue?: boolean): boolean,
  supports(feature: EnvironmentFeature, defaultValue?: boolean): boolean,
}
参照元
BaseAssetBundleConfigCreateBundleOptsDependencyEnvironmentOptionsPackageTargetDescriptorTargetTransformerResult

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

pkg#dependenciespkg#devDependenciespkg#peerDependenciesのフォーマット

type PackageDependencies = {|
|}
参照元
PackageJSON

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

package.jsonのフォーマット

type PackageJSON = {
  name: PackageName,
  version: Semver,
  type?: 'module',
  main?: FilePath,
  module?: FilePath,
  types?: FilePath,
  browser?: FilePath | {
    [FilePath]: FilePath | boolean,
    ...
  },
  source?: FilePath | Array<FilePath>,
  alias?: {
    [PackageName | FilePath | Glob]: PackageName | FilePath | {|
      global: string
    |},
    ...
  },
  browserslist?: Array<string> | {
    [string]: Array<string>
  },
  engines?: Engines,
  targets?: {
    [string]: PackageTargetDescriptor,
    ...
  },
  dependencies?: PackageDependencies,
  devDependencies?: PackageDependencies,
  peerDependencies?: PackageDependencies,
  sideEffects?: boolean | FilePath | Array<FilePath>,
  bin?: string | {|
    [string]: FilePath
  |},
}
参照元
設定

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

type LogLevel = 'none' | 'error' | 'warn' | 'info' | 'verbose';
参照元
InitialParcelOptionsPluginOptions

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

type BuildMode = 'development' | 'production' | string;
参照元
InitialParcelOptionsPluginOptions

DetailedReportOptions parcel/packages/core/types/index.js:281

type DetailedReportOptions = {|
  assetsPerBundle?: number,
|}
参照元
InitialParcelOptionsPluginOptions

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

type InitialParcelOptions = {|
  +entries?: FilePath | Array<FilePath>,
  +config?: DependencySpecifier,
  +defaultConfig?: DependencySpecifier,
  +env?: EnvMap,
  +targets?: ?(Array<string> | {
    +[string]: TargetDescriptor,
    ...
  }),
  +shouldDisableCache?: boolean,
  +cacheDir?: FilePath,
  +mode?: BuildMode,
  +hmrOptions?: ?HMROptions,
  +shouldContentHash?: boolean,
  +serveOptions?: InitialServerOptions | false,
  +shouldAutoInstall?: boolean,
  +logLevel?: LogLevel,
  +shouldProfile?: boolean,
  +shouldPatchConsole?: boolean,
  +shouldBuildLazily?: boolean,
  +shouldBundleIncrementally?: boolean,
  +inputFS?: FileSystem,
  +outputFS?: FileSystem,
  +cache?: Cache,
  +workerFarm?: WorkerFarm,
  +packageManager?: PackageManager,
  +detailedReport?: ?DetailedReportOptions,
  +defaultTargetOptions?: {|
    +shouldOptimize?: boolean,
    +shouldScopeHoist?: boolean,
    +sourceMaps?: boolean,
    +publicUrl?: string,
    +distDir?: FilePath,
    +engines?: Engines,
    +outputFormat?: OutputFormat,
    +isLibrary?: boolean,
  |},
  +additionalReporters?: Array<{|
    packageName: DependencySpecifier,
    resolveFrom: FilePath,
  |}>,
|}

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

type InitialServerOptions = {|
  +publicUrl?: string,
  +host?: string,
  +port: number,
  +https?: HTTPSOptions | boolean,
|}
参照元
InitialParcelOptions

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

interface PluginOptions {
  +mode: BuildMode,
  +env: EnvMap,
  +hmrOptions: ?HMROptions,
  +serveOptions: ServerOptions | false,
  +shouldBuildLazily: boolean,
  +shouldAutoInstall: boolean,
  +logLevel: LogLevel,
  +projectRoot: FilePath,
  +cacheDir: FilePath,
  +inputFS: FileSystem,
  +outputFS: FileSystem,
  +packageManager: PackageManager,
  +instanceId: string,
  +detailedReport: ?DetailedReportOptions,
}
参照元
BundlerCompressorDedicatedThreadValidatorMultiThreadValidatorNamerOptimizerPackagerReporterResolverRuntimeTransformer

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

type ServerOptions = {|
  +distDir: FilePath,
  +host?: string,
  +port: number,
  +https?: HTTPSOptions | boolean,
  +publicUrl?: string,
|}
参照元
PluginOptions

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

type HTTPSOptions = {|
  +cert: FilePath,
  +key: FilePath,
|}
参照元
InitialServerOptionsServerOptions

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

ソースロケーションは1ベースです。つまり、行番号と列番号は1から始まります。

type SourceLocation = {|
  +filePath: string,
  +start: {|
    +line: number,
    +column: number,
  |},

包含的

  +end: {|
    +line: number,
    +column: number,
  |},

排他的

|}
参照元
AssetSymbolsDependencyDependencyOptionsEnvironmentEnvironmentOptionsMutableAssetSymbolsMutableDependencySymbolsSymbolResolutionTargetTransformerResult

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

プラグインが任意のデータを書き込むことができるオブジェクト。

type Meta = JSONObject;
参照元
AssetSymbolsBaseAssetDependencyDependencyOptionsMutableAssetSymbolsMutableDependencySymbolsTransformerResult

Symbol parcel/packages/core/types/index.js:394

アセット内の識別子(おそらくインポート/エクスポート)。

type Symbol = string;
参照元
AssetSymbolsBundleGraphDependencyOptionsExportSymbolResolutionMutableAssetSymbolsMutableDependencySymbolsSymbolResolutionTransformerResult

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

エクスポート名と対応するアセットのローカル変数名のマップ。

interface AssetSymbols extends Iterable<[Symbol, {|
  local: Symbol,
  loc: ?SourceLocation,
  meta?: ?Meta,
|}]> {
  +isCleared: boolean,

アセットのエクスポートは空ではなく、不明です。これはデフォルトの状態です。

  get(exportSymbol: Symbol): ?{|
    local: Symbol,
    loc: ?SourceLocation,
    meta?: ?Meta,
  |},
  hasExportSymbol(exportSymbol: Symbol): boolean,
  hasLocalSymbol(local: Symbol): boolean,
  exportSymbols(): Iterable<Symbol>,
}
参照元
BaseAssetMutableAssetSymbols

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

interface MutableAssetSymbols extends AssetSymbols {
  ensure(): void,

マップを初期化し、isClearedをfalseに設定します。

  set(exportSymbol: Symbol, local: Symbol, loc: ?SourceLocation, meta?: ?Meta): void,
  delete(exportSymbol: Symbol): void,
}
参照元
MutableAsset

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

isWeakの意味:シンボルは親アセット自体では使用されず、単に再エクスポートされます。

interface MutableDependencySymbols extends Iterable<[Symbol, {|
  local: Symbol,
  loc: ?SourceLocation,
  isWeak: boolean,
  meta?: ?Meta,
|}]> {
  ensure(): void,

マップを初期化し、isClearedをfalseに設定します。

  +isCleared: boolean,

インポートであるシンボルは空ではなく、不明です。これはデフォルトの状態です。

  get(exportSymbol: Symbol): ?{|
    local: Symbol,
    loc: ?SourceLocation,
    isWeak: boolean,
    meta?: ?Meta,
  |},
  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,
}
参照元
Dependency

DependencyPriority parcel/packages/core/types/index.js:469

type DependencyPriority = 'sync' | 'parallel' | 'lazy';
参照元
DependencyDependencyOptionsResolveResult

SpecifierType parcel/packages/core/types/index.js:470

type SpecifierType = 'commonjs' | 'esm' | 'url' | 'custom';
参照元
DependencyDependencyOptionsResolveOptions

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

type File = {|
  +filePath: FilePath,
  +hash?: string,
|}

DevDepOptions parcel/packages/core/types/index.js:790

type DevDepOptions = {|
  specifier: DependencySpecifier,
  resolveFrom: FilePath,
  range?: ?SemverRange,
  additionalInvalidations?: Array<{|
    specifier: DependencySpecifier,
    resolveFrom: FilePath,
    range?: ?SemverRange,
  |}>,

このdev依存関係が無効になった場合、これらの依存関係も無効にします。これは、Parcelプラグインまたは他の親依存関係が、Nodeのrequireキャッシュ以外のこのdev依存関係に対する独自のキャッシュを持つ場合に便利です。

|}
参照元
設定

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

type Stats = {|
  time: number,
  size: number,
|}
参照元
AssetPackagedBundle

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

type Blob = string | Buffer | Readable;
参照元
BundleResultGenerateOutputOptimizerPackagerTransformerResult

PackagedBundle parcel/packages/core/types/index.js:1330

interface PackagedBundle extends NamedBundle {
  +filePath: FilePath,

書き込まれたバンドルの絶対ファイルパス。最終的なコンテンツハッシュが含まれる場合もある。

  +stats: Stats,

バンドルに関する統計情報。

}
参照元
BuildSuccessEvent

GlobInvalidation parcel/packages/core/types/index.js:1518

type GlobInvalidation = {|
  glob: Glob,
|}
参照元
FileCreateInvalidation

FileInvalidation parcel/packages/core/types/index.js:1522

type FileInvalidation = {|
  filePath: FilePath,
|}
参照元
FileCreateInvalidation

FileAboveInvalidation parcel/packages/core/types/index.js:1526

type FileAboveInvalidation = {|
  fileName: string,
  aboveFilePath: FilePath,
|}
参照元
FileCreateInvalidation

RuntimeAssetPriority parcel/packages/core/types/index.js:1613

type RuntimeAssetPriority = 'sync' | 'parallel';
参照元
RuntimeAsset

BundledProgressEvent parcel/packages/core/types/index.js:1826

type BundledProgressEvent = {|
  +type: 'buildProgress',
  +phase: 'bundled',
  +bundleGraph: BundleGraph<NamedBundle>,
  +changedAssets: Map<string, Asset>,
|}
参照元
BuildProgressEvent

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

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

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

interface IDisposable {
  dispose(): mixed,
}

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

type AsyncSubscription = {|
  unsubscribe(): Promise<mixed>,
|}