Improve schema generation and add more descriptions

This commit is contained in:
Tobias Koppers 2020-02-17 12:14:51 +01:00
parent 6477ca56f8
commit 683e867450
14 changed files with 353 additions and 241 deletions

View File

@ -6,9 +6,6 @@
/**
* Set the value of `require.amd` and `define.amd`. Or disable AMD support.
*
* This interface was referenced by `WebpackOptions`'s JSON-Schema
* via the `definition` "Amd".
*/
export type Amd =
| false
@ -17,89 +14,54 @@ export type Amd =
};
/**
* Report the first error as a hard error instead of tolerating it.
*
* This interface was referenced by `WebpackOptions`'s JSON-Schema
* via the `definition` "Bail".
*/
export type Bail = boolean;
/**
* Cache generated modules and chunks to improve performance for multiple incremental builds.
*
* This interface was referenced by `WebpackOptions`'s JSON-Schema
* via the `definition` "Cache".
*/
export type Cache = CacheNormalized | true;
/**
* Cache generated modules and chunks to improve performance for multiple incremental builds.
*
* This interface was referenced by `WebpackOptions`'s JSON-Schema
* via the `definition` "CacheNormalized".
*/
export type CacheNormalized = false | MemoryCacheOptions | FileCacheOptions;
/**
* The base directory (absolute path!) for resolving the `entry` option. If `output.pathinfo` is set, the included pathinfo is shortened to this directory.
*
* This interface was referenced by `WebpackOptions`'s JSON-Schema
* via the `definition` "Context".
*/
export type Context = string;
/**
* References to other configurations to depend on.
*
* This interface was referenced by `WebpackOptions`'s JSON-Schema
* via the `definition` "Dependencies".
*/
export type Dependencies = string[];
/**
* A developer tool to enhance debugging (false | eval | [inline-|hidden-|eval-][nosources-][cheap-[module-]]source-map).
*
* This interface was referenced by `WebpackOptions`'s JSON-Schema
* via the `definition` "DevTool".
*/
export type DevTool = (false | "eval") | string;
/**
* The entry point(s) of the compilation.
*
* This interface was referenced by `WebpackOptions`'s JSON-Schema
* via the `definition` "Entry".
*/
export type Entry = EntryDynamic | EntryStatic;
/**
* A Function returning an entry object, an entry string, an entry array or a promise to these things.
*
* This interface was referenced by `WebpackOptions`'s JSON-Schema
* via the `definition` "EntryDynamic".
*/
export type EntryDynamic = () => EntryStatic | Promise<EntryStatic>;
/**
* This interface was referenced by `WebpackOptions`'s JSON-Schema
* via the `definition` "EntryStatic".
* A static entry description
*/
export type EntryStatic = EntryObject | EntryUnnamed;
/**
* This interface was referenced by `WebpackOptions`'s JSON-Schema
* via the `definition` "EntryItem".
* Module(s) that are loaded upon startup
*/
export type EntryItem = string | NonEmptyArrayOfUniqueStringValues;
/**
* A non-empty array of non-empty strings
*
* This interface was referenced by `WebpackOptions`'s JSON-Schema
* via the `definition` "NonEmptyArrayOfUniqueStringValues".
*/
export type NonEmptyArrayOfUniqueStringValues = [string, ...string[]];
/**
* An entry point without name.
*
* This interface was referenced by `WebpackOptions`'s JSON-Schema
* via the `definition` "EntryUnnamed".
*/
export type EntryUnnamed = EntryItem;
/**
* Specify dependencies that shouldn't be resolved by webpack, but should become dependencies of the resulting bundle. The kind of the dependency depends on `output.libraryTarget`.
*
* This interface was referenced by `WebpackOptions`'s JSON-Schema
* via the `definition` "Externals".
*/
export type Externals =
| ((
@ -117,8 +79,7 @@ export type Externals =
| ExternalItem
)[];
/**
* This interface was referenced by `WebpackOptions`'s JSON-Schema
* via the `definition` "ExternalItem".
* Specify dependency that shouldn't be resolved by webpack, but should become dependencies of the resulting bundle. The kind of the dependency depends on `output.libraryTarget`.
*/
export type ExternalItem =
| string
@ -136,37 +97,27 @@ export type ExternalItem =
}
| RegExp;
/**
* This interface was referenced by `WebpackOptions`'s JSON-Schema
* via the `definition` "ArrayOfStringValues".
* Array of strings
*/
export type ArrayOfStringValues = string[];
/**
* This interface was referenced by `WebpackOptions`'s JSON-Schema
* via the `definition` "FilterTypes".
* Filtering values
*/
export type FilterTypes = FilterItemTypes | FilterItemTypes[];
/**
* This interface was referenced by `WebpackOptions`'s JSON-Schema
* via the `definition` "FilterItemTypes".
* Filtering value, regexp or function
*/
export type FilterItemTypes = RegExp | string | ((value: string) => boolean);
/**
* Enable production optimizations or development hints.
*
* This interface was referenced by `WebpackOptions`'s JSON-Schema
* via the `definition` "Mode".
*/
export type Mode = "development" | "production" | "none";
/**
* One or multiple rule conditions
*
* This interface was referenced by `WebpackOptions`'s JSON-Schema
* via the `definition` "RuleSetConditionOrConditions".
*/
export type RuleSetConditionOrConditions = RuleSetCondition | RuleSetConditions;
/**
* This interface was referenced by `WebpackOptions`'s JSON-Schema
* via the `definition` "RuleSetCondition".
* A condition matcher
*/
export type RuleSetCondition =
| RegExp
@ -200,22 +151,17 @@ export type RuleSetCondition =
test?: RuleSetConditionOrConditions;
};
/**
* This interface was referenced by `WebpackOptions`'s JSON-Schema
* via the `definition` "RuleSetConditions".
* A list of rule conditions
*/
export type RuleSetConditions = RuleSetCondition[];
/**
* One or multiple rule conditions
*
* This interface was referenced by `WebpackOptions`'s JSON-Schema
* via the `definition` "RuleSetConditionOrConditionsAbsolute".
* One or multiple rule conditions matching an absolute path
*/
export type RuleSetConditionOrConditionsAbsolute =
| RuleSetConditionAbsolute
| RuleSetConditionsAbsolute;
/**
* This interface was referenced by `WebpackOptions`'s JSON-Schema
* via the `definition` "RuleSetConditionAbsolute".
* A condition matcher matching an absolute path
*/
export type RuleSetConditionAbsolute =
| RegExp
@ -249,26 +195,22 @@ export type RuleSetConditionAbsolute =
test?: RuleSetConditionOrConditionsAbsolute;
};
/**
* This interface was referenced by `WebpackOptions`'s JSON-Schema
* via the `definition` "RuleSetConditionsAbsolute".
* A list of rule conditions matching an absolute path
*/
export type RuleSetConditionsAbsolute = RuleSetConditionAbsolute[];
/**
* This interface was referenced by `WebpackOptions`'s JSON-Schema
* via the `definition` "RuleSetLoader".
* A loader request
*/
export type RuleSetLoader = string;
/**
* This interface was referenced by `WebpackOptions`'s JSON-Schema
* via the `definition` "RuleSetUse".
* A list of descriptions of loaders applied
*/
export type RuleSetUse =
| RuleSetUseItem
| ((data: object) => RuleSetUseItem[])
| RuleSetUseItem[];
/**
* This interface was referenced by `WebpackOptions`'s JSON-Schema
* via the `definition` "RuleSetUseItem".
* A description of an applied loader
*/
export type RuleSetUseItem =
| RuleSetLoader
@ -288,8 +230,7 @@ export type RuleSetUseItem =
options?: RuleSetLoaderOptions;
};
/**
* This interface was referenced by `WebpackOptions`'s JSON-Schema
* via the `definition` "RuleSetLoaderOptions".
* Options passed to a loader
*/
export type RuleSetLoaderOptions =
| {
@ -297,34 +238,23 @@ export type RuleSetLoaderOptions =
}
| string;
/**
* This interface was referenced by `WebpackOptions`'s JSON-Schema
* via the `definition` "ArrayOfStringOrStringArrayValues".
* List of string or string-array values
*/
export type ArrayOfStringOrStringArrayValues = (string | string[])[];
/**
* This interface was referenced by `WebpackOptions`'s JSON-Schema
* via the `definition` "RuleSetRules".
* A list of rules
*/
export type RuleSetRules = RuleSetRule[];
/**
* Name of the configuration. Used when loading multiple configurations.
*
* This interface was referenced by `WebpackOptions`'s JSON-Schema
* via the `definition` "Name".
*/
export type Name = string;
/**
* Include polyfills or mocks for various node stuff.
*
* This interface was referenced by `WebpackOptions`'s JSON-Schema
* via the `definition` "Node".
*/
export type Node = false | NodeOptions;
/**
* Function acting as plugin
*
* This interface was referenced by `WebpackOptions`'s JSON-Schema
* via the `definition` "WebpackPluginFunction".
*/
export type WebpackPluginFunction = (
this: import("../lib/Compiler"),
@ -332,9 +262,6 @@ export type WebpackPluginFunction = (
) => void;
/**
* Create an additional chunk which contains only the webpack runtime and chunk hash maps
*
* This interface was referenced by `WebpackOptions`'s JSON-Schema
* via the `definition` "OptimizationRuntimeChunk".
*/
export type OptimizationRuntimeChunk =
| boolean
@ -346,8 +273,7 @@ export type OptimizationRuntimeChunk =
name?: string | Function;
};
/**
* This interface was referenced by `WebpackOptions`'s JSON-Schema
* via the `definition` "OptimizationSplitChunksGetCacheGroups".
* A function returning cache groups
*/
export type OptimizationSplitChunksGetCacheGroups = (
module: import("../lib/Module")
@ -356,8 +282,7 @@ export type OptimizationSplitChunksGetCacheGroups = (
| OptimizationSplitChunksCacheGroup[]
| void;
/**
* This interface was referenced by `WebpackOptions`'s JSON-Schema
* via the `definition` "OptimizationSplitChunksSizes".
* Size description for limits
*/
export type OptimizationSplitChunksSizes =
| number
@ -369,72 +294,42 @@ export type OptimizationSplitChunksSizes =
};
/**
* The number of parallel processed modules in the compilation.
*
* This interface was referenced by `WebpackOptions`'s JSON-Schema
* via the `definition` "Parallelism".
*/
export type Parallelism = number;
/**
* Configuration for web performance recommendations.
*
* This interface was referenced by `WebpackOptions`'s JSON-Schema
* via the `definition` "Performance".
* Configuration for web performance recommendations
*/
export type Performance = false | PerformanceOptions;
/**
* Add additional plugins to the compiler.
*
* This interface was referenced by `WebpackOptions`'s JSON-Schema
* via the `definition` "Plugins".
*/
export type Plugins = (WebpackPluginInstance | WebpackPluginFunction)[];
/**
* Capture timing information for each module.
*
* This interface was referenced by `WebpackOptions`'s JSON-Schema
* via the `definition` "Profile".
*/
export type Profile = boolean;
/**
* Store compiler state to a json file.
*
* This interface was referenced by `WebpackOptions`'s JSON-Schema
* via the `definition` "RecordsInputPath".
*/
export type RecordsInputPath = false | string;
/**
* Load compiler state from a json file.
*
* This interface was referenced by `WebpackOptions`'s JSON-Schema
* via the `definition` "RecordsOutputPath".
*/
export type RecordsOutputPath = false | string;
/**
* Store/Load compiler state from/to a json file. This will result in persistent ids of modules and chunks. An absolute path is expected. `recordsPath` is used for `recordsInputPath` and `recordsOutputPath` if they left undefined.
*
* This interface was referenced by `WebpackOptions`'s JSON-Schema
* via the `definition` "RecordsPath".
*/
export type RecordsPath = false | string;
/**
* Options for the resolver
*
* This interface was referenced by `WebpackOptions`'s JSON-Schema
* via the `definition` "Resolve".
*/
export type Resolve = ResolveOptions;
/**
* Options for the resolver when resolving loaders
*
* This interface was referenced by `WebpackOptions`'s JSON-Schema
* via the `definition` "ResolveLoader".
*/
export type ResolveLoader = ResolveOptions;
/**
* Used by the webpack CLI program to pass stats options.
*
* This interface was referenced by `WebpackOptions`'s JSON-Schema
* via the `definition` "Stats".
* Stats options object or preset name
*/
export type Stats =
| StatsOptions
@ -450,9 +345,6 @@ export type Stats =
);
/**
* Environment to build for
*
* This interface was referenced by `WebpackOptions`'s JSON-Schema
* via the `definition` "Target".
*/
export type Target =
| (
@ -468,30 +360,18 @@ export type Target =
| ((compiler: import("../lib/Compiler")) => void);
/**
* Enter watch mode, which rebuilds on file change.
*
* This interface was referenced by `WebpackOptions`'s JSON-Schema
* via the `definition` "Watch".
*/
export type Watch = boolean;
/**
* A Function returning a Promise resolving to a normalized entry.
*
* This interface was referenced by `WebpackOptions`'s JSON-Schema
* via the `definition` "EntryDynamicNormalized".
*/
export type EntryDynamicNormalized = () => Promise<EntryStaticNormalized>;
/**
* The entry point(s) of the compilation.
*
* This interface was referenced by `WebpackOptions`'s JSON-Schema
* via the `definition` "EntryNormalized".
*/
export type EntryNormalized = EntryDynamicNormalized | EntryStaticNormalized;
/**
* Create an additional chunk which contains only the webpack runtime and chunk hash maps
*
* This interface was referenced by `WebpackOptions`'s JSON-Schema
* via the `definition` "OptimizationRuntimeChunkNormalized".
*/
export type OptimizationRuntimeChunkNormalized =
| false
@ -502,43 +382,141 @@ export type OptimizationRuntimeChunkNormalized =
name?: Function;
};
/**
* webpack options object as provided by the user
*/
export interface WebpackOptions {
/**
* Set the value of `require.amd` and `define.amd`. Or disable AMD support.
*/
amd?: Amd;
/**
* Report the first error as a hard error instead of tolerating it.
*/
bail?: Bail;
/**
* Cache generated modules and chunks to improve performance for multiple incremental builds.
*/
cache?: Cache;
/**
* The base directory (absolute path!) for resolving the `entry` option. If `output.pathinfo` is set, the included pathinfo is shortened to this directory.
*/
context?: Context;
/**
* References to other configurations to depend on.
*/
dependencies?: Dependencies;
/**
* Options for the webpack-dev-server
*/
devServer?: DevServer;
/**
* A developer tool to enhance debugging (false | eval | [inline-|hidden-|eval-][nosources-][cheap-[module-]]source-map).
*/
devtool?: DevTool;
/**
* The entry point(s) of the compilation.
*/
entry?: Entry;
/**
* Enables/Disables experiments (experiemental features with relax SemVer compatibility)
*/
experiments?: Experiments;
/**
* Specify dependencies that shouldn't be resolved by webpack, but should become dependencies of the resulting bundle. The kind of the dependency depends on `output.libraryTarget`.
*/
externals?: Externals;
/**
* Options for infrastructure level logging
*/
infrastructureLogging?: InfrastructureLogging;
/**
* Custom values available in the loader context.
*/
loader?: Loader;
/**
* Enable production optimizations or development hints.
*/
mode?: Mode;
/**
* Options affecting the normal modules (`NormalModuleFactory`).
*/
module?: Module;
/**
* Name of the configuration. Used when loading multiple configurations.
*/
name?: Name;
/**
* Include polyfills or mocks for various node stuff.
*/
node?: Node;
/**
* Enables/Disables integrated optimizations
*/
optimization?: Optimization;
/**
* Options affecting the output of the compilation. `output` options tell webpack how to write the compiled files to disk.
*/
output?: Output;
/**
* The number of parallel processed modules in the compilation.
*/
parallelism?: Parallelism;
/**
* Configuration for web performance recommendations
*/
performance?: Performance;
/**
* Add additional plugins to the compiler.
*/
plugins?: Plugins;
/**
* Capture timing information for each module.
*/
profile?: Profile;
/**
* Store compiler state to a json file.
*/
recordsInputPath?: RecordsInputPath;
/**
* Load compiler state from a json file.
*/
recordsOutputPath?: RecordsOutputPath;
/**
* Store/Load compiler state from/to a json file. This will result in persistent ids of modules and chunks. An absolute path is expected. `recordsPath` is used for `recordsInputPath` and `recordsOutputPath` if they left undefined.
*/
recordsPath?: RecordsPath;
/**
* Options for the resolver
*/
resolve?: Resolve;
/**
* Options for the resolver when resolving loaders
*/
resolveLoader?: ResolveLoader;
/**
* Options for webpack-serve
*/
serve?: Serve;
/**
* Stats options object or preset name
*/
stats?: Stats;
/**
* Environment to build for
*/
target?: Target;
/**
* Enter watch mode, which rebuilds on file change.
*/
watch?: Watch;
/**
* Options for the watcher
*/
watchOptions?: WatchOptions;
}
/**
* This interface was referenced by `WebpackOptions`'s JSON-Schema
* via the `definition` "MemoryCacheOptions".
* Options object for in-memory caching
*/
export interface MemoryCacheOptions {
/**
@ -555,8 +533,7 @@ export interface MemoryCacheOptions {
type: "memory";
}
/**
* This interface was referenced by `WebpackOptions`'s JSON-Schema
* via the `definition` "FileCacheOptions".
* Options object for persistent file-based caching
*/
export interface FileCacheOptions {
/**
@ -615,18 +592,12 @@ export interface FileCacheOptions {
}
/**
* Options for the webpack-dev-server
*
* This interface was referenced by `WebpackOptions`'s JSON-Schema
* via the `definition` "DevServer".
*/
export interface DevServer {
[k: string]: any;
}
/**
* Multiple entry bundles are created. The key is the entry name. The value can be a string, an array or an entry description object.
*
* This interface was referenced by `WebpackOptions`'s JSON-Schema
* via the `definition` "EntryObject".
*/
export interface EntryObject {
/**
@ -636,9 +607,6 @@ export interface EntryObject {
}
/**
* An object with entry point description.
*
* This interface was referenced by `WebpackOptions`'s JSON-Schema
* via the `definition` "EntryDescription".
*/
export interface EntryDescription {
/**
@ -656,9 +624,6 @@ export interface EntryDescription {
}
/**
* Enables/Disables experiments (experiemental features with relax SemVer compatibility)
*
* This interface was referenced by `WebpackOptions`'s JSON-Schema
* via the `definition` "Experiments".
*/
export interface Experiments {
/**
@ -696,9 +661,6 @@ export interface Experiments {
}
/**
* Options for infrastructure level logging
*
* This interface was referenced by `WebpackOptions`'s JSON-Schema
* via the `definition` "InfrastructureLogging".
*/
export interface InfrastructureLogging {
/**
@ -712,18 +674,12 @@ export interface InfrastructureLogging {
}
/**
* Custom values available in the loader context.
*
* This interface was referenced by `WebpackOptions`'s JSON-Schema
* via the `definition` "Loader".
*/
export interface Loader {
[k: string]: any;
}
/**
* Options affecting the normal modules (`NormalModuleFactory`).
*
* This interface was referenced by `WebpackOptions`'s JSON-Schema
* via the `definition` "Module".
*/
export interface Module {
/**
@ -801,8 +757,7 @@ export interface Module {
wrappedContextRegExp?: RegExp;
}
/**
* This interface was referenced by `WebpackOptions`'s JSON-Schema
* via the `definition` "RuleSetRule".
* A rule description with conditions and effects for modules
*/
export interface RuleSetRule {
/**
@ -887,8 +842,7 @@ export interface RuleSetRule {
use?: RuleSetUse;
}
/**
* This interface was referenced by `WebpackOptions`'s JSON-Schema
* via the `definition` "ResolveOptions".
* Options object for resolving requests
*/
export interface ResolveOptions {
/**
@ -990,9 +944,6 @@ export interface ResolveOptions {
}
/**
* Plugin instance
*
* This interface was referenced by `WebpackOptions`'s JSON-Schema
* via the `definition` "ResolvePluginInstance".
*/
export interface ResolvePluginInstance {
/**
@ -1002,8 +953,7 @@ export interface ResolvePluginInstance {
[k: string]: any;
}
/**
* This interface was referenced by `WebpackOptions`'s JSON-Schema
* via the `definition` "NodeOptions".
* Options object for node compatibility features
*/
export interface NodeOptions {
/**
@ -1021,9 +971,6 @@ export interface NodeOptions {
}
/**
* Enables/Disables integrated optimizations
*
* This interface was referenced by `WebpackOptions`'s JSON-Schema
* via the `definition` "Optimization".
*/
export interface Optimization {
/**
@ -1100,6 +1047,9 @@ export interface Optimization {
* Remove chunks which are empty
*/
removeEmptyChunks?: boolean;
/**
* Create an additional chunk which contains only the webpack runtime and chunk hash maps
*/
runtimeChunk?: OptimizationRuntimeChunk;
/**
* Skip over modules which are flagged to contain no side effects when exports are not used
@ -1116,9 +1066,6 @@ export interface Optimization {
}
/**
* Plugin instance
*
* This interface was referenced by `WebpackOptions`'s JSON-Schema
* via the `definition` "WebpackPluginInstance".
*/
export interface WebpackPluginInstance {
/**
@ -1128,8 +1075,7 @@ export interface WebpackPluginInstance {
[k: string]: any;
}
/**
* This interface was referenced by `WebpackOptions`'s JSON-Schema
* via the `definition` "OptimizationSplitChunksOptions".
* Options object for splitting chunks into smaller chunks
*/
export interface OptimizationSplitChunksOptions {
/**
@ -1230,8 +1176,7 @@ export interface OptimizationSplitChunksOptions {
name?: false | Function | string;
}
/**
* This interface was referenced by `WebpackOptions`'s JSON-Schema
* via the `definition` "OptimizationSplitChunksCacheGroup".
* Options object for describing behavior of a cache group selecting modules that should be cached together
*/
export interface OptimizationSplitChunksCacheGroup {
/**
@ -1316,9 +1261,6 @@ export interface OptimizationSplitChunksCacheGroup {
}
/**
* Options affecting the output of the compilation. `output` options tell webpack how to write the compiled files to disk.
*
* This interface was referenced by `WebpackOptions`'s JSON-Schema
* via the `definition` "Output".
*/
export interface Output {
/**
@ -1495,9 +1437,6 @@ export interface Output {
}
/**
* Set explicit comments for `commonjs`, `commonjs2`, `amd`, and `root`.
*
* This interface was referenced by `WebpackOptions`'s JSON-Schema
* via the `definition` "LibraryCustomUmdCommentObject".
*/
export interface LibraryCustomUmdCommentObject {
/**
@ -1518,8 +1457,7 @@ export interface LibraryCustomUmdCommentObject {
root?: string;
}
/**
* This interface was referenced by `WebpackOptions`'s JSON-Schema
* via the `definition` "LibraryCustomUmdObject".
* Description object for all UMD variants of the library name
*/
export interface LibraryCustomUmdObject {
/**
@ -1536,8 +1474,7 @@ export interface LibraryCustomUmdObject {
root?: string | ArrayOfStringValues;
}
/**
* This interface was referenced by `WebpackOptions`'s JSON-Schema
* via the `definition` "PerformanceOptions".
* Configuration object for web performance recommendations
*/
export interface PerformanceOptions {
/**
@ -1559,16 +1496,12 @@ export interface PerformanceOptions {
}
/**
* Options for webpack-serve
*
* This interface was referenced by `WebpackOptions`'s JSON-Schema
* via the `definition` "Serve".
*/
export interface Serve {
[k: string]: any;
}
/**
* This interface was referenced by `WebpackOptions`'s JSON-Schema
* via the `definition` "StatsOptions".
* Stats options object
*/
export interface StatsOptions {
/**
@ -1805,9 +1738,6 @@ export interface StatsOptions {
}
/**
* Options for the watcher
*
* This interface was referenced by `WebpackOptions`'s JSON-Schema
* via the `definition` "WatchOptions".
*/
export interface WatchOptions {
/**
@ -1829,9 +1759,6 @@ export interface WatchOptions {
}
/**
* Multiple entry bundles are created. The key is the entry name. The value is an entry description object.
*
* This interface was referenced by `WebpackOptions`'s JSON-Schema
* via the `definition` "EntryStaticNormalized".
*/
export interface EntryStaticNormalized {
/**
@ -1840,39 +1767,131 @@ export interface EntryStaticNormalized {
[k: string]: EntryDescription;
}
/**
* This interface was referenced by `WebpackOptions`'s JSON-Schema
* via the `definition` "WebpackOptionsNormalized".
* Normalized webpack options object
*/
export interface WebpackOptionsNormalized {
/**
* Set the value of `require.amd` and `define.amd`. Or disable AMD support.
*/
amd?: Amd;
/**
* Report the first error as a hard error instead of tolerating it.
*/
bail?: Bail;
/**
* Cache generated modules and chunks to improve performance for multiple incremental builds.
*/
cache: CacheNormalized;
/**
* The base directory (absolute path!) for resolving the `entry` option. If `output.pathinfo` is set, the included pathinfo is shortened to this directory.
*/
context?: Context;
/**
* References to other configurations to depend on.
*/
dependencies?: Dependencies;
/**
* Options for the webpack-dev-server
*/
devServer?: DevServer;
/**
* A developer tool to enhance debugging (false | eval | [inline-|hidden-|eval-][nosources-][cheap-[module-]]source-map).
*/
devtool?: DevTool;
/**
* The entry point(s) of the compilation.
*/
entry: EntryNormalized;
/**
* Enables/Disables experiments (experiemental features with relax SemVer compatibility)
*/
experiments: Experiments;
/**
* Specify dependencies that shouldn't be resolved by webpack, but should become dependencies of the resulting bundle. The kind of the dependency depends on `output.libraryTarget`.
*/
externals: Externals;
/**
* Options for infrastructure level logging
*/
infrastructureLogging: InfrastructureLogging;
/**
* Custom values available in the loader context.
*/
loader?: Loader;
/**
* Enable production optimizations or development hints.
*/
mode?: Mode;
/**
* Options affecting the normal modules (`NormalModuleFactory`).
*/
module: Module;
/**
* Name of the configuration. Used when loading multiple configurations.
*/
name?: Name;
/**
* Include polyfills or mocks for various node stuff.
*/
node: Node;
/**
* Enables/Disables integrated optimizations
*/
optimization: Optimization;
/**
* Options affecting the output of the compilation. `output` options tell webpack how to write the compiled files to disk.
*/
output: Output;
/**
* The number of parallel processed modules in the compilation.
*/
parallelism?: Parallelism;
/**
* Configuration for web performance recommendations
*/
performance?: Performance;
/**
* Add additional plugins to the compiler.
*/
plugins: Plugins;
/**
* Capture timing information for each module.
*/
profile?: Profile;
/**
* Store compiler state to a json file.
*/
recordsInputPath?: RecordsInputPath;
/**
* Load compiler state from a json file.
*/
recordsOutputPath?: RecordsOutputPath;
/**
* Options for the resolver
*/
resolve: Resolve;
/**
* Options for the resolver when resolving loaders
*/
resolveLoader: ResolveLoader;
/**
* Options for webpack-serve
*/
serve?: Serve;
/**
* Stats options object or preset name
*/
stats: Stats;
/**
* Environment to build for
*/
target?: Target;
/**
* Enter watch mode, which rebuilds on file change.
*/
watch?: Watch;
/**
* Options for the watcher
*/
watchOptions: WatchOptions;
}

View File

@ -6,9 +6,6 @@
/**
* Function that executes for module and should return an DataUrl string
*
* This interface was referenced by `AssetModulesPluginGeneratorOptions`'s JSON-Schema
* via the `definition` "DataUrlFunction".
*/
export type DataUrlFunction = (
source: string | Buffer,
@ -31,8 +28,7 @@ export interface AssetModulesPluginGeneratorOptions {
) => string);
}
/**
* This interface was referenced by `AssetModulesPluginGeneratorOptions`'s JSON-Schema
* via the `definition` "DataUrlOptions".
* Options object for data url generation
*/
export interface DataUrlOptions {
/**

View File

@ -6,9 +6,6 @@
/**
* Function that executes for module and should return whenever asset should be inlined as DataUrl
*
* This interface was referenced by `AssetModulesPluginParserOptions`'s JSON-Schema
* via the `definition` "DataUrlFunction".
*/
export type DataUrlFunction = (
source: string | Buffer,
@ -22,8 +19,7 @@ export interface AssetModulesPluginParserOptions {
dataUrlCondition?: DataUrlOptions | DataUrlFunction;
}
/**
* This interface was referenced by `AssetModulesPluginParserOptions`'s JSON-Schema
* via the `definition` "DataUrlOptions".
* Options object for DataUrl condition
*/
export interface DataUrlOptions {
/**

View File

@ -16,7 +16,13 @@ export type BannerFunction = (data: {
chunk: import("../../lib/Chunk");
filename: string;
}) => string;
/**
* Filtering rules
*/
export type Rules = Rule[] | Rule;
/**
* Filtering rule as regex or string
*/
export type Rule = RegExp | string;
export interface BannerPluginOptions {

View File

@ -14,6 +14,9 @@ export type HandlerFunction = (
...args: string[]
) => void;
/**
* Options object for the ProgressPlugin
*/
export interface ProgressPluginOptions {
/**
* Show active modules count and one active module in progress message

View File

@ -5,13 +5,11 @@
*/
/**
* This interface was referenced by `SourceMapDevToolPluginOptions`'s JSON-Schema
* via the `definition` "rules".
* Include source maps for modules based on their extension (defaults to .js and .css)
*/
export type Rules = Rule[] | Rule;
/**
* This interface was referenced by `SourceMapDevToolPluginOptions`'s JSON-Schema
* via the `definition` "rule".
* Include source maps for modules based on their extension (defaults to .js and .css)
*/
export type Rule = RegExp | string;

View File

@ -14,6 +14,7 @@
]
},
"ArrayOfStringOrStringArrayValues": {
"description": "List of string or string-array values",
"type": "array",
"items": {
"description": "string or array of strings",
@ -34,6 +35,7 @@
}
},
"ArrayOfStringValues": {
"description": "Array of strings",
"type": "array",
"items": {
"description": "A non-empty string",
@ -172,6 +174,7 @@
"tsType": "(() => Promise<EntryStaticNormalized>)"
},
"EntryItem": {
"description": "Module(s) that are loaded upon startup",
"oneOf": [
{
"description": "The string is resolved to a module which is loaded upon startup.",
@ -226,6 +229,7 @@
"minProperties": 1
},
"EntryStatic": {
"description": "A static entry description",
"oneOf": [
{
"$ref": "#/definitions/EntryObject"
@ -296,6 +300,7 @@
}
},
"ExternalItem": {
"description": "Specify dependency that shouldn't be resolved by webpack, but should become dependencies of the resulting bundle. The kind of the dependency depends on `output.libraryTarget`.",
"anyOf": [
{
"description": "An exact matched dependency becomes external. The same string is used as external dependency.",
@ -359,6 +364,7 @@
]
},
"FileCacheOptions": {
"description": "Options object for persistent file-based caching",
"type": "object",
"additionalProperties": false,
"properties": {
@ -439,6 +445,7 @@
"required": ["type"]
},
"FilterItemTypes": {
"description": "Filtering value, regexp or function",
"anyOf": [
{
"instanceof": "RegExp",
@ -454,6 +461,7 @@
]
},
"FilterTypes": {
"description": "Filtering values",
"anyOf": [
{
"$ref": "#/definitions/FilterItemTypes"
@ -518,6 +526,7 @@
}
},
"LibraryCustomUmdObject": {
"description": "Description object for all UMD variants of the library name",
"type": "object",
"additionalProperties": false,
"properties": {
@ -547,6 +556,7 @@
"type": "object"
},
"MemoryCacheOptions": {
"description": "Options object for in-memory caching",
"type": "object",
"additionalProperties": false,
"properties": {
@ -736,6 +746,7 @@
]
},
"NodeOptions": {
"description": "Options object for node compatibility features",
"type": "object",
"additionalProperties": false,
"properties": {
@ -935,6 +946,7 @@
]
},
"OptimizationSplitChunksCacheGroup": {
"description": "Options object for describing behavior of a cache group selecting modules that should be cached together",
"type": "object",
"additionalProperties": false,
"properties": {
@ -1089,10 +1101,12 @@
}
},
"OptimizationSplitChunksGetCacheGroups": {
"description": "A function returning cache groups",
"instanceof": "Function",
"tsType": "((module: import('../lib/Module')) => OptimizationSplitChunksCacheGroup | OptimizationSplitChunksCacheGroup[] | void)"
},
"OptimizationSplitChunksOptions": {
"description": "Options object for splitting chunks into smaller chunks",
"type": "object",
"additionalProperties": false,
"properties": {
@ -1298,6 +1312,7 @@
}
},
"OptimizationSplitChunksSizes": {
"description": "Size description for limits",
"anyOf": [
{
"description": "Size of the javascript part of the chunk",
@ -1588,7 +1603,7 @@
"minimum": 1
},
"Performance": {
"description": "Configuration for web performance recommendations.",
"description": "Configuration for web performance recommendations",
"anyOf": [
{
"enum": [false]
@ -1599,6 +1614,7 @@
]
},
"PerformanceOptions": {
"description": "Configuration object for web performance recommendations",
"type": "object",
"additionalProperties": false,
"properties": {
@ -1693,6 +1709,7 @@
]
},
"ResolveOptions": {
"description": "Options object for resolving requests",
"type": "object",
"additionalProperties": false,
"properties": {
@ -1888,6 +1905,7 @@
"required": ["apply"]
},
"RuleSetCondition": {
"description": "A condition matcher",
"anyOf": [
{
"instanceof": "RegExp",
@ -1961,6 +1979,7 @@
]
},
"RuleSetConditionAbsolute": {
"description": "A condition matcher matching an absolute path",
"anyOf": [
{
"instanceof": "RegExp",
@ -2045,7 +2064,7 @@
]
},
"RuleSetConditionOrConditionsAbsolute": {
"description": "One or multiple rule conditions",
"description": "One or multiple rule conditions matching an absolute path",
"anyOf": [
{
"$ref": "#/definitions/RuleSetConditionAbsolute"
@ -2056,6 +2075,7 @@
]
},
"RuleSetConditions": {
"description": "A list of rule conditions",
"type": "array",
"items": {
"description": "A rule condition",
@ -2067,9 +2087,10 @@
}
},
"RuleSetConditionsAbsolute": {
"description": "A list of rule conditions matching an absolute path",
"type": "array",
"items": {
"description": "A rule condition",
"description": "A rule condition matching an absolute path",
"anyOf": [
{
"$ref": "#/definitions/RuleSetConditionAbsolute"
@ -2078,10 +2099,12 @@
}
},
"RuleSetLoader": {
"description": "A loader request",
"type": "string",
"minLength": 1
},
"RuleSetLoaderOptions": {
"description": "Options passed to a loader",
"anyOf": [
{
"type": "object"
@ -2092,6 +2115,7 @@
]
},
"RuleSetRule": {
"description": "A rule description with conditions and effects for modules",
"type": "object",
"additionalProperties": false,
"properties": {
@ -2235,6 +2259,7 @@
}
},
"RuleSetRules": {
"description": "A list of rules",
"type": "array",
"items": {
"description": "A rule",
@ -2246,6 +2271,7 @@
}
},
"RuleSetUse": {
"description": "A list of descriptions of loaders applied",
"anyOf": [
{
"$ref": "#/definitions/RuleSetUseItem"
@ -2268,6 +2294,7 @@
]
},
"RuleSetUseItem": {
"description": "A description of an applied loader",
"anyOf": [
{
"$ref": "#/definitions/RuleSetLoader"
@ -2309,7 +2336,7 @@
"type": "object"
},
"Stats": {
"description": "Used by the webpack CLI program to pass stats options.",
"description": "Stats options object or preset name",
"anyOf": [
{
"$ref": "#/definitions/StatsOptions"
@ -2331,6 +2358,7 @@
]
},
"StatsOptions": {
"description": "Stats options object",
"type": "object",
"additionalProperties": false,
"properties": {
@ -2689,6 +2717,7 @@
}
},
"WebpackOptionsNormalized": {
"description": "Normalized webpack options object",
"type": "object",
"additionalProperties": false,
"properties": {
@ -2822,6 +2851,7 @@
"required": ["apply"]
}
},
"description": "webpack options object as provided by the user",
"type": "object",
"additionalProperties": false,
"properties": {

View File

@ -6,6 +6,7 @@
"tsType": "((source: string | Buffer, context: { filename: string, module: import('../../lib/Module') }) => string)"
},
"DataUrlOptions": {
"description": "Options object for data url generation",
"type": "object",
"additionalProperties": false,
"properties": {

View File

@ -6,6 +6,7 @@
"tsType": "((source: string | Buffer, context: { filename: string, module: import('../../lib/Module') }) => boolean)"
},
"DataUrlOptions": {
"description": "Options object for DataUrl condition",
"type": "object",
"additionalProperties": false,
"properties": {

View File

@ -6,6 +6,7 @@
"tsType": "(data: { hash: string, chunk: import('../../lib/Chunk'), filename: string }) => string"
},
"Rule": {
"description": "Filtering rule as regex or string",
"oneOf": [
{
"instanceof": "RegExp",
@ -18,6 +19,7 @@
]
},
"Rules": {
"description": "Filtering rules",
"oneOf": [
{
"type": "array",

View File

@ -6,6 +6,7 @@
"tsType": "((percentage: number, msg: string, ...args: string[]) => void)"
},
"ProgressPluginOptions": {
"description": "Options object for the ProgressPlugin",
"type": "object",
"additionalProperties": false,
"properties": {

View File

@ -1,6 +1,7 @@
{
"definitions": {
"rule": {
"description": "Include source maps for modules based on their extension (defaults to .js and .css)",
"oneOf": [
{
"instanceof": "RegExp",
@ -13,6 +14,7 @@
]
},
"rules": {
"description": "Include source maps for modules based on their extension (defaults to .js and .css)",
"oneOf": [
{
"type": "array",
@ -135,12 +137,7 @@
"type": "string"
},
"test": {
"description": "Include source maps for modules based on their extension (defaults to .js and .css)",
"anyOf": [
{
"$ref": "#/definitions/rules"
}
]
"$ref": "#/definitions/rules"
}
}
}

View File

@ -139,7 +139,12 @@ describe("Schemas", () => {
if ("definitions" in item) {
Object.keys(item.definitions).forEach(name => {
describe(`#${name}`, () => {
walker(item.definitions[name]);
const def = item.definitions[name];
it("should have description set", () => {
expect(typeof def.description).toBe("string");
expect(def.description.length).toBeGreaterThan(1);
});
walker(def);
});
});
}
@ -150,14 +155,18 @@ describe("Schemas", () => {
Object.keys(item.properties).forEach(name => {
describe(`> '${name}'`, () => {
const property = item.properties[name];
validateProperty(property);
if (Object.keys(property).join() !== "$ref") {
validateProperty(property);
}
walker(property);
});
});
}
if (typeof item.additionalProperties === "object") {
describe("properties", () => {
validateProperty(item.additionalProperties);
if (Object.keys(item.additionalProperties).join() !== "$ref") {
validateProperty(item.additionalProperties);
}
walker(item.additionalProperties);
});
}

View File

@ -1,7 +1,7 @@
const fs = require("fs");
const path = require("path");
const prettierrc = require("../.prettierrc.js"); // eslint-disable-line
const { compileFromFile } = require("json-schema-to-typescript");
const { compile } = require("json-schema-to-typescript");
const schemasDir = path.resolve(__dirname, "../schemas");
const style = {
@ -32,17 +32,24 @@ const makeSchemas = () => {
};
const makeDefinitionsForSchema = absSchemaPath => {
const basename = path
const relPath = path
.relative(schemasDir, absSchemaPath)
.replace(/\.json$/i, "");
const filename = path.resolve(__dirname, `../declarations/${basename}.d.ts`);
compileFromFile(absSchemaPath, {
const basename = path.basename(relPath);
const filename = path.resolve(__dirname, `../declarations/${relPath}.d.ts`);
const schema = JSON.parse(fs.readFileSync(absSchemaPath, "utf-8"));
preprocessSchema(schema);
compile(schema, basename, {
bannerComment:
"/**\n * This file was automatically generated.\n * DO NOT MODIFY BY HAND.\n * Run `yarn special-lint-fix` to update\n */",
unreachableDefinitions: true,
style
}).then(
ts => {
ts = ts.replace(
/\s+\*\s+\* This interface was referenced by `.+`'s JSON-Schema\s+\* via the `definition` ".+"\./g,
""
);
let normalizedContent = "";
try {
const content = fs.readFileSync(filename, "utf-8");
@ -55,11 +62,11 @@ const makeDefinitionsForSchema = absSchemaPath => {
fs.mkdirSync(path.dirname(filename), { recursive: true });
fs.writeFileSync(filename, ts, "utf-8");
console.error(
`declarations/${basename.replace(/\\/g, "/")}.d.ts updated`
`declarations/${relPath.replace(/\\/g, "/")}.d.ts updated`
);
} else {
console.error(
`declarations/${basename.replace(
`declarations/${relPath.replace(
/\\/g,
"/"
)}.d.ts need to be updated`
@ -75,4 +82,50 @@ const makeDefinitionsForSchema = absSchemaPath => {
);
};
const resolvePath = (root, ref) => {
const parts = ref.split("/");
if (parts[0] !== "#") throw new Error("Unexpected ref");
let current = root;
for (const p of parts.slice(1)) {
current = current[p];
}
return current;
};
const preprocessSchema = (schema, root = schema) => {
if ("definitions" in schema) {
for (const key of Object.keys(schema.definitions)) {
preprocessSchema(schema.definitions[key], root);
}
}
if ("properties" in schema) {
for (const key of Object.keys(schema.properties)) {
const property = schema.properties[key];
if ("$ref" in property) {
const result = resolvePath(root, property.$ref);
schema.properties[key] = {
description: result.description,
anyOf: [property]
};
} else {
preprocessSchema(property, root);
}
}
}
if ("items" in schema) {
preprocessSchema(schema.items, root);
}
if (typeof schema.additionalProperties === "object") {
preprocessSchema(schema.additionalProperties, root);
}
const arrayProperties = ["oneOf", "anyOf", "allOf"];
for (const prop of arrayProperties) {
if (Array.isArray(schema[prop])) {
for (const item of schema[prop]) {
preprocessSchema(item, root);
}
}
}
};
makeSchemas();