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

View File

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

View File

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

View File

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

View File

@ -14,6 +14,9 @@ export type HandlerFunction = (
...args: string[] ...args: string[]
) => void; ) => void;
/**
* Options object for the ProgressPlugin
*/
export interface ProgressPluginOptions { export interface ProgressPluginOptions {
/** /**
* Show active modules count and one active module in progress message * 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 * Include source maps for modules based on their extension (defaults to .js and .css)
* via the `definition` "rules".
*/ */
export type Rules = Rule[] | Rule; export type Rules = Rule[] | Rule;
/** /**
* This interface was referenced by `SourceMapDevToolPluginOptions`'s JSON-Schema * Include source maps for modules based on their extension (defaults to .js and .css)
* via the `definition` "rule".
*/ */
export type Rule = RegExp | string; export type Rule = RegExp | string;

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -139,7 +139,12 @@ describe("Schemas", () => {
if ("definitions" in item) { if ("definitions" in item) {
Object.keys(item.definitions).forEach(name => { Object.keys(item.definitions).forEach(name => {
describe(`#${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 => { Object.keys(item.properties).forEach(name => {
describe(`> '${name}'`, () => { describe(`> '${name}'`, () => {
const property = item.properties[name]; const property = item.properties[name];
validateProperty(property); if (Object.keys(property).join() !== "$ref") {
validateProperty(property);
}
walker(property); walker(property);
}); });
}); });
} }
if (typeof item.additionalProperties === "object") { if (typeof item.additionalProperties === "object") {
describe("properties", () => { describe("properties", () => {
validateProperty(item.additionalProperties); if (Object.keys(item.additionalProperties).join() !== "$ref") {
validateProperty(item.additionalProperties);
}
walker(item.additionalProperties); walker(item.additionalProperties);
}); });
} }

View File

@ -1,7 +1,7 @@
const fs = require("fs"); const fs = require("fs");
const path = require("path"); const path = require("path");
const prettierrc = require("../.prettierrc.js"); // eslint-disable-line 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 schemasDir = path.resolve(__dirname, "../schemas");
const style = { const style = {
@ -32,17 +32,24 @@ const makeSchemas = () => {
}; };
const makeDefinitionsForSchema = absSchemaPath => { const makeDefinitionsForSchema = absSchemaPath => {
const basename = path const relPath = path
.relative(schemasDir, absSchemaPath) .relative(schemasDir, absSchemaPath)
.replace(/\.json$/i, ""); .replace(/\.json$/i, "");
const filename = path.resolve(__dirname, `../declarations/${basename}.d.ts`); const basename = path.basename(relPath);
compileFromFile(absSchemaPath, { const filename = path.resolve(__dirname, `../declarations/${relPath}.d.ts`);
const schema = JSON.parse(fs.readFileSync(absSchemaPath, "utf-8"));
preprocessSchema(schema);
compile(schema, basename, {
bannerComment: bannerComment:
"/**\n * This file was automatically generated.\n * DO NOT MODIFY BY HAND.\n * Run `yarn special-lint-fix` to update\n */", "/**\n * This file was automatically generated.\n * DO NOT MODIFY BY HAND.\n * Run `yarn special-lint-fix` to update\n */",
unreachableDefinitions: true, unreachableDefinitions: true,
style style
}).then( }).then(
ts => { ts => {
ts = ts.replace(
/\s+\*\s+\* This interface was referenced by `.+`'s JSON-Schema\s+\* via the `definition` ".+"\./g,
""
);
let normalizedContent = ""; let normalizedContent = "";
try { try {
const content = fs.readFileSync(filename, "utf-8"); const content = fs.readFileSync(filename, "utf-8");
@ -55,11 +62,11 @@ const makeDefinitionsForSchema = absSchemaPath => {
fs.mkdirSync(path.dirname(filename), { recursive: true }); fs.mkdirSync(path.dirname(filename), { recursive: true });
fs.writeFileSync(filename, ts, "utf-8"); fs.writeFileSync(filename, ts, "utf-8");
console.error( console.error(
`declarations/${basename.replace(/\\/g, "/")}.d.ts updated` `declarations/${relPath.replace(/\\/g, "/")}.d.ts updated`
); );
} else { } else {
console.error( console.error(
`declarations/${basename.replace( `declarations/${relPath.replace(
/\\/g, /\\/g,
"/" "/"
)}.d.ts need to be updated` )}.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(); makeSchemas();