@parcel/types
Advanced tools
Comparing version 2.0.0-alpha.1.1 to 2.0.0-alpha.2
333
index.js
@@ -6,7 +6,9 @@ // @flow strict-local | ||
import type {FileSystem} from '@parcel/fs'; | ||
import type WorkerFarm from '@parcel/workers'; | ||
import type {PackageManager} from '@parcel/package-manager'; | ||
import type {AST as _AST, Config as _Config} from './unsafe'; | ||
import type {AST as _AST, ConfigResult as _ConfigResult} from './unsafe'; | ||
export type AST = _AST; | ||
export type Config = _Config; | ||
export type ConfigResult = _ConfigResult; | ||
@@ -21,5 +23,3 @@ export type JSONValue = | ||
export type JSONObject = { | ||
[key: string]: JSONValue | ||
}; | ||
export type JSONObject = {[key: string]: JSONValue, ...}; | ||
@@ -33,3 +33,3 @@ export type PackageName = string; | ||
export type GlobMap<T> = {[Glob]: T}; | ||
export type GlobMap<T> = {[Glob]: T, ...}; | ||
@@ -39,31 +39,24 @@ export type ParcelConfigFile = { | ||
resolvers?: Array<PackageName>, | ||
transforms?: { | ||
[Glob]: Array<PackageName> | ||
}, | ||
transforms?: {[Glob]: Array<PackageName>, ...}, | ||
bundler?: PackageName, | ||
namers?: Array<PackageName>, | ||
runtimes?: { | ||
[EnvironmentContext]: Array<PackageName> | ||
}, | ||
packagers?: { | ||
[Glob]: PackageName | ||
}, | ||
optimizers?: { | ||
[Glob]: Array<PackageName> | ||
}, | ||
runtimes?: {[EnvironmentContext]: Array<PackageName>, ...}, | ||
packagers?: {[Glob]: PackageName, ...}, | ||
optimizers?: {[Glob]: Array<PackageName>, ...}, | ||
reporters?: Array<PackageName>, | ||
validators?: { | ||
[Glob]: Array<PackageName> | ||
} | ||
validators?: {[Glob]: Array<PackageName>, ...}, | ||
... | ||
}; | ||
export type ResolvedParcelConfigFile = ParcelConfigFile & { | ||
filePath: FilePath | ||
filePath: FilePath, | ||
... | ||
}; | ||
export type Engines = { | ||
browsers?: Array<string>, | ||
browsers?: string | Array<string>, | ||
electron?: SemverRange, | ||
node?: SemverRange, | ||
parcel?: SemverRange | ||
parcel?: SemverRange, | ||
... | ||
}; | ||
@@ -73,3 +66,5 @@ | ||
sourceRoot?: string, | ||
inlineSources?: boolean | ||
inline?: boolean, | ||
inlineSources?: boolean, | ||
... | ||
}; | ||
@@ -94,6 +89,8 @@ | ||
export type OutputFormat = 'esmodule' | 'commonjs' | 'global'; | ||
export type PackageTargetDescriptor = {| | ||
context?: EnvironmentContext, | ||
engines?: Engines, | ||
includeNodeModules?: boolean, | ||
includeNodeModules?: boolean | Array<PackageName>, | ||
outputFormat?: OutputFormat, | ||
publicUrl?: string, | ||
@@ -112,9 +109,19 @@ distDir?: FilePath, | ||
engines?: Engines, | ||
includeNodeModules?: boolean | ||
includeNodeModules?: boolean | Array<PackageName>, | ||
outputFormat?: OutputFormat, | ||
isLibrary?: boolean, | ||
... | ||
}; | ||
export type VersionMap = { | ||
[string]: string, | ||
... | ||
}; | ||
export interface Environment { | ||
+context: EnvironmentContext; | ||
+engines: Engines; | ||
+includeNodeModules: boolean; | ||
+includeNodeModules: boolean | Array<PackageName>; | ||
+outputFormat: OutputFormat; | ||
+isLibrary: boolean; | ||
@@ -125,2 +132,3 @@ isBrowser(): boolean; | ||
isIsolated(): boolean; | ||
matchesEngines(minVersions: VersionMap): boolean; | ||
} | ||
@@ -137,16 +145,13 @@ | ||
module?: FilePath, | ||
browser?: FilePath | {[FilePath]: FilePath | boolean}, | ||
source?: FilePath | {[FilePath]: FilePath}, | ||
alias?: { | ||
[PackageName | FilePath | Glob]: PackageName | FilePath | ||
}, | ||
browser?: FilePath | {[FilePath]: FilePath | boolean, ...}, | ||
source?: FilePath | {[FilePath]: FilePath, ...}, | ||
alias?: {[PackageName | FilePath | Glob]: PackageName | FilePath, ...}, | ||
browserslist?: Array<string>, | ||
engines?: Engines, | ||
targets?: { | ||
[string]: PackageTargetDescriptor | ||
}, | ||
targets?: {[string]: PackageTargetDescriptor, ...}, | ||
dependencies?: PackageDependencies, | ||
devDependencies?: PackageDependencies, | ||
peerDependencies?: PackageDependencies, | ||
sideEffects?: boolean | FilePath | Array<FilePath> | ||
sideEffects?: boolean | FilePath | Array<FilePath>, | ||
... | ||
}; | ||
@@ -162,4 +167,4 @@ | ||
defaultConfig?: ResolvedParcelConfigFile, | ||
env?: {[string]: string}, | ||
targets?: ?(Array<string> | {+[string]: TargetDescriptor}), | ||
env?: {[string]: string, ...}, | ||
targets?: ?(Array<string> | {+[string]: TargetDescriptor, ...}), | ||
@@ -178,5 +183,9 @@ disableCache?: boolean, | ||
profile?: boolean, | ||
patchConsole?: boolean, | ||
inputFS?: FileSystem, | ||
outputFS?: FileSystem | ||
outputFS?: FileSystem, | ||
workerFarm?: WorkerFarm, | ||
packageManager?: PackageManager, | ||
defaultEngines?: Engines | ||
@@ -194,3 +203,3 @@ // contentHash | ||
+sourceMaps: boolean; | ||
+env: {+[string]: string}; | ||
+env: {+[string]: string, ...}; | ||
+hot: ServerOptions | false; | ||
@@ -202,6 +211,6 @@ +serve: ServerOptions | false; | ||
+projectRoot: FilePath; | ||
+targets: Array<Target>; | ||
+cacheDir: FilePath; | ||
+inputFS: FileSystem; | ||
+outputFS: FileSystem; | ||
+packageManager: PackageManager; | ||
} | ||
@@ -223,9 +232,18 @@ | ||
filePath: string, | ||
start: {line: number, column: number}, | ||
end: {line: number, column: number} | ||
start: { | ||
line: number, | ||
column: number, | ||
... | ||
}, | ||
end: { | ||
line: number, | ||
column: number, | ||
... | ||
} | ||
|}; | ||
export type Meta = { | ||
globals?: Map<string, {code: string}>, | ||
[string]: JSONValue | ||
[string]: JSONValue, | ||
globals?: Map<string, ?{code: string, deps?: Array<string>, ...}>, | ||
... | ||
}; | ||
@@ -241,3 +259,3 @@ | ||
isURL?: boolean, | ||
isWeak?: boolean, | ||
isWeak?: ?boolean, | ||
loc?: SourceLocation, | ||
@@ -257,3 +275,3 @@ env?: EnvironmentOpts, | ||
+isURL: boolean; | ||
+isWeak: boolean; | ||
+isWeak: ?boolean; | ||
+loc: ?SourceLocation; | ||
@@ -266,2 +284,3 @@ +env: Environment; | ||
+symbols: Map<Symbol, Symbol>; | ||
+pipeline: ?string; | ||
} | ||
@@ -271,3 +290,4 @@ | ||
filePath: FilePath, | ||
hash?: string | ||
hash?: string, | ||
... | ||
}; | ||
@@ -283,5 +303,8 @@ | ||
+isIsolated: boolean; | ||
+isInline: boolean; | ||
+isSource: boolean; | ||
+type: string; | ||
+symbols: Map<Symbol, Symbol>; | ||
+sideEffects: boolean; | ||
+uniqueKey: ?string; | ||
@@ -292,8 +315,12 @@ getCode(): Promise<string>; | ||
getMap(): Promise<?SourceMap>; | ||
getConnectedFiles(): $ReadOnlyArray<File>; | ||
getIncludedFiles(): $ReadOnlyArray<File>; | ||
getDependencies(): $ReadOnlyArray<Dependency>; | ||
getConfig( | ||
filePaths: Array<FilePath>, | ||
options: ?{packageKey?: string, parse?: boolean} | ||
): Promise<Config | null>; | ||
options: ?{ | ||
packageKey?: string, | ||
parse?: boolean, | ||
... | ||
} | ||
): Promise<ConfigResult | null>; | ||
getPackage(): Promise<PackageJSON | null>; | ||
@@ -305,2 +332,3 @@ } | ||
isIsolated: boolean; | ||
isInline: boolean; | ||
type: string; | ||
@@ -313,3 +341,3 @@ | ||
setStream(Readable): void; | ||
addConnectedFile(file: File): Promise<void>; | ||
addIncludedFile(file: File): void; | ||
addDependency(opts: DependencyOptions): string; | ||
@@ -324,2 +352,39 @@ addURLDependency(url: string, opts: $Shape<DependencyOptions>): string; | ||
export interface Config { | ||
+isSource: boolean; | ||
+searchPath: FilePath; | ||
+result: ConfigResult; | ||
+env: Environment; | ||
setResolvedPath(filePath: FilePath): void; | ||
setResult(result: ConfigResult): void; // TODO: fix | ||
setResultHash(resultHash: string): void; | ||
addIncludedFile(filePath: FilePath): void; | ||
addDevDependency(name: PackageName, version?: Semver): void; | ||
setWatchGlob(glob: string): void; | ||
getConfigFrom( | ||
searchPath: FilePath, | ||
filePaths: Array<FilePath>, | ||
options: ?{ | ||
packageKey?: string, | ||
parse?: boolean, | ||
exclude?: boolean, | ||
... | ||
} | ||
): Promise<ConfigResult | null>; | ||
getConfig( | ||
filePaths: Array<FilePath>, | ||
options: ?{ | ||
packageKey?: string, | ||
parse?: boolean, | ||
exclude?: boolean, | ||
... | ||
} | ||
): Promise<ConfigResult | null>; | ||
getPackage(): Promise<PackageJSON | null>; | ||
shouldRehydrate(): void; | ||
shouldReload(): void; | ||
shouldInvalidateOnStartup(): void; | ||
} | ||
export type Stats = {| | ||
@@ -332,3 +397,3 @@ time: number, | ||
code: string, | ||
map?: SourceMap | ||
map?: ?SourceMap | ||
|}; | ||
@@ -345,4 +410,6 @@ | ||
dependencies?: $ReadOnlyArray<DependencyOptions>; | ||
connectedFiles?: $ReadOnlyArray<File>; | ||
includedFiles?: $ReadOnlyArray<File>; | ||
isIsolated?: boolean; | ||
isInline?: boolean; | ||
isSource?: boolean; | ||
env?: EnvironmentOpts; | ||
@@ -352,2 +419,3 @@ meta?: Meta; | ||
sideEffects?: boolean; | ||
uniqueKey?: ?string; | ||
} | ||
@@ -366,38 +434,66 @@ | ||
asset: Asset, | ||
resolveConfig: ResolveConfigFn, // This is a temporary function and should be replaced with something cacheable | ||
options: PluginOptions | ||
}): Async<void> | ||
config: ConfigResult | void, | ||
options: PluginOptions, | ||
... | ||
}): Async<void>, | ||
getConfig?: ({ | ||
asset: Asset, | ||
resolveConfig: ResolveConfigFn, | ||
options: PluginOptions, | ||
... | ||
}) => Async<ConfigResult | void> | ||
|}; | ||
export type Transformer = { | ||
// TODO: deprecate getConfig | ||
getConfig?: ({ | ||
asset: MutableAsset, | ||
resolve: ResolveFn, | ||
options: PluginOptions | ||
}) => Async<Config | void>, | ||
canReuseAST?: ({ast: AST, options: PluginOptions}) => boolean, | ||
options: PluginOptions, | ||
... | ||
}) => Async<ConfigResult | void>, | ||
loadConfig?: ({ | ||
config: Config, | ||
options: PluginOptions, | ||
... | ||
}) => Async<void>, | ||
rehydrateConfig?: ({ | ||
config: Config, | ||
options: PluginOptions, | ||
... | ||
}) => Async<void>, | ||
canReuseAST?: ({ | ||
ast: AST, | ||
options: PluginOptions, | ||
... | ||
}) => boolean, | ||
parse?: ({ | ||
asset: MutableAsset, | ||
config: ?Config, | ||
config: ?ConfigResult, | ||
resolve: ResolveFn, | ||
options: PluginOptions | ||
options: PluginOptions, | ||
... | ||
}) => Async<?AST>, | ||
transform({ | ||
asset: MutableAsset, | ||
config: ?Config, | ||
config: ?ConfigResult, | ||
resolve: ResolveFn, | ||
options: PluginOptions | ||
options: PluginOptions, | ||
... | ||
}): Async<Array<TransformerResult | MutableAsset>>, | ||
generate?: ({ | ||
asset: MutableAsset, | ||
config: ?Config, | ||
config: ?ConfigResult, | ||
resolve: ResolveFn, | ||
options: PluginOptions | ||
options: PluginOptions, | ||
... | ||
}) => Async<GenerateOutput>, | ||
postProcess?: ({ | ||
assets: Array<MutableAsset>, | ||
config: ?Config, | ||
config: ?ConfigResult, | ||
resolve: ResolveFn, | ||
options: PluginOptions | ||
}) => Async<Array<TransformerResult>> | ||
options: PluginOptions, | ||
... | ||
}) => Async<Array<TransformerResult>>, | ||
... | ||
}; | ||
@@ -438,2 +534,3 @@ | ||
isEntry?: ?boolean, | ||
isInline?: ?boolean, | ||
type?: ?string, | ||
@@ -449,2 +546,3 @@ env?: ?Environment | ||
isEntry?: ?boolean, | ||
isInline?: ?boolean, | ||
type: string, | ||
@@ -454,30 +552,2 @@ env: Environment | ||
export interface BundlerBundleGraph { | ||
addBundleToBundleGroup(Bundle, BundleGroup): void; | ||
addAssetToBundle(Asset, Bundle): void; | ||
createAssetReference(Dependency, Asset): void; | ||
createBundle(CreateBundleOpts): Bundle; | ||
createBundleGroup(Dependency, Target): BundleGroup; | ||
getDependencyAssets(Dependency): Array<Asset>; | ||
traverse<TContext>( | ||
GraphVisitor<BundlerBundleGraphTraversable, TContext> | ||
): ?TContext; | ||
} | ||
export interface BundlerOptimizeBundleGraph extends BundlerBundleGraph { | ||
addAssetGraphToBundle(Asset, Bundle): void; | ||
findBundlesWithAsset(Asset): Array<Bundle>; | ||
getBundleGroupsContainingBundle(Bundle): Array<BundleGroup>; | ||
getBundlesInBundleGroup(BundleGroup): Array<Bundle>; | ||
getDependenciesInBundle(Bundle, Asset): Array<Dependency>; | ||
getTotalSize(Asset): number; | ||
isAssetInAncestorBundles(Bundle, Asset): boolean; | ||
removeAssetFromBundle(Asset, Bundle): void; | ||
removeAssetGraphFromBundle(Asset, Bundle): void; | ||
traverseBundles<TContext>(GraphVisitor<Bundle, TContext>): ?TContext; | ||
traverseContents<TContext>( | ||
GraphVisitor<BundlerBundleGraphTraversable, TContext> | ||
): ?TContext; | ||
} | ||
export type SymbolResolution = {| | ||
@@ -494,2 +564,3 @@ asset: Asset, | ||
+isEntry: ?boolean; | ||
+isInline: ?boolean; | ||
+target: Target; | ||
@@ -517,5 +588,29 @@ +filePath: ?FilePath; | ||
target: Target, | ||
entryAssetId: string | ||
entryAssetId: string, | ||
... | ||
}; | ||
export interface MutableBundleGraph { | ||
addAssetGraphToBundle(Asset, Bundle): void; | ||
addBundleToBundleGroup(Bundle, BundleGroup): void; | ||
createAssetReference(Dependency, Asset): void; | ||
createBundle(CreateBundleOpts): Bundle; | ||
createBundleGroup(Dependency, Target): BundleGroup; | ||
findBundlesWithAsset(Asset): Array<Bundle>; | ||
getDependencyAssets(Dependency): Array<Asset>; | ||
getDependencyResolution(Dependency): ?Asset; | ||
getBundleGroupsContainingBundle(Bundle): Array<BundleGroup>; | ||
getBundlesInBundleGroup(BundleGroup): Array<Bundle>; | ||
getTotalSize(Asset): number; | ||
isAssetInAncestorBundles(Bundle, Asset): boolean; | ||
removeAssetGraphFromBundle(Asset, Bundle): void; | ||
traverse<TContext>( | ||
GraphVisitor<BundlerBundleGraphTraversable, TContext> | ||
): ?TContext; | ||
traverseBundles<TContext>(GraphVisitor<Bundle, TContext>): ?TContext; | ||
traverseContents<TContext>( | ||
GraphVisitor<BundlerBundleGraphTraversable, TContext> | ||
): ?TContext; | ||
} | ||
export interface BundleGraph { | ||
@@ -526,3 +621,7 @@ getBundles(): Array<Bundle>; | ||
bundle: Bundle | ||
): Array<{bundleGroup: BundleGroup, dependency: Dependency}>; | ||
): Array<{ | ||
bundleGroup: BundleGroup, | ||
dependency: Dependency, | ||
... | ||
}>; | ||
getBundlesInBundleGroup(bundleGroup: BundleGroup): Array<Bundle>; | ||
@@ -537,5 +636,7 @@ getDependencies(asset: Asset): Array<Dependency>; | ||
resolveSymbol(asset: Asset, symbol: Symbol): SymbolResolution; | ||
getExportedSymbols(asset: Asset): Array<SymbolResolution>; | ||
traverseBundles<TContext>( | ||
visit: GraphTraversalCallback<Bundle, TContext> | ||
): ?TContext; | ||
findBundlesWithAsset(Asset): Array<Bundle>; | ||
} | ||
@@ -550,3 +651,4 @@ | ||
export type ResolveResult = {| | ||
filePath: FilePath, | ||
filePath?: FilePath, | ||
isExcluded?: boolean, | ||
sideEffects?: boolean, | ||
@@ -558,8 +660,10 @@ code?: string | ||
bundle({ | ||
bundleGraph: BundlerBundleGraph, | ||
options: PluginOptions | ||
bundleGraph: MutableBundleGraph, | ||
options: PluginOptions, | ||
... | ||
}): Async<void>, | ||
optimize({ | ||
bundleGraph: BundlerOptimizeBundleGraph, | ||
options: PluginOptions | ||
bundleGraph: MutableBundleGraph, | ||
options: PluginOptions, | ||
... | ||
}): Async<void> | ||
@@ -572,3 +676,4 @@ |}; | ||
bundleGraph: BundleGraph, | ||
options: PluginOptions | ||
options: PluginOptions, | ||
... | ||
}): Async<?FilePath> | ||
@@ -588,3 +693,4 @@ |}; | ||
bundleGraph: BundleGraph, | ||
options: PluginOptions | ||
options: PluginOptions, | ||
... | ||
}): Async<void | RuntimeAsset | Array<RuntimeAsset>> | ||
@@ -598,3 +704,8 @@ |}; | ||
options: PluginOptions, | ||
sourceMapPath: FilePath | ||
getSourceMapReference: (map: SourceMap) => Promise<string> | string, | ||
getInlineBundleContents: ( | ||
Bundle, | ||
BundleGraph | ||
) => Async<{|contents: Blob, map: ?(Readable | string)|}>, | ||
... | ||
}): Async<BundleResult> | ||
@@ -608,3 +719,4 @@ |}; | ||
map: ?SourceMap, | ||
options: PluginOptions | ||
options: PluginOptions, | ||
... | ||
}): Async<BundleResult> | ||
@@ -616,3 +728,4 @@ |}; | ||
dependency: Dependency, | ||
options: PluginOptions | ||
options: PluginOptions, | ||
... | ||
}): Async<?ResolveResult> | ||
@@ -619,0 +732,0 @@ |}; |
{ | ||
"name": "@parcel/types", | ||
"version": "2.0.0-alpha.1.1", | ||
"version": "2.0.0-alpha.2", | ||
"license": "MIT", | ||
@@ -13,3 +13,3 @@ "main": "src/index.js", | ||
}, | ||
"gitHead": "8f9c49c1c53753b1139501cc4090cd4b1ab5ac0b" | ||
"gitHead": "aa2619af0a50fecbab024d30521391814560337f" | ||
} |
// @flow | ||
export type Config = any; | ||
export type ConfigResult = any; | ||
@@ -5,0 +5,0 @@ export type AST = {| |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
19879
720