From 162ed5f38251e3edc24460b81651bcf244d3bcec Mon Sep 17 00:00:00 2001 From: Tobias Koppers Date: Fri, 11 May 2018 14:13:06 +0200 Subject: [PATCH 01/29] add some missing types for validation --- declarations.d.ts | 15 ++++++++------- lib/Module.js | 4 ++++ lib/dependencies/WebAssemblyImportDependency.js | 10 +++++++++- 3 files changed, 21 insertions(+), 8 deletions(-) diff --git a/declarations.d.ts b/declarations.d.ts index bd50da6c9..fceb5dac9 100644 --- a/declarations.d.ts +++ b/declarations.d.ts @@ -110,7 +110,7 @@ declare module "@webassemblyjs/ast" { Start?: (p: NodePath) => void; Global?: (p: NodePath) => void; } - ); + ): void; export class NodePath { node: T; } @@ -121,14 +121,15 @@ declare module "@webassemblyjs/ast" { export class Start extends Node { index: Identifier; } + export class ModuleImportDescription { + type: string; + valtype?: string; + id?: Identifier; + signature?: Signature; + } export class ModuleImport extends Node { module: string; - descr: { - type: string; - valtype?: string; - id?: Identifier; - signature?: Signature; - }; + descr: ModuleImportDescription; name: string; } export class ModuleExport extends Node { diff --git a/lib/Module.js b/lib/Module.js index 7685740ab..3fb571cbe 100644 --- a/lib/Module.js +++ b/lib/Module.js @@ -262,6 +262,10 @@ class Module extends DependenciesBlock { } } + /** + * @param {string=} exportName the name of the export + * @returns {boolean|string} false if the export isn't used, true if no exportName is provided and the module is used, or the name to access it if the export is used + */ isUsed(exportName) { if (!exportName) return this.used !== false; if (this.used === null || this.usedExports === null) return exportName; diff --git a/lib/dependencies/WebAssemblyImportDependency.js b/lib/dependencies/WebAssemblyImportDependency.js index 64e971597..d765b0db0 100644 --- a/lib/dependencies/WebAssemblyImportDependency.js +++ b/lib/dependencies/WebAssemblyImportDependency.js @@ -8,12 +8,20 @@ const DependencyReference = require("./DependencyReference"); const ModuleDependency = require("./ModuleDependency"); const UnsupportedWebAssemblyFeatureError = require("../wasm/UnsupportedWebAssemblyFeatureError"); +/** @typedef {import("@webassemblyjs/ast").ModuleImportDescription} ModuleImportDescription */ + class WebAssemblyImportDependency extends ModuleDependency { + /** + * @param {string} request the request + * @param {string} name the imported name + * @param {ModuleImportDescription} description the WASM ast node + * @param {false | string} onlyDirectImport if only direct imports are allowed + */ constructor(request, name, description, onlyDirectImport) { super(request); /** @type {string} */ this.name = name; - /** @type {TODO} */ + /** @type {ModuleImportDescription} */ this.description = description; /** @type {false | string} */ this.onlyDirectImport = onlyDirectImport; From 62e01d3caef232339ea9f65e626239c8be3eed0f Mon Sep 17 00:00:00 2001 From: Tobias Koppers Date: Fri, 11 May 2018 13:16:27 +0200 Subject: [PATCH 02/29] add some random types --- lib/Chunk.js | 3 +++ lib/HotUpdateChunk.js | 1 + lib/Template.js | 1 + 3 files changed, 5 insertions(+) diff --git a/lib/Chunk.js b/lib/Chunk.js index f0bb2ea72..e9bcb709e 100644 --- a/lib/Chunk.js +++ b/lib/Chunk.js @@ -339,6 +339,9 @@ class Chunk { return this._modules.has(module); } + /** + * @returns {Module[]} an array of modules (do not modify) + */ getModules() { return this._modules.getFromCache(getArray); } diff --git a/lib/HotUpdateChunk.js b/lib/HotUpdateChunk.js index 17eaf1281..8845643b4 100644 --- a/lib/HotUpdateChunk.js +++ b/lib/HotUpdateChunk.js @@ -9,6 +9,7 @@ const Chunk = require("./Chunk"); class HotUpdateChunk extends Chunk { constructor() { super(); + /** @type {(string|number)[]} */ this.removedModules = undefined; } } diff --git a/lib/Template.js b/lib/Template.js index 572d4b5ed..adb168364 100644 --- a/lib/Template.js +++ b/lib/Template.js @@ -252,6 +252,7 @@ class Template { source.add(`Array(${minId}).concat(`); } source.add("[\n"); + /** @type {Map} */ const modules = new Map(); for (const module of allModules) { modules.set(module.id, module); From cd8be8637a62f092afbd618163e6cb467d2f7d5a Mon Sep 17 00:00:00 2001 From: Sven SAULEAU Date: Wed, 19 Sep 2018 07:44:45 +0200 Subject: [PATCH 03/29] chore: bump webassemblyjs --- package.json | 8 +-- yarn.lock | 184 +++++++++++++++++++++++++-------------------------- 2 files changed, 96 insertions(+), 96 deletions(-) diff --git a/package.json b/package.json index 98def2ac0..ff629880d 100644 --- a/package.json +++ b/package.json @@ -5,10 +5,10 @@ "description": "Packs CommonJs/AMD modules for the browser. Allows to split your codebase into multiple bundles, which can be loaded on demand. Support loaders to preprocess files, i.e. json, jsx, es7, css, less, ... and your custom stuff.", "license": "MIT", "dependencies": { - "@webassemblyjs/ast": "1.7.6", - "@webassemblyjs/helper-module-context": "1.7.6", - "@webassemblyjs/wasm-edit": "1.7.6", - "@webassemblyjs/wasm-parser": "1.7.6", + "@webassemblyjs/ast": "1.7.7", + "@webassemblyjs/helper-module-context": "1.7.7", + "@webassemblyjs/wasm-edit": "1.7.7", + "@webassemblyjs/wasm-parser": "1.7.7", "acorn": "^5.6.2", "acorn-dynamic-import": "^3.0.0", "ajv": "^6.1.0", diff --git a/yarn.lock b/yarn.lock index dceefda10..44a4cc501 100644 --- a/yarn.lock +++ b/yarn.lock @@ -56,133 +56,133 @@ "@types/source-list-map" "*" source-map "^0.6.1" -"@webassemblyjs/ast@1.7.6": - version "1.7.6" - resolved "https://registry.yarnpkg.com/@webassemblyjs/ast/-/ast-1.7.6.tgz#3ef8c45b3e5e943a153a05281317474fef63e21e" +"@webassemblyjs/ast@1.7.7": + version "1.7.7" + resolved "https://registry.yarnpkg.com/@webassemblyjs/ast/-/ast-1.7.7.tgz#d801b79ab0d609ca087278028f6b7dd4f14ef883" dependencies: - "@webassemblyjs/helper-module-context" "1.7.6" - "@webassemblyjs/helper-wasm-bytecode" "1.7.6" - "@webassemblyjs/wast-parser" "1.7.6" + "@webassemblyjs/helper-module-context" "1.7.7" + "@webassemblyjs/helper-wasm-bytecode" "1.7.7" + "@webassemblyjs/wast-parser" "1.7.7" mamacro "^0.0.3" -"@webassemblyjs/floating-point-hex-parser@1.7.6": - version "1.7.6" - resolved "https://registry.yarnpkg.com/@webassemblyjs/floating-point-hex-parser/-/floating-point-hex-parser-1.7.6.tgz#7cb37d51a05c3fe09b464ae7e711d1ab3837801f" +"@webassemblyjs/floating-point-hex-parser@1.7.7": + version "1.7.7" + resolved "https://registry.yarnpkg.com/@webassemblyjs/floating-point-hex-parser/-/floating-point-hex-parser-1.7.7.tgz#d25c4612410bf7fad5dbaed992f7c6bc2440b2d2" -"@webassemblyjs/helper-api-error@1.7.6": - version "1.7.6" - resolved "https://registry.yarnpkg.com/@webassemblyjs/helper-api-error/-/helper-api-error-1.7.6.tgz#99b7e30e66f550a2638299a109dda84a622070ef" +"@webassemblyjs/helper-api-error@1.7.7": + version "1.7.7" + resolved "https://registry.yarnpkg.com/@webassemblyjs/helper-api-error/-/helper-api-error-1.7.7.tgz#ac3fe3310530155ca9eb365638d0e1e0603e3834" -"@webassemblyjs/helper-buffer@1.7.6": - version "1.7.6" - resolved "https://registry.yarnpkg.com/@webassemblyjs/helper-buffer/-/helper-buffer-1.7.6.tgz#ba0648be12bbe560c25c997e175c2018df39ca3e" +"@webassemblyjs/helper-buffer@1.7.7": + version "1.7.7" + resolved "https://registry.yarnpkg.com/@webassemblyjs/helper-buffer/-/helper-buffer-1.7.7.tgz#0efa7cec26a2718da36126fa287e4a20fc6cdcc2" -"@webassemblyjs/helper-code-frame@1.7.6": - version "1.7.6" - resolved "https://registry.yarnpkg.com/@webassemblyjs/helper-code-frame/-/helper-code-frame-1.7.6.tgz#5a94d21b0057b69a7403fca0c253c3aaca95b1a5" +"@webassemblyjs/helper-code-frame@1.7.7": + version "1.7.7" + resolved "https://registry.yarnpkg.com/@webassemblyjs/helper-code-frame/-/helper-code-frame-1.7.7.tgz#ebed8533dbc1efc38c521c1c998a06ece2d5486e" dependencies: - "@webassemblyjs/wast-printer" "1.7.6" + "@webassemblyjs/wast-printer" "1.7.7" -"@webassemblyjs/helper-fsm@1.7.6": - version "1.7.6" - resolved "https://registry.yarnpkg.com/@webassemblyjs/helper-fsm/-/helper-fsm-1.7.6.tgz#ae1741c6f6121213c7a0b587fb964fac492d3e49" +"@webassemblyjs/helper-fsm@1.7.7": + version "1.7.7" + resolved "https://registry.yarnpkg.com/@webassemblyjs/helper-fsm/-/helper-fsm-1.7.7.tgz#4ebecc02fc190d57928cda1755c4c9a820be2304" -"@webassemblyjs/helper-module-context@1.7.6": - version "1.7.6" - resolved "https://registry.yarnpkg.com/@webassemblyjs/helper-module-context/-/helper-module-context-1.7.6.tgz#116d19a51a6cebc8900ad53ca34ff8269c668c23" +"@webassemblyjs/helper-module-context@1.7.7": + version "1.7.7" + resolved "https://registry.yarnpkg.com/@webassemblyjs/helper-module-context/-/helper-module-context-1.7.7.tgz#f441652ecf4726cd952b9e235e2ce0e3ccd521c9" dependencies: mamacro "^0.0.3" -"@webassemblyjs/helper-wasm-bytecode@1.7.6": - version "1.7.6" - resolved "https://registry.yarnpkg.com/@webassemblyjs/helper-wasm-bytecode/-/helper-wasm-bytecode-1.7.6.tgz#98e515eaee611aa6834eb5f6a7f8f5b29fefb6f1" +"@webassemblyjs/helper-wasm-bytecode@1.7.7": + version "1.7.7" + resolved "https://registry.yarnpkg.com/@webassemblyjs/helper-wasm-bytecode/-/helper-wasm-bytecode-1.7.7.tgz#9699da0b6bf9f48ac40feef66ddc2f9adfa3926a" -"@webassemblyjs/helper-wasm-section@1.7.6": - version "1.7.6" - resolved "https://registry.yarnpkg.com/@webassemblyjs/helper-wasm-section/-/helper-wasm-section-1.7.6.tgz#783835867bdd686df7a95377ab64f51a275e8333" +"@webassemblyjs/helper-wasm-section@1.7.7": + version "1.7.7" + resolved "https://registry.yarnpkg.com/@webassemblyjs/helper-wasm-section/-/helper-wasm-section-1.7.7.tgz#13eabdfef67a76dae199bd8407299e50fa591715" dependencies: - "@webassemblyjs/ast" "1.7.6" - "@webassemblyjs/helper-buffer" "1.7.6" - "@webassemblyjs/helper-wasm-bytecode" "1.7.6" - "@webassemblyjs/wasm-gen" "1.7.6" + "@webassemblyjs/ast" "1.7.7" + "@webassemblyjs/helper-buffer" "1.7.7" + "@webassemblyjs/helper-wasm-bytecode" "1.7.7" + "@webassemblyjs/wasm-gen" "1.7.7" -"@webassemblyjs/ieee754@1.7.6": - version "1.7.6" - resolved "https://registry.yarnpkg.com/@webassemblyjs/ieee754/-/ieee754-1.7.6.tgz#c34fc058f2f831fae0632a8bb9803cf2d3462eb1" +"@webassemblyjs/ieee754@1.7.7": + version "1.7.7" + resolved "https://registry.yarnpkg.com/@webassemblyjs/ieee754/-/ieee754-1.7.7.tgz#1d891f11ba6a70855b8d8713cc7e86359237afb5" dependencies: "@xtuc/ieee754" "^1.2.0" -"@webassemblyjs/leb128@1.7.6": - version "1.7.6" - resolved "https://registry.yarnpkg.com/@webassemblyjs/leb128/-/leb128-1.7.6.tgz#197f75376a29f6ed6ace15898a310d871d92f03b" +"@webassemblyjs/leb128@1.7.7": + version "1.7.7" + resolved "https://registry.yarnpkg.com/@webassemblyjs/leb128/-/leb128-1.7.7.tgz#ea467bf93b708b14fa9734226c5e7036e38e1d4a" dependencies: "@xtuc/long" "4.2.1" -"@webassemblyjs/utf8@1.7.6": - version "1.7.6" - resolved "https://registry.yarnpkg.com/@webassemblyjs/utf8/-/utf8-1.7.6.tgz#eb62c66f906af2be70de0302e29055d25188797d" +"@webassemblyjs/utf8@1.7.7": + version "1.7.7" + resolved "https://registry.yarnpkg.com/@webassemblyjs/utf8/-/utf8-1.7.7.tgz#cbbbc2299192eb3ca297573ff1cfe227c966ba0e" -"@webassemblyjs/wasm-edit@1.7.6": - version "1.7.6" - resolved "https://registry.yarnpkg.com/@webassemblyjs/wasm-edit/-/wasm-edit-1.7.6.tgz#fa41929160cd7d676d4c28ecef420eed5b3733c5" +"@webassemblyjs/wasm-edit@1.7.7": + version "1.7.7" + resolved "https://registry.yarnpkg.com/@webassemblyjs/wasm-edit/-/wasm-edit-1.7.7.tgz#0777da9fc26c2a97aad9eda9bbb05bacafa6a358" dependencies: - "@webassemblyjs/ast" "1.7.6" - "@webassemblyjs/helper-buffer" "1.7.6" - "@webassemblyjs/helper-wasm-bytecode" "1.7.6" - "@webassemblyjs/helper-wasm-section" "1.7.6" - "@webassemblyjs/wasm-gen" "1.7.6" - "@webassemblyjs/wasm-opt" "1.7.6" - "@webassemblyjs/wasm-parser" "1.7.6" - "@webassemblyjs/wast-printer" "1.7.6" + "@webassemblyjs/ast" "1.7.7" + "@webassemblyjs/helper-buffer" "1.7.7" + "@webassemblyjs/helper-wasm-bytecode" "1.7.7" + "@webassemblyjs/helper-wasm-section" "1.7.7" + "@webassemblyjs/wasm-gen" "1.7.7" + "@webassemblyjs/wasm-opt" "1.7.7" + "@webassemblyjs/wasm-parser" "1.7.7" + "@webassemblyjs/wast-printer" "1.7.7" -"@webassemblyjs/wasm-gen@1.7.6": - version "1.7.6" - resolved "https://registry.yarnpkg.com/@webassemblyjs/wasm-gen/-/wasm-gen-1.7.6.tgz#695ac38861ab3d72bf763c8c75e5f087ffabc322" +"@webassemblyjs/wasm-gen@1.7.7": + version "1.7.7" + resolved "https://registry.yarnpkg.com/@webassemblyjs/wasm-gen/-/wasm-gen-1.7.7.tgz#7ccbb089c34b60efbf0764b868a461a8d83e5883" dependencies: - "@webassemblyjs/ast" "1.7.6" - "@webassemblyjs/helper-wasm-bytecode" "1.7.6" - "@webassemblyjs/ieee754" "1.7.6" - "@webassemblyjs/leb128" "1.7.6" - "@webassemblyjs/utf8" "1.7.6" + "@webassemblyjs/ast" "1.7.7" + "@webassemblyjs/helper-wasm-bytecode" "1.7.7" + "@webassemblyjs/ieee754" "1.7.7" + "@webassemblyjs/leb128" "1.7.7" + "@webassemblyjs/utf8" "1.7.7" -"@webassemblyjs/wasm-opt@1.7.6": - version "1.7.6" - resolved "https://registry.yarnpkg.com/@webassemblyjs/wasm-opt/-/wasm-opt-1.7.6.tgz#fbafa78e27e1a75ab759a4b658ff3d50b4636c21" +"@webassemblyjs/wasm-opt@1.7.7": + version "1.7.7" + resolved "https://registry.yarnpkg.com/@webassemblyjs/wasm-opt/-/wasm-opt-1.7.7.tgz#a3d692696618be0d823aa2bbaedf72ea6a1b3c95" dependencies: - "@webassemblyjs/ast" "1.7.6" - "@webassemblyjs/helper-buffer" "1.7.6" - "@webassemblyjs/wasm-gen" "1.7.6" - "@webassemblyjs/wasm-parser" "1.7.6" + "@webassemblyjs/ast" "1.7.7" + "@webassemblyjs/helper-buffer" "1.7.7" + "@webassemblyjs/wasm-gen" "1.7.7" + "@webassemblyjs/wasm-parser" "1.7.7" -"@webassemblyjs/wasm-parser@1.7.6": - version "1.7.6" - resolved "https://registry.yarnpkg.com/@webassemblyjs/wasm-parser/-/wasm-parser-1.7.6.tgz#84eafeeff405ad6f4c4b5777d6a28ae54eed51fe" +"@webassemblyjs/wasm-parser@1.7.7": + version "1.7.7" + resolved "https://registry.yarnpkg.com/@webassemblyjs/wasm-parser/-/wasm-parser-1.7.7.tgz#04f34715d3138c1ee937ced679750223bec5b519" dependencies: - "@webassemblyjs/ast" "1.7.6" - "@webassemblyjs/helper-api-error" "1.7.6" - "@webassemblyjs/helper-wasm-bytecode" "1.7.6" - "@webassemblyjs/ieee754" "1.7.6" - "@webassemblyjs/leb128" "1.7.6" - "@webassemblyjs/utf8" "1.7.6" + "@webassemblyjs/ast" "1.7.7" + "@webassemblyjs/helper-api-error" "1.7.7" + "@webassemblyjs/helper-wasm-bytecode" "1.7.7" + "@webassemblyjs/ieee754" "1.7.7" + "@webassemblyjs/leb128" "1.7.7" + "@webassemblyjs/utf8" "1.7.7" -"@webassemblyjs/wast-parser@1.7.6": - version "1.7.6" - resolved "https://registry.yarnpkg.com/@webassemblyjs/wast-parser/-/wast-parser-1.7.6.tgz#ca4d20b1516e017c91981773bd7e819d6bd9c6a7" +"@webassemblyjs/wast-parser@1.7.7": + version "1.7.7" + resolved "https://registry.yarnpkg.com/@webassemblyjs/wast-parser/-/wast-parser-1.7.7.tgz#c7422cd45c124efdd071839919029294b9bf8b23" dependencies: - "@webassemblyjs/ast" "1.7.6" - "@webassemblyjs/floating-point-hex-parser" "1.7.6" - "@webassemblyjs/helper-api-error" "1.7.6" - "@webassemblyjs/helper-code-frame" "1.7.6" - "@webassemblyjs/helper-fsm" "1.7.6" + "@webassemblyjs/ast" "1.7.7" + "@webassemblyjs/floating-point-hex-parser" "1.7.7" + "@webassemblyjs/helper-api-error" "1.7.7" + "@webassemblyjs/helper-code-frame" "1.7.7" + "@webassemblyjs/helper-fsm" "1.7.7" "@xtuc/long" "4.2.1" mamacro "^0.0.3" -"@webassemblyjs/wast-printer@1.7.6": - version "1.7.6" - resolved "https://registry.yarnpkg.com/@webassemblyjs/wast-printer/-/wast-printer-1.7.6.tgz#a6002c526ac5fa230fe2c6d2f1bdbf4aead43a5e" +"@webassemblyjs/wast-printer@1.7.7": + version "1.7.7" + resolved "https://registry.yarnpkg.com/@webassemblyjs/wast-printer/-/wast-printer-1.7.7.tgz#2b7df79d0a925b9dcb11447fdebacb4e3a91238c" dependencies: - "@webassemblyjs/ast" "1.7.6" - "@webassemblyjs/wast-parser" "1.7.6" + "@webassemblyjs/ast" "1.7.7" + "@webassemblyjs/wast-parser" "1.7.7" "@xtuc/long" "4.2.1" "@xtuc/ieee754@^1.2.0": From 1252b89a6f35f86061aedeb499204e7ab4c1b5a8 Mon Sep 17 00:00:00 2001 From: Tobias Koppers Date: Wed, 19 Sep 2018 23:19:07 +0200 Subject: [PATCH 04/29] Fix handling of non-zero exit codes --- azure-pipelines.yml | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index e14b12825..cc862765c 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -11,17 +11,20 @@ jobs: curl -o- -L https://yarnpkg.com/install.sh | bash displayName: "Install Yarn" - script: | + set -e export PATH="$HOME/.yarn/bin:$HOME/.config/yarn/global/node_modules/.bin:$PATH" node -v yarn -v displayName: "Print versions" - script: | + set -e export PATH="$HOME/.yarn/bin:$HOME/.config/yarn/global/node_modules/.bin:$PATH" yarn --frozen-lockfile yarn link --frozen-lockfile || true yarn link webpack --frozen-lockfile displayName: "Install dependencies" - script: | + set -e export PATH="$HOME/.yarn/bin:$HOME/.config/yarn/global/node_modules/.bin:$PATH" yarn test:basic --ci yarn test:unit --ci @@ -38,17 +41,20 @@ jobs: curl -o- -L https://yarnpkg.com/install.sh | bash displayName: "Install Yarn" - script: | + set -e export PATH="$HOME/.yarn/bin:$HOME/.config/yarn/global/node_modules/.bin:$PATH" node -v yarn -v displayName: "Print versions" - script: | + set -e export PATH="$HOME/.yarn/bin:$HOME/.config/yarn/global/node_modules/.bin:$PATH" yarn --frozen-lockfile yarn link --frozen-lockfile || true yarn link webpack --frozen-lockfile displayName: "Install dependencies" - script: | + set -e export PATH="$HOME/.yarn/bin:$HOME/.config/yarn/global/node_modules/.bin:$PATH" yarn lint displayName: "Run linting" @@ -76,17 +82,20 @@ jobs: curl -o- -L https://yarnpkg.com/install.sh | bash displayName: "Install Yarn" - script: | + set -e export PATH="$HOME/.yarn/bin:$HOME/.config/yarn/global/node_modules/.bin:$PATH" node -v yarn -v displayName: "Print versions" - script: | + set -e export PATH="$HOME/.yarn/bin:$HOME/.config/yarn/global/node_modules/.bin:$PATH" yarn --frozen-lockfile yarn link --frozen-lockfile || true yarn link webpack --frozen-lockfile displayName: "Install dependencies" - script: | + set -e export PATH="$HOME/.yarn/bin:$HOME/.config/yarn/global/node_modules/.bin:$PATH" yarn cover:init yarn cover:integration "test/(?!TestCases)" --ci --maxWorkers=2 @@ -120,17 +129,20 @@ jobs: curl -o- -L https://yarnpkg.com/install.sh | bash displayName: "Install Yarn" - script: | + set -e export PATH="$HOME/.yarn/bin:$HOME/.config/yarn/global/node_modules/.bin:$PATH" node -v yarn -v displayName: "Print versions" - script: | + set -e export PATH="$HOME/.yarn/bin:$HOME/.config/yarn/global/node_modules/.bin:$PATH" yarn --frozen-lockfile yarn link --frozen-lockfile || true yarn link webpack --frozen-lockfile displayName: "Install dependencies" - script: | + set -e export PATH="$HOME/.yarn/bin:$HOME/.config/yarn/global/node_modules/.bin:$PATH" yarn cover:init yarn cover:integration "test/(?!TestCases)" --ci @@ -164,14 +176,17 @@ jobs: npm install --global yarn displayName: "Install Yarn" - script: | + set -e node -v yarn -v displayName: "Print versions" - script: | + set -e yarn --frozen-lockfile yarn link --frozen-lockfile || true yarn link webpack --frozen-lockfile displayName: "Install dependencies" - - script: + - script: | + set -e yarn cover:init && yarn cover:integration "test/(?!TestCases)" --ci --maxWorkers=2 && move coverage\\coverage-final.json coverage\\coverage-final-1.json && yarn cover:integration "test/TestCasesD" --ci --maxWorkers=2 && move coverage\\coverage-final.json coverage\\coverage-final-2.json && yarn cover:integration "test/TestCases(?!D)" --ci --maxWorkers=2 && move coverage\\coverage-final.json coverage\\coverage-final-3.json displayName: "Run tests with coverage" From 1b59400e8077d7ca2aee87dcbe3036fc98778bcc Mon Sep 17 00:00:00 2001 From: Tobias Koppers Date: Thu, 20 Sep 2018 11:10:10 +0200 Subject: [PATCH 05/29] upgrade webpack-sources --- package.json | 2 +- yarn.lock | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/package.json b/package.json index ff629880d..d24084eef 100644 --- a/package.json +++ b/package.json @@ -28,7 +28,7 @@ "tapable": "^1.1.0", "uglifyjs-webpack-plugin": "^1.2.4", "watchpack": "^1.5.0", - "webpack-sources": "^1.2.0" + "webpack-sources": "^1.3.0" }, "devDependencies": { "@types/node": "^9.6.4", diff --git a/yarn.lock b/yarn.lock index 44a4cc501..d01935674 100644 --- a/yarn.lock +++ b/yarn.lock @@ -6709,9 +6709,9 @@ webpack-dev-middleware@^1.9.0: range-parser "^1.0.3" time-stamp "^2.0.0" -webpack-sources@^1.1.0, webpack-sources@^1.2.0: - version "1.2.0" - resolved "https://registry.yarnpkg.com/webpack-sources/-/webpack-sources-1.2.0.tgz#18181e0d013fce096faf6f8e6d41eeffffdceac2" +webpack-sources@^1.1.0, webpack-sources@^1.3.0: + version "1.3.0" + resolved "https://registry.yarnpkg.com/webpack-sources/-/webpack-sources-1.3.0.tgz#2a28dcb9f1f45fe960d8f1493252b5ee6530fa85" dependencies: source-list-map "^2.0.0" source-map "~0.6.1" From a71c4003c71059cbc500b7e90689f8264dce29c3 Mon Sep 17 00:00:00 2001 From: David Staheli Date: Thu, 20 Sep 2018 18:56:22 -0400 Subject: [PATCH 06/29] Add build badge for azure pipelines --- README.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/README.md b/README.md index 8ee539501..344ca1fa9 100644 --- a/README.md +++ b/README.md @@ -11,6 +11,7 @@ [![deps][deps]][deps-url] [![tests][tests]][tests-url] [![builds][builds]][builds-url] +[![builds2][builds2]][builds2-url] [![coverage][cover]][cover-url] [![licenses][licenses]][licenses-url] @@ -752,6 +753,9 @@ src="https://static.monei.net/monei-logo.svg" height="30" alt="MONEI"> [builds-url]: https://ci.appveyor.com/project/sokra/webpack/branch/master [builds]: https://ci.appveyor.com/api/projects/status/github/webpack/webpack?svg=true +[builds2]: https://dev.azure.com/webpack/webpack/_apis/build/status/webpack.webpack +[builds2-url]: https://dev.azure.com/webpack/webpack/_build/latest?definitionId=3 + [licenses-url]: https://app.fossa.io/projects/git%2Bhttps%3A%2F%2Fgithub.com%2Fwebpack%2Fwebpack?ref=badge_shield [licenses]: https://app.fossa.io/api/projects/git%2Bhttps%3A%2F%2Fgithub.com%2Fwebpack%2Fwebpack.svg?type=shield From 1af7caf41784a59fee9869a9e4bbde1cf45bd58d Mon Sep 17 00:00:00 2001 From: Sven SAULEAU Date: Fri, 21 Sep 2018 11:03:07 +0200 Subject: [PATCH 07/29] chore: bump webassemblyjs --- package.json | 8 +-- yarn.lock | 196 ++++++++++++++++++++++++--------------------------- 2 files changed, 98 insertions(+), 106 deletions(-) diff --git a/package.json b/package.json index d24084eef..084947902 100644 --- a/package.json +++ b/package.json @@ -5,10 +5,10 @@ "description": "Packs CommonJs/AMD modules for the browser. Allows to split your codebase into multiple bundles, which can be loaded on demand. Support loaders to preprocess files, i.e. json, jsx, es7, css, less, ... and your custom stuff.", "license": "MIT", "dependencies": { - "@webassemblyjs/ast": "1.7.7", - "@webassemblyjs/helper-module-context": "1.7.7", - "@webassemblyjs/wasm-edit": "1.7.7", - "@webassemblyjs/wasm-parser": "1.7.7", + "@webassemblyjs/ast": "1.7.8", + "@webassemblyjs/helper-module-context": "1.7.8", + "@webassemblyjs/wasm-edit": "1.7.8", + "@webassemblyjs/wasm-parser": "1.7.8", "acorn": "^5.6.2", "acorn-dynamic-import": "^3.0.0", "ajv": "^6.1.0", diff --git a/yarn.lock b/yarn.lock index d01935674..c90867f96 100644 --- a/yarn.lock +++ b/yarn.lock @@ -56,133 +56,129 @@ "@types/source-list-map" "*" source-map "^0.6.1" -"@webassemblyjs/ast@1.7.7": - version "1.7.7" - resolved "https://registry.yarnpkg.com/@webassemblyjs/ast/-/ast-1.7.7.tgz#d801b79ab0d609ca087278028f6b7dd4f14ef883" +"@webassemblyjs/ast@1.7.8": + version "1.7.8" + resolved "https://registry.yarnpkg.com/@webassemblyjs/ast/-/ast-1.7.8.tgz#f31f480debeef957f01b623f27eabc695fa4fe8f" dependencies: - "@webassemblyjs/helper-module-context" "1.7.7" - "@webassemblyjs/helper-wasm-bytecode" "1.7.7" - "@webassemblyjs/wast-parser" "1.7.7" - mamacro "^0.0.3" + "@webassemblyjs/helper-module-context" "1.7.8" + "@webassemblyjs/helper-wasm-bytecode" "1.7.8" + "@webassemblyjs/wast-parser" "1.7.8" -"@webassemblyjs/floating-point-hex-parser@1.7.7": - version "1.7.7" - resolved "https://registry.yarnpkg.com/@webassemblyjs/floating-point-hex-parser/-/floating-point-hex-parser-1.7.7.tgz#d25c4612410bf7fad5dbaed992f7c6bc2440b2d2" +"@webassemblyjs/floating-point-hex-parser@1.7.8": + version "1.7.8" + resolved "https://registry.yarnpkg.com/@webassemblyjs/floating-point-hex-parser/-/floating-point-hex-parser-1.7.8.tgz#1b3ed0e27e384032254e9322fc646dd3e70ef1b9" -"@webassemblyjs/helper-api-error@1.7.7": - version "1.7.7" - resolved "https://registry.yarnpkg.com/@webassemblyjs/helper-api-error/-/helper-api-error-1.7.7.tgz#ac3fe3310530155ca9eb365638d0e1e0603e3834" +"@webassemblyjs/helper-api-error@1.7.8": + version "1.7.8" + resolved "https://registry.yarnpkg.com/@webassemblyjs/helper-api-error/-/helper-api-error-1.7.8.tgz#a2b49c11f615e736f815ec927f035dcfa690d572" -"@webassemblyjs/helper-buffer@1.7.7": - version "1.7.7" - resolved "https://registry.yarnpkg.com/@webassemblyjs/helper-buffer/-/helper-buffer-1.7.7.tgz#0efa7cec26a2718da36126fa287e4a20fc6cdcc2" +"@webassemblyjs/helper-buffer@1.7.8": + version "1.7.8" + resolved "https://registry.yarnpkg.com/@webassemblyjs/helper-buffer/-/helper-buffer-1.7.8.tgz#3fc66bfa09c1c60e824cf3d5887826fac062877d" -"@webassemblyjs/helper-code-frame@1.7.7": - version "1.7.7" - resolved "https://registry.yarnpkg.com/@webassemblyjs/helper-code-frame/-/helper-code-frame-1.7.7.tgz#ebed8533dbc1efc38c521c1c998a06ece2d5486e" +"@webassemblyjs/helper-code-frame@1.7.8": + version "1.7.8" + resolved "https://registry.yarnpkg.com/@webassemblyjs/helper-code-frame/-/helper-code-frame-1.7.8.tgz#cc5a7e9522b70e7580df056dfd34020cf29645b0" dependencies: - "@webassemblyjs/wast-printer" "1.7.7" + "@webassemblyjs/wast-printer" "1.7.8" -"@webassemblyjs/helper-fsm@1.7.7": - version "1.7.7" - resolved "https://registry.yarnpkg.com/@webassemblyjs/helper-fsm/-/helper-fsm-1.7.7.tgz#4ebecc02fc190d57928cda1755c4c9a820be2304" +"@webassemblyjs/helper-fsm@1.7.8": + version "1.7.8" + resolved "https://registry.yarnpkg.com/@webassemblyjs/helper-fsm/-/helper-fsm-1.7.8.tgz#fe4607430af466912797c21acafd3046080182ea" -"@webassemblyjs/helper-module-context@1.7.7": - version "1.7.7" - resolved "https://registry.yarnpkg.com/@webassemblyjs/helper-module-context/-/helper-module-context-1.7.7.tgz#f441652ecf4726cd952b9e235e2ce0e3ccd521c9" +"@webassemblyjs/helper-module-context@1.7.8": + version "1.7.8" + resolved "https://registry.yarnpkg.com/@webassemblyjs/helper-module-context/-/helper-module-context-1.7.8.tgz#3c2e7ee93d14ff4768ba66fb1be42fdc9dc7160a" + +"@webassemblyjs/helper-wasm-bytecode@1.7.8": + version "1.7.8" + resolved "https://registry.yarnpkg.com/@webassemblyjs/helper-wasm-bytecode/-/helper-wasm-bytecode-1.7.8.tgz#89bdb78cd6dd5209ae2ed2925de78d0f0e00b6f0" + +"@webassemblyjs/helper-wasm-section@1.7.8": + version "1.7.8" + resolved "https://registry.yarnpkg.com/@webassemblyjs/helper-wasm-section/-/helper-wasm-section-1.7.8.tgz#c68ef7d26a6fc12421b2e6e56f9bc810dfb33e87" dependencies: - mamacro "^0.0.3" + "@webassemblyjs/ast" "1.7.8" + "@webassemblyjs/helper-buffer" "1.7.8" + "@webassemblyjs/helper-wasm-bytecode" "1.7.8" + "@webassemblyjs/wasm-gen" "1.7.8" -"@webassemblyjs/helper-wasm-bytecode@1.7.7": - version "1.7.7" - resolved "https://registry.yarnpkg.com/@webassemblyjs/helper-wasm-bytecode/-/helper-wasm-bytecode-1.7.7.tgz#9699da0b6bf9f48ac40feef66ddc2f9adfa3926a" - -"@webassemblyjs/helper-wasm-section@1.7.7": - version "1.7.7" - resolved "https://registry.yarnpkg.com/@webassemblyjs/helper-wasm-section/-/helper-wasm-section-1.7.7.tgz#13eabdfef67a76dae199bd8407299e50fa591715" - dependencies: - "@webassemblyjs/ast" "1.7.7" - "@webassemblyjs/helper-buffer" "1.7.7" - "@webassemblyjs/helper-wasm-bytecode" "1.7.7" - "@webassemblyjs/wasm-gen" "1.7.7" - -"@webassemblyjs/ieee754@1.7.7": - version "1.7.7" - resolved "https://registry.yarnpkg.com/@webassemblyjs/ieee754/-/ieee754-1.7.7.tgz#1d891f11ba6a70855b8d8713cc7e86359237afb5" +"@webassemblyjs/ieee754@1.7.8": + version "1.7.8" + resolved "https://registry.yarnpkg.com/@webassemblyjs/ieee754/-/ieee754-1.7.8.tgz#1f37974b13cb486a9237e73ce04cac7a2f1265ed" dependencies: "@xtuc/ieee754" "^1.2.0" -"@webassemblyjs/leb128@1.7.7": - version "1.7.7" - resolved "https://registry.yarnpkg.com/@webassemblyjs/leb128/-/leb128-1.7.7.tgz#ea467bf93b708b14fa9734226c5e7036e38e1d4a" +"@webassemblyjs/leb128@1.7.8": + version "1.7.8" + resolved "https://registry.yarnpkg.com/@webassemblyjs/leb128/-/leb128-1.7.8.tgz#1bee83426819192db2ea1a234b84c7ebc6d34c1f" dependencies: "@xtuc/long" "4.2.1" -"@webassemblyjs/utf8@1.7.7": - version "1.7.7" - resolved "https://registry.yarnpkg.com/@webassemblyjs/utf8/-/utf8-1.7.7.tgz#cbbbc2299192eb3ca297573ff1cfe227c966ba0e" +"@webassemblyjs/utf8@1.7.8": + version "1.7.8" + resolved "https://registry.yarnpkg.com/@webassemblyjs/utf8/-/utf8-1.7.8.tgz#2b489d5cf43e0aebb93d8e2d792aff9879c61f05" -"@webassemblyjs/wasm-edit@1.7.7": - version "1.7.7" - resolved "https://registry.yarnpkg.com/@webassemblyjs/wasm-edit/-/wasm-edit-1.7.7.tgz#0777da9fc26c2a97aad9eda9bbb05bacafa6a358" +"@webassemblyjs/wasm-edit@1.7.8": + version "1.7.8" + resolved "https://registry.yarnpkg.com/@webassemblyjs/wasm-edit/-/wasm-edit-1.7.8.tgz#f8bdbe7088718eca27b1c349bb7c06b8a457950c" dependencies: - "@webassemblyjs/ast" "1.7.7" - "@webassemblyjs/helper-buffer" "1.7.7" - "@webassemblyjs/helper-wasm-bytecode" "1.7.7" - "@webassemblyjs/helper-wasm-section" "1.7.7" - "@webassemblyjs/wasm-gen" "1.7.7" - "@webassemblyjs/wasm-opt" "1.7.7" - "@webassemblyjs/wasm-parser" "1.7.7" - "@webassemblyjs/wast-printer" "1.7.7" + "@webassemblyjs/ast" "1.7.8" + "@webassemblyjs/helper-buffer" "1.7.8" + "@webassemblyjs/helper-wasm-bytecode" "1.7.8" + "@webassemblyjs/helper-wasm-section" "1.7.8" + "@webassemblyjs/wasm-gen" "1.7.8" + "@webassemblyjs/wasm-opt" "1.7.8" + "@webassemblyjs/wasm-parser" "1.7.8" + "@webassemblyjs/wast-printer" "1.7.8" -"@webassemblyjs/wasm-gen@1.7.7": - version "1.7.7" - resolved "https://registry.yarnpkg.com/@webassemblyjs/wasm-gen/-/wasm-gen-1.7.7.tgz#7ccbb089c34b60efbf0764b868a461a8d83e5883" +"@webassemblyjs/wasm-gen@1.7.8": + version "1.7.8" + resolved "https://registry.yarnpkg.com/@webassemblyjs/wasm-gen/-/wasm-gen-1.7.8.tgz#7e8abf1545eae74ac6781d545c034af3cfd0c7d5" dependencies: - "@webassemblyjs/ast" "1.7.7" - "@webassemblyjs/helper-wasm-bytecode" "1.7.7" - "@webassemblyjs/ieee754" "1.7.7" - "@webassemblyjs/leb128" "1.7.7" - "@webassemblyjs/utf8" "1.7.7" + "@webassemblyjs/ast" "1.7.8" + "@webassemblyjs/helper-wasm-bytecode" "1.7.8" + "@webassemblyjs/ieee754" "1.7.8" + "@webassemblyjs/leb128" "1.7.8" + "@webassemblyjs/utf8" "1.7.8" -"@webassemblyjs/wasm-opt@1.7.7": - version "1.7.7" - resolved "https://registry.yarnpkg.com/@webassemblyjs/wasm-opt/-/wasm-opt-1.7.7.tgz#a3d692696618be0d823aa2bbaedf72ea6a1b3c95" +"@webassemblyjs/wasm-opt@1.7.8": + version "1.7.8" + resolved "https://registry.yarnpkg.com/@webassemblyjs/wasm-opt/-/wasm-opt-1.7.8.tgz#7ada6e211914728fce02ff0ff9c344edc6d41f26" dependencies: - "@webassemblyjs/ast" "1.7.7" - "@webassemblyjs/helper-buffer" "1.7.7" - "@webassemblyjs/wasm-gen" "1.7.7" - "@webassemblyjs/wasm-parser" "1.7.7" + "@webassemblyjs/ast" "1.7.8" + "@webassemblyjs/helper-buffer" "1.7.8" + "@webassemblyjs/wasm-gen" "1.7.8" + "@webassemblyjs/wasm-parser" "1.7.8" -"@webassemblyjs/wasm-parser@1.7.7": - version "1.7.7" - resolved "https://registry.yarnpkg.com/@webassemblyjs/wasm-parser/-/wasm-parser-1.7.7.tgz#04f34715d3138c1ee937ced679750223bec5b519" +"@webassemblyjs/wasm-parser@1.7.8": + version "1.7.8" + resolved "https://registry.yarnpkg.com/@webassemblyjs/wasm-parser/-/wasm-parser-1.7.8.tgz#dac47c291fb6a3e63529aecd647592cd34afbf94" dependencies: - "@webassemblyjs/ast" "1.7.7" - "@webassemblyjs/helper-api-error" "1.7.7" - "@webassemblyjs/helper-wasm-bytecode" "1.7.7" - "@webassemblyjs/ieee754" "1.7.7" - "@webassemblyjs/leb128" "1.7.7" - "@webassemblyjs/utf8" "1.7.7" + "@webassemblyjs/ast" "1.7.8" + "@webassemblyjs/helper-api-error" "1.7.8" + "@webassemblyjs/helper-wasm-bytecode" "1.7.8" + "@webassemblyjs/ieee754" "1.7.8" + "@webassemblyjs/leb128" "1.7.8" + "@webassemblyjs/utf8" "1.7.8" -"@webassemblyjs/wast-parser@1.7.7": - version "1.7.7" - resolved "https://registry.yarnpkg.com/@webassemblyjs/wast-parser/-/wast-parser-1.7.7.tgz#c7422cd45c124efdd071839919029294b9bf8b23" +"@webassemblyjs/wast-parser@1.7.8": + version "1.7.8" + resolved "https://registry.yarnpkg.com/@webassemblyjs/wast-parser/-/wast-parser-1.7.8.tgz#f8aab9a450c048c1f9537695c89faeb92fabfba5" dependencies: - "@webassemblyjs/ast" "1.7.7" - "@webassemblyjs/floating-point-hex-parser" "1.7.7" - "@webassemblyjs/helper-api-error" "1.7.7" - "@webassemblyjs/helper-code-frame" "1.7.7" - "@webassemblyjs/helper-fsm" "1.7.7" + "@webassemblyjs/ast" "1.7.8" + "@webassemblyjs/floating-point-hex-parser" "1.7.8" + "@webassemblyjs/helper-api-error" "1.7.8" + "@webassemblyjs/helper-code-frame" "1.7.8" + "@webassemblyjs/helper-fsm" "1.7.8" "@xtuc/long" "4.2.1" - mamacro "^0.0.3" -"@webassemblyjs/wast-printer@1.7.7": - version "1.7.7" - resolved "https://registry.yarnpkg.com/@webassemblyjs/wast-printer/-/wast-printer-1.7.7.tgz#2b7df79d0a925b9dcb11447fdebacb4e3a91238c" +"@webassemblyjs/wast-printer@1.7.8": + version "1.7.8" + resolved "https://registry.yarnpkg.com/@webassemblyjs/wast-printer/-/wast-printer-1.7.8.tgz#e7e965782c1912f6a965f14a53ff43d8ad0403a5" dependencies: - "@webassemblyjs/ast" "1.7.7" - "@webassemblyjs/wast-parser" "1.7.7" + "@webassemblyjs/ast" "1.7.8" + "@webassemblyjs/wast-parser" "1.7.8" "@xtuc/long" "4.2.1" "@xtuc/ieee754@^1.2.0": @@ -4051,10 +4047,6 @@ makeerror@1.0.x: dependencies: tmpl "1.0.x" -mamacro@^0.0.3: - version "0.0.3" - resolved "https://registry.yarnpkg.com/mamacro/-/mamacro-0.0.3.tgz#ad2c9576197c9f1abf308d0787865bd975a3f3e4" - map-cache@^0.2.2: version "0.2.2" resolved "https://registry.yarnpkg.com/map-cache/-/map-cache-0.2.2.tgz#c32abd0bd6525d9b051645bb4f26ac5dc98a0dbf" From 22be95d7bfc61f71e707c39e7a0fd47df89fed86 Mon Sep 17 00:00:00 2001 From: Sean Larkin Date: Mon, 7 May 2018 23:04:57 -0500 Subject: [PATCH 08/29] add all declarations files and folder --- declarations/BannerPlugin.d.ts | 47 + declarations/DllPlugin.d.ts | 28 + declarations/DllReferencePlugin.d.ts | 9 + declarations/HashedModuleIdsPlugin.d.ts | 20 + declarations/IgnorePlugin.d.ts | 35 + declarations/LoaderOptionsPlugin.d.ts | 27 + declarations/SourceMapDevToolPlugin.d.ts | 98 ++ declarations/WatchIgnorePlugin.d.ts | 14 + declarations/WebpackOptions.d.ts | 1313 ++++++++++++++++++++++ package.json | 1 + tooling/compile-to-definitions.js | 49 + tsconfig.json | 8 +- yarn.lock | 203 +++- 13 files changed, 1847 insertions(+), 5 deletions(-) create mode 100644 declarations/BannerPlugin.d.ts create mode 100644 declarations/DllPlugin.d.ts create mode 100644 declarations/DllReferencePlugin.d.ts create mode 100644 declarations/HashedModuleIdsPlugin.d.ts create mode 100644 declarations/IgnorePlugin.d.ts create mode 100644 declarations/LoaderOptionsPlugin.d.ts create mode 100644 declarations/SourceMapDevToolPlugin.d.ts create mode 100644 declarations/WatchIgnorePlugin.d.ts create mode 100644 declarations/WebpackOptions.d.ts create mode 100644 tooling/compile-to-definitions.js diff --git a/declarations/BannerPlugin.d.ts b/declarations/BannerPlugin.d.ts new file mode 100644 index 000000000..4b6e51e23 --- /dev/null +++ b/declarations/BannerPlugin.d.ts @@ -0,0 +1,47 @@ +/** + * This file was automatically generated by json-schema-to-typescript. + * DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file, + * and run json-schema-to-typescript to regenerate this file. + */ + +export type BannerPlugin = + | { + /** + * Specifies the banner + */ + banner: + | { + [k: string]: any; + } + | string; + /** + * If true, banner will not be wrapped in a comment + */ + raw?: boolean; + /** + * If true, the banner will only be added to the entry chunks + */ + entryOnly?: boolean; + /** + * Include all modules that pass test assertion + */ + test?: Rules; + /** + * Include all modules matching any of these conditions + */ + include?: Rules; + /** + * Exclude all modules matching any of these conditions + */ + exclude?: Rules; + } + | { + [k: string]: any; + } + | string; +export type Rules = Rule[] | Rule; +export type Rule = + | { + [k: string]: any; + } + | string; diff --git a/declarations/DllPlugin.d.ts b/declarations/DllPlugin.d.ts new file mode 100644 index 000000000..59991cbf9 --- /dev/null +++ b/declarations/DllPlugin.d.ts @@ -0,0 +1,28 @@ +/** + * This file was automatically generated by json-schema-to-typescript. + * DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file, + * and run json-schema-to-typescript to regenerate this file. + */ + +export interface DllPlugin { + /** + * Context of requests in the manifest file (defaults to the webpack context) + */ + context?: string; + /** + * Name of the exposed dll function (external name, use value of 'output.library') + */ + name?: string; + /** + * Type of the dll bundle (external type, use value of 'output.libraryTarget') + */ + type?: string; + /** + * Absolute path to the manifest json file (output) + */ + path: string; + /** + * If true, only entry points will be exposed + */ + entryOnly?: boolean; +} diff --git a/declarations/DllReferencePlugin.d.ts b/declarations/DllReferencePlugin.d.ts new file mode 100644 index 000000000..7635029b3 --- /dev/null +++ b/declarations/DllReferencePlugin.d.ts @@ -0,0 +1,9 @@ +/** + * This file was automatically generated by json-schema-to-typescript. + * DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file, + * and run json-schema-to-typescript to regenerate this file. + */ + +export type DllReferencePlugin = { + [k: string]: any; +}; diff --git a/declarations/HashedModuleIdsPlugin.d.ts b/declarations/HashedModuleIdsPlugin.d.ts new file mode 100644 index 000000000..0784b1419 --- /dev/null +++ b/declarations/HashedModuleIdsPlugin.d.ts @@ -0,0 +1,20 @@ +/** + * This file was automatically generated by json-schema-to-typescript. + * DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file, + * and run json-schema-to-typescript to regenerate this file. + */ + +export interface HashedModuleIdsPlugin { + /** + * The hashing algorithm to use, defaults to 'md5'. All functions from Node.JS' crypto.createHash are supported. + */ + hashFunction?: string; + /** + * The encoding to use when generating the hash, defaults to 'base64'. All encodings from Node.JS' hash.digest are supported. + */ + hashDigest?: "hex" | "latin1" | "base64"; + /** + * The prefix length of the hash digest to use, defaults to 4. + */ + hashDigestLength?: number; +} diff --git a/declarations/IgnorePlugin.d.ts b/declarations/IgnorePlugin.d.ts new file mode 100644 index 000000000..715d02b5b --- /dev/null +++ b/declarations/IgnorePlugin.d.ts @@ -0,0 +1,35 @@ +/** + * This file was automatically generated by json-schema-to-typescript. + * DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file, + * and run json-schema-to-typescript to regenerate this file. + */ + +export type IgnorePlugin = + | { + /** + * A RegExp to test the request against + */ + resourceRegExp?: { + [k: string]: any; + }; + /** + * A RegExp to test the context (directory) against + */ + contextRegExp?: { + [k: string]: any; + }; + } + | { + /** + * A filter function for resource + */ + checkResource?: { + [k: string]: any; + }; + /** + * A filter function for context + */ + checkContext?: { + [k: string]: any; + }; + }; diff --git a/declarations/LoaderOptionsPlugin.d.ts b/declarations/LoaderOptionsPlugin.d.ts new file mode 100644 index 000000000..5d666ff8e --- /dev/null +++ b/declarations/LoaderOptionsPlugin.d.ts @@ -0,0 +1,27 @@ +/** + * This file was automatically generated by json-schema-to-typescript. + * DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file, + * and run json-schema-to-typescript to regenerate this file. + */ + +export interface LoaderOptionsPlugin { + /** + * Whether loaders should be in debug mode or not. debug will be removed as of webpack 3 + */ + debug?: boolean; + /** + * Where loaders can be switched to minimize mode + */ + minimize?: boolean; + /** + * A configuration object that can be used to configure older loaders + */ + options?: { + /** + * The context that can be used to configure older loaders + */ + context?: string; + [k: string]: any; + }; + [k: string]: any; +} diff --git a/declarations/SourceMapDevToolPlugin.d.ts b/declarations/SourceMapDevToolPlugin.d.ts new file mode 100644 index 000000000..e8ecc3049 --- /dev/null +++ b/declarations/SourceMapDevToolPlugin.d.ts @@ -0,0 +1,98 @@ +/** + * This file was automatically generated by json-schema-to-typescript. + * DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file, + * and run json-schema-to-typescript to regenerate this file. + */ + +export type Rules = Rule[] | Rule; +export type Rule = + | { + [k: string]: any; + } + | string; + +export interface SourceMapDevToolPlugin { + /** + * Include source maps for modules based on their extension (defaults to .js and .css) + */ + test?: Rules; + /** + * Include source maps for module paths that match the given value + */ + include?: Rules; + /** + * Exclude modules that match the given value from source map generation + */ + exclude?: Rules; + /** + * Defines the output filename of the SourceMap (will be inlined if no value is provided) + */ + filename?: (false | null) | string; + /** + * Appends the given value to the original asset. Usually the #sourceMappingURL comment. [url] is replaced with a URL to the source map file. false disables the appending + */ + append?: (false | null) | string; + /** + * Generator string or function to create identifiers of modules for the 'sources' array in the SourceMap + */ + moduleFilenameTemplate?: + | { + [k: string]: any; + } + | string; + /** + * Generator string or function to create identifiers of modules for the 'sources' array in the SourceMap used only if 'moduleFilenameTemplate' would result in a conflict + */ + fallbackModuleFilenameTemplate?: + | { + [k: string]: any; + } + | string; + /** + * Namespace prefix to allow multiple webpack roots in the devtools + */ + namespace?: string; + /** + * Indicates whether SourceMaps from loaders should be used (defaults to true) + */ + module?: boolean; + /** + * Indicates whether column mappings should be used (defaults to true) + */ + columns?: boolean; + /** + * Omit the 'sourceContents' array from the SourceMap + */ + noSources?: boolean; + /** + * Provide a custom value for the 'sourceRoot' property in the SourceMap + */ + sourceRoot?: string; + /** + * Provide a custom public path for the SourceMapping comment + */ + publicPath?: string; + /** + * Path prefix to which the [file] placeholder is relative to + */ + fileContext?: string; + /** + * (deprecated) try to map original files line to line to generated files + */ + lineToLine?: + | boolean + | { + /** + * Include source maps for modules based on their extension (defaults to .js and .css) + */ + test?: Rules; + /** + * Include source maps for module paths that match the given value + */ + include?: Rules; + /** + * Exclude modules that match the given value from source map generation + */ + exclude?: Rules; + }; +} diff --git a/declarations/WatchIgnorePlugin.d.ts b/declarations/WatchIgnorePlugin.d.ts new file mode 100644 index 000000000..3dd9727d4 --- /dev/null +++ b/declarations/WatchIgnorePlugin.d.ts @@ -0,0 +1,14 @@ +/** + * This file was automatically generated by json-schema-to-typescript. + * DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file, + * and run json-schema-to-typescript to regenerate this file. + */ + +/** + * A list of RegExps or absolute paths to directories or files that should be ignored + */ +export type WatchIgnorePlugin = ( + | string + | { + [k: string]: any; + })[]; diff --git a/declarations/WebpackOptions.d.ts b/declarations/WebpackOptions.d.ts new file mode 100644 index 000000000..637877b06 --- /dev/null +++ b/declarations/WebpackOptions.d.ts @@ -0,0 +1,1313 @@ +/** + * This file was automatically generated by json-schema-to-typescript. + * DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file, + * and run json-schema-to-typescript to regenerate this file. + */ + +export type Entry = + | { + /** + * An entry point with name + */ + [k: string]: string | CommonNonEmptyArrayOfUniqueStringValues; + } + | string + | CommonNonEmptyArrayOfUniqueStringValues + | { + [k: string]: any; + }; +export type CommonNonEmptyArrayOfUniqueStringValues = string[]; +export type Externals = + | string + | { + /** + * The dependency used for the external + */ + [k: string]: + | string + | { + [k: string]: any; + } + | CommonArrayOfStringValues + | boolean; + } + | { + [k: string]: any; + } + | Externals[]; +export type CommonArrayOfStringValues = string[]; +export type RuleSetCondition = + | { + [k: string]: any; + } + | string + | { + [k: string]: any; + } + | RuleSetConditions + | { + /** + * Logical AND + */ + and?: RuleSetConditions; + /** + * Exclude all modules matching any of these conditions + */ + exclude?: RuleSetCondition; + /** + * Exclude all modules matching not any of these conditions + */ + include?: RuleSetCondition; + /** + * Logical NOT + */ + not?: RuleSetConditions; + /** + * Logical OR + */ + or?: RuleSetConditions; + /** + * Exclude all modules matching any of these conditions + */ + test?: RuleSetCondition; + }; +export type RuleSetConditions = RuleSetCondition[]; +export type RuleSetLoader = string; +export type RuleSetUse = + | RuleSetUseItem + | { + [k: string]: any; + } + | RuleSetUseItem[]; +export type RuleSetUseItem = + | RuleSetLoader + | { + [k: string]: any; + } + | { + /** + * Loader name + */ + loader?: RuleSetLoader; + /** + * Loader options + */ + options?: RuleSetQuery; + /** + * Unique loader identifier + */ + ident?: string; + /** + * Loader query + */ + query?: RuleSetQuery; + }; +export type RuleSetQuery = + | { + [k: string]: any; + } + | string; +export type CommonArrayOfStringOrStringArrayValues = (string | string[])[]; +export type RuleSetRules = RuleSetRule[]; +export type FilterTypes = FilterItemTypes | FilterItemTypes[]; +export type FilterItemTypes = + | { + [k: string]: any; + } + | string; + +export interface WebpackOptions { + /** + * Enable production optimizations or development hints. + */ + mode?: "development" | "production" | "none"; + /** + * Set the value of `require.amd` and `define.amd`. + */ + amd?: { + [k: string]: any; + }; + /** + * Report the first error as a hard error instead of tolerating it. + */ + bail?: boolean; + /** + * Cache generated modules and chunks to improve performance for multiple incremental builds. + */ + cache?: + | boolean + | { + [k: string]: any; + }; + /** + * The base directory (absolute path!) for resolving the `entry` option. If `output.pathinfo` is set, the included pathinfo is shortened to this directory. + */ + context?: string; + /** + * References to other configurations to depend on. + */ + dependencies?: string[]; + /** + * Options for the webpack-dev-server + */ + devServer?: { + [k: string]: any; + }; + /** + * A developer tool to enhance debugging. + */ + devtool?: string | false; + /** + * The entry point(s) of the compilation. + */ + entry?: Entry; + /** + * 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; + /** + * Custom values available in the loader context. + */ + loader?: { + [k: string]: any; + }; + /** + * Options affecting the normal modules (`NormalModuleFactory`). + */ + module?: Module; + /** + * Name of the configuration. Used when loading multiple configurations. + */ + name?: string; + /** + * Include polyfills or mocks for various node stuff. + */ + node?: + | false + | { + /** + * Include a polyfill for the 'Buffer' variable + */ + Buffer?: false | true | "mock"; + /** + * Include a polyfill for the '__dirname' variable + */ + __dirname?: false | true | "mock"; + /** + * Include a polyfill for the '__filename' variable + */ + __filename?: false | true | "mock"; + /** + * Include a polyfill for the 'console' variable + */ + console?: false | true | "mock"; + /** + * Include a polyfill for the 'global' variable + */ + global?: boolean; + /** + * Include a polyfill for the 'process' variable + */ + process?: false | true | "mock"; + /** + * Include a polyfill for the node.js module + */ + [k: string]: false | true | "mock" | "empty"; + }; + /** + * Options affecting the output of the compilation. `output` options tell webpack how to write the compiled files to disk. + */ + output?: Output; + /** + * Enables/Disables integrated optimizations + */ + optimization?: { + /** + * Removes modules from chunks when these modules are already included in all parents + */ + removeAvailableModules?: boolean; + /** + * Remove chunks which are empty + */ + removeEmptyChunks?: boolean; + /** + * Merge chunks which contain the same modules + */ + mergeDuplicateChunks?: boolean; + /** + * Also flag chunks as loaded which contain a subset of the modules + */ + flagIncludedChunks?: boolean; + /** + * Figure out a order of modules which results in the smallest initial bundle + */ + occurrenceOrder?: boolean; + /** + * Skip over modules which are flagged to contain no side effects when exports are not used + */ + sideEffects?: boolean; + /** + * Figure out which exports are provided by modules to generate more efficient code + */ + providedExports?: boolean; + /** + * Figure out which exports are used by modules to mangle export names, omit unused exports and generate more efficient code + */ + usedExports?: boolean; + /** + * Concatenate modules when possible to generate less modules, more efficient code and enable more optimizations by the minimizer + */ + concatenateModules?: boolean; + /** + * Optimize duplication and caching by splitting chunks by shared modules and cache group + */ + splitChunks?: + | false + | { + /** + * Select chunks for determining shared modules (defaults to "async", "initial" and "all" requires adding these chunks to the HTML) + */ + chunks?: + | ("initial" | "async" | "all") + | { + [k: string]: any; + }; + /** + * Minimal size for the created chunks + */ + minSize?: number; + /** + * Maximal size hint for the created chunks + */ + maxSize?: number; + /** + * Minimum number of times a module has to be duplicated until it's considered for splitting + */ + minChunks?: number; + /** + * Maximum number of requests which are accepted for on-demand loading + */ + maxAsyncRequests?: number; + /** + * Maximum number of initial chunks which are accepted for an entry point + */ + maxInitialRequests?: number; + /** + * Give chunks created a name (chunks with equal name are merged) + */ + name?: + | boolean + | { + [k: string]: any; + } + | string; + /** + * Sets the template for the filename for created chunks (Only works for initial chunks) + */ + filename?: string; + /** + * Sets the name delimiter for created chunks + */ + automaticNameDelimiter?: string; + /** + * Prevents exposing path info when creating names for parts splitted by maxSize + */ + hidePathInfo?: boolean; + /** + * Options for modules not selected by any other cache group + */ + fallbackCacheGroup?: { + /** + * Minimal size for the created chunk + */ + minSize?: number; + /** + * Maximal size hint for the created chunks + */ + maxSize?: number; + /** + * Sets the name delimiter for created chunks + */ + automaticNameDelimiter?: string; + }; + /** + * Assign modules to a cache group (modules from different cache groups are tried to keep in separate chunks) + */ + cacheGroups?: { + /** + * Configuration for a cache group + */ + [k: string]: + | false + | { + [k: string]: any; + } + | string + | { + /** + * Assign modules to a cache group + */ + test?: + | { + [k: string]: any; + } + | string; + /** + * Select chunks for determining cache group content (defaults to "initial", "initial" and "all" requires adding these chunks to the HTML) + */ + chunks?: + | ("initial" | "async" | "all") + | { + [k: string]: any; + }; + /** + * Ignore minimum size, minimum chunks and maximum requests and always create chunks for this cache group + */ + enforce?: boolean; + /** + * Priority of this cache group + */ + priority?: number; + /** + * Minimal size for the created chunk + */ + minSize?: number; + /** + * Maximal size hint for the created chunks + */ + maxSize?: number; + /** + * Minimum number of times a module has to be duplicated until it's considered for splitting + */ + minChunks?: number; + /** + * Maximum number of requests which are accepted for on-demand loading + */ + maxAsyncRequests?: number; + /** + * Maximum number of initial chunks which are accepted for an entry point + */ + maxInitialRequests?: number; + /** + * Try to reuse existing chunk (with name) when it has matching modules + */ + reuseExistingChunk?: boolean; + /** + * Give chunks for this cache group a name (chunks with equal name are merged) + */ + name?: + | boolean + | { + [k: string]: any; + } + | string; + /** + * Sets the name delimiter for created chunks + */ + automaticNameDelimiter?: string; + /** + * Sets the name prefix for created chunks + */ + automaticNamePrefix?: string; + /** + * Sets the template for the filename for created chunks (Only works for initial chunks) + */ + filename?: string; + }; + }; + }; + /** + * Create an additional chunk which contains only the webpack runtime and chunk hash maps + */ + runtimeChunk?: + | boolean + | ("single" | "multiple") + | { + /** + * The name or name factory for the runtime chunks + */ + name?: + | string + | { + [k: string]: any; + }; + }; + /** + * Avoid emitting assets when errors occur + */ + noEmitOnErrors?: boolean; + /** + * Check for incompatible wasm types when importing/exporting from/to ESM + */ + checkWasmTypes?: boolean; + /** + * Reduce size of WASM by changing imports to shorter strings. + */ + mangleWasmImports?: boolean; + /** + * Define the algorithm to choose module ids (natural: numeric ids in order of usage, named: readable ids for better debugging, hashed: short hashes as ids for better long term caching, size: numeric ids focused on minimal initial download size, total-size: numeric ids focused on minimal total download size, false: no algorithm used, as custom one can be provided via plugin) + */ + moduleIds?: "natural" | "named" | "hashed" | "size" | "total-size" | false; + /** + * Define the algorithm to choose chunk ids (named: readable ids for better debugging, size: numeric ids focused on minimal initial download size, total-size: numeric ids focused on minimal total download size, false: no algorithm used, as custom one can be provided via plugin) + */ + chunkIds?: "natural" | "named" | "size" | "total-size" | false; + /** + * Use readable module identifiers for better debugging (deprecated, used moduleIds: named instead) + */ + namedModules?: boolean; + /** + * Use hashed module id instead module identifiers for better long term caching (deprecated, used moduleIds: hashed instead) + */ + hashedModuleIds?: boolean; + /** + * Use readable chunk identifiers for better debugging (deprecated, used chunkIds: named instead) + */ + namedChunks?: boolean; + /** + * Generate records with relative paths to be able to move the context folder + */ + portableRecords?: boolean; + /** + * Enable minimizing the output. Uses optimization.minimizer. + */ + minimize?: boolean; + /** + * Minimizer(s) to use for minimizing the output + */ + minimizer?: (CommonPluginObject | CommonPluginFunction)[]; + /** + * Set process.env.NODE_ENV to a specific value + */ + nodeEnv?: false | string; + }; + /** + * The number of parallel processed modules in the compilation. + */ + parallelism?: number; + /** + * Configuration for web performance recommendations. + */ + performance?: + | false + | { + /** + * Filter function to select assets that are checked + */ + assetFilter?: { + [k: string]: any; + }; + /** + * Sets the format of the hints: warnings, errors or nothing at all + */ + hints?: false | "warning" | "error"; + /** + * Total size of an entry point (in bytes) + */ + maxEntrypointSize?: number; + /** + * Filesize limit (in bytes) when exceeded, that webpack will provide performance hints + */ + maxAssetSize?: number; + }; + /** + * Add additional plugins to the compiler. + */ + plugins?: (CommonPluginObject | CommonPluginFunction)[]; + /** + * Capture timing information for each module. + */ + profile?: boolean; + /** + * Store compiler state to a json file. + */ + recordsInputPath?: string; + /** + * Load compiler state from a json file. + */ + recordsOutputPath?: 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. + */ + recordsPath?: string; + /** + * Options for the resolver + */ + resolve?: Resolve; + /** + * Options for the resolver when resolving loaders + */ + resolveLoader?: Resolve; + /** + * Options for webpack-serve + */ + serve?: { + [k: string]: any; + }; + /** + * Used by the webpack CLI program to pass stats options. + */ + stats?: + | { + /** + * fallback value for stats options when an option is not defined (has precedence over local webpack defaults) + */ + all?: boolean; + /** + * context directory for request shortening + */ + context?: string; + /** + * add the hash of the compilation + */ + hash?: boolean; + /** + * add webpack version information + */ + version?: boolean; + /** + * add timing information + */ + timings?: boolean; + /** + * add built at time information + */ + builtAt?: boolean; + /** + * add performance hint flags + */ + performance?: boolean; + /** + * add module depth in module graph + */ + depth?: boolean; + /** + * add assets information + */ + assets?: boolean; + /** + * add --env information + */ + env?: boolean; + /** + * Enables/Disables colorful output + */ + colors?: + | boolean + | { + /** + * Custom color for bold text + */ + bold?: string; + /** + * Custom color for red text + */ + red?: string; + /** + * Custom color for green text + */ + green?: string; + /** + * Custom color for cyan text + */ + cyan?: string; + /** + * Custom color for magenta text + */ + magenta?: string; + /** + * Custom color for yellow text + */ + yellow?: string; + }; + /** + * Set the maximum number of modules to be shown + */ + maxModules?: number; + /** + * add chunk information + */ + chunks?: boolean; + /** + * add built modules information to chunk information + */ + chunkModules?: boolean; + /** + * add built modules information + */ + modules?: boolean; + /** + * add information about modules nested in other modules (like with module concatenation) + */ + nestedModules?: boolean; + /** + * add information about assets inside modules + */ + moduleAssets?: boolean; + /** + * add children information + */ + children?: boolean; + /** + * add also information about cached (not built) modules + */ + cached?: boolean; + /** + * Show cached assets (setting this to `false` only shows emitted files) + */ + cachedAssets?: boolean; + /** + * add information about the reasons why modules are included + */ + reasons?: boolean; + /** + * add the source code of modules + */ + source?: boolean; + /** + * add warnings + */ + warnings?: boolean; + /** + * add errors + */ + errors?: boolean; + /** + * Suppress warnings that match the specified filters. Filters can be Strings, RegExps or Functions + */ + warningsFilter?: FilterTypes; + /** + * Suppress assets that match the specified filters. Filters can be Strings, RegExps or Functions + */ + excludeAssets?: FilterTypes; + /** + * Suppress modules that match the specified filters. Filters can be Strings, RegExps, Booleans or Functions + */ + excludeModules?: FilterTypes | boolean; + /** + * Please use excludeModules instead. + */ + exclude?: FilterTypes | boolean; + /** + * Display the entry points with the corresponding bundles + */ + entrypoints?: boolean; + /** + * Display all chunk groups with the corresponding bundles + */ + chunkGroups?: boolean; + /** + * add details to errors (like resolving log) + */ + errorDetails?: boolean; + /** + * add the origins of chunks and chunk merging info + */ + chunkOrigins?: boolean; + /** + * sort the modules by that field + */ + modulesSort?: string; + /** + * add dependencies and origin of warnings/errors + */ + moduleTrace?: boolean; + /** + * sort the chunks by that field + */ + chunksSort?: string; + /** + * sort the assets by that field + */ + assetsSort?: string; + /** + * Add public path information + */ + publicPath?: boolean; + /** + * Add output path information + */ + outputPath?: boolean; + /** + * show exports provided by modules + */ + providedExports?: boolean; + /** + * show exports used by modules + */ + usedExports?: boolean; + /** + * show reasons why optimization bailed out for modules + */ + optimizationBailout?: boolean; + } + | boolean + | ("none" | "errors-only" | "minimal" | "normal" | "detailed" | "verbose"); + /** + * Environment to build for + */ + target?: + | ( + | "web" + | "webworker" + | "node" + | "async-node" + | "node-webkit" + | "electron-main" + | "electron-renderer") + | { + [k: string]: any; + }; + /** + * Enter watch mode, which rebuilds on file change. + */ + watch?: boolean; + /** + * Options for the watcher + */ + watchOptions?: { + /** + * Delay the rebuilt after the first change. Value is a time in ms. + */ + aggregateTimeout?: number; + /** + * Ignore some files from watching + */ + ignored?: { + [k: string]: any; + }; + /** + * Stop watching when stdin stream has ended + */ + stdin?: boolean; + /** + * Enable polling mode for watching + */ + poll?: boolean | number; + }; +} +export interface Module { + /** + * Enable warnings for full dynamic dependencies + */ + exprContextCritical?: boolean; + /** + * Enable recursive directory lookup for full dynamic dependencies + */ + exprContextRecursive?: boolean; + /** + * Sets the default regular expression for full dynamic dependencies + */ + exprContextRegExp?: + | boolean + | { + [k: string]: any; + }; + /** + * Set the default request for full dynamic dependencies + */ + exprContextRequest?: string; + /** + * Don't parse files matching. It's matched against the full resolved request. + */ + noParse?: + | { + [k: string]: any; + }[] + | { + [k: string]: any; + } + | string[] + | string; + /** + * An array of rules applied for modules. + */ + rules?: RuleSetRules; + /** + * An array of rules applied by default for modules. + */ + defaultRules?: RuleSetRules; + /** + * Enable warnings when using the require function in a not statically analyse-able way + */ + unknownContextCritical?: boolean; + /** + * Enable recursive directory lookup when using the require function in a not statically analyse-able way + */ + unknownContextRecursive?: boolean; + /** + * Sets the regular expression when using the require function in a not statically analyse-able way + */ + unknownContextRegExp?: + | boolean + | { + [k: string]: any; + }; + /** + * Sets the request when using the require function in a not statically analyse-able way + */ + unknownContextRequest?: string; + /** + * Cache the resolving of module requests + */ + unsafeCache?: + | boolean + | { + [k: string]: any; + }; + /** + * Enable warnings for partial dynamic dependencies + */ + wrappedContextCritical?: boolean; + /** + * Enable recursive directory lookup for partial dynamic dependencies + */ + wrappedContextRecursive?: boolean; + /** + * Set the inner regular expression for partial dynamic dependencies + */ + wrappedContextRegExp?: { + [k: string]: any; + }; + /** + * Emit errors instead of warnings when imported names don't exist in imported module + */ + strictExportPresence?: boolean; + /** + * Handle the this context correctly according to the spec for namespace objects + */ + strictThisContextOnImports?: boolean; +} +export interface RuleSetRule { + /** + * Enforce this rule as pre or post step + */ + enforce?: "pre" | "post"; + /** + * Shortcut for resource.exclude + */ + exclude?: RuleSetCondition & { + [k: string]: any; + }; + /** + * Shortcut for resource.include + */ + include?: RuleSetCondition & { + [k: string]: any; + }; + /** + * Match the issuer of the module (The module pointing to this module) + */ + issuer?: RuleSetCondition & { + [k: string]: any; + }; + /** + * Shortcut for use.loader + */ + loader?: RuleSetLoader | RuleSetUse; + /** + * Shortcut for use.loader + */ + loaders?: RuleSetUse; + /** + * Only execute the first matching rule in this array + */ + oneOf?: RuleSetRules; + /** + * Shortcut for use.options + */ + options?: RuleSetQuery; + /** + * Options for parsing + */ + parser?: { + [k: string]: any; + }; + /** + * Options for the resolver + */ + resolve?: Resolve; + /** + * Flags a module as with or without side effects + */ + sideEffects?: boolean; + /** + * Shortcut for use.query + */ + query?: RuleSetQuery; + /** + * Module type to use for the module + */ + type?: + | "javascript/auto" + | "javascript/dynamic" + | "javascript/esm" + | "json" + | "webassembly/experimental"; + /** + * Match the resource path of the module + */ + resource?: RuleSetCondition & { + [k: string]: any; + }; + /** + * Match the resource query of the module + */ + resourceQuery?: RuleSetCondition; + /** + * Match the child compiler name + */ + compiler?: RuleSetCondition; + /** + * Match and execute these rules when this rule is matched + */ + rules?: RuleSetRules; + /** + * Shortcut for resource.test + */ + test?: RuleSetCondition & { + [k: string]: any; + }; + /** + * Modifiers applied to the module when rule is matched + */ + use?: RuleSetUse; +} +export interface Resolve { + /** + * Redirect module requests + */ + alias?: + | { + /** + * New request + */ + [k: string]: string; + } + | { + /** + * New request + */ + alias?: string; + /** + * Request to be redirected + */ + name?: string; + /** + * Redirect only exact matching request + */ + onlyModule?: boolean; + }[]; + /** + * Fields in the description file (package.json) which are used to redirect requests inside the module + */ + aliasFields?: CommonArrayOfStringOrStringArrayValues; + /** + * Predicate function to decide which requests should be cached + */ + cachePredicate?: { + [k: string]: any; + }; + /** + * Include the context information in the cache identifier when caching + */ + cacheWithContext?: boolean; + /** + * Filenames used to find a description file + */ + descriptionFiles?: CommonArrayOfStringValues; + /** + * Enforce using one of the extensions from the extensions option + */ + enforceExtension?: boolean; + /** + * Enforce using one of the module extensions from the moduleExtensions option + */ + enforceModuleExtension?: boolean; + /** + * Extensions added to the request when trying to find the file + */ + extensions?: CommonArrayOfStringValues; + /** + * Filesystem for the resolver + */ + fileSystem?: { + [k: string]: any; + }; + /** + * Field names from the description file (package.json) which are used to find the default entry point + */ + mainFields?: CommonArrayOfStringOrStringArrayValues; + /** + * Filenames used to find the default entry point if there is no description file or main field + */ + mainFiles?: CommonArrayOfStringValues; + /** + * Extensions added to the module request when trying to find the module + */ + moduleExtensions?: CommonArrayOfStringValues; + /** + * Folder names or directory paths where to find modules + */ + modules?: CommonArrayOfStringValues; + /** + * Plugins for the resolver + */ + plugins?: (CommonPluginObject | CommonPluginFunction)[]; + /** + * Custom resolver + */ + resolver?: { + [k: string]: any; + }; + /** + * Enable resolving symlinks to the original location + */ + symlinks?: boolean; + /** + * Enable concord resolving extras + */ + concord?: boolean; + /** + * Enable caching of successfully resolved requests + */ + unsafeCache?: + | boolean + | { + [k: string]: any; + }; + /** + * Use synchronous filesystem calls for the resolver + */ + useSyncFileSystemCalls?: boolean; +} +/** + * Plugin instance + */ +export interface CommonPluginObject { + /** + * The run point of the plugin, required method. + */ + apply: { + [k: string]: any; + }; + [k: string]: any; +} +/** + * Function acting as plugin + */ +export interface CommonPluginFunction { + /** + * The run point of the plugin, required method. + */ + apply: { + [k: string]: any; + }; + [k: string]: any; +} +export interface Output { + /** + * Add a comment in the UMD wrapper. + */ + auxiliaryComment?: + | string + | { + /** + * Set comment for `amd` section in UMD + */ + amd?: string; + /** + * Set comment for `commonjs` (exports) section in UMD + */ + commonjs?: string; + /** + * Set comment for `commonjs2` (module.exports) section in UMD + */ + commonjs2?: string; + /** + * Set comment for `root` (global variable) section in UMD + */ + root?: string; + }; + /** + * The filename of non-entry chunks as relative path inside the `output.path` directory. + */ + chunkFilename?: string; + /** + * The filename of WebAssembly modules as relative path inside the `output.path` directory. + */ + webassemblyModuleFilename?: string; + /** + * An expression which is used to address the global object/scope in runtime code + */ + globalObject?: string; + /** + * This option enables cross-origin loading of chunks. + */ + crossOriginLoading?: false | "anonymous" | "use-credentials"; + /** + * This option enables loading async chunks via a custom script type, such as script type="module" + */ + jsonpScriptType?: false | "text/javascript" | "module"; + /** + * Number of milliseconds before chunk request expires + */ + chunkLoadTimeout?: number; + /** + * Similar to `output.devtoolModuleFilenameTemplate`, but used in the case of duplicate module identifiers. + */ + devtoolFallbackModuleFilenameTemplate?: + | string + | { + [k: string]: any; + }; + /** + * Enable line to line mapped mode for all/specified modules. Line to line mapped mode uses a simple SourceMap where each line of the generated source is mapped to the same line of the original source. It’s a performance optimization. Only use it if your performance need to be better and you are sure that input lines match which generated lines. + */ + devtoolLineToLine?: + | boolean + | { + [k: string]: any; + }; + /** + * Filename template string of function for the sources array in a generated SourceMap. + */ + devtoolModuleFilenameTemplate?: + | string + | { + [k: string]: any; + }; + /** + * Module namespace to use when interpolating filename template string for the sources array in a generated SourceMap. Defaults to `output.library` if not set. It's useful for avoiding runtime collisions in sourcemaps from multiple webpack projects built as libraries. + */ + devtoolNamespace?: string; + /** + * Specifies the name of each output file on disk. You must **not** specify an absolute path here! The `output.path` option determines the location on disk the files are written to, filename is used solely for naming the individual files. + */ + filename?: + | string + | { + [k: string]: any; + }; + /** + * Digest type used for the hash + */ + hashDigest?: string; + /** + * Number of chars which are used for the hash + */ + hashDigestLength?: number; + /** + * Algorithm used for generation the hash (see node.js crypto package) + */ + hashFunction?: + | string + | { + [k: string]: any; + }; + /** + * Any string which is added to the hash to salt it + */ + hashSalt?: string; + /** + * The filename of the Hot Update Chunks. They are inside the output.path directory. + */ + hotUpdateChunkFilename?: + | string + | { + [k: string]: any; + }; + /** + * The JSONP function used by webpack for async loading of hot update chunks. + */ + hotUpdateFunction?: string; + /** + * The filename of the Hot Update Main File. It is inside the `output.path` directory. + */ + hotUpdateMainFilename?: + | string + | { + [k: string]: any; + }; + /** + * The JSONP function used by webpack for async loading of chunks. + */ + jsonpFunction?: string; + /** + * The callback function name used by webpack for loading of chunks in WebWorkers. + */ + chunkCallbackName?: string; + /** + * If set, export the bundle as library. `output.library` is the name. + */ + library?: + | string + | string[] + | { + /** + * Name of the property exposed globally by a UMD library + */ + root?: string | CommonArrayOfStringValues; + /** + * Name of the exposed AMD library in the UMD + */ + amd?: string; + /** + * Name of the exposed commonjs export in the UMD + */ + commonjs?: string; + }; + /** + * Type of library + */ + libraryTarget?: + | "var" + | "assign" + | "this" + | "window" + | "self" + | "global" + | "commonjs" + | "commonjs2" + | "commonjs-module" + | "amd" + | "umd" + | "umd2" + | "jsonp"; + /** + * Specify which export should be exposed as library + */ + libraryExport?: string | CommonArrayOfStringValues; + /** + * The output directory as **absolute path** (required). + */ + path?: string; + /** + * Include comments with information about the modules. + */ + pathinfo?: boolean; + /** + * The `publicPath` specifies the public URL address of the output files when referenced in a browser. + */ + publicPath?: + | string + | { + [k: string]: any; + }; + /** + * The filename of the SourceMaps for the JavaScript files. They are inside the `output.path` directory. + */ + sourceMapFilename?: string; + /** + * Prefixes every line of the source in the bundle with this string. + */ + sourcePrefix?: string; + /** + * Handles exceptions in module loading correctly at a performance cost. + */ + strictModuleExceptionHandling?: boolean; + /** + * If `output.libraryTarget` is set to umd and `output.library` is set, setting this to true will name the AMD module. + */ + umdNamedDefine?: boolean; +} diff --git a/package.json b/package.json index d24084eef..45856ac25 100644 --- a/package.json +++ b/package.json @@ -17,6 +17,7 @@ "enhanced-resolve": "^4.1.0", "eslint-scope": "^4.0.0", "json-parse-better-errors": "^1.0.2", + "json-schema-to-typescript": "^5.7.0", "loader-runner": "^2.3.0", "loader-utils": "^1.1.0", "memory-fs": "~0.4.1", diff --git a/tooling/compile-to-definitions.js b/tooling/compile-to-definitions.js new file mode 100644 index 000000000..f7f9e2753 --- /dev/null +++ b/tooling/compile-to-definitions.js @@ -0,0 +1,49 @@ +const fs = require("fs"); +const path = require("path"); +const style = require("../.prettierrc.js"); // eslint-disable-line +const { compileFromFile } = require("json-schema-to-typescript"); +const schemasDir = path.resolve(__dirname, "../schemas"); + +const makeSchemas = () => { + // include the top level folder "./schemas" by default + const dirs = [schemasDir]; + + // search for all nestedDirs inside of this folder + // TODO: Although I don't think it makes sense at all to ever have nested folders here, (just one level deep) + // this should technically have recursive handling for those nested folers + for (let dir of fs.readdirSync(schemasDir)) { + const absDirPath = path.resolve(schemasDir, dir); + console.log(dir, schemasDir); + if (fs.statSync(absDirPath).isDirectory()) { + dirs.push(absDirPath); + } + } + + for (let dirWithSchemas of dirs) { + processSchemasInDir(dirWithSchemas); + } +}; + +const processSchemasInDir = absDirPath => { + const schemas = fs + .readdirSync(absDirPath) + .filter(name => name.endsWith(".json")) + .map(name => ({ + fileName: name.split(".")[0], + name: path.resolve(absDirPath, name) + })); + for (let { fileName, name } of schemas) { + makeDefinitionsForSchema(fileName, path.resolve(absDirPath, name)); + } +}; + +const makeDefinitionsForSchema = (fileName, absSchemaPath) => { + compileFromFile(absSchemaPath, { style }).then(ts => { + fs.writeFileSync( + path.resolve(__dirname, `../declarations/${fileName}.d.ts`), + ts + ); + }); +}; + +makeSchemas(); diff --git a/tsconfig.json b/tsconfig.json index e94475dc7..3df37338c 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -12,5 +12,11 @@ "types": ["node"], "esModuleInterop": true }, - "include": ["declarations.d.ts", "bin/*.js", "lib/**/*.js", "tooling/**/*.js"] + "include": [ + "declarations.d.ts", + "declarations/*.d.ts", + "bin/*.js", + "lib/**/*.js", + "tooling/**/*.js" + ] } diff --git a/yarn.lock b/yarn.lock index d01935674..aa7cddfd8 100644 --- a/yarn.lock +++ b/yarn.lock @@ -32,14 +32,44 @@ dependencies: "@types/babel-types" "*" +"@types/cli-color@^0.3.29": + version "0.3.29" + resolved "https://registry.yarnpkg.com/@types/cli-color/-/cli-color-0.3.29.tgz#c83a71fe02c8c7e1ccec048dd6a2458d1f6c96ea" + +"@types/json-schema@^7.0.0": + version "7.0.0" + resolved "https://registry.yarnpkg.com/@types/json-schema/-/json-schema-7.0.0.tgz#5a2b780fec9f2cf851e1b5e0a29a4cac6c9686c5" + +"@types/lodash@^4.14.116": + version "4.14.116" + resolved "https://registry.yarnpkg.com/@types/lodash/-/lodash-4.14.116.tgz#5ccf215653e3e8c786a58390751033a9adca0eb9" + +"@types/minimist@^1.2.0": + version "1.2.0" + resolved "https://registry.yarnpkg.com/@types/minimist/-/minimist-1.2.0.tgz#69a23a3ad29caf0097f06eda59b361ee2f0639f6" + +"@types/mz@0.0.32": + version "0.0.32" + resolved "https://registry.yarnpkg.com/@types/mz/-/mz-0.0.32.tgz#e8248b4e41424c052edc1725dd33650c313a3659" + dependencies: + "@types/node" "*" + "@types/node@*": version "10.5.1" resolved "https://registry.yarnpkg.com/@types/node/-/node-10.5.1.tgz#d578446f4abff5c0b49ade9b4e5274f6badaadfc" +"@types/node@^10.9.4": + version "10.10.1" + resolved "https://registry.yarnpkg.com/@types/node/-/node-10.10.1.tgz#d5c96ca246a418404914d180b7fdd625ad18eca6" + "@types/node@^9.6.4": version "9.6.30" resolved "https://registry.yarnpkg.com/@types/node/-/node-9.6.30.tgz#1ecf83eaf7ac2d0dada7a9d61a1e4e7a6183ac06" +"@types/prettier@^1.13.2": + version "1.13.2" + resolved "https://registry.yarnpkg.com/@types/prettier/-/prettier-1.13.2.tgz#ffe96278e712a8d4e467e367a338b05e22872646" + "@types/source-list-map@*": version "0.1.2" resolved "https://registry.yarnpkg.com/@types/source-list-map/-/source-list-map-0.1.2.tgz#0078836063ffaf17412349bba364087e0ac02ec9" @@ -319,7 +349,7 @@ ansi-escapes@^3.0.0: version "3.1.0" resolved "https://registry.yarnpkg.com/ansi-escapes/-/ansi-escapes-3.1.0.tgz#f73207bb81207d75fd6c83f125af26eea378ca30" -ansi-regex@^2.0.0: +ansi-regex@^2.0.0, ansi-regex@^2.1.1: version "2.1.1" resolved "https://registry.yarnpkg.com/ansi-regex/-/ansi-regex-2.1.1.tgz#c3b33ab5ee360d86e0e628f0468ae7ef27d654df" @@ -341,6 +371,10 @@ any-observable@^0.3.0: version "0.3.0" resolved "https://registry.yarnpkg.com/any-observable/-/any-observable-0.3.0.tgz#af933475e5806a67d0d7df090dd5e8bef65d119b" +any-promise@^1.0.0: + version "1.3.0" + resolved "https://registry.yarnpkg.com/any-promise/-/any-promise-1.3.0.tgz#abc6afeedcea52e809cdc0376aed3ce39635d17f" + anymatch@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/anymatch/-/anymatch-2.0.0.tgz#bcb24b4f37934d9aa7ac17b4adaf89e7c76ef2eb" @@ -889,6 +923,10 @@ cache-base@^1.0.1: union-value "^1.0.0" unset-value "^1.0.0" +call-me-maybe@^1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/call-me-maybe/-/call-me-maybe-1.0.1.tgz#26d208ea89e37b5cbde60250a15f031c16a4d66b" + caller-path@^0.1.0: version "0.1.0" resolved "https://registry.yarnpkg.com/caller-path/-/caller-path-0.1.0.tgz#94085ef63581ecd3daa92444a8fe94e82577751f" @@ -1056,6 +1094,17 @@ clean-css@^4.1.11: dependencies: source-map "0.5.x" +cli-color@^1.3.0: + version "1.3.0" + resolved "https://registry.yarnpkg.com/cli-color/-/cli-color-1.3.0.tgz#cd2ec212efbd1a0eeb5b017f17d4e2d15e91420f" + dependencies: + ansi-regex "^2.1.1" + d "1" + es5-ext "^0.10.46" + es6-iterator "^2.0.3" + memoizee "^0.4.14" + timers-ext "^0.1.5" + cli-cursor@^1.0.2: version "1.0.2" resolved "https://registry.yarnpkg.com/cli-cursor/-/cli-cursor-1.0.2.tgz#64da3f7d56a54412e59794bd62dc35295e8f2987" @@ -1533,6 +1582,12 @@ cyclist@~0.2.2: version "0.2.2" resolved "https://registry.yarnpkg.com/cyclist/-/cyclist-0.2.2.tgz#1b33792e11e914a2fd6d6ed6447464444e5fa640" +d@1: + version "1.0.0" + resolved "https://registry.yarnpkg.com/d/-/d-1.0.0.tgz#754bb5bfe55451da69a58b94d45f4c5b0462d58f" + dependencies: + es5-ext "^0.10.9" + dashdash@^1.12.0: version "1.14.1" resolved "https://registry.yarnpkg.com/dashdash/-/dashdash-1.14.1.tgz#853cfa0f7cbe2fed5de20326b8dd581035f6e2f0" @@ -1808,10 +1863,42 @@ es-to-primitive@^1.1.1: is-date-object "^1.0.1" is-symbol "^1.0.1" +es5-ext@^0.10.14, es5-ext@^0.10.35, es5-ext@^0.10.45, es5-ext@^0.10.46, es5-ext@^0.10.9, es5-ext@~0.10.14, es5-ext@~0.10.2: + version "0.10.46" + resolved "https://registry.yarnpkg.com/es5-ext/-/es5-ext-0.10.46.tgz#efd99f67c5a7ec789baa3daa7f79870388f7f572" + dependencies: + es6-iterator "~2.0.3" + es6-symbol "~3.1.1" + next-tick "1" + +es6-iterator@^2.0.1, es6-iterator@^2.0.3, es6-iterator@~2.0.3: + version "2.0.3" + resolved "https://registry.yarnpkg.com/es6-iterator/-/es6-iterator-2.0.3.tgz#a7de889141a05a94b0854403b2d0a0fbfa98f3b7" + dependencies: + d "1" + es5-ext "^0.10.35" + es6-symbol "^3.1.1" + es6-promise-polyfill@^1.1.1: version "1.2.0" resolved "https://registry.yarnpkg.com/es6-promise-polyfill/-/es6-promise-polyfill-1.2.0.tgz#f38925f23cb3e3e8ce6cda8ff774fcebbb090cde" +es6-symbol@^3.1.1, es6-symbol@~3.1.1: + version "3.1.1" + resolved "https://registry.yarnpkg.com/es6-symbol/-/es6-symbol-3.1.1.tgz#bf00ef4fdab6ba1b46ecb7b629b4c7ed5715cc77" + dependencies: + d "1" + es5-ext "~0.10.14" + +es6-weak-map@^2.0.2: + version "2.0.2" + resolved "https://registry.yarnpkg.com/es6-weak-map/-/es6-weak-map-2.0.2.tgz#5e3ab32251ffd1538a1f8e5ffa1357772f92d96f" + dependencies: + d "1" + es5-ext "^0.10.14" + es6-iterator "^2.0.1" + es6-symbol "^3.1.1" + escape-html@~1.0.3: version "1.0.3" resolved "https://registry.yarnpkg.com/escape-html/-/escape-html-1.0.3.tgz#0258eae4d3d0c0974de1c169188ef0051d1d1988" @@ -1982,6 +2069,13 @@ etag@~1.7.0: version "1.7.0" resolved "https://registry.yarnpkg.com/etag/-/etag-1.7.0.tgz#03d30b5f67dd6e632d2945d30d6652731a34d5d8" +event-emitter@^0.3.5: + version "0.3.5" + resolved "https://registry.yarnpkg.com/event-emitter/-/event-emitter-0.3.5.tgz#df8c69eef1647923c7157b9ce83840610b02cc39" + dependencies: + d "1" + es5-ext "~0.10.14" + events@^1.0.0: version "1.1.1" resolved "https://registry.yarnpkg.com/events/-/events-1.1.1.tgz#9ebdb7635ad099c70dcc4c2a1f5004288e8bd924" @@ -2335,6 +2429,10 @@ form-data@~2.3.1: combined-stream "1.0.6" mime-types "^2.1.12" +format-util@^1.0.3: + version "1.0.3" + resolved "https://registry.yarnpkg.com/format-util/-/format-util-1.0.3.tgz#032dca4a116262a12c43f4c3ec8566416c5b2d95" + forwarded@~0.1.0: version "0.1.2" resolved "https://registry.yarnpkg.com/forwarded/-/forwarded-0.1.2.tgz#98c23dab1175657b8c0573e8ceccd91b0ff18c84" @@ -3089,7 +3187,7 @@ is-primitive@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/is-primitive/-/is-primitive-2.0.0.tgz#207bab91638499c07b2adf240a41a87210034575" -is-promise@^2.0.0, is-promise@^2.1.0: +is-promise@^2.0.0, is-promise@^2.1, is-promise@^2.1.0: version "2.1.0" resolved "https://registry.yarnpkg.com/is-promise/-/is-promise-2.1.0.tgz#79a2a9ece7f096e80f36d2b2f3bc16c1ff4bf3fa" @@ -3639,7 +3737,7 @@ js-yaml@3.x, js-yaml@^3.9.0: argparse "^1.0.7" esprima "^4.0.0" -js-yaml@^3.11.0, js-yaml@^3.7.0: +js-yaml@^3.11.0, js-yaml@^3.12.0, js-yaml@^3.7.0: version "3.12.0" resolved "https://registry.yarnpkg.com/js-yaml/-/js-yaml-3.12.0.tgz#eaed656ec8344f10f527c6bfa1b6e2244de167d1" dependencies: @@ -3704,6 +3802,35 @@ json-parse-better-errors@^1.0.1, json-parse-better-errors@^1.0.2: version "1.0.2" resolved "https://registry.yarnpkg.com/json-parse-better-errors/-/json-parse-better-errors-1.0.2.tgz#bb867cfb3450e69107c131d1c514bab3dc8bcaa9" +json-schema-ref-parser@^5.1.3: + version "5.1.3" + resolved "https://registry.yarnpkg.com/json-schema-ref-parser/-/json-schema-ref-parser-5.1.3.tgz#f86c5868f40898e69169e1bbc854725a4fd0e1ad" + dependencies: + call-me-maybe "^1.0.1" + debug "^3.1.0" + js-yaml "^3.12.0" + ono "^4.0.6" + +json-schema-to-typescript@^5.7.0: + version "5.7.0" + resolved "https://registry.yarnpkg.com/json-schema-to-typescript/-/json-schema-to-typescript-5.7.0.tgz#8a22356896abcf6148a4e99bacd93f0d8792befe" + dependencies: + "@types/cli-color" "^0.3.29" + "@types/json-schema" "^7.0.0" + "@types/lodash" "^4.14.116" + "@types/minimist" "^1.2.0" + "@types/mz" "0.0.32" + "@types/node" "^10.9.4" + "@types/prettier" "^1.13.2" + cli-color "^1.3.0" + json-schema-ref-parser "^5.1.3" + json-stringify-safe "^5.0.1" + lodash "^4.17.11" + minimist "^1.2.0" + mz "^2.7.0" + prettier "^1.14.2" + stdin "0.0.1" + json-schema-traverse@^0.3.0: version "0.3.1" resolved "https://registry.yarnpkg.com/json-schema-traverse/-/json-schema-traverse-0.3.1.tgz#349a6d44c53a51de89b40805c5d5e59b417d3340" @@ -3726,7 +3853,7 @@ json-stable-stringify@^1.0.1: dependencies: jsonify "~0.0.0" -json-stringify-safe@~5.0.1: +json-stringify-safe@^5.0.1, json-stringify-safe@~5.0.1: version "5.0.1" resolved "https://registry.yarnpkg.com/json-stringify-safe/-/json-stringify-safe-5.0.1.tgz#1296a2d58fd45f19a0f6ce01d65701e2c735b6eb" @@ -3985,6 +4112,10 @@ lodash@^4.13.1, lodash@^4.17.10, lodash@^4.17.4, lodash@^4.17.5, lodash@^4.3.0: version "4.17.10" resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.10.tgz#1b7793cf7259ea38fb3661d4d38b3260af8ae4e7" +lodash@^4.17.11: + version "4.17.11" + resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.11.tgz#b39ea6229ef607ecd89e2c8df12536891cac9b8d" + log-driver@1.2.5: version "1.2.5" resolved "https://registry.yarnpkg.com/log-driver/-/log-driver-1.2.5.tgz#7ae4ec257302fd790d557cb10c97100d857b0056" @@ -4035,6 +4166,12 @@ lru-cache@^4.0.1, lru-cache@^4.1.1: pseudomap "^1.0.2" yallist "^2.1.2" +lru-queue@0.1: + version "0.1.0" + resolved "https://registry.yarnpkg.com/lru-queue/-/lru-queue-0.1.0.tgz#2738bd9f0d3cf4f84490c5736c48699ac632cda3" + dependencies: + es5-ext "~0.10.2" + macaddress@^0.2.8: version "0.2.8" resolved "https://registry.yarnpkg.com/macaddress/-/macaddress-0.2.8.tgz#5904dc537c39ec6dbefeae902327135fa8511f12" @@ -4090,6 +4227,19 @@ mem@^1.1.0: dependencies: mimic-fn "^1.0.0" +memoizee@^0.4.14: + version "0.4.14" + resolved "https://registry.yarnpkg.com/memoizee/-/memoizee-0.4.14.tgz#07a00f204699f9a95c2d9e77218271c7cd610d57" + dependencies: + d "1" + es5-ext "^0.10.45" + es6-weak-map "^2.0.2" + event-emitter "^0.3.5" + is-promise "^2.1" + lru-queue "0.1" + next-tick "1" + timers-ext "^0.1.5" + memory-fs@^0.4.0, memory-fs@~0.4.1: version "0.4.1" resolved "https://registry.yarnpkg.com/memory-fs/-/memory-fs-0.4.1.tgz#3a9a20b8462523e447cfbc7e8bb80ed667bfc552" @@ -4280,6 +4430,14 @@ mute-stream@0.0.7: version "0.0.7" resolved "https://registry.yarnpkg.com/mute-stream/-/mute-stream-0.0.7.tgz#3075ce93bc21b8fab43e1bc4da7e8115ed1e7bab" +mz@^2.7.0: + version "2.7.0" + resolved "https://registry.yarnpkg.com/mz/-/mz-2.7.0.tgz#95008057a56cafadc2bc63dde7f9ff6955948e32" + dependencies: + any-promise "^1.0.0" + object-assign "^4.0.1" + thenify-all "^1.0.0" + nan@^2.9.2: version "2.10.0" resolved "https://registry.yarnpkg.com/nan/-/nan-2.10.0.tgz#96d0cd610ebd58d4b4de9cc0c6828cda99c7548f" @@ -4320,6 +4478,10 @@ neo-async@^2.5.0: version "2.5.1" resolved "https://registry.yarnpkg.com/neo-async/-/neo-async-2.5.1.tgz#acb909e327b1e87ec9ef15f41b8a269512ad41ee" +next-tick@1: + version "1.0.0" + resolved "https://registry.yarnpkg.com/next-tick/-/next-tick-1.0.0.tgz#ca86d1fe8828169b0120208e3dc8424b9db8342c" + nice-try@^1.0.4: version "1.0.5" resolved "https://registry.yarnpkg.com/nice-try/-/nice-try-1.0.5.tgz#a3378a7696ce7d223e88fc9b764bd7ef1089e366" @@ -4563,6 +4725,12 @@ onetime@^2.0.0: dependencies: mimic-fn "^1.0.0" +ono@^4.0.6: + version "4.0.8" + resolved "https://registry.yarnpkg.com/ono/-/ono-4.0.8.tgz#d1b12e048cd8a9fe5d2fbf69d3ad42bf7b0feb5e" + dependencies: + format-util "^1.0.3" + optimist@^0.6.1: version "0.6.1" resolved "https://registry.yarnpkg.com/optimist/-/optimist-0.6.1.tgz#da3ea74686fa21a19a111c326e90eb15a0196686" @@ -5081,6 +5249,10 @@ prettier@^1.14.0: version "1.14.0" resolved "https://registry.yarnpkg.com/prettier/-/prettier-1.14.0.tgz#847c235522035fd988100f1f43cf20a7d24f9372" +prettier@^1.14.2: + version "1.14.2" + resolved "https://registry.yarnpkg.com/prettier/-/prettier-1.14.2.tgz#0ac1c6e1a90baa22a62925f41963c841983282f9" + pretty-format@^23.2.0: version "23.2.0" resolved "https://registry.yarnpkg.com/pretty-format/-/pretty-format-23.2.0.tgz#3b0aaa63c018a53583373c1cb3a5d96cc5e83017" @@ -6114,6 +6286,10 @@ statuses@~1.2.1: version "1.2.1" resolved "https://registry.yarnpkg.com/statuses/-/statuses-1.2.1.tgz#dded45cc18256d51ed40aec142489d5c61026d28" +stdin@0.0.1: + version "0.0.1" + resolved "https://registry.yarnpkg.com/stdin/-/stdin-0.0.1.tgz#d3041981aaec3dfdbc77a1b38d6372e38f5fb71e" + stealthy-require@^1.1.0: version "1.1.1" resolved "https://registry.yarnpkg.com/stealthy-require/-/stealthy-require-1.1.1.tgz#35b09875b4ff49f26a777e509b3090a3226bf24b" @@ -6318,6 +6494,18 @@ text-table@^0.2.0: version "0.2.0" resolved "https://registry.yarnpkg.com/text-table/-/text-table-0.2.0.tgz#7f5ee823ae805207c00af2df4a84ec3fcfa570b4" +thenify-all@^1.0.0: + version "1.6.0" + resolved "https://registry.yarnpkg.com/thenify-all/-/thenify-all-1.6.0.tgz#1a1918d402d8fc3f98fbf234db0bcc8cc10e9726" + dependencies: + thenify ">= 3.1.0 < 4" + +"thenify@>= 3.1.0 < 4": + version "3.3.0" + resolved "https://registry.yarnpkg.com/thenify/-/thenify-3.3.0.tgz#e69e38a1babe969b0108207978b9f62b88604839" + dependencies: + any-promise "^1.0.0" + throat@^4.0.0: version "4.1.0" resolved "https://registry.yarnpkg.com/throat/-/throat-4.1.0.tgz#89037cbc92c56ab18926e6ba4cbb200e15672a6a" @@ -6343,6 +6531,13 @@ timers-browserify@^2.0.4: dependencies: setimmediate "^1.0.4" +timers-ext@^0.1.5: + version "0.1.5" + resolved "https://registry.yarnpkg.com/timers-ext/-/timers-ext-0.1.5.tgz#77147dd4e76b660c2abb8785db96574cbbd12922" + dependencies: + es5-ext "~0.10.14" + next-tick "1" + tmp@^0.0.33: version "0.0.33" resolved "https://registry.yarnpkg.com/tmp/-/tmp-0.0.33.tgz#6d34335889768d21b2bcda0aa277ced3b1bfadf9" From c14c73e0343ea5ff742c19f39edb99448cbd5ced Mon Sep 17 00:00:00 2001 From: Tobias Koppers Date: Tue, 18 Sep 2018 13:57:44 +0200 Subject: [PATCH 09/29] update script to * handle recursive folders * create nested folders * have a linting mode * have better banner --- declarations/DllReferencePlugin.d.ts | 9 -- declarations/WatchIgnorePlugin.d.ts | 14 --- declarations/WebpackOptions.d.ts | 87 +++++++++++++++-- declarations/{ => plugins}/BannerPlugin.d.ts | 6 +- declarations/{ => plugins}/DllPlugin.d.ts | 6 +- declarations/plugins/DllReferencePlugin.d.ts | 9 ++ .../{ => plugins}/HashedModuleIdsPlugin.d.ts | 6 +- declarations/{ => plugins}/IgnorePlugin.d.ts | 6 +- .../{ => plugins}/LoaderOptionsPlugin.d.ts | 6 +- .../{ => plugins}/SourceMapDevToolPlugin.d.ts | 14 ++- declarations/plugins/WatchIgnorePlugin.d.ts | 14 +++ .../plugins/debug/ProfilingPlugin.d.ts | 12 +++ .../optimize/AggressiveSplittingPlugin.d.ts | 24 +++++ .../optimize/LimitChunkCountPlugin.d.ts | 16 ++++ .../plugins/optimize/MinChunkSizePlugin.d.ts | 12 +++ .../OccurrenceOrderChunkIdsPlugin.d.ts | 12 +++ .../OccurrenceOrderModuleIdsPlugin.d.ts | 12 +++ tooling/compile-to-definitions.js | 96 ++++++++++++------- 18 files changed, 281 insertions(+), 80 deletions(-) delete mode 100644 declarations/DllReferencePlugin.d.ts delete mode 100644 declarations/WatchIgnorePlugin.d.ts rename declarations/{ => plugins}/BannerPlugin.d.ts (78%) rename declarations/{ => plugins}/DllPlugin.d.ts (71%) create mode 100644 declarations/plugins/DllReferencePlugin.d.ts rename declarations/{ => plugins}/HashedModuleIdsPlugin.d.ts (70%) rename declarations/{ => plugins}/IgnorePlugin.d.ts (69%) rename declarations/{ => plugins}/LoaderOptionsPlugin.d.ts (69%) rename declarations/{ => plugins}/SourceMapDevToolPlugin.d.ts (87%) create mode 100644 declarations/plugins/WatchIgnorePlugin.d.ts create mode 100644 declarations/plugins/debug/ProfilingPlugin.d.ts create mode 100644 declarations/plugins/optimize/AggressiveSplittingPlugin.d.ts create mode 100644 declarations/plugins/optimize/LimitChunkCountPlugin.d.ts create mode 100644 declarations/plugins/optimize/MinChunkSizePlugin.d.ts create mode 100644 declarations/plugins/optimize/OccurrenceOrderChunkIdsPlugin.d.ts create mode 100644 declarations/plugins/optimize/OccurrenceOrderModuleIdsPlugin.d.ts diff --git a/declarations/DllReferencePlugin.d.ts b/declarations/DllReferencePlugin.d.ts deleted file mode 100644 index 7635029b3..000000000 --- a/declarations/DllReferencePlugin.d.ts +++ /dev/null @@ -1,9 +0,0 @@ -/** - * This file was automatically generated by json-schema-to-typescript. - * DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file, - * and run json-schema-to-typescript to regenerate this file. - */ - -export type DllReferencePlugin = { - [k: string]: any; -}; diff --git a/declarations/WatchIgnorePlugin.d.ts b/declarations/WatchIgnorePlugin.d.ts deleted file mode 100644 index 3dd9727d4..000000000 --- a/declarations/WatchIgnorePlugin.d.ts +++ /dev/null @@ -1,14 +0,0 @@ -/** - * This file was automatically generated by json-schema-to-typescript. - * DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file, - * and run json-schema-to-typescript to regenerate this file. - */ - -/** - * A list of RegExps or absolute paths to directories or files that should be ignored - */ -export type WatchIgnorePlugin = ( - | string - | { - [k: string]: any; - })[]; diff --git a/declarations/WebpackOptions.d.ts b/declarations/WebpackOptions.d.ts index 637877b06..d18c7f33b 100644 --- a/declarations/WebpackOptions.d.ts +++ b/declarations/WebpackOptions.d.ts @@ -1,9 +1,13 @@ /** - * This file was automatically generated by json-schema-to-typescript. - * DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file, - * and run json-schema-to-typescript to regenerate this file. + * This file was automatically generated. + * DO NOT MODIFY BY HAND. + * Run `yarn special-lint-fix` to update */ +/** + * This interface was referenced by `WebpackOptions`'s JSON-Schema + * via the `definition` "entry". + */ export type Entry = | { /** @@ -16,7 +20,15 @@ export type Entry = | { [k: string]: any; }; +/** + * This interface was referenced by `WebpackOptions`'s JSON-Schema + * via the `definition` "common.nonEmptyArrayOfUniqueStringValues". + */ export type CommonNonEmptyArrayOfUniqueStringValues = string[]; +/** + * This interface was referenced by `WebpackOptions`'s JSON-Schema + * via the `definition` "externals". + */ export type Externals = | string | { @@ -35,15 +47,20 @@ export type Externals = [k: string]: any; } | Externals[]; +/** + * This interface was referenced by `WebpackOptions`'s JSON-Schema + * via the `definition` "common.arrayOfStringValues". + */ export type CommonArrayOfStringValues = string[]; +/** + * This interface was referenced by `WebpackOptions`'s JSON-Schema + * via the `definition` "ruleSet-condition". + */ export type RuleSetCondition = | { [k: string]: any; } | string - | { - [k: string]: any; - } | RuleSetConditions | { /** @@ -71,14 +88,30 @@ export type RuleSetCondition = */ test?: RuleSetCondition; }; +/** + * This interface was referenced by `WebpackOptions`'s JSON-Schema + * via the `definition` "ruleSet-conditions". + */ export type RuleSetConditions = RuleSetCondition[]; +/** + * This interface was referenced by `WebpackOptions`'s JSON-Schema + * via the `definition` "ruleSet-loader". + */ export type RuleSetLoader = string; +/** + * This interface was referenced by `WebpackOptions`'s JSON-Schema + * via the `definition` "ruleSet-use". + */ export type RuleSetUse = | RuleSetUseItem | { [k: string]: any; } | RuleSetUseItem[]; +/** + * This interface was referenced by `WebpackOptions`'s JSON-Schema + * via the `definition` "ruleSet-use-item". + */ export type RuleSetUseItem = | RuleSetLoader | { @@ -102,14 +135,34 @@ export type RuleSetUseItem = */ query?: RuleSetQuery; }; +/** + * This interface was referenced by `WebpackOptions`'s JSON-Schema + * via the `definition` "ruleSet-query". + */ export type RuleSetQuery = | { [k: string]: any; } | string; +/** + * This interface was referenced by `WebpackOptions`'s JSON-Schema + * via the `definition` "common.arrayOfStringOrStringArrayValues". + */ export type CommonArrayOfStringOrStringArrayValues = (string | string[])[]; +/** + * This interface was referenced by `WebpackOptions`'s JSON-Schema + * via the `definition` "ruleSet-rules". + */ export type RuleSetRules = RuleSetRule[]; +/** + * This interface was referenced by `WebpackOptions`'s JSON-Schema + * via the `definition` "filter-types". + */ export type FilterTypes = FilterItemTypes | FilterItemTypes[]; +/** + * This interface was referenced by `WebpackOptions`'s JSON-Schema + * via the `definition` "filter-item-types". + */ export type FilterItemTypes = | { [k: string]: any; @@ -786,6 +839,10 @@ export interface WebpackOptions { poll?: boolean | number; }; } +/** + * This interface was referenced by `WebpackOptions`'s JSON-Schema + * via the `definition` "module". + */ export interface Module { /** * Enable warnings for full dynamic dependencies @@ -878,6 +935,10 @@ export interface Module { */ strictThisContextOnImports?: boolean; } +/** + * This interface was referenced by `WebpackOptions`'s JSON-Schema + * via the `definition` "ruleSet-rule". + */ export interface RuleSetRule { /** * Enforce this rule as pre or post step @@ -973,6 +1034,10 @@ export interface RuleSetRule { */ use?: RuleSetUse; } +/** + * This interface was referenced by `WebpackOptions`'s JSON-Schema + * via the `definition` "resolve". + */ export interface Resolve { /** * Redirect module requests @@ -1083,6 +1148,9 @@ export interface Resolve { } /** * Plugin instance + * + * This interface was referenced by `WebpackOptions`'s JSON-Schema + * via the `definition` "common.pluginObject". */ export interface CommonPluginObject { /** @@ -1095,6 +1163,9 @@ export interface CommonPluginObject { } /** * Function acting as plugin + * + * This interface was referenced by `WebpackOptions`'s JSON-Schema + * via the `definition` "common.pluginFunction". */ export interface CommonPluginFunction { /** @@ -1105,6 +1176,10 @@ export interface CommonPluginFunction { }; [k: string]: any; } +/** + * This interface was referenced by `WebpackOptions`'s JSON-Schema + * via the `definition` "output". + */ export interface Output { /** * Add a comment in the UMD wrapper. diff --git a/declarations/BannerPlugin.d.ts b/declarations/plugins/BannerPlugin.d.ts similarity index 78% rename from declarations/BannerPlugin.d.ts rename to declarations/plugins/BannerPlugin.d.ts index 4b6e51e23..f2fed4076 100644 --- a/declarations/BannerPlugin.d.ts +++ b/declarations/plugins/BannerPlugin.d.ts @@ -1,7 +1,7 @@ /** - * This file was automatically generated by json-schema-to-typescript. - * DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file, - * and run json-schema-to-typescript to regenerate this file. + * This file was automatically generated. + * DO NOT MODIFY BY HAND. + * Run `yarn special-lint-fix` to update */ export type BannerPlugin = diff --git a/declarations/DllPlugin.d.ts b/declarations/plugins/DllPlugin.d.ts similarity index 71% rename from declarations/DllPlugin.d.ts rename to declarations/plugins/DllPlugin.d.ts index 59991cbf9..d1bca110f 100644 --- a/declarations/DllPlugin.d.ts +++ b/declarations/plugins/DllPlugin.d.ts @@ -1,7 +1,7 @@ /** - * This file was automatically generated by json-schema-to-typescript. - * DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file, - * and run json-schema-to-typescript to regenerate this file. + * This file was automatically generated. + * DO NOT MODIFY BY HAND. + * Run `yarn special-lint-fix` to update */ export interface DllPlugin { diff --git a/declarations/plugins/DllReferencePlugin.d.ts b/declarations/plugins/DllReferencePlugin.d.ts new file mode 100644 index 000000000..192d154f7 --- /dev/null +++ b/declarations/plugins/DllReferencePlugin.d.ts @@ -0,0 +1,9 @@ +/** + * This file was automatically generated. + * DO NOT MODIFY BY HAND. + * Run `yarn special-lint-fix` to update + */ + +export type DllReferencePlugin = { + [k: string]: any; +}; diff --git a/declarations/HashedModuleIdsPlugin.d.ts b/declarations/plugins/HashedModuleIdsPlugin.d.ts similarity index 70% rename from declarations/HashedModuleIdsPlugin.d.ts rename to declarations/plugins/HashedModuleIdsPlugin.d.ts index 0784b1419..8fcc1324b 100644 --- a/declarations/HashedModuleIdsPlugin.d.ts +++ b/declarations/plugins/HashedModuleIdsPlugin.d.ts @@ -1,7 +1,7 @@ /** - * This file was automatically generated by json-schema-to-typescript. - * DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file, - * and run json-schema-to-typescript to regenerate this file. + * This file was automatically generated. + * DO NOT MODIFY BY HAND. + * Run `yarn special-lint-fix` to update */ export interface HashedModuleIdsPlugin { diff --git a/declarations/IgnorePlugin.d.ts b/declarations/plugins/IgnorePlugin.d.ts similarity index 69% rename from declarations/IgnorePlugin.d.ts rename to declarations/plugins/IgnorePlugin.d.ts index 715d02b5b..099e09ed7 100644 --- a/declarations/IgnorePlugin.d.ts +++ b/declarations/plugins/IgnorePlugin.d.ts @@ -1,7 +1,7 @@ /** - * This file was automatically generated by json-schema-to-typescript. - * DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file, - * and run json-schema-to-typescript to regenerate this file. + * This file was automatically generated. + * DO NOT MODIFY BY HAND. + * Run `yarn special-lint-fix` to update */ export type IgnorePlugin = diff --git a/declarations/LoaderOptionsPlugin.d.ts b/declarations/plugins/LoaderOptionsPlugin.d.ts similarity index 69% rename from declarations/LoaderOptionsPlugin.d.ts rename to declarations/plugins/LoaderOptionsPlugin.d.ts index 5d666ff8e..61ab8d058 100644 --- a/declarations/LoaderOptionsPlugin.d.ts +++ b/declarations/plugins/LoaderOptionsPlugin.d.ts @@ -1,7 +1,7 @@ /** - * This file was automatically generated by json-schema-to-typescript. - * DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file, - * and run json-schema-to-typescript to regenerate this file. + * This file was automatically generated. + * DO NOT MODIFY BY HAND. + * Run `yarn special-lint-fix` to update */ export interface LoaderOptionsPlugin { diff --git a/declarations/SourceMapDevToolPlugin.d.ts b/declarations/plugins/SourceMapDevToolPlugin.d.ts similarity index 87% rename from declarations/SourceMapDevToolPlugin.d.ts rename to declarations/plugins/SourceMapDevToolPlugin.d.ts index e8ecc3049..1bd374c2e 100644 --- a/declarations/SourceMapDevToolPlugin.d.ts +++ b/declarations/plugins/SourceMapDevToolPlugin.d.ts @@ -1,10 +1,18 @@ /** - * This file was automatically generated by json-schema-to-typescript. - * DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file, - * and run json-schema-to-typescript to regenerate this file. + * This file was automatically generated. + * DO NOT MODIFY BY HAND. + * Run `yarn special-lint-fix` to update */ +/** + * This interface was referenced by `SourceMapDevToolPlugin`'s JSON-Schema + * via the `definition` "rules". + */ export type Rules = Rule[] | Rule; +/** + * This interface was referenced by `SourceMapDevToolPlugin`'s JSON-Schema + * via the `definition` "rule". + */ export type Rule = | { [k: string]: any; diff --git a/declarations/plugins/WatchIgnorePlugin.d.ts b/declarations/plugins/WatchIgnorePlugin.d.ts new file mode 100644 index 000000000..540269afd --- /dev/null +++ b/declarations/plugins/WatchIgnorePlugin.d.ts @@ -0,0 +1,14 @@ +/** + * This file was automatically generated. + * DO NOT MODIFY BY HAND. + * Run `yarn special-lint-fix` to update + */ + +/** + * A list of RegExps or absolute paths to directories or files that should be ignored + */ +export type WatchIgnorePlugin = ( + | string + | { + [k: string]: any; + })[]; diff --git a/declarations/plugins/debug/ProfilingPlugin.d.ts b/declarations/plugins/debug/ProfilingPlugin.d.ts new file mode 100644 index 000000000..d24395557 --- /dev/null +++ b/declarations/plugins/debug/ProfilingPlugin.d.ts @@ -0,0 +1,12 @@ +/** + * This file was automatically generated. + * DO NOT MODIFY BY HAND. + * Run `yarn special-lint-fix` to update + */ + +export interface ProfilingPlugin { + /** + * Path to the output file e.g. `profiling/events.json`. Defaults to `events.json`. + */ + outputPath?: string; +} diff --git a/declarations/plugins/optimize/AggressiveSplittingPlugin.d.ts b/declarations/plugins/optimize/AggressiveSplittingPlugin.d.ts new file mode 100644 index 000000000..6ee0dbd69 --- /dev/null +++ b/declarations/plugins/optimize/AggressiveSplittingPlugin.d.ts @@ -0,0 +1,24 @@ +/** + * This file was automatically generated. + * DO NOT MODIFY BY HAND. + * Run `yarn special-lint-fix` to update + */ + +export interface AggressiveSplittingPlugin { + /** + * Byte, split point. Default: 30720 + */ + minSize?: number; + /** + * Byte, maxsize of per file. Default: 51200 + */ + maxSize?: number; + /** + * Default: 0 + */ + chunkOverhead?: number; + /** + * Default: 1 + */ + entryChunkMultiplicator?: number; +} diff --git a/declarations/plugins/optimize/LimitChunkCountPlugin.d.ts b/declarations/plugins/optimize/LimitChunkCountPlugin.d.ts new file mode 100644 index 000000000..38756335b --- /dev/null +++ b/declarations/plugins/optimize/LimitChunkCountPlugin.d.ts @@ -0,0 +1,16 @@ +/** + * This file was automatically generated. + * DO NOT MODIFY BY HAND. + * Run `yarn special-lint-fix` to update + */ + +export interface LimitChunkCountPlugin { + /** + * Limit the maximum number of chunks using a value greater greater than or equal to 1 + */ + maxChunks?: number; + /** + * Set a minimum chunk size + */ + minChunkSize?: number; +} diff --git a/declarations/plugins/optimize/MinChunkSizePlugin.d.ts b/declarations/plugins/optimize/MinChunkSizePlugin.d.ts new file mode 100644 index 000000000..959b23ce5 --- /dev/null +++ b/declarations/plugins/optimize/MinChunkSizePlugin.d.ts @@ -0,0 +1,12 @@ +/** + * This file was automatically generated. + * DO NOT MODIFY BY HAND. + * Run `yarn special-lint-fix` to update + */ + +export interface MinChunkSizePlugin { + /** + * Minimum number of characters + */ + minChunkSize: number; +} diff --git a/declarations/plugins/optimize/OccurrenceOrderChunkIdsPlugin.d.ts b/declarations/plugins/optimize/OccurrenceOrderChunkIdsPlugin.d.ts new file mode 100644 index 000000000..3c3ad828d --- /dev/null +++ b/declarations/plugins/optimize/OccurrenceOrderChunkIdsPlugin.d.ts @@ -0,0 +1,12 @@ +/** + * This file was automatically generated. + * DO NOT MODIFY BY HAND. + * Run `yarn special-lint-fix` to update + */ + +export interface OccurrenceOrderChunkIdsPlugin { + /** + * Prioritise initial size over total size + */ + prioritiseInitial?: boolean; +} diff --git a/declarations/plugins/optimize/OccurrenceOrderModuleIdsPlugin.d.ts b/declarations/plugins/optimize/OccurrenceOrderModuleIdsPlugin.d.ts new file mode 100644 index 000000000..7c8f3b412 --- /dev/null +++ b/declarations/plugins/optimize/OccurrenceOrderModuleIdsPlugin.d.ts @@ -0,0 +1,12 @@ +/** + * This file was automatically generated. + * DO NOT MODIFY BY HAND. + * Run `yarn special-lint-fix` to update + */ + +export interface OccurrenceOrderModuleIdsPlugin { + /** + * Prioritise initial size over total size + */ + prioritiseInitial?: boolean; +} diff --git a/tooling/compile-to-definitions.js b/tooling/compile-to-definitions.js index f7f9e2753..994293b1e 100644 --- a/tooling/compile-to-definitions.js +++ b/tooling/compile-to-definitions.js @@ -1,49 +1,79 @@ const fs = require("fs"); const path = require("path"); -const style = require("../.prettierrc.js"); // eslint-disable-line +const mkdirp = require("mkdirp"); +const prettierrc = require("../.prettierrc.js"); // eslint-disable-line const { compileFromFile } = require("json-schema-to-typescript"); + const schemasDir = path.resolve(__dirname, "../schemas"); +const style = { + printWidth: prettierrc.printWidth, + useTabs: prettierrc.useTabs, + tabWidth: prettierrc.tabWidth +}; + +// When --write is set, files will be written in place +// Elsewise it only prints outdated files +const doWrite = process.argv.includes("--write"); const makeSchemas = () => { // include the top level folder "./schemas" by default - const dirs = [schemasDir]; + const dirs = new Set([schemasDir]); // search for all nestedDirs inside of this folder - // TODO: Although I don't think it makes sense at all to ever have nested folders here, (just one level deep) - // this should technically have recursive handling for those nested folers - for (let dir of fs.readdirSync(schemasDir)) { - const absDirPath = path.resolve(schemasDir, dir); - console.log(dir, schemasDir); - if (fs.statSync(absDirPath).isDirectory()) { - dirs.push(absDirPath); + for (let dirWithSchemas of dirs) { + for (let item of fs.readdirSync(dirWithSchemas)) { + const absPath = path.resolve(dirWithSchemas, item); + if (fs.statSync(absPath).isDirectory()) { + dirs.add(absPath); + } else if (item.endsWith(".json")) { + makeDefinitionsForSchema(absPath); + } } } - - for (let dirWithSchemas of dirs) { - processSchemasInDir(dirWithSchemas); - } }; -const processSchemasInDir = absDirPath => { - const schemas = fs - .readdirSync(absDirPath) - .filter(name => name.endsWith(".json")) - .map(name => ({ - fileName: name.split(".")[0], - name: path.resolve(absDirPath, name) - })); - for (let { fileName, name } of schemas) { - makeDefinitionsForSchema(fileName, path.resolve(absDirPath, name)); - } -}; - -const makeDefinitionsForSchema = (fileName, absSchemaPath) => { - compileFromFile(absSchemaPath, { style }).then(ts => { - fs.writeFileSync( - path.resolve(__dirname, `../declarations/${fileName}.d.ts`), - ts - ); - }); +const makeDefinitionsForSchema = absSchemaPath => { + const basename = path + .relative(schemasDir, absSchemaPath) + .replace(/\.json$/i, ""); + const filename = path.resolve(__dirname, `../declarations/${basename}.d.ts`); + compileFromFile(absSchemaPath, { + 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 => { + let normalizedContent = ""; + try { + const content = fs.readFileSync(filename, "utf-8"); + normalizedContent = content.replace(/\r\n?/g, "\n"); + } catch (e) { + // ignore + } + if (normalizedContent.trim() !== ts.trim()) { + if (doWrite) { + mkdirp.sync(path.dirname(filename)); + fs.writeFileSync(filename, ts, "utf-8"); + console.error( + `declarations/${basename.replace(/\\/g, "/")}.d.ts updated` + ); + } else { + console.error( + `declarations/${basename.replace( + /\\/g, + "/" + )}.d.ts need to be updated` + ); + } + process.exitCode = 1; + } + }, + err => { + console.error(err); + process.exitCode = 1; + } + ); }; makeSchemas(); From 8bb985dd43481106b27e977c648bb08380420e0c Mon Sep 17 00:00:00 2001 From: Tobias Koppers Date: Tue, 18 Sep 2018 13:59:06 +0200 Subject: [PATCH 10/29] add lint and fix steps to scripts --- package.json | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 45856ac25..fa1441539 100644 --- a/package.json +++ b/package.json @@ -119,10 +119,12 @@ "build:examples": "cd examples && node buildAll.js", "pretest": "yarn lint", "prelint": "yarn setup", - "lint": "yarn code-lint && yarn schema-lint && yarn type-lint", + "lint": "yarn code-lint && yarn schema-lint && yarn type-lint && yarn special-lint", "code-lint": "eslint --cache \"{setup,lib,bin,hot,buildin,benchmark,tooling,schemas}/**/*.js\" \"test/*.js\" \"test/{configCases,watchCases,statsCases,hotCases}/**/webpack.config.js\" \"examples/**/webpack.config.js\"", "type-lint": "tsc --pretty", - "fix": "yarn code-lint --fix", + "special-lint": "node tooling/inherit-types && node tooling/compile-to-definitions", + "special-lint-fix": "node tooling/inherit-types --write --override && node tooling/compile-to-definitions --write", + "fix": "yarn code-lint --fix && yarn special-lint-fix", "pretty": "prettier --loglevel warn --write \"*.{ts,js,json}\" \"{setup,lib,bin,hot,buildin,benchmark,tooling,schemas}/**/*.{js,json}\" \"test/*.js\" \"test/{configCases,watchCases,statsCases,hotCases}/**/webpack.config.js\" \"examples/**/webpack.config.js\"", "schema-lint": "node --max-old-space-size=4096 node_modules/jest-cli/bin/jest --testMatch \"/test/*.lint.js\" --no-verbose", "benchmark": "node --max-old-space-size=4096 --trace-deprecation node_modules/jest-cli/bin/jest --testMatch \"/test/*.benchmark.js\" --runInBand", From 20d9cca01f90e79255b86563e59ee56fbaccfdf0 Mon Sep 17 00:00:00 2001 From: Tobias Koppers Date: Wed, 19 Sep 2018 10:17:33 +0200 Subject: [PATCH 11/29] add tooling to sort schema properties --- declarations/WebpackOptions.d.ts | 794 +++++----- declarations/plugins/BannerPlugin.d.ts | 16 +- declarations/plugins/DllPlugin.d.ts | 12 +- .../plugins/HashedModuleIdsPlugin.d.ts | 8 +- declarations/plugins/IgnorePlugin.d.ts | 20 +- .../plugins/SourceMapDevToolPlugin.d.ts | 100 +- .../optimize/AggressiveSplittingPlugin.d.ts | 16 +- package.json | 4 +- schemas/WebpackOptions.json | 1406 ++++++++--------- schemas/plugins/BannerPlugin.json | 32 +- schemas/plugins/DllPlugin.json | 38 +- schemas/plugins/DllReferencePlugin.json | 70 +- schemas/plugins/HashedModuleIdsPlugin.json | 10 +- schemas/plugins/IgnorePlugin.json | 16 +- schemas/plugins/SourceMapDevToolPlugin.json | 170 +- .../optimize/AggressiveSplittingPlugin.json | 16 +- .../plugins/optimize/MinChunkSizePlugin.json | 6 +- .../OccurrenceOrderChunkIdsPlugin.json | 2 +- .../OccurrenceOrderModuleIdsPlugin.json | 2 +- tooling/format-schemas.js | 144 ++ 20 files changed, 1513 insertions(+), 1369 deletions(-) create mode 100644 tooling/format-schemas.js diff --git a/declarations/WebpackOptions.d.ts b/declarations/WebpackOptions.d.ts index d18c7f33b..7238d38e9 100644 --- a/declarations/WebpackOptions.d.ts +++ b/declarations/WebpackOptions.d.ts @@ -118,6 +118,10 @@ export type RuleSetUseItem = [k: string]: any; } | { + /** + * Unique loader identifier + */ + ident?: string; /** * Loader name */ @@ -126,10 +130,6 @@ export type RuleSetUseItem = * Loader options */ options?: RuleSetQuery; - /** - * Unique loader identifier - */ - ident?: string; /** * Loader query */ @@ -170,10 +170,6 @@ export type FilterItemTypes = | string; export interface WebpackOptions { - /** - * Enable production optimizations or development hints. - */ - mode?: "development" | "production" | "none"; /** * Set the value of `require.amd` and `define.amd`. */ @@ -224,6 +220,10 @@ export interface WebpackOptions { loader?: { [k: string]: any; }; + /** + * Enable production optimizations or development hints. + */ + mode?: "development" | "production" | "none"; /** * Options affecting the normal modules (`NormalModuleFactory`). */ @@ -267,14 +267,78 @@ export interface WebpackOptions { */ [k: string]: false | true | "mock" | "empty"; }; - /** - * Options affecting the output of the compilation. `output` options tell webpack how to write the compiled files to disk. - */ - output?: Output; /** * Enables/Disables integrated optimizations */ optimization?: { + /** + * Check for incompatible wasm types when importing/exporting from/to ESM + */ + checkWasmTypes?: boolean; + /** + * Define the algorithm to choose chunk ids (named: readable ids for better debugging, size: numeric ids focused on minimal initial download size, total-size: numeric ids focused on minimal total download size, false: no algorithm used, as custom one can be provided via plugin) + */ + chunkIds?: "natural" | "named" | "size" | "total-size" | false; + /** + * Concatenate modules when possible to generate less modules, more efficient code and enable more optimizations by the minimizer + */ + concatenateModules?: boolean; + /** + * Also flag chunks as loaded which contain a subset of the modules + */ + flagIncludedChunks?: boolean; + /** + * Use hashed module id instead module identifiers for better long term caching (deprecated, used moduleIds: hashed instead) + */ + hashedModuleIds?: boolean; + /** + * Reduce size of WASM by changing imports to shorter strings. + */ + mangleWasmImports?: boolean; + /** + * Merge chunks which contain the same modules + */ + mergeDuplicateChunks?: boolean; + /** + * Enable minimizing the output. Uses optimization.minimizer. + */ + minimize?: boolean; + /** + * Minimizer(s) to use for minimizing the output + */ + minimizer?: (CommonPluginObject | CommonPluginFunction)[]; + /** + * Define the algorithm to choose module ids (natural: numeric ids in order of usage, named: readable ids for better debugging, hashed: short hashes as ids for better long term caching, size: numeric ids focused on minimal initial download size, total-size: numeric ids focused on minimal total download size, false: no algorithm used, as custom one can be provided via plugin) + */ + moduleIds?: "natural" | "named" | "hashed" | "size" | "total-size" | false; + /** + * Use readable chunk identifiers for better debugging (deprecated, used chunkIds: named instead) + */ + namedChunks?: boolean; + /** + * Use readable module identifiers for better debugging (deprecated, used moduleIds: named instead) + */ + namedModules?: boolean; + /** + * Avoid emitting assets when errors occur + */ + noEmitOnErrors?: boolean; + /** + * Set process.env.NODE_ENV to a specific value + */ + nodeEnv?: false | string; + /** + * Figure out a order of modules which results in the smallest initial bundle + */ + occurrenceOrder?: boolean; + /** + * Generate records with relative paths to be able to move the context folder + */ + portableRecords?: boolean; + /** + * Figure out which exports are provided by modules to generate more efficient code + */ + providedExports?: boolean; /** * Removes modules from chunks when these modules are already included in all parents */ @@ -283,192 +347,6 @@ export interface WebpackOptions { * Remove chunks which are empty */ removeEmptyChunks?: boolean; - /** - * Merge chunks which contain the same modules - */ - mergeDuplicateChunks?: boolean; - /** - * Also flag chunks as loaded which contain a subset of the modules - */ - flagIncludedChunks?: boolean; - /** - * Figure out a order of modules which results in the smallest initial bundle - */ - occurrenceOrder?: boolean; - /** - * Skip over modules which are flagged to contain no side effects when exports are not used - */ - sideEffects?: boolean; - /** - * Figure out which exports are provided by modules to generate more efficient code - */ - providedExports?: boolean; - /** - * Figure out which exports are used by modules to mangle export names, omit unused exports and generate more efficient code - */ - usedExports?: boolean; - /** - * Concatenate modules when possible to generate less modules, more efficient code and enable more optimizations by the minimizer - */ - concatenateModules?: boolean; - /** - * Optimize duplication and caching by splitting chunks by shared modules and cache group - */ - splitChunks?: - | false - | { - /** - * Select chunks for determining shared modules (defaults to "async", "initial" and "all" requires adding these chunks to the HTML) - */ - chunks?: - | ("initial" | "async" | "all") - | { - [k: string]: any; - }; - /** - * Minimal size for the created chunks - */ - minSize?: number; - /** - * Maximal size hint for the created chunks - */ - maxSize?: number; - /** - * Minimum number of times a module has to be duplicated until it's considered for splitting - */ - minChunks?: number; - /** - * Maximum number of requests which are accepted for on-demand loading - */ - maxAsyncRequests?: number; - /** - * Maximum number of initial chunks which are accepted for an entry point - */ - maxInitialRequests?: number; - /** - * Give chunks created a name (chunks with equal name are merged) - */ - name?: - | boolean - | { - [k: string]: any; - } - | string; - /** - * Sets the template for the filename for created chunks (Only works for initial chunks) - */ - filename?: string; - /** - * Sets the name delimiter for created chunks - */ - automaticNameDelimiter?: string; - /** - * Prevents exposing path info when creating names for parts splitted by maxSize - */ - hidePathInfo?: boolean; - /** - * Options for modules not selected by any other cache group - */ - fallbackCacheGroup?: { - /** - * Minimal size for the created chunk - */ - minSize?: number; - /** - * Maximal size hint for the created chunks - */ - maxSize?: number; - /** - * Sets the name delimiter for created chunks - */ - automaticNameDelimiter?: string; - }; - /** - * Assign modules to a cache group (modules from different cache groups are tried to keep in separate chunks) - */ - cacheGroups?: { - /** - * Configuration for a cache group - */ - [k: string]: - | false - | { - [k: string]: any; - } - | string - | { - /** - * Assign modules to a cache group - */ - test?: - | { - [k: string]: any; - } - | string; - /** - * Select chunks for determining cache group content (defaults to "initial", "initial" and "all" requires adding these chunks to the HTML) - */ - chunks?: - | ("initial" | "async" | "all") - | { - [k: string]: any; - }; - /** - * Ignore minimum size, minimum chunks and maximum requests and always create chunks for this cache group - */ - enforce?: boolean; - /** - * Priority of this cache group - */ - priority?: number; - /** - * Minimal size for the created chunk - */ - minSize?: number; - /** - * Maximal size hint for the created chunks - */ - maxSize?: number; - /** - * Minimum number of times a module has to be duplicated until it's considered for splitting - */ - minChunks?: number; - /** - * Maximum number of requests which are accepted for on-demand loading - */ - maxAsyncRequests?: number; - /** - * Maximum number of initial chunks which are accepted for an entry point - */ - maxInitialRequests?: number; - /** - * Try to reuse existing chunk (with name) when it has matching modules - */ - reuseExistingChunk?: boolean; - /** - * Give chunks for this cache group a name (chunks with equal name are merged) - */ - name?: - | boolean - | { - [k: string]: any; - } - | string; - /** - * Sets the name delimiter for created chunks - */ - automaticNameDelimiter?: string; - /** - * Sets the name prefix for created chunks - */ - automaticNamePrefix?: string; - /** - * Sets the template for the filename for created chunks (Only works for initial chunks) - */ - filename?: string; - }; - }; - }; /** * Create an additional chunk which contains only the webpack runtime and chunk hash maps */ @@ -486,54 +364,176 @@ export interface WebpackOptions { }; }; /** - * Avoid emitting assets when errors occur + * Skip over modules which are flagged to contain no side effects when exports are not used */ - noEmitOnErrors?: boolean; + sideEffects?: boolean; /** - * Check for incompatible wasm types when importing/exporting from/to ESM + * Optimize duplication and caching by splitting chunks by shared modules and cache group */ - checkWasmTypes?: boolean; + splitChunks?: + | false + | { + /** + * Sets the name delimiter for created chunks + */ + automaticNameDelimiter?: string; + /** + * Assign modules to a cache group (modules from different cache groups are tried to keep in separate chunks) + */ + cacheGroups?: { + /** + * Configuration for a cache group + */ + [k: string]: + | false + | { + [k: string]: any; + } + | string + | { + /** + * Sets the name delimiter for created chunks + */ + automaticNameDelimiter?: string; + /** + * Sets the name prefix for created chunks + */ + automaticNamePrefix?: string; + /** + * Select chunks for determining cache group content (defaults to "initial", "initial" and "all" requires adding these chunks to the HTML) + */ + chunks?: + | ("initial" | "async" | "all") + | { + [k: string]: any; + }; + /** + * Ignore minimum size, minimum chunks and maximum requests and always create chunks for this cache group + */ + enforce?: boolean; + /** + * Sets the template for the filename for created chunks (Only works for initial chunks) + */ + filename?: string; + /** + * Maximum number of requests which are accepted for on-demand loading + */ + maxAsyncRequests?: number; + /** + * Maximum number of initial chunks which are accepted for an entry point + */ + maxInitialRequests?: number; + /** + * Maximal size hint for the created chunks + */ + maxSize?: number; + /** + * Minimum number of times a module has to be duplicated until it's considered for splitting + */ + minChunks?: number; + /** + * Minimal size for the created chunk + */ + minSize?: number; + /** + * Give chunks for this cache group a name (chunks with equal name are merged) + */ + name?: + | boolean + | { + [k: string]: any; + } + | string; + /** + * Priority of this cache group + */ + priority?: number; + /** + * Try to reuse existing chunk (with name) when it has matching modules + */ + reuseExistingChunk?: boolean; + /** + * Assign modules to a cache group + */ + test?: + | { + [k: string]: any; + } + | string; + }; + }; + /** + * Select chunks for determining shared modules (defaults to "async", "initial" and "all" requires adding these chunks to the HTML) + */ + chunks?: + | ("initial" | "async" | "all") + | { + [k: string]: any; + }; + /** + * Options for modules not selected by any other cache group + */ + fallbackCacheGroup?: { + /** + * Sets the name delimiter for created chunks + */ + automaticNameDelimiter?: string; + /** + * Maximal size hint for the created chunks + */ + maxSize?: number; + /** + * Minimal size for the created chunk + */ + minSize?: number; + }; + /** + * Sets the template for the filename for created chunks (Only works for initial chunks) + */ + filename?: string; + /** + * Prevents exposing path info when creating names for parts splitted by maxSize + */ + hidePathInfo?: boolean; + /** + * Maximum number of requests which are accepted for on-demand loading + */ + maxAsyncRequests?: number; + /** + * Maximum number of initial chunks which are accepted for an entry point + */ + maxInitialRequests?: number; + /** + * Maximal size hint for the created chunks + */ + maxSize?: number; + /** + * Minimum number of times a module has to be duplicated until it's considered for splitting + */ + minChunks?: number; + /** + * Minimal size for the created chunks + */ + minSize?: number; + /** + * Give chunks created a name (chunks with equal name are merged) + */ + name?: + | boolean + | { + [k: string]: any; + } + | string; + }; /** - * Reduce size of WASM by changing imports to shorter strings. + * Figure out which exports are used by modules to mangle export names, omit unused exports and generate more efficient code */ - mangleWasmImports?: boolean; - /** - * Define the algorithm to choose module ids (natural: numeric ids in order of usage, named: readable ids for better debugging, hashed: short hashes as ids for better long term caching, size: numeric ids focused on minimal initial download size, total-size: numeric ids focused on minimal total download size, false: no algorithm used, as custom one can be provided via plugin) - */ - moduleIds?: "natural" | "named" | "hashed" | "size" | "total-size" | false; - /** - * Define the algorithm to choose chunk ids (named: readable ids for better debugging, size: numeric ids focused on minimal initial download size, total-size: numeric ids focused on minimal total download size, false: no algorithm used, as custom one can be provided via plugin) - */ - chunkIds?: "natural" | "named" | "size" | "total-size" | false; - /** - * Use readable module identifiers for better debugging (deprecated, used moduleIds: named instead) - */ - namedModules?: boolean; - /** - * Use hashed module id instead module identifiers for better long term caching (deprecated, used moduleIds: hashed instead) - */ - hashedModuleIds?: boolean; - /** - * Use readable chunk identifiers for better debugging (deprecated, used chunkIds: named instead) - */ - namedChunks?: boolean; - /** - * Generate records with relative paths to be able to move the context folder - */ - portableRecords?: boolean; - /** - * Enable minimizing the output. Uses optimization.minimizer. - */ - minimize?: boolean; - /** - * Minimizer(s) to use for minimizing the output - */ - minimizer?: (CommonPluginObject | CommonPluginFunction)[]; - /** - * Set process.env.NODE_ENV to a specific value - */ - nodeEnv?: false | string; + usedExports?: boolean; }; + /** + * 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. */ @@ -554,14 +554,14 @@ export interface WebpackOptions { * Sets the format of the hints: warnings, errors or nothing at all */ hints?: false | "warning" | "error"; - /** - * Total size of an entry point (in bytes) - */ - maxEntrypointSize?: number; /** * Filesize limit (in bytes) when exceeded, that webpack will provide performance hints */ maxAssetSize?: number; + /** + * Total size of an entry point (in bytes) + */ + maxEntrypointSize?: number; }; /** * Add additional plugins to the compiler. @@ -607,41 +607,49 @@ export interface WebpackOptions { */ all?: boolean; /** - * context directory for request shortening + * add assets information */ - context?: string; + assets?: boolean; /** - * add the hash of the compilation + * sort the assets by that field */ - hash?: boolean; - /** - * add webpack version information - */ - version?: boolean; - /** - * add timing information - */ - timings?: boolean; + assetsSort?: string; /** * add built at time information */ builtAt?: boolean; /** - * add performance hint flags + * add also information about cached (not built) modules */ - performance?: boolean; + cached?: boolean; /** - * add module depth in module graph + * Show cached assets (setting this to `false` only shows emitted files) */ - depth?: boolean; + cachedAssets?: boolean; /** - * add assets information + * add children information */ - assets?: boolean; + children?: boolean; /** - * add --env information + * Display all chunk groups with the corresponding bundles */ - env?: boolean; + chunkGroups?: boolean; + /** + * add built modules information to chunk information + */ + chunkModules?: boolean; + /** + * add the origins of chunks and chunk merging info + */ + chunkOrigins?: boolean; + /** + * add chunk information + */ + chunks?: boolean; + /** + * sort the chunks by that field + */ + chunksSort?: string; /** * Enables/Disables colorful output */ @@ -653,82 +661,54 @@ export interface WebpackOptions { */ bold?: string; /** - * Custom color for red text + * Custom color for cyan text */ - red?: string; + cyan?: string; /** * Custom color for green text */ green?: string; - /** - * Custom color for cyan text - */ - cyan?: string; /** * Custom color for magenta text */ magenta?: string; + /** + * Custom color for red text + */ + red?: string; /** * Custom color for yellow text */ yellow?: string; }; /** - * Set the maximum number of modules to be shown + * context directory for request shortening */ - maxModules?: number; + context?: string; /** - * add chunk information + * add module depth in module graph */ - chunks?: boolean; + depth?: boolean; /** - * add built modules information to chunk information + * Display the entry points with the corresponding bundles */ - chunkModules?: boolean; + entrypoints?: boolean; /** - * add built modules information + * add --env information */ - modules?: boolean; + env?: boolean; /** - * add information about modules nested in other modules (like with module concatenation) + * add details to errors (like resolving log) */ - nestedModules?: boolean; - /** - * add information about assets inside modules - */ - moduleAssets?: boolean; - /** - * add children information - */ - children?: boolean; - /** - * add also information about cached (not built) modules - */ - cached?: boolean; - /** - * Show cached assets (setting this to `false` only shows emitted files) - */ - cachedAssets?: boolean; - /** - * add information about the reasons why modules are included - */ - reasons?: boolean; - /** - * add the source code of modules - */ - source?: boolean; - /** - * add warnings - */ - warnings?: boolean; + errorDetails?: boolean; /** * add errors */ errors?: boolean; /** - * Suppress warnings that match the specified filters. Filters can be Strings, RegExps or Functions + * Please use excludeModules instead. */ - warningsFilter?: FilterTypes; + exclude?: FilterTypes | boolean; /** * Suppress assets that match the specified filters. Filters can be Strings, RegExps or Functions */ @@ -738,61 +718,81 @@ export interface WebpackOptions { */ excludeModules?: FilterTypes | boolean; /** - * Please use excludeModules instead. + * add the hash of the compilation */ - exclude?: FilterTypes | boolean; + hash?: boolean; /** - * Display the entry points with the corresponding bundles + * Set the maximum number of modules to be shown */ - entrypoints?: boolean; + maxModules?: number; /** - * Display all chunk groups with the corresponding bundles + * add information about assets inside modules */ - chunkGroups?: boolean; - /** - * add details to errors (like resolving log) - */ - errorDetails?: boolean; - /** - * add the origins of chunks and chunk merging info - */ - chunkOrigins?: boolean; - /** - * sort the modules by that field - */ - modulesSort?: string; + moduleAssets?: boolean; /** * add dependencies and origin of warnings/errors */ moduleTrace?: boolean; /** - * sort the chunks by that field + * add built modules information */ - chunksSort?: string; + modules?: boolean; /** - * sort the assets by that field + * sort the modules by that field */ - assetsSort?: string; + modulesSort?: string; /** - * Add public path information + * add information about modules nested in other modules (like with module concatenation) */ - publicPath?: boolean; + nestedModules?: boolean; + /** + * show reasons why optimization bailed out for modules + */ + optimizationBailout?: boolean; /** * Add output path information */ outputPath?: boolean; + /** + * add performance hint flags + */ + performance?: boolean; /** * show exports provided by modules */ providedExports?: boolean; + /** + * Add public path information + */ + publicPath?: boolean; + /** + * add information about the reasons why modules are included + */ + reasons?: boolean; + /** + * add the source code of modules + */ + source?: boolean; + /** + * add timing information + */ + timings?: boolean; /** * show exports used by modules */ usedExports?: boolean; /** - * show reasons why optimization bailed out for modules + * add webpack version information */ - optimizationBailout?: boolean; + version?: boolean; + /** + * add warnings + */ + warnings?: boolean; + /** + * Suppress warnings that match the specified filters. Filters can be Strings, RegExps or Functions + */ + warningsFilter?: FilterTypes; } | boolean | ("none" | "errors-only" | "minimal" | "normal" | "detailed" | "verbose"); @@ -829,14 +829,14 @@ export interface WebpackOptions { ignored?: { [k: string]: any; }; - /** - * Stop watching when stdin stream has ended - */ - stdin?: boolean; /** * Enable polling mode for watching */ poll?: boolean | number; + /** + * Stop watching when stdin stream has ended + */ + stdin?: boolean; }; } /** @@ -844,6 +844,10 @@ export interface WebpackOptions { * via the `definition` "module". */ export interface Module { + /** + * An array of rules applied by default for modules. + */ + defaultRules?: RuleSetRules; /** * Enable warnings for full dynamic dependencies */ @@ -881,9 +885,13 @@ export interface Module { */ rules?: RuleSetRules; /** - * An array of rules applied by default for modules. + * Emit errors instead of warnings when imported names don't exist in imported module */ - defaultRules?: RuleSetRules; + strictExportPresence?: boolean; + /** + * Handle the this context correctly according to the spec for namespace objects + */ + strictThisContextOnImports?: boolean; /** * Enable warnings when using the require function in a not statically analyse-able way */ @@ -926,20 +934,16 @@ export interface Module { wrappedContextRegExp?: { [k: string]: any; }; - /** - * Emit errors instead of warnings when imported names don't exist in imported module - */ - strictExportPresence?: boolean; - /** - * Handle the this context correctly according to the spec for namespace objects - */ - strictThisContextOnImports?: boolean; } /** * This interface was referenced by `WebpackOptions`'s JSON-Schema * via the `definition` "ruleSet-rule". */ export interface RuleSetRule { + /** + * Match the child compiler name + */ + compiler?: RuleSetCondition; /** * Enforce this rule as pre or post step */ @@ -984,27 +988,14 @@ export interface RuleSetRule { parser?: { [k: string]: any; }; - /** - * Options for the resolver - */ - resolve?: Resolve; - /** - * Flags a module as with or without side effects - */ - sideEffects?: boolean; /** * Shortcut for use.query */ query?: RuleSetQuery; /** - * Module type to use for the module + * Options for the resolver */ - type?: - | "javascript/auto" - | "javascript/dynamic" - | "javascript/esm" - | "json" - | "webassembly/experimental"; + resolve?: Resolve; /** * Match the resource path of the module */ @@ -1015,20 +1006,29 @@ export interface RuleSetRule { * Match the resource query of the module */ resourceQuery?: RuleSetCondition; - /** - * Match the child compiler name - */ - compiler?: RuleSetCondition; /** * Match and execute these rules when this rule is matched */ rules?: RuleSetRules; + /** + * Flags a module as with or without side effects + */ + sideEffects?: boolean; /** * Shortcut for resource.test */ test?: RuleSetCondition & { [k: string]: any; }; + /** + * Module type to use for the module + */ + type?: + | "javascript/auto" + | "javascript/dynamic" + | "javascript/esm" + | "json" + | "webassembly/experimental"; /** * Modifiers applied to the module when rule is matched */ @@ -1077,6 +1077,10 @@ export interface Resolve { * Include the context information in the cache identifier when caching */ cacheWithContext?: boolean; + /** + * Enable concord resolving extras + */ + concord?: boolean; /** * Filenames used to find a description file */ @@ -1129,10 +1133,6 @@ export interface Resolve { * Enable resolving symlinks to the original location */ symlinks?: boolean; - /** - * Enable concord resolving extras - */ - concord?: boolean; /** * Enable caching of successfully resolved requests */ @@ -1204,30 +1204,22 @@ export interface Output { */ root?: string; }; + /** + * The callback function name used by webpack for loading of chunks in WebWorkers. + */ + chunkCallbackName?: string; /** * The filename of non-entry chunks as relative path inside the `output.path` directory. */ chunkFilename?: string; /** - * The filename of WebAssembly modules as relative path inside the `output.path` directory. + * Number of milliseconds before chunk request expires */ - webassemblyModuleFilename?: string; - /** - * An expression which is used to address the global object/scope in runtime code - */ - globalObject?: string; + chunkLoadTimeout?: number; /** * This option enables cross-origin loading of chunks. */ crossOriginLoading?: false | "anonymous" | "use-credentials"; - /** - * This option enables loading async chunks via a custom script type, such as script type="module" - */ - jsonpScriptType?: false | "text/javascript" | "module"; - /** - * Number of milliseconds before chunk request expires - */ - chunkLoadTimeout?: number; /** * Similar to `output.devtoolModuleFilenameTemplate`, but used in the case of duplicate module identifiers. */ @@ -1264,6 +1256,10 @@ export interface Output { | { [k: string]: any; }; + /** + * An expression which is used to address the global object/scope in runtime code + */ + globalObject?: string; /** * Digest type used for the hash */ @@ -1309,9 +1305,9 @@ export interface Output { */ jsonpFunction?: string; /** - * The callback function name used by webpack for loading of chunks in WebWorkers. + * This option enables loading async chunks via a custom script type, such as script type="module" */ - chunkCallbackName?: string; + jsonpScriptType?: false | "text/javascript" | "module"; /** * If set, export the bundle as library. `output.library` is the name. */ @@ -1319,10 +1315,6 @@ export interface Output { | string | string[] | { - /** - * Name of the property exposed globally by a UMD library - */ - root?: string | CommonArrayOfStringValues; /** * Name of the exposed AMD library in the UMD */ @@ -1331,7 +1323,15 @@ export interface Output { * Name of the exposed commonjs export in the UMD */ commonjs?: string; + /** + * Name of the property exposed globally by a UMD library + */ + root?: string | CommonArrayOfStringValues; }; + /** + * Specify which export should be exposed as library + */ + libraryExport?: string | CommonArrayOfStringValues; /** * Type of library */ @@ -1349,10 +1349,6 @@ export interface Output { | "umd" | "umd2" | "jsonp"; - /** - * Specify which export should be exposed as library - */ - libraryExport?: string | CommonArrayOfStringValues; /** * The output directory as **absolute path** (required). */ @@ -1385,4 +1381,8 @@ export interface Output { * If `output.libraryTarget` is set to umd and `output.library` is set, setting this to true will name the AMD module. */ umdNamedDefine?: boolean; + /** + * The filename of WebAssembly modules as relative path inside the `output.path` directory. + */ + webassemblyModuleFilename?: string; } diff --git a/declarations/plugins/BannerPlugin.d.ts b/declarations/plugins/BannerPlugin.d.ts index f2fed4076..b511c8873 100644 --- a/declarations/plugins/BannerPlugin.d.ts +++ b/declarations/plugins/BannerPlugin.d.ts @@ -14,26 +14,26 @@ export type BannerPlugin = [k: string]: any; } | string; - /** - * If true, banner will not be wrapped in a comment - */ - raw?: boolean; /** * If true, the banner will only be added to the entry chunks */ entryOnly?: boolean; /** - * Include all modules that pass test assertion + * Exclude all modules matching any of these conditions */ - test?: Rules; + exclude?: Rules; /** * Include all modules matching any of these conditions */ include?: Rules; /** - * Exclude all modules matching any of these conditions + * If true, banner will not be wrapped in a comment */ - exclude?: Rules; + raw?: boolean; + /** + * Include all modules that pass test assertion + */ + test?: Rules; } | { [k: string]: any; diff --git a/declarations/plugins/DllPlugin.d.ts b/declarations/plugins/DllPlugin.d.ts index d1bca110f..136cbe18d 100644 --- a/declarations/plugins/DllPlugin.d.ts +++ b/declarations/plugins/DllPlugin.d.ts @@ -9,20 +9,20 @@ export interface DllPlugin { * Context of requests in the manifest file (defaults to the webpack context) */ context?: string; + /** + * If true, only entry points will be exposed + */ + entryOnly?: boolean; /** * Name of the exposed dll function (external name, use value of 'output.library') */ name?: string; - /** - * Type of the dll bundle (external type, use value of 'output.libraryTarget') - */ - type?: string; /** * Absolute path to the manifest json file (output) */ path: string; /** - * If true, only entry points will be exposed + * Type of the dll bundle (external type, use value of 'output.libraryTarget') */ - entryOnly?: boolean; + type?: string; } diff --git a/declarations/plugins/HashedModuleIdsPlugin.d.ts b/declarations/plugins/HashedModuleIdsPlugin.d.ts index 8fcc1324b..8175918c5 100644 --- a/declarations/plugins/HashedModuleIdsPlugin.d.ts +++ b/declarations/plugins/HashedModuleIdsPlugin.d.ts @@ -5,10 +5,6 @@ */ export interface HashedModuleIdsPlugin { - /** - * The hashing algorithm to use, defaults to 'md5'. All functions from Node.JS' crypto.createHash are supported. - */ - hashFunction?: string; /** * The encoding to use when generating the hash, defaults to 'base64'. All encodings from Node.JS' hash.digest are supported. */ @@ -17,4 +13,8 @@ export interface HashedModuleIdsPlugin { * The prefix length of the hash digest to use, defaults to 4. */ hashDigestLength?: number; + /** + * The hashing algorithm to use, defaults to 'md5'. All functions from Node.JS' crypto.createHash are supported. + */ + hashFunction?: string; } diff --git a/declarations/plugins/IgnorePlugin.d.ts b/declarations/plugins/IgnorePlugin.d.ts index 099e09ed7..7b5685983 100644 --- a/declarations/plugins/IgnorePlugin.d.ts +++ b/declarations/plugins/IgnorePlugin.d.ts @@ -6,30 +6,30 @@ export type IgnorePlugin = | { - /** - * A RegExp to test the request against - */ - resourceRegExp?: { - [k: string]: any; - }; /** * A RegExp to test the context (directory) against */ contextRegExp?: { [k: string]: any; }; - } - | { /** - * A filter function for resource + * A RegExp to test the request against */ - checkResource?: { + resourceRegExp?: { [k: string]: any; }; + } + | { /** * A filter function for context */ checkContext?: { [k: string]: any; }; + /** + * A filter function for resource + */ + checkResource?: { + [k: string]: any; + }; }; diff --git a/declarations/plugins/SourceMapDevToolPlugin.d.ts b/declarations/plugins/SourceMapDevToolPlugin.d.ts index 1bd374c2e..c8957e1e5 100644 --- a/declarations/plugins/SourceMapDevToolPlugin.d.ts +++ b/declarations/plugins/SourceMapDevToolPlugin.d.ts @@ -20,34 +20,18 @@ export type Rule = | string; export interface SourceMapDevToolPlugin { - /** - * Include source maps for modules based on their extension (defaults to .js and .css) - */ - test?: Rules; - /** - * Include source maps for module paths that match the given value - */ - include?: Rules; - /** - * Exclude modules that match the given value from source map generation - */ - exclude?: Rules; - /** - * Defines the output filename of the SourceMap (will be inlined if no value is provided) - */ - filename?: (false | null) | string; /** * Appends the given value to the original asset. Usually the #sourceMappingURL comment. [url] is replaced with a URL to the source map file. false disables the appending */ append?: (false | null) | string; /** - * Generator string or function to create identifiers of modules for the 'sources' array in the SourceMap + * Indicates whether column mappings should be used (defaults to true) */ - moduleFilenameTemplate?: - | { - [k: string]: any; - } - | string; + columns?: boolean; + /** + * Exclude modules that match the given value from source map generation + */ + exclude?: Rules; /** * Generator string or function to create identifiers of modules for the 'sources' array in the SourceMap used only if 'moduleFilenameTemplate' would result in a conflict */ @@ -56,34 +40,18 @@ export interface SourceMapDevToolPlugin { [k: string]: any; } | string; - /** - * Namespace prefix to allow multiple webpack roots in the devtools - */ - namespace?: string; - /** - * Indicates whether SourceMaps from loaders should be used (defaults to true) - */ - module?: boolean; - /** - * Indicates whether column mappings should be used (defaults to true) - */ - columns?: boolean; - /** - * Omit the 'sourceContents' array from the SourceMap - */ - noSources?: boolean; - /** - * Provide a custom value for the 'sourceRoot' property in the SourceMap - */ - sourceRoot?: string; - /** - * Provide a custom public path for the SourceMapping comment - */ - publicPath?: string; /** * Path prefix to which the [file] placeholder is relative to */ fileContext?: string; + /** + * Defines the output filename of the SourceMap (will be inlined if no value is provided) + */ + filename?: (false | null) | string; + /** + * Include source maps for module paths that match the given value + */ + include?: Rules; /** * (deprecated) try to map original files line to line to generated files */ @@ -91,16 +59,48 @@ export interface SourceMapDevToolPlugin { | boolean | { /** - * Include source maps for modules based on their extension (defaults to .js and .css) + * Exclude modules that match the given value from source map generation */ - test?: Rules; + exclude?: Rules; /** * Include source maps for module paths that match the given value */ include?: Rules; /** - * Exclude modules that match the given value from source map generation + * Include source maps for modules based on their extension (defaults to .js and .css) */ - exclude?: Rules; + test?: Rules; }; + /** + * Indicates whether SourceMaps from loaders should be used (defaults to true) + */ + module?: boolean; + /** + * Generator string or function to create identifiers of modules for the 'sources' array in the SourceMap + */ + moduleFilenameTemplate?: + | { + [k: string]: any; + } + | string; + /** + * Namespace prefix to allow multiple webpack roots in the devtools + */ + namespace?: string; + /** + * Omit the 'sourceContents' array from the SourceMap + */ + noSources?: boolean; + /** + * Provide a custom public path for the SourceMapping comment + */ + publicPath?: string; + /** + * Provide a custom value for the 'sourceRoot' property in the SourceMap + */ + sourceRoot?: string; + /** + * Include source maps for modules based on their extension (defaults to .js and .css) + */ + test?: Rules; } diff --git a/declarations/plugins/optimize/AggressiveSplittingPlugin.d.ts b/declarations/plugins/optimize/AggressiveSplittingPlugin.d.ts index 6ee0dbd69..4088b94d0 100644 --- a/declarations/plugins/optimize/AggressiveSplittingPlugin.d.ts +++ b/declarations/plugins/optimize/AggressiveSplittingPlugin.d.ts @@ -5,14 +5,6 @@ */ export interface AggressiveSplittingPlugin { - /** - * Byte, split point. Default: 30720 - */ - minSize?: number; - /** - * Byte, maxsize of per file. Default: 51200 - */ - maxSize?: number; /** * Default: 0 */ @@ -21,4 +13,12 @@ export interface AggressiveSplittingPlugin { * Default: 1 */ entryChunkMultiplicator?: number; + /** + * Byte, maxsize of per file. Default: 51200 + */ + maxSize?: number; + /** + * Byte, split point. Default: 30720 + */ + minSize?: number; } diff --git a/package.json b/package.json index fa1441539..f91dab308 100644 --- a/package.json +++ b/package.json @@ -122,8 +122,8 @@ "lint": "yarn code-lint && yarn schema-lint && yarn type-lint && yarn special-lint", "code-lint": "eslint --cache \"{setup,lib,bin,hot,buildin,benchmark,tooling,schemas}/**/*.js\" \"test/*.js\" \"test/{configCases,watchCases,statsCases,hotCases}/**/webpack.config.js\" \"examples/**/webpack.config.js\"", "type-lint": "tsc --pretty", - "special-lint": "node tooling/inherit-types && node tooling/compile-to-definitions", - "special-lint-fix": "node tooling/inherit-types --write --override && node tooling/compile-to-definitions --write", + "special-lint": "node tooling/inherit-types && node tooling/format-schemas && node tooling/compile-to-definitions", + "special-lint-fix": "node tooling/inherit-types --write --override && node tooling/format-schemas --write && node tooling/compile-to-definitions --write", "fix": "yarn code-lint --fix && yarn special-lint-fix", "pretty": "prettier --loglevel warn --write \"*.{ts,js,json}\" \"{setup,lib,bin,hot,buildin,benchmark,tooling,schemas}/**/*.{js,json}\" \"test/*.js\" \"test/{configCases,watchCases,statsCases,hotCases}/**/webpack.config.js\" \"examples/**/webpack.config.js\"", "schema-lint": "node --max-old-space-size=4096 node_modules/jest-cli/bin/jest --testMatch \"/test/*.lint.js\" --no-verbose", diff --git a/schemas/WebpackOptions.json b/schemas/WebpackOptions.json index ac11bfcdd..e5f9c6529 100644 --- a/schemas/WebpackOptions.json +++ b/schemas/WebpackOptions.json @@ -1,79 +1,79 @@ { - "additionalProperties": false, "definitions": { - "common.pluginFunction": { - "description": "Function acting as plugin", - "instanceof": "Function", - "properties": { - "apply": { - "description": "The run point of the plugin, required method.", - "instanceof": "Function" - } - }, - "additionalProperties": true, - "required": ["apply"] - }, - "common.pluginObject": { - "description": "Plugin instance", - "type": "object", - "properties": { - "apply": { - "description": "The run point of the plugin, required method.", - "instanceof": "Function" - } - }, - "additionalProperties": true, - "required": ["apply"] - }, "common.arrayOfStringOrStringArrayValues": { + "type": "array", "items": { "description": "string or array of strings", "anyOf": [ { - "minLength": 1, - "type": "string" + "type": "string", + "minLength": 1 }, { + "type": "array", "items": { "description": "A non-empty string", - "minLength": 1, - "type": "string" - }, - "type": "array" + "type": "string", + "minLength": 1 + } } ] - }, - "type": "array" + } }, "common.arrayOfStringValues": { + "type": "array", "items": { "description": "A non-empty string", - "minLength": 1, - "type": "string" - }, - "type": "array" + "type": "string", + "minLength": 1 + } }, "common.nonEmptyArrayOfUniqueStringValues": { + "type": "array", "items": { "description": "A non-empty string", - "minLength": 1, - "type": "string" + "type": "string", + "minLength": 1 }, "minItems": 1, - "type": "array", "uniqueItems": true }, + "common.pluginFunction": { + "description": "Function acting as plugin", + "additionalProperties": true, + "properties": { + "apply": { + "description": "The run point of the plugin, required method.", + "instanceof": "Function" + } + }, + "required": ["apply"], + "instanceof": "Function" + }, + "common.pluginObject": { + "description": "Plugin instance", + "type": "object", + "additionalProperties": true, + "properties": { + "apply": { + "description": "The run point of the plugin, required method.", + "instanceof": "Function" + } + }, + "required": ["apply"] + }, "entry": { "oneOf": [ { - "minProperties": 1, + "description": "Multiple entry bundles are created. The key is the chunk name. The value can be a string or an array.", + "type": "object", "additionalProperties": { "description": "An entry point with name", "oneOf": [ { "description": "The string is resolved to a module which is loaded upon startup.", - "minLength": 1, - "type": "string" + "type": "string", + "minLength": 1 }, { "description": "All modules are loaded upon startup. The last one is exported.", @@ -85,13 +85,12 @@ } ] }, - "description": "Multiple entry bundles are created. The key is the chunk name. The value can be a string or an array.", - "type": "object" + "minProperties": 1 }, { "description": "An entry point without name. The string is resolved to a module which is loaded upon startup.", - "minLength": 1, - "type": "string" + "type": "string", + "minLength": 1 }, { "description": "An entry point without name. All modules are loaded upon startup. The last one is exported.", @@ -114,6 +113,8 @@ "type": "string" }, { + "description": "If an dependency matches exactly a property of the object, the property value is used as dependency.", + "type": "object", "additionalProperties": { "description": "The dependency used for the external", "anyOf": [ @@ -130,9 +131,7 @@ "type": "boolean" } ] - }, - "description": "If an dependency matches exactly a property of the object, the property value is used as dependency.", - "type": "object" + } }, { "description": "`function(context, request, callback(err, result))` The function is called on each dependency.", @@ -143,6 +142,7 @@ "instanceof": "RegExp" }, { + "type": "array", "items": { "description": "External configuration", "anyOf": [ @@ -150,14 +150,53 @@ "$ref": "#/definitions/externals" } ] - }, - "type": "array" + } + } + ] + }, + "filter-item-types": { + "anyOf": [ + { + "instanceof": "RegExp" + }, + { + "type": "string" + }, + { + "instanceof": "Function" + } + ] + }, + "filter-types": { + "anyOf": [ + { + "$ref": "#/definitions/filter-item-types" + }, + { + "type": "array", + "items": { + "description": "Rule to filter", + "anyOf": [ + { + "$ref": "#/definitions/filter-item-types" + } + ] + } } ] }, "module": { + "type": "object", "additionalProperties": false, "properties": { + "defaultRules": { + "description": "An array of rules applied by default for modules.", + "anyOf": [ + { + "$ref": "#/definitions/ruleSet-rules" + } + ] + }, "exprContextCritical": { "description": "Enable warnings for full dynamic dependencies", "type": "boolean" @@ -185,12 +224,12 @@ "description": "Don't parse files matching. It's matched against the full resolved request.", "anyOf": [ { + "type": "array", "items": { "description": "A regular expression, when matched the module is not parsed", "instanceof": "RegExp" }, - "minItems": 1, - "type": "array" + "minItems": 1 }, { "instanceof": "RegExp" @@ -199,13 +238,13 @@ "instanceof": "Function" }, { + "type": "array", "items": { "description": "An absolute path, when the module starts with this path it is not parsed", "type": "string", "absolutePath": true }, - "minItems": 1, - "type": "array" + "minItems": 1 }, { "type": "string", @@ -214,21 +253,21 @@ ] }, "rules": { + "description": "An array of rules applied for modules.", "allOf": [ { "$ref": "#/definitions/ruleSet-rules" } - ], - "description": "An array of rules applied for modules." - }, - "defaultRules": { - "description": "An array of rules applied by default for modules.", - "anyOf": [ - { - "$ref": "#/definitions/ruleSet-rules" - } ] }, + "strictExportPresence": { + "description": "Emit errors instead of warnings when imported names don't exist in imported module", + "type": "boolean" + }, + "strictThisContextOnImports": { + "description": "Handle the this context correctly according to the spec for namespace objects", + "type": "boolean" + }, "unknownContextCritical": { "description": "Enable warnings when using the require function in a not statically analyse-able way", "type": "boolean" @@ -274,19 +313,11 @@ "wrappedContextRegExp": { "description": "Set the inner regular expression for partial dynamic dependencies", "instanceof": "RegExp" - }, - "strictExportPresence": { - "description": "Emit errors instead of warnings when imported names don't exist in imported module", - "type": "boolean" - }, - "strictThisContextOnImports": { - "description": "Handle the this context correctly according to the spec for namespace objects", - "type": "boolean" } - }, - "type": "object" + } }, "output": { + "type": "object", "additionalProperties": false, "properties": { "auxiliaryComment": { @@ -297,8 +328,9 @@ "type": "string" }, { - "additionalProperties": false, "description": "Set explicit comments for `commonjs`, `commonjs2`, `amd`, and `root`.", + "type": "object", + "additionalProperties": false, "properties": { "amd": { "description": "Set comment for `amd` section in UMD", @@ -316,38 +348,27 @@ "description": "Set comment for `root` (global variable) section in UMD", "type": "string" } - }, - "type": "object" + } } ] }, + "chunkCallbackName": { + "description": "The callback function name used by webpack for loading of chunks in WebWorkers.", + "type": "string" + }, "chunkFilename": { "description": "The filename of non-entry chunks as relative path inside the `output.path` directory.", "type": "string", "absolutePath": false }, - "webassemblyModuleFilename": { - "description": "The filename of WebAssembly modules as relative path inside the `output.path` directory.", - "type": "string", - "absolutePath": false - }, - "globalObject": { - "description": "An expression which is used to address the global object/scope in runtime code", - "type": "string", - "minLength": 1 + "chunkLoadTimeout": { + "description": "Number of milliseconds before chunk request expires", + "type": "number" }, "crossOriginLoading": { "description": "This option enables cross-origin loading of chunks.", "enum": [false, "anonymous", "use-credentials"] }, - "jsonpScriptType": { - "description": "This option enables loading async chunks via a custom script type, such as script type=\"module\"", - "enum": [false, "text/javascript", "module"] - }, - "chunkLoadTimeout": { - "description": "Number of milliseconds before chunk request expires", - "type": "number" - }, "devtoolFallbackModuleFilenameTemplate": { "description": "Similar to `output.devtoolModuleFilenameTemplate`, but used in the case of duplicate module identifiers.", "anyOf": [ @@ -399,14 +420,19 @@ ], "absolutePath": false }, + "globalObject": { + "description": "An expression which is used to address the global object/scope in runtime code", + "type": "string", + "minLength": 1 + }, "hashDigest": { "description": "Digest type used for the hash", "type": "string" }, "hashDigestLength": { "description": "Number of chars which are used for the hash", - "minimum": 1, - "type": "number" + "type": "number", + "minimum": 1 }, "hashFunction": { "description": "Algorithm used for generation the hash (see node.js crypto package)", @@ -422,8 +448,8 @@ }, "hashSalt": { "description": "Any string which is added to the hash to salt it", - "minLength": 1, - "type": "string" + "type": "string", + "minLength": 1 }, "hotUpdateChunkFilename": { "description": "The filename of the Hot Update Chunks. They are inside the output.path directory.", @@ -457,26 +483,35 @@ "description": "The JSONP function used by webpack for async loading of chunks.", "type": "string" }, - "chunkCallbackName": { - "description": "The callback function name used by webpack for loading of chunks in WebWorkers.", - "type": "string" + "jsonpScriptType": { + "description": "This option enables loading async chunks via a custom script type, such as script type=\"module\"", + "enum": [false, "text/javascript", "module"] }, "library": { + "description": "If set, export the bundle as library. `output.library` is the name.", "anyOf": [ { "type": "string" }, { + "type": "array", "items": { "description": "A part of the library name", "type": "string" - }, - "type": "array" + } }, { "type": "object", "additionalProperties": false, "properties": { + "amd": { + "description": "Name of the exposed AMD library in the UMD", + "type": "string" + }, + "commonjs": { + "description": "Name of the exposed commonjs export in the UMD", + "type": "string" + }, "root": { "description": "Name of the property exposed globally by a UMD library", "anyOf": [ @@ -487,19 +522,21 @@ "$ref": "#/definitions/common.arrayOfStringValues" } ] - }, - "amd": { - "description": "Name of the exposed AMD library in the UMD", - "type": "string" - }, - "commonjs": { - "description": "Name of the exposed commonjs export in the UMD", - "type": "string" } } } - ], - "description": "If set, export the bundle as library. `output.library` is the name." + ] + }, + "libraryExport": { + "description": "Specify which export should be exposed as library", + "anyOf": [ + { + "type": "string" + }, + { + "$ref": "#/definitions/common.arrayOfStringValues" + } + ] }, "libraryTarget": { "description": "Type of library", @@ -519,17 +556,6 @@ "jsonp" ] }, - "libraryExport": { - "description": "Specify which export should be exposed as library", - "anyOf": [ - { - "type": "string" - }, - { - "$ref": "#/definitions/common.arrayOfStringValues" - } - ] - }, "path": { "description": "The output directory as **absolute path** (required).", "type": "string", @@ -566,26 +592,33 @@ "umdNamedDefine": { "description": "If `output.libraryTarget` is set to umd and `output.library` is set, setting this to true will name the AMD module.", "type": "boolean" + }, + "webassemblyModuleFilename": { + "description": "The filename of WebAssembly modules as relative path inside the `output.path` directory.", + "type": "string", + "absolutePath": false } - }, - "type": "object" + } }, "resolve": { + "type": "object", "additionalProperties": false, "properties": { "alias": { "description": "Redirect module requests", "anyOf": [ { + "type": "object", "additionalProperties": { "description": "New request", "type": "string" - }, - "type": "object" + } }, { + "type": "array", "items": { "description": "Alias configuration", + "type": "object", "additionalProperties": false, "properties": { "alias": { @@ -600,10 +633,8 @@ "description": "Redirect only exact matching request", "type": "boolean" } - }, - "type": "object" - }, - "type": "array" + } + } } ] }, @@ -623,6 +654,10 @@ "description": "Include the context information in the cache identifier when caching", "type": "boolean" }, + "concord": { + "description": "Enable concord resolving extras", + "type": "boolean" + }, "descriptionFiles": { "description": "Filenames used to find a description file", "anyOf": [ @@ -704,10 +739,6 @@ "description": "Enable resolving symlinks to the original location", "type": "boolean" }, - "concord": { - "description": "Enable concord resolving extras", - "type": "boolean" - }, "unsafeCache": { "description": "Enable caching of successfully resolved requests", "anyOf": [ @@ -715,8 +746,8 @@ "type": "boolean" }, { - "additionalProperties": true, - "type": "object" + "type": "object", + "additionalProperties": true } ] }, @@ -724,8 +755,7 @@ "description": "Use synchronous filesystem calls for the resolver", "type": "boolean" } - }, - "type": "object" + } }, "ruleSet-condition": { "anyOf": [ @@ -733,8 +763,8 @@ "instanceof": "RegExp" }, { - "minLength": 1, - "type": "string" + "type": "string", + "minLength": 1 }, { "instanceof": "Function" @@ -743,6 +773,7 @@ "$ref": "#/definitions/ruleSet-conditions" }, { + "type": "object", "additionalProperties": false, "properties": { "and": { @@ -793,12 +824,12 @@ } ] } - }, - "type": "object" + } } ] }, "ruleSet-conditions": { + "type": "array", "items": { "description": "A rule condition", "anyOf": [ @@ -806,12 +837,11 @@ "$ref": "#/definitions/ruleSet-condition" } ] - }, - "type": "array" + } }, "ruleSet-loader": { - "minLength": 1, - "type": "string" + "type": "string", + "minLength": 1 }, "ruleSet-query": { "anyOf": [ @@ -824,8 +854,17 @@ ] }, "ruleSet-rule": { + "type": "object", "additionalProperties": false, "properties": { + "compiler": { + "description": "Match the child compiler name", + "anyOf": [ + { + "$ref": "#/definitions/ruleSet-condition" + } + ] + }, "enforce": { "description": "Enforce this rule as pre or post step", "enum": ["pre", "post"] @@ -900,21 +939,8 @@ }, "parser": { "description": "Options for parsing", - "additionalProperties": true, - "type": "object" - }, - "resolve": { - "description": "Options for the resolver", "type": "object", - "anyOf": [ - { - "$ref": "#/definitions/resolve" - } - ] - }, - "sideEffects": { - "description": "Flags a module as with or without side effects", - "type": "boolean" + "additionalProperties": true }, "query": { "description": "Shortcut for use.query", @@ -924,14 +950,13 @@ } ] }, - "type": { - "description": "Module type to use for the module", - "enum": [ - "javascript/auto", - "javascript/dynamic", - "javascript/esm", - "json", - "webassembly/experimental" + "resolve": { + "description": "Options for the resolver", + "type": "object", + "anyOf": [ + { + "$ref": "#/definitions/resolve" + } ] }, "resource": { @@ -953,14 +978,6 @@ } ] }, - "compiler": { - "description": "Match the child compiler name", - "anyOf": [ - { - "$ref": "#/definitions/ruleSet-condition" - } - ] - }, "rules": { "description": "Match and execute these rules when this rule is matched", "anyOf": [ @@ -969,6 +986,10 @@ } ] }, + "sideEffects": { + "description": "Flags a module as with or without side effects", + "type": "boolean" + }, "test": { "description": "Shortcut for resource.test", "allOf": [ @@ -980,6 +1001,16 @@ } ] }, + "type": { + "description": "Module type to use for the module", + "enum": [ + "javascript/auto", + "javascript/dynamic", + "javascript/esm", + "json", + "webassembly/experimental" + ] + }, "use": { "description": "Modifiers applied to the module when rule is matched", "anyOf": [ @@ -988,10 +1019,10 @@ } ] } - }, - "type": "object" + } }, "ruleSet-rules": { + "type": "array", "items": { "description": "A rule", "anyOf": [ @@ -999,8 +1030,7 @@ "$ref": "#/definitions/ruleSet-rule" } ] - }, - "type": "array" + } }, "ruleSet-use": { "anyOf": [ @@ -1011,6 +1041,7 @@ "instanceof": "Function" }, { + "type": "array", "items": { "description": "An use item", "anyOf": [ @@ -1018,8 +1049,7 @@ "$ref": "#/definitions/ruleSet-use-item" } ] - }, - "type": "array" + } } ] }, @@ -1032,8 +1062,13 @@ "instanceof": "Function" }, { + "type": "object", "additionalProperties": false, "properties": { + "ident": { + "description": "Unique loader identifier", + "type": "string" + }, "loader": { "description": "Loader name", "anyOf": [ @@ -1050,10 +1085,6 @@ } ] }, - "ident": { - "description": "Unique loader identifier", - "type": "string" - }, "query": { "description": "Loader query", "anyOf": [ @@ -1062,48 +1093,14 @@ } ] } - }, - "type": "object" - } - ] - }, - "filter-item-types": { - "anyOf": [ - { - "instanceof": "RegExp" - }, - { - "type": "string" - }, - { - "instanceof": "Function" - } - ] - }, - "filter-types": { - "anyOf": [ - { - "$ref": "#/definitions/filter-item-types" - }, - { - "type": "array", - "items": { - "description": "Rule to filter", - "anyOf": [ - { - "$ref": "#/definitions/filter-item-types" - } - ] } } ] } }, + "type": "object", + "additionalProperties": false, "properties": { - "mode": { - "description": "Enable production optimizations or development hints.", - "enum": ["development", "production", "none"] - }, "amd": { "description": "Set the value of `require.amd` and `define.amd`." }, @@ -1131,11 +1128,11 @@ }, "dependencies": { "description": "References to other configurations to depend on.", + "type": "array", "items": { "description": "References to another configuration to depend on.", "type": "string" - }, - "type": "array" + } }, "devServer": { "description": "Options for the webpack-dev-server", @@ -1172,6 +1169,10 @@ "description": "Custom values available in the loader context.", "type": "object" }, + "mode": { + "description": "Enable production optimizations or development hints.", + "enum": ["development", "production", "none"] + }, "module": { "description": "Options affecting the normal modules (`NormalModuleFactory`).", "anyOf": [ @@ -1191,6 +1192,7 @@ "enum": [false] }, { + "type": "object", "additionalProperties": { "description": "Include a polyfill for the node.js module", "enum": [false, true, "mock", "empty"] @@ -1220,16 +1222,7 @@ "description": "Include a polyfill for the 'process' variable", "enum": [false, true, "mock"] } - }, - "type": "object" - } - ] - }, - "output": { - "description": "Options affecting the output of the compilation. `output` options tell webpack how to write the compiled files to disk.", - "anyOf": [ - { - "$ref": "#/definitions/output" + } } ] }, @@ -1238,6 +1231,92 @@ "type": "object", "additionalProperties": false, "properties": { + "checkWasmTypes": { + "description": "Check for incompatible wasm types when importing/exporting from/to ESM", + "type": "boolean" + }, + "chunkIds": { + "description": "Define the algorithm to choose chunk ids (named: readable ids for better debugging, size: numeric ids focused on minimal initial download size, total-size: numeric ids focused on minimal total download size, false: no algorithm used, as custom one can be provided via plugin)", + "enum": ["natural", "named", "size", "total-size", false] + }, + "concatenateModules": { + "description": "Concatenate modules when possible to generate less modules, more efficient code and enable more optimizations by the minimizer", + "type": "boolean" + }, + "flagIncludedChunks": { + "description": "Also flag chunks as loaded which contain a subset of the modules", + "type": "boolean" + }, + "hashedModuleIds": { + "description": "Use hashed module id instead module identifiers for better long term caching (deprecated, used moduleIds: hashed instead)", + "type": "boolean" + }, + "mangleWasmImports": { + "description": "Reduce size of WASM by changing imports to shorter strings.", + "type": "boolean" + }, + "mergeDuplicateChunks": { + "description": "Merge chunks which contain the same modules", + "type": "boolean" + }, + "minimize": { + "description": "Enable minimizing the output. Uses optimization.minimizer.", + "type": "boolean" + }, + "minimizer": { + "description": "Minimizer(s) to use for minimizing the output", + "type": "array", + "items": { + "description": "Plugin of type object or instanceof Function", + "anyOf": [ + { + "$ref": "#/definitions/common.pluginObject" + }, + { + "$ref": "#/definitions/common.pluginFunction" + } + ] + } + }, + "moduleIds": { + "description": "Define the algorithm to choose module ids (natural: numeric ids in order of usage, named: readable ids for better debugging, hashed: short hashes as ids for better long term caching, size: numeric ids focused on minimal initial download size, total-size: numeric ids focused on minimal total download size, false: no algorithm used, as custom one can be provided via plugin)", + "enum": ["natural", "named", "hashed", "size", "total-size", false] + }, + "namedChunks": { + "description": "Use readable chunk identifiers for better debugging (deprecated, used chunkIds: named instead)", + "type": "boolean" + }, + "namedModules": { + "description": "Use readable module identifiers for better debugging (deprecated, used moduleIds: named instead)", + "type": "boolean" + }, + "noEmitOnErrors": { + "description": "Avoid emitting assets when errors occur", + "type": "boolean" + }, + "nodeEnv": { + "description": "Set process.env.NODE_ENV to a specific value", + "anyOf": [ + { + "enum": [false] + }, + { + "type": "string" + } + ] + }, + "occurrenceOrder": { + "description": "Figure out a order of modules which results in the smallest initial bundle", + "type": "boolean" + }, + "portableRecords": { + "description": "Generate records with relative paths to be able to move the context folder", + "type": "boolean" + }, + "providedExports": { + "description": "Figure out which exports are provided by modules to generate more efficient code", + "type": "boolean" + }, "removeAvailableModules": { "description": "Removes modules from chunks when these modules are already included in all parents", "type": "boolean" @@ -1246,251 +1325,6 @@ "description": "Remove chunks which are empty", "type": "boolean" }, - "mergeDuplicateChunks": { - "description": "Merge chunks which contain the same modules", - "type": "boolean" - }, - "flagIncludedChunks": { - "description": "Also flag chunks as loaded which contain a subset of the modules", - "type": "boolean" - }, - "occurrenceOrder": { - "description": "Figure out a order of modules which results in the smallest initial bundle", - "type": "boolean" - }, - "sideEffects": { - "description": "Skip over modules which are flagged to contain no side effects when exports are not used", - "type": "boolean" - }, - "providedExports": { - "description": "Figure out which exports are provided by modules to generate more efficient code", - "type": "boolean" - }, - "usedExports": { - "description": "Figure out which exports are used by modules to mangle export names, omit unused exports and generate more efficient code", - "type": "boolean" - }, - "concatenateModules": { - "description": "Concatenate modules when possible to generate less modules, more efficient code and enable more optimizations by the minimizer", - "type": "boolean" - }, - "splitChunks": { - "description": "Optimize duplication and caching by splitting chunks by shared modules and cache group", - "oneOf": [ - { - "enum": [false] - }, - { - "type": "object", - "additionalProperties": false, - "properties": { - "chunks": { - "description": "Select chunks for determining shared modules (defaults to \"async\", \"initial\" and \"all\" requires adding these chunks to the HTML)", - "oneOf": [ - { - "enum": ["initial", "async", "all"] - }, - { - "instanceof": "Function" - } - ] - }, - "minSize": { - "description": "Minimal size for the created chunks", - "type": "number", - "minimum": 0 - }, - "maxSize": { - "description": "Maximal size hint for the created chunks", - "type": "number", - "minimum": 0 - }, - "minChunks": { - "description": "Minimum number of times a module has to be duplicated until it's considered for splitting", - "type": "number", - "minimum": 1 - }, - "maxAsyncRequests": { - "description": "Maximum number of requests which are accepted for on-demand loading", - "type": "number", - "minimum": 1 - }, - "maxInitialRequests": { - "description": "Maximum number of initial chunks which are accepted for an entry point", - "type": "number", - "minimum": 1 - }, - "name": { - "description": "Give chunks created a name (chunks with equal name are merged)", - "oneOf": [ - { - "type": "boolean" - }, - { - "instanceof": "Function" - }, - { - "type": "string" - } - ] - }, - "filename": { - "description": "Sets the template for the filename for created chunks (Only works for initial chunks)", - "type": "string", - "minLength": 1 - }, - "automaticNameDelimiter": { - "description": "Sets the name delimiter for created chunks", - "type": "string", - "minLength": 1 - }, - "hidePathInfo": { - "description": "Prevents exposing path info when creating names for parts splitted by maxSize", - "type": "boolean" - }, - "fallbackCacheGroup": { - "description": "Options for modules not selected by any other cache group", - "type": "object", - "additionalProperties": false, - "properties": { - "minSize": { - "description": "Minimal size for the created chunk", - "type": "number", - "minimum": 0 - }, - "maxSize": { - "description": "Maximal size hint for the created chunks", - "type": "number", - "minimum": 0 - }, - "automaticNameDelimiter": { - "description": "Sets the name delimiter for created chunks", - "type": "string", - "minLength": 1 - } - } - }, - "cacheGroups": { - "description": "Assign modules to a cache group (modules from different cache groups are tried to keep in separate chunks)", - "type": "object", - "additionalProperties": { - "description": "Configuration for a cache group", - "anyOf": [ - { - "enum": [false] - }, - { - "instanceof": "Function" - }, - { - "type": "string" - }, - { - "instanceof": "RegExp" - }, - { - "type": "object", - "additionalProperties": false, - "properties": { - "test": { - "description": "Assign modules to a cache group", - "oneOf": [ - { - "instanceof": "Function" - }, - { - "type": "string" - }, - { - "instanceof": "RegExp" - } - ] - }, - "chunks": { - "description": "Select chunks for determining cache group content (defaults to \"initial\", \"initial\" and \"all\" requires adding these chunks to the HTML)", - "oneOf": [ - { - "enum": ["initial", "async", "all"] - }, - { - "instanceof": "Function" - } - ] - }, - "enforce": { - "description": "Ignore minimum size, minimum chunks and maximum requests and always create chunks for this cache group", - "type": "boolean" - }, - "priority": { - "description": "Priority of this cache group", - "type": "number" - }, - "minSize": { - "description": "Minimal size for the created chunk", - "type": "number", - "minimum": 0 - }, - "maxSize": { - "description": "Maximal size hint for the created chunks", - "type": "number", - "minimum": 0 - }, - "minChunks": { - "description": "Minimum number of times a module has to be duplicated until it's considered for splitting", - "type": "number", - "minimum": 1 - }, - "maxAsyncRequests": { - "description": "Maximum number of requests which are accepted for on-demand loading", - "type": "number", - "minimum": 1 - }, - "maxInitialRequests": { - "description": "Maximum number of initial chunks which are accepted for an entry point", - "type": "number", - "minimum": 1 - }, - "reuseExistingChunk": { - "description": "Try to reuse existing chunk (with name) when it has matching modules", - "type": "boolean" - }, - "name": { - "description": "Give chunks for this cache group a name (chunks with equal name are merged)", - "oneOf": [ - { - "type": "boolean" - }, - { - "instanceof": "Function" - }, - { - "type": "string" - } - ] - }, - "automaticNameDelimiter": { - "description": "Sets the name delimiter for created chunks", - "type": "string", - "minLength": 1 - }, - "automaticNamePrefix": { - "description": "Sets the name prefix for created chunks", - "type": "string" - }, - "filename": { - "description": "Sets the template for the filename for created chunks (Only works for initial chunks)", - "type": "string", - "minLength": 1 - } - } - } - ] - } - } - } - } - ] - }, "runtimeChunk": { "description": "Create an additional chunk which contains only the webpack runtime and chunk hash maps", "oneOf": [ @@ -1519,78 +1353,245 @@ } ] }, - "noEmitOnErrors": { - "description": "Avoid emitting assets when errors occur", + "sideEffects": { + "description": "Skip over modules which are flagged to contain no side effects when exports are not used", "type": "boolean" }, - "checkWasmTypes": { - "description": "Check for incompatible wasm types when importing/exporting from/to ESM", - "type": "boolean" - }, - "mangleWasmImports": { - "description": "Reduce size of WASM by changing imports to shorter strings.", - "type": "boolean" - }, - "moduleIds": { - "description": "Define the algorithm to choose module ids (natural: numeric ids in order of usage, named: readable ids for better debugging, hashed: short hashes as ids for better long term caching, size: numeric ids focused on minimal initial download size, total-size: numeric ids focused on minimal total download size, false: no algorithm used, as custom one can be provided via plugin)", - "enum": ["natural", "named", "hashed", "size", "total-size", false] - }, - "chunkIds": { - "description": "Define the algorithm to choose chunk ids (named: readable ids for better debugging, size: numeric ids focused on minimal initial download size, total-size: numeric ids focused on minimal total download size, false: no algorithm used, as custom one can be provided via plugin)", - "enum": ["natural", "named", "size", "total-size", false] - }, - "namedModules": { - "description": "Use readable module identifiers for better debugging (deprecated, used moduleIds: named instead)", - "type": "boolean" - }, - "hashedModuleIds": { - "description": "Use hashed module id instead module identifiers for better long term caching (deprecated, used moduleIds: hashed instead)", - "type": "boolean" - }, - "namedChunks": { - "description": "Use readable chunk identifiers for better debugging (deprecated, used chunkIds: named instead)", - "type": "boolean" - }, - "portableRecords": { - "description": "Generate records with relative paths to be able to move the context folder", - "type": "boolean" - }, - "minimize": { - "description": "Enable minimizing the output. Uses optimization.minimizer.", - "type": "boolean" - }, - "minimizer": { - "description": "Minimizer(s) to use for minimizing the output", - "type": "array", - "items": { - "description": "Plugin of type object or instanceof Function", - "anyOf": [ - { - "$ref": "#/definitions/common.pluginObject" - }, - { - "$ref": "#/definitions/common.pluginFunction" - } - ] - } - }, - "nodeEnv": { - "description": "Set process.env.NODE_ENV to a specific value", - "anyOf": [ + "splitChunks": { + "description": "Optimize duplication and caching by splitting chunks by shared modules and cache group", + "oneOf": [ { "enum": [false] }, { - "type": "string" + "type": "object", + "additionalProperties": false, + "properties": { + "automaticNameDelimiter": { + "description": "Sets the name delimiter for created chunks", + "type": "string", + "minLength": 1 + }, + "cacheGroups": { + "description": "Assign modules to a cache group (modules from different cache groups are tried to keep in separate chunks)", + "type": "object", + "additionalProperties": { + "description": "Configuration for a cache group", + "anyOf": [ + { + "enum": [false] + }, + { + "instanceof": "Function" + }, + { + "type": "string" + }, + { + "instanceof": "RegExp" + }, + { + "type": "object", + "additionalProperties": false, + "properties": { + "automaticNameDelimiter": { + "description": "Sets the name delimiter for created chunks", + "type": "string", + "minLength": 1 + }, + "automaticNamePrefix": { + "description": "Sets the name prefix for created chunks", + "type": "string" + }, + "chunks": { + "description": "Select chunks for determining cache group content (defaults to \"initial\", \"initial\" and \"all\" requires adding these chunks to the HTML)", + "oneOf": [ + { + "enum": ["initial", "async", "all"] + }, + { + "instanceof": "Function" + } + ] + }, + "enforce": { + "description": "Ignore minimum size, minimum chunks and maximum requests and always create chunks for this cache group", + "type": "boolean" + }, + "filename": { + "description": "Sets the template for the filename for created chunks (Only works for initial chunks)", + "type": "string", + "minLength": 1 + }, + "maxAsyncRequests": { + "description": "Maximum number of requests which are accepted for on-demand loading", + "type": "number", + "minimum": 1 + }, + "maxInitialRequests": { + "description": "Maximum number of initial chunks which are accepted for an entry point", + "type": "number", + "minimum": 1 + }, + "maxSize": { + "description": "Maximal size hint for the created chunks", + "type": "number", + "minimum": 0 + }, + "minChunks": { + "description": "Minimum number of times a module has to be duplicated until it's considered for splitting", + "type": "number", + "minimum": 1 + }, + "minSize": { + "description": "Minimal size for the created chunk", + "type": "number", + "minimum": 0 + }, + "name": { + "description": "Give chunks for this cache group a name (chunks with equal name are merged)", + "oneOf": [ + { + "type": "boolean" + }, + { + "instanceof": "Function" + }, + { + "type": "string" + } + ] + }, + "priority": { + "description": "Priority of this cache group", + "type": "number" + }, + "reuseExistingChunk": { + "description": "Try to reuse existing chunk (with name) when it has matching modules", + "type": "boolean" + }, + "test": { + "description": "Assign modules to a cache group", + "oneOf": [ + { + "instanceof": "Function" + }, + { + "type": "string" + }, + { + "instanceof": "RegExp" + } + ] + } + } + } + ] + } + }, + "chunks": { + "description": "Select chunks for determining shared modules (defaults to \"async\", \"initial\" and \"all\" requires adding these chunks to the HTML)", + "oneOf": [ + { + "enum": ["initial", "async", "all"] + }, + { + "instanceof": "Function" + } + ] + }, + "fallbackCacheGroup": { + "description": "Options for modules not selected by any other cache group", + "type": "object", + "additionalProperties": false, + "properties": { + "automaticNameDelimiter": { + "description": "Sets the name delimiter for created chunks", + "type": "string", + "minLength": 1 + }, + "maxSize": { + "description": "Maximal size hint for the created chunks", + "type": "number", + "minimum": 0 + }, + "minSize": { + "description": "Minimal size for the created chunk", + "type": "number", + "minimum": 0 + } + } + }, + "filename": { + "description": "Sets the template for the filename for created chunks (Only works for initial chunks)", + "type": "string", + "minLength": 1 + }, + "hidePathInfo": { + "description": "Prevents exposing path info when creating names for parts splitted by maxSize", + "type": "boolean" + }, + "maxAsyncRequests": { + "description": "Maximum number of requests which are accepted for on-demand loading", + "type": "number", + "minimum": 1 + }, + "maxInitialRequests": { + "description": "Maximum number of initial chunks which are accepted for an entry point", + "type": "number", + "minimum": 1 + }, + "maxSize": { + "description": "Maximal size hint for the created chunks", + "type": "number", + "minimum": 0 + }, + "minChunks": { + "description": "Minimum number of times a module has to be duplicated until it's considered for splitting", + "type": "number", + "minimum": 1 + }, + "minSize": { + "description": "Minimal size for the created chunks", + "type": "number", + "minimum": 0 + }, + "name": { + "description": "Give chunks created a name (chunks with equal name are merged)", + "oneOf": [ + { + "type": "boolean" + }, + { + "instanceof": "Function" + }, + { + "type": "string" + } + ] + } + } } ] + }, + "usedExports": { + "description": "Figure out which exports are used by modules to mangle export names, omit unused exports and generate more efficient code", + "type": "boolean" } } }, + "output": { + "description": "Options affecting the output of the compilation. `output` options tell webpack how to write the compiled files to disk.", + "anyOf": [ + { + "$ref": "#/definitions/output" + } + ] + }, "parallelism": { "description": "The number of parallel processed modules in the compilation.", - "minimum": 1, - "type": "number" + "type": "number", + "minimum": 1 }, "performance": { "description": "Configuration for web performance recommendations.", @@ -1599,6 +1600,7 @@ "enum": [false] }, { + "type": "object", "additionalProperties": false, "properties": { "assetFilter": { @@ -1609,16 +1611,15 @@ "description": "Sets the format of the hints: warnings, errors or nothing at all", "enum": [false, "warning", "error"] }, - "maxEntrypointSize": { - "description": "Total size of an entry point (in bytes)", - "type": "number" - }, "maxAssetSize": { "description": "Filesize limit (in bytes) when exceeded, that webpack will provide performance hints", "type": "number" + }, + "maxEntrypointSize": { + "description": "Total size of an entry point (in bytes)", + "type": "number" } - }, - "type": "object" + } } ] }, @@ -1684,52 +1685,59 @@ "additionalProperties": false, "properties": { "all": { - "type": "boolean", - "description": "fallback value for stats options when an option is not defined (has precedence over local webpack defaults)" - }, - "context": { - "type": "string", - "description": "context directory for request shortening", - "absolutePath": true - }, - "hash": { - "type": "boolean", - "description": "add the hash of the compilation" - }, - "version": { - "type": "boolean", - "description": "add webpack version information" - }, - "timings": { - "type": "boolean", - "description": "add timing information" - }, - "builtAt": { - "type": "boolean", - "description": "add built at time information" - }, - "performance": { - "type": "boolean", - "description": "add performance hint flags" - }, - "depth": { - "type": "boolean", - "description": "add module depth in module graph" + "description": "fallback value for stats options when an option is not defined (has precedence over local webpack defaults)", + "type": "boolean" }, "assets": { - "type": "boolean", - "description": "add assets information" + "description": "add assets information", + "type": "boolean" }, - "env": { - "type": "boolean", - "description": "add --env information" + "assetsSort": { + "description": "sort the assets by that field", + "type": "string" + }, + "builtAt": { + "description": "add built at time information", + "type": "boolean" + }, + "cached": { + "description": "add also information about cached (not built) modules", + "type": "boolean" + }, + "cachedAssets": { + "description": "Show cached assets (setting this to `false` only shows emitted files)", + "type": "boolean" + }, + "children": { + "description": "add children information", + "type": "boolean" + }, + "chunkGroups": { + "description": "Display all chunk groups with the corresponding bundles", + "type": "boolean" + }, + "chunkModules": { + "description": "add built modules information to chunk information", + "type": "boolean" + }, + "chunkOrigins": { + "description": "add the origins of chunks and chunk merging info", + "type": "boolean" + }, + "chunks": { + "description": "add chunk information", + "type": "boolean" + }, + "chunksSort": { + "description": "sort the chunks by that field", + "type": "string" }, "colors": { "description": "Enables/Disables colorful output", "oneOf": [ { - "type": "boolean", - "description": "`webpack --colors` equivalent" + "description": "`webpack --colors` equivalent", + "type": "boolean" }, { "type": "object", @@ -1739,22 +1747,22 @@ "description": "Custom color for bold text", "type": "string" }, - "red": { - "description": "Custom color for red text", + "cyan": { + "description": "Custom color for cyan text", "type": "string" }, "green": { "description": "Custom color for green text", "type": "string" }, - "cyan": { - "description": "Custom color for cyan text", - "type": "string" - }, "magenta": { "description": "Custom color for magenta text", "type": "string" }, + "red": { + "description": "Custom color for red text", + "type": "string" + }, "yellow": { "description": "Custom color for yellow text", "type": "string" @@ -1763,63 +1771,39 @@ } ] }, - "maxModules": { - "type": "number", - "description": "Set the maximum number of modules to be shown" + "context": { + "description": "context directory for request shortening", + "type": "string", + "absolutePath": true }, - "chunks": { - "type": "boolean", - "description": "add chunk information" + "depth": { + "description": "add module depth in module graph", + "type": "boolean" }, - "chunkModules": { - "type": "boolean", - "description": "add built modules information to chunk information" + "entrypoints": { + "description": "Display the entry points with the corresponding bundles", + "type": "boolean" }, - "modules": { - "type": "boolean", - "description": "add built modules information" + "env": { + "description": "add --env information", + "type": "boolean" }, - "nestedModules": { - "type": "boolean", - "description": "add information about modules nested in other modules (like with module concatenation)" - }, - "moduleAssets": { - "type": "boolean", - "description": "add information about assets inside modules" - }, - "children": { - "type": "boolean", - "description": "add children information" - }, - "cached": { - "type": "boolean", - "description": "add also information about cached (not built) modules" - }, - "cachedAssets": { - "type": "boolean", - "description": "Show cached assets (setting this to `false` only shows emitted files)" - }, - "reasons": { - "type": "boolean", - "description": "add information about the reasons why modules are included" - }, - "source": { - "type": "boolean", - "description": "add the source code of modules" - }, - "warnings": { - "type": "boolean", - "description": "add warnings" + "errorDetails": { + "description": "add details to errors (like resolving log)", + "type": "boolean" }, "errors": { - "type": "boolean", - "description": "add errors" + "description": "add errors", + "type": "boolean" }, - "warningsFilter": { - "description": "Suppress warnings that match the specified filters. Filters can be Strings, RegExps or Functions", + "exclude": { + "description": "Please use excludeModules instead.", "anyOf": [ { "$ref": "#/definitions/filter-types" + }, + { + "type": "boolean" } ] }, @@ -1842,68 +1826,85 @@ } ] }, - "exclude": { - "description": "Please use excludeModules instead.", + "hash": { + "description": "add the hash of the compilation", + "type": "boolean" + }, + "maxModules": { + "description": "Set the maximum number of modules to be shown", + "type": "number" + }, + "moduleAssets": { + "description": "add information about assets inside modules", + "type": "boolean" + }, + "moduleTrace": { + "description": "add dependencies and origin of warnings/errors", + "type": "boolean" + }, + "modules": { + "description": "add built modules information", + "type": "boolean" + }, + "modulesSort": { + "description": "sort the modules by that field", + "type": "string" + }, + "nestedModules": { + "description": "add information about modules nested in other modules (like with module concatenation)", + "type": "boolean" + }, + "optimizationBailout": { + "description": "show reasons why optimization bailed out for modules", + "type": "boolean" + }, + "outputPath": { + "description": "Add output path information", + "type": "boolean" + }, + "performance": { + "description": "add performance hint flags", + "type": "boolean" + }, + "providedExports": { + "description": "show exports provided by modules", + "type": "boolean" + }, + "publicPath": { + "description": "Add public path information", + "type": "boolean" + }, + "reasons": { + "description": "add information about the reasons why modules are included", + "type": "boolean" + }, + "source": { + "description": "add the source code of modules", + "type": "boolean" + }, + "timings": { + "description": "add timing information", + "type": "boolean" + }, + "usedExports": { + "description": "show exports used by modules", + "type": "boolean" + }, + "version": { + "description": "add webpack version information", + "type": "boolean" + }, + "warnings": { + "description": "add warnings", + "type": "boolean" + }, + "warningsFilter": { + "description": "Suppress warnings that match the specified filters. Filters can be Strings, RegExps or Functions", "anyOf": [ { "$ref": "#/definitions/filter-types" - }, - { - "type": "boolean" } ] - }, - "entrypoints": { - "type": "boolean", - "description": "Display the entry points with the corresponding bundles" - }, - "chunkGroups": { - "type": "boolean", - "description": "Display all chunk groups with the corresponding bundles" - }, - "errorDetails": { - "type": "boolean", - "description": "add details to errors (like resolving log)" - }, - "chunkOrigins": { - "type": "boolean", - "description": "add the origins of chunks and chunk merging info" - }, - "modulesSort": { - "type": "string", - "description": "sort the modules by that field" - }, - "moduleTrace": { - "type": "boolean", - "description": "add dependencies and origin of warnings/errors" - }, - "chunksSort": { - "type": "string", - "description": "sort the chunks by that field" - }, - "assetsSort": { - "type": "string", - "description": "sort the assets by that field" - }, - "publicPath": { - "type": "boolean", - "description": "Add public path information" - }, - "outputPath": { - "type": "boolean", - "description": "Add output path information" - }, - "providedExports": { - "type": "boolean", - "description": "show exports provided by modules" - }, - "usedExports": { - "type": "boolean", - "description": "show exports used by modules" - }, - "optimizationBailout": { - "type": "boolean", - "description": "show reasons why optimization bailed out for modules" } } }, @@ -1947,6 +1948,7 @@ }, "watchOptions": { "description": "Options for the watcher", + "type": "object", "additionalProperties": false, "properties": { "aggregateTimeout": { @@ -1956,10 +1958,6 @@ "ignored": { "description": "Ignore some files from watching" }, - "stdin": { - "description": "Stop watching when stdin stream has ended", - "type": "boolean" - }, "poll": { "description": "Enable polling mode for watching", "anyOf": [ @@ -1972,10 +1970,12 @@ "type": "number" } ] + }, + "stdin": { + "description": "Stop watching when stdin stream has ended", + "type": "boolean" } - }, - "type": "object" + } } - }, - "type": "object" + } } diff --git a/schemas/plugins/BannerPlugin.json b/schemas/plugins/BannerPlugin.json index 6ebebcc5f..9c86c502e 100644 --- a/schemas/plugins/BannerPlugin.json +++ b/schemas/plugins/BannerPlugin.json @@ -6,14 +6,15 @@ "instanceof": "RegExp" }, { - "minLength": 1, - "type": "string" + "type": "string", + "minLength": 1 } ] }, "rules": { "oneOf": [ { + "type": "array", "items": { "description": "A rule condition", "anyOf": [ @@ -21,8 +22,7 @@ "$ref": "#/definitions/rule" } ] - }, - "type": "array" + } }, { "$ref": "#/definitions/rule" @@ -34,7 +34,6 @@ { "type": "object", "additionalProperties": false, - "required": ["banner"], "properties": { "banner": { "description": "Specifies the banner", @@ -47,16 +46,12 @@ } ] }, - "raw": { - "description": "If true, banner will not be wrapped in a comment", - "type": "boolean" - }, "entryOnly": { "description": "If true, the banner will only be added to the entry chunks", "type": "boolean" }, - "test": { - "description": "Include all modules that pass test assertion", + "exclude": { + "description": "Exclude all modules matching any of these conditions", "anyOf": [ { "$ref": "#/definitions/rules" @@ -71,15 +66,20 @@ } ] }, - "exclude": { - "description": "Exclude all modules matching any of these conditions", + "raw": { + "description": "If true, banner will not be wrapped in a comment", + "type": "boolean" + }, + "test": { + "description": "Include all modules that pass test assertion", "anyOf": [ { "$ref": "#/definitions/rules" } ] } - } + }, + "required": ["banner"] }, { "description": "The banner as function, it will be wrapped in a comment", @@ -87,8 +87,8 @@ }, { "description": "The banner as string, it will be wrapped in a comment", - "minLength": 1, - "type": "string" + "type": "string", + "minLength": 1 } ] } diff --git a/schemas/plugins/DllPlugin.json b/schemas/plugins/DllPlugin.json index c8ea5402f..18a0351bf 100644 --- a/schemas/plugins/DllPlugin.json +++ b/schemas/plugins/DllPlugin.json @@ -1,30 +1,30 @@ { "additionalProperties": false, - "required": ["path"], "properties": { "context": { "description": "Context of requests in the manifest file (defaults to the webpack context)", - "minLength": 1, - "type": "string" - }, - "name": { - "description": "Name of the exposed dll function (external name, use value of 'output.library')", - "minLength": 1, - "type": "string" - }, - "type": { - "description": "Type of the dll bundle (external type, use value of 'output.libraryTarget')", - "minLength": 1, - "type": "string" - }, - "path": { - "description": "Absolute path to the manifest json file (output)", - "minLength": 1, - "type": "string" + "type": "string", + "minLength": 1 }, "entryOnly": { "description": "If true, only entry points will be exposed", "type": "boolean" + }, + "name": { + "description": "Name of the exposed dll function (external name, use value of 'output.library')", + "type": "string", + "minLength": 1 + }, + "path": { + "description": "Absolute path to the manifest json file (output)", + "type": "string", + "minLength": 1 + }, + "type": { + "description": "Type of the dll bundle (external type, use value of 'output.libraryTarget')", + "type": "string", + "minLength": 1 } - } + }, + "required": ["path"] } diff --git a/schemas/plugins/DllReferencePlugin.json b/schemas/plugins/DllReferencePlugin.json index cd0c9ba86..17587b186 100644 --- a/schemas/plugins/DllReferencePlugin.json +++ b/schemas/plugins/DllReferencePlugin.json @@ -1,19 +1,24 @@ { "additionalProperties": false, - "anyOf": [ - { - "required": ["manifest"] - }, - { - "required": ["content"] - } - ], "properties": { + "content": { + "description": "The mappings from request to module id (defaults to manifest.content)", + "type": "object", + "minLength": 1 + }, "context": { "description": "(absolute path) context of requests in the manifest (or content property)", "type": "string", "absolutePath": true }, + "extensions": { + "description": "Extensions used to resolve modules in the dll bundle (only used when using 'scope')", + "type": "array", + "items": { + "description": "An extension", + "type": "string" + } + }, "manifest": { "description": "An object containing content and name or a string to the absolute path of the JSON manifest to be loaded upon compilation", "oneOf": [ @@ -23,18 +28,18 @@ "properties": { "content": { "description": "The mappings from request to module id", - "minLength": 1, - "type": "object" + "type": "object", + "minLength": 1 }, "name": { "description": "The name where the dll is exposed (external name)", - "minLength": 1, - "type": "string" + "type": "string", + "minLength": 1 }, "type": { "description": "The type how the dll is exposed (external type)", - "minLength": 1, - "type": "string" + "type": "string", + "minLength": 1 } } }, @@ -44,24 +49,15 @@ } ] }, - "content": { - "description": "The mappings from request to module id (defaults to manifest.content)", - "minLength": 1, - "type": "object" - }, "name": { "description": "The name where the dll is exposed (external name, defaults to manifest.name)", - "minLength": 1, - "type": "string" - }, - "type": { - "description": "The way how the export of the dll bundle is used", - "enum": ["require", "object"] + "type": "string", + "minLength": 1 }, "scope": { "description": "Prefix which is used for accessing the content of the dll", - "minLength": 1, - "type": "string" + "type": "string", + "minLength": 1 }, "sourceType": { "description": "How the dll is exposed (libraryTarget, defaults to manifest.type)", @@ -80,13 +76,17 @@ "jsonp" ] }, - "extensions": { - "description": "Extensions used to resolve modules in the dll bundle (only used when using 'scope')", - "type": "array", - "items": { - "description": "An extension", - "type": "string" - } + "type": { + "description": "The way how the export of the dll bundle is used", + "enum": ["require", "object"] } - } + }, + "anyOf": [ + { + "required": ["manifest"] + }, + { + "required": ["content"] + } + ] } diff --git a/schemas/plugins/HashedModuleIdsPlugin.json b/schemas/plugins/HashedModuleIdsPlugin.json index 30c6c71cc..5645bdd12 100644 --- a/schemas/plugins/HashedModuleIdsPlugin.json +++ b/schemas/plugins/HashedModuleIdsPlugin.json @@ -2,11 +2,6 @@ "type": "object", "additionalProperties": false, "properties": { - "hashFunction": { - "description": "The hashing algorithm to use, defaults to 'md5'. All functions from Node.JS' crypto.createHash are supported.", - "type": "string", - "minLength": 1 - }, "hashDigest": { "description": "The encoding to use when generating the hash, defaults to 'base64'. All encodings from Node.JS' hash.digest are supported.", "enum": ["hex", "latin1", "base64"] @@ -15,6 +10,11 @@ "description": "The prefix length of the hash digest to use, defaults to 4.", "type": "number", "minimum": 1 + }, + "hashFunction": { + "description": "The hashing algorithm to use, defaults to 'md5'. All functions from Node.JS' crypto.createHash are supported.", + "type": "string", + "minLength": 1 } } } diff --git a/schemas/plugins/IgnorePlugin.json b/schemas/plugins/IgnorePlugin.json index 8823634a0..e8319f1d1 100644 --- a/schemas/plugins/IgnorePlugin.json +++ b/schemas/plugins/IgnorePlugin.json @@ -4,26 +4,26 @@ { "additionalProperties": false, "properties": { - "resourceRegExp": { - "description": "A RegExp to test the request against", - "instanceof": "RegExp" - }, "contextRegExp": { "description": "A RegExp to test the context (directory) against", "instanceof": "RegExp" + }, + "resourceRegExp": { + "description": "A RegExp to test the request against", + "instanceof": "RegExp" } } }, { "additionalProperties": false, "properties": { - "checkResource": { - "description": "A filter function for resource", - "instanceof": "Function" - }, "checkContext": { "description": "A filter function for context", "instanceof": "Function" + }, + "checkResource": { + "description": "A filter function for resource", + "instanceof": "Function" } } } diff --git a/schemas/plugins/SourceMapDevToolPlugin.json b/schemas/plugins/SourceMapDevToolPlugin.json index e0f7d9b21..873e2aa98 100644 --- a/schemas/plugins/SourceMapDevToolPlugin.json +++ b/schemas/plugins/SourceMapDevToolPlugin.json @@ -1,6 +1,4 @@ { - "type": "object", - "additionalProperties": false, "definitions": { "rule": { "oneOf": [ @@ -8,14 +6,15 @@ "instanceof": "RegExp" }, { - "minLength": 1, - "type": "string" + "type": "string", + "minLength": 1 } ] }, "rules": { "oneOf": [ { + "type": "array", "items": { "description": "A rule condition", "anyOf": [ @@ -23,8 +22,7 @@ "$ref": "#/definitions/rule" } ] - }, - "type": "array" + } }, { "$ref": "#/definitions/rule" @@ -32,45 +30,9 @@ ] } }, + "type": "object", + "additionalProperties": false, "properties": { - "test": { - "description": "Include source maps for modules based on their extension (defaults to .js and .css)", - "anyOf": [ - { - "$ref": "#/definitions/rules" - } - ] - }, - "include": { - "description": "Include source maps for module paths that match the given value", - "anyOf": [ - { - "$ref": "#/definitions/rules" - } - ] - }, - "exclude": { - "description": "Exclude modules that match the given value from source map generation", - "anyOf": [ - { - "$ref": "#/definitions/rules" - } - ] - }, - "filename": { - "description": "Defines the output filename of the SourceMap (will be inlined if no value is provided)", - "oneOf": [ - { - "description": "Disable separate SourceMap file and inline SourceMap as DataUrl", - "enum": [false, null] - }, - { - "type": "string", - "minLength": 1, - "absolutePath": false - } - ] - }, "append": { "description": "Appends the given value to the original asset. Usually the #sourceMappingURL comment. [url] is replaced with a URL to the source map file. false disables the appending", "oneOf": [ @@ -79,21 +41,20 @@ "enum": [false, null] }, { - "minLength": 1, - "type": "string" + "type": "string", + "minLength": 1 } ] }, - "moduleFilenameTemplate": { - "description": "Generator string or function to create identifiers of modules for the 'sources' array in the SourceMap", - "oneOf": [ + "columns": { + "description": "Indicates whether column mappings should be used (defaults to true)", + "type": "boolean" + }, + "exclude": { + "description": "Exclude modules that match the given value from source map generation", + "anyOf": [ { - "description": "Custom function generating the identifer", - "instanceof": "Function" - }, - { - "minLength": 1, - "type": "string" + "$ref": "#/definitions/rules" } ] }, @@ -105,39 +66,37 @@ "instanceof": "Function" }, { - "minLength": 1, - "type": "string" + "type": "string", + "minLength": 1 } ] }, - "namespace": { - "description": "Namespace prefix to allow multiple webpack roots in the devtools", - "type": "string" - }, - "module": { - "description": "Indicates whether SourceMaps from loaders should be used (defaults to true)", - "type": "boolean" - }, - "columns": { - "description": "Indicates whether column mappings should be used (defaults to true)", - "type": "boolean" - }, - "noSources": { - "description": "Omit the 'sourceContents' array from the SourceMap", - "type": "boolean" - }, - "sourceRoot": { - "description": "Provide a custom value for the 'sourceRoot' property in the SourceMap", - "type": "string" - }, - "publicPath": { - "description": "Provide a custom public path for the SourceMapping comment", - "type": "string" - }, "fileContext": { "description": "Path prefix to which the [file] placeholder is relative to", "type": "string" }, + "filename": { + "description": "Defines the output filename of the SourceMap (will be inlined if no value is provided)", + "oneOf": [ + { + "description": "Disable separate SourceMap file and inline SourceMap as DataUrl", + "enum": [false, null] + }, + { + "type": "string", + "absolutePath": false, + "minLength": 1 + } + ] + }, + "include": { + "description": "Include source maps for module paths that match the given value", + "anyOf": [ + { + "$ref": "#/definitions/rules" + } + ] + }, "lineToLine": { "description": "(deprecated) try to map original files line to line to generated files", "anyOf": [ @@ -149,8 +108,8 @@ "type": "object", "additionalProperties": false, "properties": { - "test": { - "description": "Include source maps for modules based on their extension (defaults to .js and .css)", + "exclude": { + "description": "Exclude modules that match the given value from source map generation", "anyOf": [ { "$ref": "#/definitions/rules" @@ -165,8 +124,8 @@ } ] }, - "exclude": { - "description": "Exclude modules that match the given value from source map generation", + "test": { + "description": "Include source maps for modules based on their extension (defaults to .js and .css)", "anyOf": [ { "$ref": "#/definitions/rules" @@ -176,6 +135,47 @@ } } ] + }, + "module": { + "description": "Indicates whether SourceMaps from loaders should be used (defaults to true)", + "type": "boolean" + }, + "moduleFilenameTemplate": { + "description": "Generator string or function to create identifiers of modules for the 'sources' array in the SourceMap", + "oneOf": [ + { + "description": "Custom function generating the identifer", + "instanceof": "Function" + }, + { + "type": "string", + "minLength": 1 + } + ] + }, + "namespace": { + "description": "Namespace prefix to allow multiple webpack roots in the devtools", + "type": "string" + }, + "noSources": { + "description": "Omit the 'sourceContents' array from the SourceMap", + "type": "boolean" + }, + "publicPath": { + "description": "Provide a custom public path for the SourceMapping comment", + "type": "string" + }, + "sourceRoot": { + "description": "Provide a custom value for the 'sourceRoot' property in the SourceMap", + "type": "string" + }, + "test": { + "description": "Include source maps for modules based on their extension (defaults to .js and .css)", + "anyOf": [ + { + "$ref": "#/definitions/rules" + } + ] } } } diff --git a/schemas/plugins/optimize/AggressiveSplittingPlugin.json b/schemas/plugins/optimize/AggressiveSplittingPlugin.json index 6c699d5e6..31c439901 100644 --- a/schemas/plugins/optimize/AggressiveSplittingPlugin.json +++ b/schemas/plugins/optimize/AggressiveSplittingPlugin.json @@ -2,14 +2,6 @@ "type": "object", "additionalProperties": false, "properties": { - "minSize": { - "description": "Byte, split point. Default: 30720", - "type": "number" - }, - "maxSize": { - "description": "Byte, maxsize of per file. Default: 51200", - "type": "number" - }, "chunkOverhead": { "description": "Default: 0", "type": "number" @@ -17,6 +9,14 @@ "entryChunkMultiplicator": { "description": "Default: 1", "type": "number" + }, + "maxSize": { + "description": "Byte, maxsize of per file. Default: 51200", + "type": "number" + }, + "minSize": { + "description": "Byte, split point. Default: 30720", + "type": "number" } } } diff --git a/schemas/plugins/optimize/MinChunkSizePlugin.json b/schemas/plugins/optimize/MinChunkSizePlugin.json index 26b78da99..0250ec5f3 100644 --- a/schemas/plugins/optimize/MinChunkSizePlugin.json +++ b/schemas/plugins/optimize/MinChunkSizePlugin.json @@ -1,11 +1,11 @@ { - "additionalProperties": false, "type": "object", - "required": ["minChunkSize"], + "additionalProperties": false, "properties": { "minChunkSize": { "description": "Minimum number of characters", "type": "number" } - } + }, + "required": ["minChunkSize"] } diff --git a/schemas/plugins/optimize/OccurrenceOrderChunkIdsPlugin.json b/schemas/plugins/optimize/OccurrenceOrderChunkIdsPlugin.json index f1e85ac5d..98f12f132 100644 --- a/schemas/plugins/optimize/OccurrenceOrderChunkIdsPlugin.json +++ b/schemas/plugins/optimize/OccurrenceOrderChunkIdsPlugin.json @@ -1,6 +1,6 @@ { - "additionalProperties": false, "type": "object", + "additionalProperties": false, "properties": { "prioritiseInitial": { "description": "Prioritise initial size over total size", diff --git a/schemas/plugins/optimize/OccurrenceOrderModuleIdsPlugin.json b/schemas/plugins/optimize/OccurrenceOrderModuleIdsPlugin.json index f1e85ac5d..98f12f132 100644 --- a/schemas/plugins/optimize/OccurrenceOrderModuleIdsPlugin.json +++ b/schemas/plugins/optimize/OccurrenceOrderModuleIdsPlugin.json @@ -1,6 +1,6 @@ { - "additionalProperties": false, "type": "object", + "additionalProperties": false, "properties": { "prioritiseInitial": { "description": "Prioritise initial size over total size", diff --git a/tooling/format-schemas.js b/tooling/format-schemas.js new file mode 100644 index 000000000..59bfdcef3 --- /dev/null +++ b/tooling/format-schemas.js @@ -0,0 +1,144 @@ +const fs = require("fs"); +const path = require("path"); +const prettier = require("prettier"); + +const schemasDir = path.resolve(__dirname, "../schemas"); + +// When --write is set, files will be written in place +// Elsewise it only prints outdated files +const doWrite = process.argv.includes("--write"); + +const sortObjectAlphabetically = obj => { + const keys = Object.keys(obj).sort(); + const newObj = {}; + for (const key of keys) { + newObj[key] = obj[key]; + } + return newObj; +}; + +const sortObjectWithList = (obj, props) => { + const keys = Object.keys(obj) + .filter(p => !props.includes(p)) + .sort(); + const newObj = {}; + for (const key of props) { + if (key in obj) { + newObj[key] = obj[key]; + } + } + for (const key of keys) { + newObj[key] = obj[key]; + } + return newObj; +}; + +const PROPERTIES = [ + "$ref", + "definitions", + + "id", + "description", + "type", + + "items", + "minItems", + "uniqueItems", + + "additionalProperties", + "properties", + "required", + "minProperties", + + "oneOf", + "anyOf", + "allOf", + "enum", + + "absolutePath", + "minLength", + + "minimum", + + "instanceof", + + "tsType" +]; + +const NESTED_WITH_NAME = ["definitions", "properties"]; + +const NESTED_DIRECT = ["items", "additionalProperties"]; + +const NESTED_ARRAY = ["oneOf", "anyOf", "allOf"]; + +const processJson = json => { + json = sortObjectWithList(json, PROPERTIES); + + for (const name of NESTED_WITH_NAME) { + if (name in json && json[name] && typeof json[name] === "object") { + json[name] = sortObjectAlphabetically(json[name]); + for (const key in json[name]) { + json[name][key] = processJson(json[name][key]); + } + } + } + for (const name of NESTED_DIRECT) { + if (name in json && json[name] && typeof json[name] === "object") { + json[name] = processJson(json[name]); + } + } + for (const name of NESTED_ARRAY) { + if (name in json && Array.isArray(json[name])) { + for (let i = 0; i < json[name].length; i++) { + json[name][i] = processJson(json[name][i]); + } + } + } + + return json; +}; + +const formatSchema = schemaPath => { + const json = require(schemaPath); + const processedJson = processJson(json); + const rawString = JSON.stringify(processedJson, null, 2); + prettier.resolveConfig(schemaPath).then(config => { + config.filepath = schemaPath; + config.parser = "json"; + const prettyString = prettier.format(rawString, config); + let normalizedContent = ""; + try { + const content = fs.readFileSync(schemaPath, "utf-8"); + normalizedContent = content.replace(/\r\n?/g, "\n"); + } catch (e) { + // ignore + } + if (normalizedContent.trim() !== prettyString.trim()) { + const basename = path.relative(schemasDir, schemaPath); + if (doWrite) { + fs.writeFileSync(schemaPath, prettyString, "utf-8"); + console.error(`schemas/${basename.replace(/\\/g, "/")} updated`); + } else { + console.error( + `schemas/${basename.replace(/\\/g, "/")} need to be updated` + ); + } + process.exitCode = 1; + } + }); +}; + +// include the top level folder "./schemas" by default +const dirs = new Set([schemasDir]); + +// search for all nestedDirs inside of this folder +for (let dirWithSchemas of dirs) { + for (let item of fs.readdirSync(dirWithSchemas)) { + const absPath = path.resolve(dirWithSchemas, item); + if (fs.statSync(absPath).isDirectory()) { + dirs.add(absPath); + } else if (item.endsWith(".json")) { + formatSchema(absPath); + } + } +} From 64b27537da9be6735757c547e631e37929665c28 Mon Sep 17 00:00:00 2001 From: Tobias Koppers Date: Tue, 18 Sep 2018 15:17:44 +0200 Subject: [PATCH 12/29] improve schema to be able to use it --- declarations.d.ts | 5 +++ declarations/WebpackOptions.d.ts | 67 +++++++++++++++++--------------- schemas/WebpackOptions.json | 51 +++++++++++++++++------- test/Schemas.lint.js | 3 +- 4 files changed, 78 insertions(+), 48 deletions(-) diff --git a/declarations.d.ts b/declarations.d.ts index fceb5dac9..719b6ebad 100644 --- a/declarations.d.ts +++ b/declarations.d.ts @@ -220,6 +220,11 @@ declare module "@webassemblyjs/ast" { export function isFuncImportDescr(n: Node): boolean; } +// This "hack" is needed because typescript doesn't support recursive type definitions +// It's referenced from "ruleSet-conditions" in schemas/WebpackOptions.json +interface RuleSetConditionsRecursive + extends Array {} + /** * Global variable declarations * @todo Once this issue is resolved, remove these globals and add JSDoc onsite instead diff --git a/declarations/WebpackOptions.d.ts b/declarations/WebpackOptions.d.ts index 7238d38e9..6e4c32301 100644 --- a/declarations/WebpackOptions.d.ts +++ b/declarations/WebpackOptions.d.ts @@ -29,7 +29,12 @@ export type CommonNonEmptyArrayOfUniqueStringValues = string[]; * This interface was referenced by `WebpackOptions`'s JSON-Schema * via the `definition` "externals". */ -export type Externals = +export type Externals = ExternalItem | ExternalItem[]; +/** + * This interface was referenced by `WebpackOptions`'s JSON-Schema + * via the `definition` "external-item". + */ +export type ExternalItem = | string | { /** @@ -45,13 +50,19 @@ export type Externals = } | { [k: string]: any; - } - | Externals[]; + }; /** * This interface was referenced by `WebpackOptions`'s JSON-Schema * via the `definition` "common.arrayOfStringValues". */ export type CommonArrayOfStringValues = string[]; +/** + * One or multiple rule conditions + * + * This interface was referenced by `WebpackOptions`'s JSON-Schema + * via the `definition` "ruleSet-condition-or-conditions". + */ +export type RuleSetConditionOrConditions = RuleSetCondition | RuleSetConditions; /** * This interface was referenced by `WebpackOptions`'s JSON-Schema * via the `definition` "ruleSet-condition". @@ -70,11 +81,11 @@ export type RuleSetCondition = /** * Exclude all modules matching any of these conditions */ - exclude?: RuleSetCondition; + exclude?: RuleSetConditionOrConditions; /** * Exclude all modules matching not any of these conditions */ - include?: RuleSetCondition; + include?: RuleSetConditionOrConditions; /** * Logical NOT */ @@ -86,13 +97,13 @@ export type RuleSetCondition = /** * Exclude all modules matching any of these conditions */ - test?: RuleSetCondition; + test?: RuleSetConditionOrConditions; }; /** * This interface was referenced by `WebpackOptions`'s JSON-Schema * via the `definition` "ruleSet-conditions". */ -export type RuleSetConditions = RuleSetCondition[]; +export type RuleSetConditions = RuleSetConditionsRecursive; /** * This interface was referenced by `WebpackOptions`'s JSON-Schema * via the `definition` "ruleSet-loader". @@ -149,6 +160,15 @@ export type RuleSetQuery = * via the `definition` "common.arrayOfStringOrStringArrayValues". */ export type CommonArrayOfStringOrStringArrayValues = (string | string[])[]; +/** + * Function acting as plugin + * + * This interface was referenced by `WebpackOptions`'s JSON-Schema + * via the `definition` "common.pluginFunction". + */ +export type CommonPluginFunction = ( + compiler: import("../lib/Compiler") +) => void; /** * This interface was referenced by `WebpackOptions`'s JSON-Schema * via the `definition` "ruleSet-rules". @@ -943,7 +963,7 @@ export interface RuleSetRule { /** * Match the child compiler name */ - compiler?: RuleSetCondition; + compiler?: RuleSetConditionOrConditions; /** * Enforce this rule as pre or post step */ @@ -951,19 +971,19 @@ export interface RuleSetRule { /** * Shortcut for resource.exclude */ - exclude?: RuleSetCondition & { + exclude?: RuleSetConditionOrConditions & { [k: string]: any; }; /** * Shortcut for resource.include */ - include?: RuleSetCondition & { + include?: RuleSetConditionOrConditions & { [k: string]: any; }; /** * Match the issuer of the module (The module pointing to this module) */ - issuer?: RuleSetCondition & { + issuer?: RuleSetConditionOrConditions & { [k: string]: any; }; /** @@ -999,13 +1019,13 @@ export interface RuleSetRule { /** * Match the resource path of the module */ - resource?: RuleSetCondition & { + resource?: RuleSetConditionOrConditions & { [k: string]: any; }; /** * Match the resource query of the module */ - resourceQuery?: RuleSetCondition; + resourceQuery?: RuleSetConditionOrConditions; /** * Match and execute these rules when this rule is matched */ @@ -1017,7 +1037,7 @@ export interface RuleSetRule { /** * Shortcut for resource.test */ - test?: RuleSetCondition & { + test?: RuleSetConditionOrConditions & { [k: string]: any; }; /** @@ -1156,24 +1176,7 @@ export interface CommonPluginObject { /** * The run point of the plugin, required method. */ - apply: { - [k: string]: any; - }; - [k: string]: any; -} -/** - * Function acting as plugin - * - * This interface was referenced by `WebpackOptions`'s JSON-Schema - * via the `definition` "common.pluginFunction". - */ -export interface CommonPluginFunction { - /** - * The run point of the plugin, required method. - */ - apply: { - [k: string]: any; - }; + apply: (compiler: import("../lib/Compiler")) => void; [k: string]: any; } /** diff --git a/schemas/WebpackOptions.json b/schemas/WebpackOptions.json index e5f9c6529..8df328ab9 100644 --- a/schemas/WebpackOptions.json +++ b/schemas/WebpackOptions.json @@ -48,7 +48,8 @@ } }, "required": ["apply"], - "instanceof": "Function" + "instanceof": "Function", + "tsType": "(compiler: import('../lib/Compiler')) => void" }, "common.pluginObject": { "description": "Plugin instance", @@ -57,7 +58,8 @@ "properties": { "apply": { "description": "The run point of the plugin, required method.", - "instanceof": "Function" + "instanceof": "Function", + "tsType": "(compiler: import('../lib/Compiler')) => void" } }, "required": ["apply"] @@ -106,7 +108,7 @@ } ] }, - "externals": { + "external-item": { "anyOf": [ { "description": "An exact matched dependency becomes external. The same string is used as external dependency.", @@ -140,6 +142,13 @@ { "description": "Every matched dependency becomes external.", "instanceof": "RegExp" + } + ] + }, + "externals": { + "anyOf": [ + { + "$ref": "#/definitions/external-item" }, { "type": "array", @@ -147,7 +156,7 @@ "description": "External configuration", "anyOf": [ { - "$ref": "#/definitions/externals" + "$ref": "#/definitions/external-item" } ] } @@ -788,7 +797,7 @@ "description": "Exclude all modules matching any of these conditions", "anyOf": [ { - "$ref": "#/definitions/ruleSet-condition" + "$ref": "#/definitions/ruleSet-condition-or-conditions" } ] }, @@ -796,7 +805,7 @@ "description": "Exclude all modules matching not any of these conditions", "anyOf": [ { - "$ref": "#/definitions/ruleSet-condition" + "$ref": "#/definitions/ruleSet-condition-or-conditions" } ] }, @@ -820,7 +829,7 @@ "description": "Exclude all modules matching any of these conditions", "anyOf": [ { - "$ref": "#/definitions/ruleSet-condition" + "$ref": "#/definitions/ruleSet-condition-or-conditions" } ] } @@ -828,6 +837,17 @@ } ] }, + "ruleSet-condition-or-conditions": { + "description": "One or multiple rule conditions", + "anyOf": [ + { + "$ref": "#/definitions/ruleSet-condition" + }, + { + "$ref": "#/definitions/ruleSet-conditions" + } + ] + }, "ruleSet-conditions": { "type": "array", "items": { @@ -837,7 +857,8 @@ "$ref": "#/definitions/ruleSet-condition" } ] - } + }, + "tsType": "RuleSetConditionsRecursive" }, "ruleSet-loader": { "type": "string", @@ -861,7 +882,7 @@ "description": "Match the child compiler name", "anyOf": [ { - "$ref": "#/definitions/ruleSet-condition" + "$ref": "#/definitions/ruleSet-condition-or-conditions" } ] }, @@ -873,7 +894,7 @@ "description": "Shortcut for resource.exclude", "allOf": [ { - "$ref": "#/definitions/ruleSet-condition" + "$ref": "#/definitions/ruleSet-condition-or-conditions" }, { "absolutePath": true @@ -884,7 +905,7 @@ "description": "Shortcut for resource.include", "allOf": [ { - "$ref": "#/definitions/ruleSet-condition" + "$ref": "#/definitions/ruleSet-condition-or-conditions" }, { "absolutePath": true @@ -895,7 +916,7 @@ "description": "Match the issuer of the module (The module pointing to this module)", "allOf": [ { - "$ref": "#/definitions/ruleSet-condition" + "$ref": "#/definitions/ruleSet-condition-or-conditions" }, { "absolutePath": true @@ -963,7 +984,7 @@ "description": "Match the resource path of the module", "allOf": [ { - "$ref": "#/definitions/ruleSet-condition" + "$ref": "#/definitions/ruleSet-condition-or-conditions" }, { "absolutePath": true @@ -974,7 +995,7 @@ "description": "Match the resource query of the module", "anyOf": [ { - "$ref": "#/definitions/ruleSet-condition" + "$ref": "#/definitions/ruleSet-condition-or-conditions" } ] }, @@ -994,7 +1015,7 @@ "description": "Shortcut for resource.test", "allOf": [ { - "$ref": "#/definitions/ruleSet-condition" + "$ref": "#/definitions/ruleSet-condition-or-conditions" }, { "absolutePath": true diff --git a/test/Schemas.lint.js b/test/Schemas.lint.js index 075c39bfa..e0a8984f2 100644 --- a/test/Schemas.lint.js +++ b/test/Schemas.lint.js @@ -49,7 +49,8 @@ describe("Schemas", () => { "uniqueItems", "minItems", "minProperties", - "instanceof" + "instanceof", + "tsType" ]; const validateProperty = property => { From 3a896c96b64abb993b83f15dec460faf8d9bf2b3 Mon Sep 17 00:00:00 2001 From: Tobias Koppers Date: Wed, 19 Sep 2018 10:37:53 +0200 Subject: [PATCH 13/29] reorganize webpack options schema --- declarations/WebpackOptions.d.ts | 1139 +++++++++++----------- schemas/WebpackOptions.json | 1513 +++++++++++++++--------------- 2 files changed, 1347 insertions(+), 1305 deletions(-) diff --git a/declarations/WebpackOptions.d.ts b/declarations/WebpackOptions.d.ts index 6e4c32301..a1bf99f57 100644 --- a/declarations/WebpackOptions.d.ts +++ b/declarations/WebpackOptions.d.ts @@ -6,33 +6,33 @@ /** * This interface was referenced by `WebpackOptions`'s JSON-Schema - * via the `definition` "entry". + * via the `definition` "Entry". */ export type Entry = | { /** * An entry point with name */ - [k: string]: string | CommonNonEmptyArrayOfUniqueStringValues; + [k: string]: string | NonEmptyArrayOfUniqueStringValues; } | string - | CommonNonEmptyArrayOfUniqueStringValues + | NonEmptyArrayOfUniqueStringValues | { [k: string]: any; }; /** * This interface was referenced by `WebpackOptions`'s JSON-Schema - * via the `definition` "common.nonEmptyArrayOfUniqueStringValues". + * via the `definition` "NonEmptyArrayOfUniqueStringValues". */ -export type CommonNonEmptyArrayOfUniqueStringValues = string[]; +export type NonEmptyArrayOfUniqueStringValues = string[]; /** * This interface was referenced by `WebpackOptions`'s JSON-Schema - * via the `definition` "externals". + * via the `definition` "Externals". */ export type Externals = ExternalItem | ExternalItem[]; /** * This interface was referenced by `WebpackOptions`'s JSON-Schema - * via the `definition` "external-item". + * via the `definition` "ExternalItem". */ export type ExternalItem = | string @@ -45,7 +45,7 @@ export type ExternalItem = | { [k: string]: any; } - | CommonArrayOfStringValues + | ArrayOfStringValues | boolean; } | { @@ -53,19 +53,19 @@ export type ExternalItem = }; /** * This interface was referenced by `WebpackOptions`'s JSON-Schema - * via the `definition` "common.arrayOfStringValues". + * via the `definition` "ArrayOfStringValues". */ -export type CommonArrayOfStringValues = string[]; +export type ArrayOfStringValues = string[]; /** * One or multiple rule conditions * * This interface was referenced by `WebpackOptions`'s JSON-Schema - * via the `definition` "ruleSet-condition-or-conditions". + * via the `definition` "RuleSetConditionOrConditions". */ export type RuleSetConditionOrConditions = RuleSetCondition | RuleSetConditions; /** * This interface was referenced by `WebpackOptions`'s JSON-Schema - * via the `definition` "ruleSet-condition". + * via the `definition` "RuleSetCondition". */ export type RuleSetCondition = | { @@ -101,17 +101,17 @@ export type RuleSetCondition = }; /** * This interface was referenced by `WebpackOptions`'s JSON-Schema - * via the `definition` "ruleSet-conditions". + * via the `definition` "RuleSetConditions". */ export type RuleSetConditions = RuleSetConditionsRecursive; /** * This interface was referenced by `WebpackOptions`'s JSON-Schema - * via the `definition` "ruleSet-loader". + * via the `definition` "RuleSetLoader". */ export type RuleSetLoader = string; /** * This interface was referenced by `WebpackOptions`'s JSON-Schema - * via the `definition` "ruleSet-use". + * via the `definition` "RuleSetUse". */ export type RuleSetUse = | RuleSetUseItem @@ -121,7 +121,7 @@ export type RuleSetUse = | RuleSetUseItem[]; /** * This interface was referenced by `WebpackOptions`'s JSON-Schema - * via the `definition` "ruleSet-use-item". + * via the `definition` "RuleSetUseItem". */ export type RuleSetUseItem = | RuleSetLoader @@ -148,7 +148,7 @@ export type RuleSetUseItem = }; /** * This interface was referenced by `WebpackOptions`'s JSON-Schema - * via the `definition` "ruleSet-query". + * via the `definition` "RuleSetQuery". */ export type RuleSetQuery = | { @@ -157,31 +157,31 @@ export type RuleSetQuery = | string; /** * This interface was referenced by `WebpackOptions`'s JSON-Schema - * via the `definition` "common.arrayOfStringOrStringArrayValues". + * via the `definition` "ArrayOfStringOrStringArrayValues". */ -export type CommonArrayOfStringOrStringArrayValues = (string | string[])[]; +export type ArrayOfStringOrStringArrayValues = (string | string[])[]; /** * Function acting as plugin * * This interface was referenced by `WebpackOptions`'s JSON-Schema - * via the `definition` "common.pluginFunction". + * via the `definition` "WebpackPluginFunction". */ -export type CommonPluginFunction = ( +export type WebpackPluginFunction = ( compiler: import("../lib/Compiler") ) => void; /** * This interface was referenced by `WebpackOptions`'s JSON-Schema - * via the `definition` "ruleSet-rules". + * via the `definition` "RuleSetRules". */ export type RuleSetRules = RuleSetRule[]; /** * This interface was referenced by `WebpackOptions`'s JSON-Schema - * via the `definition` "filter-types". + * via the `definition` "FilterTypes". */ export type FilterTypes = FilterItemTypes | FilterItemTypes[]; /** * This interface was referenced by `WebpackOptions`'s JSON-Schema - * via the `definition` "filter-item-types". + * via the `definition` "FilterItemTypes". */ export type FilterItemTypes = | { @@ -247,7 +247,7 @@ export interface WebpackOptions { /** * Options affecting the normal modules (`NormalModuleFactory`). */ - module?: Module; + module?: ModuleOptions; /** * Name of the configuration. Used when loading multiple configurations. */ @@ -255,305 +255,15 @@ export interface WebpackOptions { /** * Include polyfills or mocks for various node stuff. */ - node?: - | false - | { - /** - * Include a polyfill for the 'Buffer' variable - */ - Buffer?: false | true | "mock"; - /** - * Include a polyfill for the '__dirname' variable - */ - __dirname?: false | true | "mock"; - /** - * Include a polyfill for the '__filename' variable - */ - __filename?: false | true | "mock"; - /** - * Include a polyfill for the 'console' variable - */ - console?: false | true | "mock"; - /** - * Include a polyfill for the 'global' variable - */ - global?: boolean; - /** - * Include a polyfill for the 'process' variable - */ - process?: false | true | "mock"; - /** - * Include a polyfill for the node.js module - */ - [k: string]: false | true | "mock" | "empty"; - }; + node?: false | NodeOptions; /** * Enables/Disables integrated optimizations */ - optimization?: { - /** - * Check for incompatible wasm types when importing/exporting from/to ESM - */ - checkWasmTypes?: boolean; - /** - * Define the algorithm to choose chunk ids (named: readable ids for better debugging, size: numeric ids focused on minimal initial download size, total-size: numeric ids focused on minimal total download size, false: no algorithm used, as custom one can be provided via plugin) - */ - chunkIds?: "natural" | "named" | "size" | "total-size" | false; - /** - * Concatenate modules when possible to generate less modules, more efficient code and enable more optimizations by the minimizer - */ - concatenateModules?: boolean; - /** - * Also flag chunks as loaded which contain a subset of the modules - */ - flagIncludedChunks?: boolean; - /** - * Use hashed module id instead module identifiers for better long term caching (deprecated, used moduleIds: hashed instead) - */ - hashedModuleIds?: boolean; - /** - * Reduce size of WASM by changing imports to shorter strings. - */ - mangleWasmImports?: boolean; - /** - * Merge chunks which contain the same modules - */ - mergeDuplicateChunks?: boolean; - /** - * Enable minimizing the output. Uses optimization.minimizer. - */ - minimize?: boolean; - /** - * Minimizer(s) to use for minimizing the output - */ - minimizer?: (CommonPluginObject | CommonPluginFunction)[]; - /** - * Define the algorithm to choose module ids (natural: numeric ids in order of usage, named: readable ids for better debugging, hashed: short hashes as ids for better long term caching, size: numeric ids focused on minimal initial download size, total-size: numeric ids focused on minimal total download size, false: no algorithm used, as custom one can be provided via plugin) - */ - moduleIds?: "natural" | "named" | "hashed" | "size" | "total-size" | false; - /** - * Use readable chunk identifiers for better debugging (deprecated, used chunkIds: named instead) - */ - namedChunks?: boolean; - /** - * Use readable module identifiers for better debugging (deprecated, used moduleIds: named instead) - */ - namedModules?: boolean; - /** - * Avoid emitting assets when errors occur - */ - noEmitOnErrors?: boolean; - /** - * Set process.env.NODE_ENV to a specific value - */ - nodeEnv?: false | string; - /** - * Figure out a order of modules which results in the smallest initial bundle - */ - occurrenceOrder?: boolean; - /** - * Generate records with relative paths to be able to move the context folder - */ - portableRecords?: boolean; - /** - * Figure out which exports are provided by modules to generate more efficient code - */ - providedExports?: boolean; - /** - * Removes modules from chunks when these modules are already included in all parents - */ - removeAvailableModules?: boolean; - /** - * Remove chunks which are empty - */ - removeEmptyChunks?: boolean; - /** - * Create an additional chunk which contains only the webpack runtime and chunk hash maps - */ - runtimeChunk?: - | boolean - | ("single" | "multiple") - | { - /** - * The name or name factory for the runtime chunks - */ - name?: - | string - | { - [k: string]: any; - }; - }; - /** - * Skip over modules which are flagged to contain no side effects when exports are not used - */ - sideEffects?: boolean; - /** - * Optimize duplication and caching by splitting chunks by shared modules and cache group - */ - splitChunks?: - | false - | { - /** - * Sets the name delimiter for created chunks - */ - automaticNameDelimiter?: string; - /** - * Assign modules to a cache group (modules from different cache groups are tried to keep in separate chunks) - */ - cacheGroups?: { - /** - * Configuration for a cache group - */ - [k: string]: - | false - | { - [k: string]: any; - } - | string - | { - /** - * Sets the name delimiter for created chunks - */ - automaticNameDelimiter?: string; - /** - * Sets the name prefix for created chunks - */ - automaticNamePrefix?: string; - /** - * Select chunks for determining cache group content (defaults to "initial", "initial" and "all" requires adding these chunks to the HTML) - */ - chunks?: - | ("initial" | "async" | "all") - | { - [k: string]: any; - }; - /** - * Ignore minimum size, minimum chunks and maximum requests and always create chunks for this cache group - */ - enforce?: boolean; - /** - * Sets the template for the filename for created chunks (Only works for initial chunks) - */ - filename?: string; - /** - * Maximum number of requests which are accepted for on-demand loading - */ - maxAsyncRequests?: number; - /** - * Maximum number of initial chunks which are accepted for an entry point - */ - maxInitialRequests?: number; - /** - * Maximal size hint for the created chunks - */ - maxSize?: number; - /** - * Minimum number of times a module has to be duplicated until it's considered for splitting - */ - minChunks?: number; - /** - * Minimal size for the created chunk - */ - minSize?: number; - /** - * Give chunks for this cache group a name (chunks with equal name are merged) - */ - name?: - | boolean - | { - [k: string]: any; - } - | string; - /** - * Priority of this cache group - */ - priority?: number; - /** - * Try to reuse existing chunk (with name) when it has matching modules - */ - reuseExistingChunk?: boolean; - /** - * Assign modules to a cache group - */ - test?: - | { - [k: string]: any; - } - | string; - }; - }; - /** - * Select chunks for determining shared modules (defaults to "async", "initial" and "all" requires adding these chunks to the HTML) - */ - chunks?: - | ("initial" | "async" | "all") - | { - [k: string]: any; - }; - /** - * Options for modules not selected by any other cache group - */ - fallbackCacheGroup?: { - /** - * Sets the name delimiter for created chunks - */ - automaticNameDelimiter?: string; - /** - * Maximal size hint for the created chunks - */ - maxSize?: number; - /** - * Minimal size for the created chunk - */ - minSize?: number; - }; - /** - * Sets the template for the filename for created chunks (Only works for initial chunks) - */ - filename?: string; - /** - * Prevents exposing path info when creating names for parts splitted by maxSize - */ - hidePathInfo?: boolean; - /** - * Maximum number of requests which are accepted for on-demand loading - */ - maxAsyncRequests?: number; - /** - * Maximum number of initial chunks which are accepted for an entry point - */ - maxInitialRequests?: number; - /** - * Maximal size hint for the created chunks - */ - maxSize?: number; - /** - * Minimum number of times a module has to be duplicated until it's considered for splitting - */ - minChunks?: number; - /** - * Minimal size for the created chunks - */ - minSize?: number; - /** - * Give chunks created a name (chunks with equal name are merged) - */ - name?: - | boolean - | { - [k: string]: any; - } - | string; - }; - /** - * Figure out which exports are used by modules to mangle export names, omit unused exports and generate more efficient code - */ - usedExports?: boolean; - }; + optimization?: OptimizationOptions; /** * Options affecting the output of the compilation. `output` options tell webpack how to write the compiled files to disk. */ - output?: Output; + output?: string | OutputOptions; /** * The number of parallel processed modules in the compilation. */ @@ -561,32 +271,11 @@ export interface WebpackOptions { /** * Configuration for web performance recommendations. */ - performance?: - | false - | { - /** - * Filter function to select assets that are checked - */ - assetFilter?: { - [k: string]: any; - }; - /** - * Sets the format of the hints: warnings, errors or nothing at all - */ - hints?: false | "warning" | "error"; - /** - * Filesize limit (in bytes) when exceeded, that webpack will provide performance hints - */ - maxAssetSize?: number; - /** - * Total size of an entry point (in bytes) - */ - maxEntrypointSize?: number; - }; + performance?: false | PerformanceOptions; /** * Add additional plugins to the compiler. */ - plugins?: (CommonPluginObject | CommonPluginFunction)[]; + plugins?: (WebpackPluginInstance | WebpackPluginFunction)[]; /** * Capture timing information for each module. */ @@ -606,11 +295,11 @@ export interface WebpackOptions { /** * Options for the resolver */ - resolve?: Resolve; + resolve?: ResolveOptions; /** * Options for the resolver when resolving loaders */ - resolveLoader?: Resolve; + resolveLoader?: ResolveOptions; /** * Options for webpack-serve */ @@ -621,199 +310,7 @@ export interface WebpackOptions { * Used by the webpack CLI program to pass stats options. */ stats?: - | { - /** - * fallback value for stats options when an option is not defined (has precedence over local webpack defaults) - */ - all?: boolean; - /** - * add assets information - */ - assets?: boolean; - /** - * sort the assets by that field - */ - assetsSort?: string; - /** - * add built at time information - */ - builtAt?: boolean; - /** - * add also information about cached (not built) modules - */ - cached?: boolean; - /** - * Show cached assets (setting this to `false` only shows emitted files) - */ - cachedAssets?: boolean; - /** - * add children information - */ - children?: boolean; - /** - * Display all chunk groups with the corresponding bundles - */ - chunkGroups?: boolean; - /** - * add built modules information to chunk information - */ - chunkModules?: boolean; - /** - * add the origins of chunks and chunk merging info - */ - chunkOrigins?: boolean; - /** - * add chunk information - */ - chunks?: boolean; - /** - * sort the chunks by that field - */ - chunksSort?: string; - /** - * Enables/Disables colorful output - */ - colors?: - | boolean - | { - /** - * Custom color for bold text - */ - bold?: string; - /** - * Custom color for cyan text - */ - cyan?: string; - /** - * Custom color for green text - */ - green?: string; - /** - * Custom color for magenta text - */ - magenta?: string; - /** - * Custom color for red text - */ - red?: string; - /** - * Custom color for yellow text - */ - yellow?: string; - }; - /** - * context directory for request shortening - */ - context?: string; - /** - * add module depth in module graph - */ - depth?: boolean; - /** - * Display the entry points with the corresponding bundles - */ - entrypoints?: boolean; - /** - * add --env information - */ - env?: boolean; - /** - * add details to errors (like resolving log) - */ - errorDetails?: boolean; - /** - * add errors - */ - errors?: boolean; - /** - * Please use excludeModules instead. - */ - exclude?: FilterTypes | boolean; - /** - * Suppress assets that match the specified filters. Filters can be Strings, RegExps or Functions - */ - excludeAssets?: FilterTypes; - /** - * Suppress modules that match the specified filters. Filters can be Strings, RegExps, Booleans or Functions - */ - excludeModules?: FilterTypes | boolean; - /** - * add the hash of the compilation - */ - hash?: boolean; - /** - * Set the maximum number of modules to be shown - */ - maxModules?: number; - /** - * add information about assets inside modules - */ - moduleAssets?: boolean; - /** - * add dependencies and origin of warnings/errors - */ - moduleTrace?: boolean; - /** - * add built modules information - */ - modules?: boolean; - /** - * sort the modules by that field - */ - modulesSort?: string; - /** - * add information about modules nested in other modules (like with module concatenation) - */ - nestedModules?: boolean; - /** - * show reasons why optimization bailed out for modules - */ - optimizationBailout?: boolean; - /** - * Add output path information - */ - outputPath?: boolean; - /** - * add performance hint flags - */ - performance?: boolean; - /** - * show exports provided by modules - */ - providedExports?: boolean; - /** - * Add public path information - */ - publicPath?: boolean; - /** - * add information about the reasons why modules are included - */ - reasons?: boolean; - /** - * add the source code of modules - */ - source?: boolean; - /** - * add timing information - */ - timings?: boolean; - /** - * show exports used by modules - */ - usedExports?: boolean; - /** - * add webpack version information - */ - version?: boolean; - /** - * add warnings - */ - warnings?: boolean; - /** - * Suppress warnings that match the specified filters. Filters can be Strings, RegExps or Functions - */ - warningsFilter?: FilterTypes; - } + | StatsOptions | boolean | ("none" | "errors-only" | "minimal" | "normal" | "detailed" | "verbose"); /** @@ -861,9 +358,9 @@ export interface WebpackOptions { } /** * This interface was referenced by `WebpackOptions`'s JSON-Schema - * via the `definition` "module". + * via the `definition` "ModuleOptions". */ -export interface Module { +export interface ModuleOptions { /** * An array of rules applied by default for modules. */ @@ -957,7 +454,7 @@ export interface Module { } /** * This interface was referenced by `WebpackOptions`'s JSON-Schema - * via the `definition` "ruleSet-rule". + * via the `definition` "RuleSetRule". */ export interface RuleSetRule { /** @@ -1015,7 +512,7 @@ export interface RuleSetRule { /** * Options for the resolver */ - resolve?: Resolve; + resolve?: ResolveOptions; /** * Match the resource path of the module */ @@ -1056,9 +553,9 @@ export interface RuleSetRule { } /** * This interface was referenced by `WebpackOptions`'s JSON-Schema - * via the `definition` "resolve". + * via the `definition` "ResolveOptions". */ -export interface Resolve { +export interface ResolveOptions { /** * Redirect module requests */ @@ -1086,7 +583,7 @@ export interface Resolve { /** * Fields in the description file (package.json) which are used to redirect requests inside the module */ - aliasFields?: CommonArrayOfStringOrStringArrayValues; + aliasFields?: ArrayOfStringOrStringArrayValues; /** * Predicate function to decide which requests should be cached */ @@ -1104,7 +601,7 @@ export interface Resolve { /** * Filenames used to find a description file */ - descriptionFiles?: CommonArrayOfStringValues; + descriptionFiles?: ArrayOfStringValues; /** * Enforce using one of the extensions from the extensions option */ @@ -1116,7 +613,7 @@ export interface Resolve { /** * Extensions added to the request when trying to find the file */ - extensions?: CommonArrayOfStringValues; + extensions?: ArrayOfStringValues; /** * Filesystem for the resolver */ @@ -1126,23 +623,23 @@ export interface Resolve { /** * Field names from the description file (package.json) which are used to find the default entry point */ - mainFields?: CommonArrayOfStringOrStringArrayValues; + mainFields?: ArrayOfStringOrStringArrayValues; /** * Filenames used to find the default entry point if there is no description file or main field */ - mainFiles?: CommonArrayOfStringValues; + mainFiles?: ArrayOfStringValues; /** * Extensions added to the module request when trying to find the module */ - moduleExtensions?: CommonArrayOfStringValues; + moduleExtensions?: ArrayOfStringValues; /** * Folder names or directory paths where to find modules */ - modules?: CommonArrayOfStringValues; + modules?: ArrayOfStringValues; /** * Plugins for the resolver */ - plugins?: (CommonPluginObject | CommonPluginFunction)[]; + plugins?: (WebpackPluginInstance | WebpackPluginFunction)[]; /** * Custom resolver */ @@ -1170,9 +667,9 @@ export interface Resolve { * Plugin instance * * This interface was referenced by `WebpackOptions`'s JSON-Schema - * via the `definition` "common.pluginObject". + * via the `definition` "WebpackPluginInstance". */ -export interface CommonPluginObject { +export interface WebpackPluginInstance { /** * The run point of the plugin, required method. */ @@ -1181,9 +678,312 @@ export interface CommonPluginObject { } /** * This interface was referenced by `WebpackOptions`'s JSON-Schema - * via the `definition` "output". + * via the `definition` "NodeOptions". */ -export interface Output { +export interface NodeOptions { + /** + * Include a polyfill for the 'Buffer' variable + */ + Buffer?: false | true | "mock"; + /** + * Include a polyfill for the '__dirname' variable + */ + __dirname?: false | true | "mock"; + /** + * Include a polyfill for the '__filename' variable + */ + __filename?: false | true | "mock"; + /** + * Include a polyfill for the 'console' variable + */ + console?: false | true | "mock"; + /** + * Include a polyfill for the 'global' variable + */ + global?: boolean; + /** + * Include a polyfill for the 'process' variable + */ + process?: false | true | "mock"; + /** + * Include a polyfill for the node.js module + */ + [k: string]: false | true | "mock" | "empty"; +} +/** + * Enables/Disables integrated optimizations + * + * This interface was referenced by `WebpackOptions`'s JSON-Schema + * via the `definition` "OptimizationOptions". + */ +export interface OptimizationOptions { + /** + * Check for incompatible wasm types when importing/exporting from/to ESM + */ + checkWasmTypes?: boolean; + /** + * Define the algorithm to choose chunk ids (named: readable ids for better debugging, size: numeric ids focused on minimal initial download size, total-size: numeric ids focused on minimal total download size, false: no algorithm used, as custom one can be provided via plugin) + */ + chunkIds?: "natural" | "named" | "size" | "total-size" | false; + /** + * Concatenate modules when possible to generate less modules, more efficient code and enable more optimizations by the minimizer + */ + concatenateModules?: boolean; + /** + * Also flag chunks as loaded which contain a subset of the modules + */ + flagIncludedChunks?: boolean; + /** + * Use hashed module id instead module identifiers for better long term caching (deprecated, used moduleIds: hashed instead) + */ + hashedModuleIds?: boolean; + /** + * Reduce size of WASM by changing imports to shorter strings. + */ + mangleWasmImports?: boolean; + /** + * Merge chunks which contain the same modules + */ + mergeDuplicateChunks?: boolean; + /** + * Enable minimizing the output. Uses optimization.minimizer. + */ + minimize?: boolean; + /** + * Minimizer(s) to use for minimizing the output + */ + minimizer?: (WebpackPluginInstance | WebpackPluginFunction)[]; + /** + * Define the algorithm to choose module ids (natural: numeric ids in order of usage, named: readable ids for better debugging, hashed: short hashes as ids for better long term caching, size: numeric ids focused on minimal initial download size, total-size: numeric ids focused on minimal total download size, false: no algorithm used, as custom one can be provided via plugin) + */ + moduleIds?: "natural" | "named" | "hashed" | "size" | "total-size" | false; + /** + * Use readable chunk identifiers for better debugging (deprecated, used chunkIds: named instead) + */ + namedChunks?: boolean; + /** + * Use readable module identifiers for better debugging (deprecated, used moduleIds: named instead) + */ + namedModules?: boolean; + /** + * Avoid emitting assets when errors occur + */ + noEmitOnErrors?: boolean; + /** + * Set process.env.NODE_ENV to a specific value + */ + nodeEnv?: false | string; + /** + * Figure out a order of modules which results in the smallest initial bundle + */ + occurrenceOrder?: boolean; + /** + * Generate records with relative paths to be able to move the context folder + */ + portableRecords?: boolean; + /** + * Figure out which exports are provided by modules to generate more efficient code + */ + providedExports?: boolean; + /** + * Removes modules from chunks when these modules are already included in all parents + */ + removeAvailableModules?: boolean; + /** + * Remove chunks which are empty + */ + removeEmptyChunks?: boolean; + /** + * Create an additional chunk which contains only the webpack runtime and chunk hash maps + */ + runtimeChunk?: + | boolean + | ("single" | "multiple") + | { + /** + * The name or name factory for the runtime chunks + */ + name?: + | string + | { + [k: string]: any; + }; + }; + /** + * Skip over modules which are flagged to contain no side effects when exports are not used + */ + sideEffects?: boolean; + /** + * Optimize duplication and caching by splitting chunks by shared modules and cache group + */ + splitChunks?: false | OptimizationSplitChunksOptions; + /** + * Figure out which exports are used by modules to mangle export names, omit unused exports and generate more efficient code + */ + usedExports?: boolean; +} +/** + * This interface was referenced by `WebpackOptions`'s JSON-Schema + * via the `definition` "OptimizationSplitChunksOptions". + */ +export interface OptimizationSplitChunksOptions { + /** + * Sets the name delimiter for created chunks + */ + automaticNameDelimiter?: string; + /** + * Assign modules to a cache group (modules from different cache groups are tried to keep in separate chunks) + */ + cacheGroups?: { + /** + * Configuration for a cache group + */ + [k: string]: + | false + | { + [k: string]: any; + } + | string + | { + /** + * Sets the name delimiter for created chunks + */ + automaticNameDelimiter?: string; + /** + * Sets the name prefix for created chunks + */ + automaticNamePrefix?: string; + /** + * Select chunks for determining cache group content (defaults to "initial", "initial" and "all" requires adding these chunks to the HTML) + */ + chunks?: + | ("initial" | "async" | "all") + | { + [k: string]: any; + }; + /** + * Ignore minimum size, minimum chunks and maximum requests and always create chunks for this cache group + */ + enforce?: boolean; + /** + * Sets the template for the filename for created chunks (Only works for initial chunks) + */ + filename?: string; + /** + * Maximum number of requests which are accepted for on-demand loading + */ + maxAsyncRequests?: number; + /** + * Maximum number of initial chunks which are accepted for an entry point + */ + maxInitialRequests?: number; + /** + * Maximal size hint for the created chunks + */ + maxSize?: number; + /** + * Minimum number of times a module has to be duplicated until it's considered for splitting + */ + minChunks?: number; + /** + * Minimal size for the created chunk + */ + minSize?: number; + /** + * Give chunks for this cache group a name (chunks with equal name are merged) + */ + name?: + | boolean + | { + [k: string]: any; + } + | string; + /** + * Priority of this cache group + */ + priority?: number; + /** + * Try to reuse existing chunk (with name) when it has matching modules + */ + reuseExistingChunk?: boolean; + /** + * Assign modules to a cache group + */ + test?: + | { + [k: string]: any; + } + | string; + }; + }; + /** + * Select chunks for determining shared modules (defaults to "async", "initial" and "all" requires adding these chunks to the HTML) + */ + chunks?: + | ("initial" | "async" | "all") + | { + [k: string]: any; + }; + /** + * Options for modules not selected by any other cache group + */ + fallbackCacheGroup?: { + /** + * Sets the name delimiter for created chunks + */ + automaticNameDelimiter?: string; + /** + * Maximal size hint for the created chunks + */ + maxSize?: number; + /** + * Minimal size for the created chunk + */ + minSize?: number; + }; + /** + * Sets the template for the filename for created chunks (Only works for initial chunks) + */ + filename?: string; + /** + * Prevents exposing path info when creating names for parts splitted by maxSize + */ + hidePathInfo?: boolean; + /** + * Maximum number of requests which are accepted for on-demand loading + */ + maxAsyncRequests?: number; + /** + * Maximum number of initial chunks which are accepted for an entry point + */ + maxInitialRequests?: number; + /** + * Maximal size hint for the created chunks + */ + maxSize?: number; + /** + * Minimum number of times a module has to be duplicated until it's considered for splitting + */ + minChunks?: number; + /** + * Minimal size for the created chunks + */ + minSize?: number; + /** + * Give chunks created a name (chunks with equal name are merged) + */ + name?: + | boolean + | { + [k: string]: any; + } + | string; +} +/** + * This interface was referenced by `WebpackOptions`'s JSON-Schema + * via the `definition` "OutputOptions". + */ +export interface OutputOptions { /** * Add a comment in the UMD wrapper. */ @@ -1274,11 +1074,7 @@ export interface Output { /** * Algorithm used for generation the hash (see node.js crypto package) */ - hashFunction?: - | string - | { - [k: string]: any; - }; + hashFunction?: string | (new () => import("../lib/util/createHash").Hash); /** * Any string which is added to the hash to salt it */ @@ -1329,12 +1125,12 @@ export interface Output { /** * Name of the property exposed globally by a UMD library */ - root?: string | CommonArrayOfStringValues; + root?: string | ArrayOfStringValues; }; /** * Specify which export should be exposed as library */ - libraryExport?: string | CommonArrayOfStringValues; + libraryExport?: string | ArrayOfStringValues; /** * Type of library */ @@ -1389,3 +1185,224 @@ export interface Output { */ webassemblyModuleFilename?: string; } +/** + * This interface was referenced by `WebpackOptions`'s JSON-Schema + * via the `definition` "PerformanceOptions". + */ +export interface PerformanceOptions { + /** + * Filter function to select assets that are checked + */ + assetFilter?: { + [k: string]: any; + }; + /** + * Sets the format of the hints: warnings, errors or nothing at all + */ + hints?: false | "warning" | "error"; + /** + * Filesize limit (in bytes) when exceeded, that webpack will provide performance hints + */ + maxAssetSize?: number; + /** + * Total size of an entry point (in bytes) + */ + maxEntrypointSize?: number; +} +/** + * This interface was referenced by `WebpackOptions`'s JSON-Schema + * via the `definition` "StatsOptions". + */ +export interface StatsOptions { + /** + * fallback value for stats options when an option is not defined (has precedence over local webpack defaults) + */ + all?: boolean; + /** + * add assets information + */ + assets?: boolean; + /** + * sort the assets by that field + */ + assetsSort?: string; + /** + * add built at time information + */ + builtAt?: boolean; + /** + * add also information about cached (not built) modules + */ + cached?: boolean; + /** + * Show cached assets (setting this to `false` only shows emitted files) + */ + cachedAssets?: boolean; + /** + * add children information + */ + children?: boolean; + /** + * Display all chunk groups with the corresponding bundles + */ + chunkGroups?: boolean; + /** + * add built modules information to chunk information + */ + chunkModules?: boolean; + /** + * add the origins of chunks and chunk merging info + */ + chunkOrigins?: boolean; + /** + * add chunk information + */ + chunks?: boolean; + /** + * sort the chunks by that field + */ + chunksSort?: string; + /** + * Enables/Disables colorful output + */ + colors?: + | boolean + | { + /** + * Custom color for bold text + */ + bold?: string; + /** + * Custom color for cyan text + */ + cyan?: string; + /** + * Custom color for green text + */ + green?: string; + /** + * Custom color for magenta text + */ + magenta?: string; + /** + * Custom color for red text + */ + red?: string; + /** + * Custom color for yellow text + */ + yellow?: string; + }; + /** + * context directory for request shortening + */ + context?: string; + /** + * add module depth in module graph + */ + depth?: boolean; + /** + * Display the entry points with the corresponding bundles + */ + entrypoints?: boolean; + /** + * add --env information + */ + env?: boolean; + /** + * add details to errors (like resolving log) + */ + errorDetails?: boolean; + /** + * add errors + */ + errors?: boolean; + /** + * Please use excludeModules instead. + */ + exclude?: FilterTypes | boolean; + /** + * Suppress assets that match the specified filters. Filters can be Strings, RegExps or Functions + */ + excludeAssets?: FilterTypes; + /** + * Suppress modules that match the specified filters. Filters can be Strings, RegExps, Booleans or Functions + */ + excludeModules?: FilterTypes | boolean; + /** + * add the hash of the compilation + */ + hash?: boolean; + /** + * Set the maximum number of modules to be shown + */ + maxModules?: number; + /** + * add information about assets inside modules + */ + moduleAssets?: boolean; + /** + * add dependencies and origin of warnings/errors + */ + moduleTrace?: boolean; + /** + * add built modules information + */ + modules?: boolean; + /** + * sort the modules by that field + */ + modulesSort?: string; + /** + * add information about modules nested in other modules (like with module concatenation) + */ + nestedModules?: boolean; + /** + * show reasons why optimization bailed out for modules + */ + optimizationBailout?: boolean; + /** + * Add output path information + */ + outputPath?: boolean; + /** + * add performance hint flags + */ + performance?: boolean; + /** + * show exports provided by modules + */ + providedExports?: boolean; + /** + * Add public path information + */ + publicPath?: boolean; + /** + * add information about the reasons why modules are included + */ + reasons?: boolean; + /** + * add the source code of modules + */ + source?: boolean; + /** + * add timing information + */ + timings?: boolean; + /** + * show exports used by modules + */ + usedExports?: boolean; + /** + * add webpack version information + */ + version?: boolean; + /** + * add warnings + */ + warnings?: boolean; + /** + * Suppress warnings that match the specified filters. Filters can be Strings, RegExps or Functions + */ + warningsFilter?: FilterTypes; +} diff --git a/schemas/WebpackOptions.json b/schemas/WebpackOptions.json index 8df328ab9..58b4d01a9 100644 --- a/schemas/WebpackOptions.json +++ b/schemas/WebpackOptions.json @@ -1,6 +1,6 @@ { "definitions": { - "common.arrayOfStringOrStringArrayValues": { + "ArrayOfStringOrStringArrayValues": { "type": "array", "items": { "description": "string or array of strings", @@ -20,7 +20,7 @@ ] } }, - "common.arrayOfStringValues": { + "ArrayOfStringValues": { "type": "array", "items": { "description": "A non-empty string", @@ -28,43 +28,7 @@ "minLength": 1 } }, - "common.nonEmptyArrayOfUniqueStringValues": { - "type": "array", - "items": { - "description": "A non-empty string", - "type": "string", - "minLength": 1 - }, - "minItems": 1, - "uniqueItems": true - }, - "common.pluginFunction": { - "description": "Function acting as plugin", - "additionalProperties": true, - "properties": { - "apply": { - "description": "The run point of the plugin, required method.", - "instanceof": "Function" - } - }, - "required": ["apply"], - "instanceof": "Function", - "tsType": "(compiler: import('../lib/Compiler')) => void" - }, - "common.pluginObject": { - "description": "Plugin instance", - "type": "object", - "additionalProperties": true, - "properties": { - "apply": { - "description": "The run point of the plugin, required method.", - "instanceof": "Function", - "tsType": "(compiler: import('../lib/Compiler')) => void" - } - }, - "required": ["apply"] - }, - "entry": { + "Entry": { "oneOf": [ { "description": "Multiple entry bundles are created. The key is the chunk name. The value can be a string or an array.", @@ -81,7 +45,7 @@ "description": "All modules are loaded upon startup. The last one is exported.", "anyOf": [ { - "$ref": "#/definitions/common.nonEmptyArrayOfUniqueStringValues" + "$ref": "#/definitions/NonEmptyArrayOfUniqueStringValues" } ] } @@ -98,7 +62,7 @@ "description": "An entry point without name. All modules are loaded upon startup. The last one is exported.", "anyOf": [ { - "$ref": "#/definitions/common.nonEmptyArrayOfUniqueStringValues" + "$ref": "#/definitions/NonEmptyArrayOfUniqueStringValues" } ] }, @@ -108,7 +72,7 @@ } ] }, - "external-item": { + "ExternalItem": { "anyOf": [ { "description": "An exact matched dependency becomes external. The same string is used as external dependency.", @@ -127,7 +91,7 @@ "type": "object" }, { - "$ref": "#/definitions/common.arrayOfStringValues" + "$ref": "#/definitions/ArrayOfStringValues" }, { "type": "boolean" @@ -145,10 +109,10 @@ } ] }, - "externals": { + "Externals": { "anyOf": [ { - "$ref": "#/definitions/external-item" + "$ref": "#/definitions/ExternalItem" }, { "type": "array", @@ -156,14 +120,14 @@ "description": "External configuration", "anyOf": [ { - "$ref": "#/definitions/external-item" + "$ref": "#/definitions/ExternalItem" } ] } } ] }, - "filter-item-types": { + "FilterItemTypes": { "anyOf": [ { "instanceof": "RegExp" @@ -176,10 +140,10 @@ } ] }, - "filter-types": { + "FilterTypes": { "anyOf": [ { - "$ref": "#/definitions/filter-item-types" + "$ref": "#/definitions/FilterItemTypes" }, { "type": "array", @@ -187,14 +151,14 @@ "description": "Rule to filter", "anyOf": [ { - "$ref": "#/definitions/filter-item-types" + "$ref": "#/definitions/FilterItemTypes" } ] } } ] }, - "module": { + "ModuleOptions": { "type": "object", "additionalProperties": false, "properties": { @@ -202,7 +166,7 @@ "description": "An array of rules applied by default for modules.", "anyOf": [ { - "$ref": "#/definitions/ruleSet-rules" + "$ref": "#/definitions/RuleSetRules" } ] }, @@ -265,7 +229,7 @@ "description": "An array of rules applied for modules.", "allOf": [ { - "$ref": "#/definitions/ruleSet-rules" + "$ref": "#/definitions/RuleSetRules" } ] }, @@ -325,7 +289,407 @@ } } }, - "output": { + "NodeOptions": { + "type": "object", + "additionalProperties": { + "description": "Include a polyfill for the node.js module", + "enum": [false, true, "mock", "empty"] + }, + "properties": { + "Buffer": { + "description": "Include a polyfill for the 'Buffer' variable", + "enum": [false, true, "mock"] + }, + "__dirname": { + "description": "Include a polyfill for the '__dirname' variable", + "enum": [false, true, "mock"] + }, + "__filename": { + "description": "Include a polyfill for the '__filename' variable", + "enum": [false, true, "mock"] + }, + "console": { + "description": "Include a polyfill for the 'console' variable", + "enum": [false, true, "mock"] + }, + "global": { + "description": "Include a polyfill for the 'global' variable", + "type": "boolean" + }, + "process": { + "description": "Include a polyfill for the 'process' variable", + "enum": [false, true, "mock"] + } + } + }, + "NonEmptyArrayOfUniqueStringValues": { + "type": "array", + "items": { + "description": "A non-empty string", + "type": "string", + "minLength": 1 + }, + "minItems": 1, + "uniqueItems": true + }, + "OptimizationOptions": { + "description": "Enables/Disables integrated optimizations", + "type": "object", + "additionalProperties": false, + "properties": { + "checkWasmTypes": { + "description": "Check for incompatible wasm types when importing/exporting from/to ESM", + "type": "boolean" + }, + "chunkIds": { + "description": "Define the algorithm to choose chunk ids (named: readable ids for better debugging, size: numeric ids focused on minimal initial download size, total-size: numeric ids focused on minimal total download size, false: no algorithm used, as custom one can be provided via plugin)", + "enum": ["natural", "named", "size", "total-size", false] + }, + "concatenateModules": { + "description": "Concatenate modules when possible to generate less modules, more efficient code and enable more optimizations by the minimizer", + "type": "boolean" + }, + "flagIncludedChunks": { + "description": "Also flag chunks as loaded which contain a subset of the modules", + "type": "boolean" + }, + "hashedModuleIds": { + "description": "Use hashed module id instead module identifiers for better long term caching (deprecated, used moduleIds: hashed instead)", + "type": "boolean" + }, + "mangleWasmImports": { + "description": "Reduce size of WASM by changing imports to shorter strings.", + "type": "boolean" + }, + "mergeDuplicateChunks": { + "description": "Merge chunks which contain the same modules", + "type": "boolean" + }, + "minimize": { + "description": "Enable minimizing the output. Uses optimization.minimizer.", + "type": "boolean" + }, + "minimizer": { + "description": "Minimizer(s) to use for minimizing the output", + "type": "array", + "items": { + "description": "Plugin of type object or instanceof Function", + "anyOf": [ + { + "$ref": "#/definitions/WebpackPluginInstance" + }, + { + "$ref": "#/definitions/WebpackPluginFunction" + } + ] + } + }, + "moduleIds": { + "description": "Define the algorithm to choose module ids (natural: numeric ids in order of usage, named: readable ids for better debugging, hashed: short hashes as ids for better long term caching, size: numeric ids focused on minimal initial download size, total-size: numeric ids focused on minimal total download size, false: no algorithm used, as custom one can be provided via plugin)", + "enum": ["natural", "named", "hashed", "size", "total-size", false] + }, + "namedChunks": { + "description": "Use readable chunk identifiers for better debugging (deprecated, used chunkIds: named instead)", + "type": "boolean" + }, + "namedModules": { + "description": "Use readable module identifiers for better debugging (deprecated, used moduleIds: named instead)", + "type": "boolean" + }, + "noEmitOnErrors": { + "description": "Avoid emitting assets when errors occur", + "type": "boolean" + }, + "nodeEnv": { + "description": "Set process.env.NODE_ENV to a specific value", + "anyOf": [ + { + "enum": [false] + }, + { + "type": "string" + } + ] + }, + "occurrenceOrder": { + "description": "Figure out a order of modules which results in the smallest initial bundle", + "type": "boolean" + }, + "portableRecords": { + "description": "Generate records with relative paths to be able to move the context folder", + "type": "boolean" + }, + "providedExports": { + "description": "Figure out which exports are provided by modules to generate more efficient code", + "type": "boolean" + }, + "removeAvailableModules": { + "description": "Removes modules from chunks when these modules are already included in all parents", + "type": "boolean" + }, + "removeEmptyChunks": { + "description": "Remove chunks which are empty", + "type": "boolean" + }, + "runtimeChunk": { + "description": "Create an additional chunk which contains only the webpack runtime and chunk hash maps", + "oneOf": [ + { + "type": "boolean" + }, + { + "enum": ["single", "multiple"] + }, + { + "type": "object", + "additionalProperties": false, + "properties": { + "name": { + "description": "The name or name factory for the runtime chunks", + "oneOf": [ + { + "type": "string" + }, + { + "instanceof": "Function" + } + ] + } + } + } + ] + }, + "sideEffects": { + "description": "Skip over modules which are flagged to contain no side effects when exports are not used", + "type": "boolean" + }, + "splitChunks": { + "description": "Optimize duplication and caching by splitting chunks by shared modules and cache group", + "oneOf": [ + { + "enum": [false] + }, + { + "$ref": "#/definitions/OptimizationSplitChunksOptions" + } + ] + }, + "usedExports": { + "description": "Figure out which exports are used by modules to mangle export names, omit unused exports and generate more efficient code", + "type": "boolean" + } + } + }, + "OptimizationSplitChunksOptions": { + "type": "object", + "additionalProperties": false, + "properties": { + "automaticNameDelimiter": { + "description": "Sets the name delimiter for created chunks", + "type": "string", + "minLength": 1 + }, + "cacheGroups": { + "description": "Assign modules to a cache group (modules from different cache groups are tried to keep in separate chunks)", + "type": "object", + "additionalProperties": { + "description": "Configuration for a cache group", + "anyOf": [ + { + "enum": [false] + }, + { + "instanceof": "Function" + }, + { + "type": "string" + }, + { + "instanceof": "RegExp" + }, + { + "type": "object", + "additionalProperties": false, + "properties": { + "automaticNameDelimiter": { + "description": "Sets the name delimiter for created chunks", + "type": "string", + "minLength": 1 + }, + "automaticNamePrefix": { + "description": "Sets the name prefix for created chunks", + "type": "string" + }, + "chunks": { + "description": "Select chunks for determining cache group content (defaults to \"initial\", \"initial\" and \"all\" requires adding these chunks to the HTML)", + "oneOf": [ + { + "enum": ["initial", "async", "all"] + }, + { + "instanceof": "Function" + } + ] + }, + "enforce": { + "description": "Ignore minimum size, minimum chunks and maximum requests and always create chunks for this cache group", + "type": "boolean" + }, + "filename": { + "description": "Sets the template for the filename for created chunks (Only works for initial chunks)", + "type": "string", + "minLength": 1 + }, + "maxAsyncRequests": { + "description": "Maximum number of requests which are accepted for on-demand loading", + "type": "number", + "minimum": 1 + }, + "maxInitialRequests": { + "description": "Maximum number of initial chunks which are accepted for an entry point", + "type": "number", + "minimum": 1 + }, + "maxSize": { + "description": "Maximal size hint for the created chunks", + "type": "number", + "minimum": 0 + }, + "minChunks": { + "description": "Minimum number of times a module has to be duplicated until it's considered for splitting", + "type": "number", + "minimum": 1 + }, + "minSize": { + "description": "Minimal size for the created chunk", + "type": "number", + "minimum": 0 + }, + "name": { + "description": "Give chunks for this cache group a name (chunks with equal name are merged)", + "oneOf": [ + { + "type": "boolean" + }, + { + "instanceof": "Function" + }, + { + "type": "string" + } + ] + }, + "priority": { + "description": "Priority of this cache group", + "type": "number" + }, + "reuseExistingChunk": { + "description": "Try to reuse existing chunk (with name) when it has matching modules", + "type": "boolean" + }, + "test": { + "description": "Assign modules to a cache group", + "oneOf": [ + { + "instanceof": "Function" + }, + { + "type": "string" + }, + { + "instanceof": "RegExp" + } + ] + } + } + } + ] + } + }, + "chunks": { + "description": "Select chunks for determining shared modules (defaults to \"async\", \"initial\" and \"all\" requires adding these chunks to the HTML)", + "oneOf": [ + { + "enum": ["initial", "async", "all"] + }, + { + "instanceof": "Function" + } + ] + }, + "fallbackCacheGroup": { + "description": "Options for modules not selected by any other cache group", + "type": "object", + "additionalProperties": false, + "properties": { + "automaticNameDelimiter": { + "description": "Sets the name delimiter for created chunks", + "type": "string", + "minLength": 1 + }, + "maxSize": { + "description": "Maximal size hint for the created chunks", + "type": "number", + "minimum": 0 + }, + "minSize": { + "description": "Minimal size for the created chunk", + "type": "number", + "minimum": 0 + } + } + }, + "filename": { + "description": "Sets the template for the filename for created chunks (Only works for initial chunks)", + "type": "string", + "minLength": 1 + }, + "hidePathInfo": { + "description": "Prevents exposing path info when creating names for parts splitted by maxSize", + "type": "boolean" + }, + "maxAsyncRequests": { + "description": "Maximum number of requests which are accepted for on-demand loading", + "type": "number", + "minimum": 1 + }, + "maxInitialRequests": { + "description": "Maximum number of initial chunks which are accepted for an entry point", + "type": "number", + "minimum": 1 + }, + "maxSize": { + "description": "Maximal size hint for the created chunks", + "type": "number", + "minimum": 0 + }, + "minChunks": { + "description": "Minimum number of times a module has to be duplicated until it's considered for splitting", + "type": "number", + "minimum": 1 + }, + "minSize": { + "description": "Minimal size for the created chunks", + "type": "number", + "minimum": 0 + }, + "name": { + "description": "Give chunks created a name (chunks with equal name are merged)", + "oneOf": [ + { + "type": "boolean" + }, + { + "instanceof": "Function" + }, + { + "type": "string" + } + ] + } + } + }, + "OutputOptions": { "type": "object", "additionalProperties": false, "properties": { @@ -451,7 +815,8 @@ "minLength": 1 }, { - "instanceof": "Function" + "instanceof": "Function", + "tsType": "(new () => import('../lib/util/createHash').Hash)" } ] }, @@ -528,7 +893,7 @@ "type": "string" }, { - "$ref": "#/definitions/common.arrayOfStringValues" + "$ref": "#/definitions/ArrayOfStringValues" } ] } @@ -543,7 +908,7 @@ "type": "string" }, { - "$ref": "#/definitions/common.arrayOfStringValues" + "$ref": "#/definitions/ArrayOfStringValues" } ] }, @@ -609,7 +974,29 @@ } } }, - "resolve": { + "PerformanceOptions": { + "type": "object", + "additionalProperties": false, + "properties": { + "assetFilter": { + "description": "Filter function to select assets that are checked", + "instanceof": "Function" + }, + "hints": { + "description": "Sets the format of the hints: warnings, errors or nothing at all", + "enum": [false, "warning", "error"] + }, + "maxAssetSize": { + "description": "Filesize limit (in bytes) when exceeded, that webpack will provide performance hints", + "type": "number" + }, + "maxEntrypointSize": { + "description": "Total size of an entry point (in bytes)", + "type": "number" + } + } + }, + "ResolveOptions": { "type": "object", "additionalProperties": false, "properties": { @@ -651,7 +1038,7 @@ "description": "Fields in the description file (package.json) which are used to redirect requests inside the module", "anyOf": [ { - "$ref": "#/definitions/common.arrayOfStringOrStringArrayValues" + "$ref": "#/definitions/ArrayOfStringOrStringArrayValues" } ] }, @@ -671,7 +1058,7 @@ "description": "Filenames used to find a description file", "anyOf": [ { - "$ref": "#/definitions/common.arrayOfStringValues" + "$ref": "#/definitions/ArrayOfStringValues" } ] }, @@ -687,7 +1074,7 @@ "description": "Extensions added to the request when trying to find the file", "anyOf": [ { - "$ref": "#/definitions/common.arrayOfStringValues" + "$ref": "#/definitions/ArrayOfStringValues" } ] }, @@ -698,7 +1085,7 @@ "description": "Field names from the description file (package.json) which are used to find the default entry point", "anyOf": [ { - "$ref": "#/definitions/common.arrayOfStringOrStringArrayValues" + "$ref": "#/definitions/ArrayOfStringOrStringArrayValues" } ] }, @@ -706,7 +1093,7 @@ "description": "Filenames used to find the default entry point if there is no description file or main field", "anyOf": [ { - "$ref": "#/definitions/common.arrayOfStringValues" + "$ref": "#/definitions/ArrayOfStringValues" } ] }, @@ -714,7 +1101,7 @@ "description": "Extensions added to the module request when trying to find the module", "anyOf": [ { - "$ref": "#/definitions/common.arrayOfStringValues" + "$ref": "#/definitions/ArrayOfStringValues" } ] }, @@ -722,7 +1109,7 @@ "description": "Folder names or directory paths where to find modules", "anyOf": [ { - "$ref": "#/definitions/common.arrayOfStringValues" + "$ref": "#/definitions/ArrayOfStringValues" } ] }, @@ -733,10 +1120,10 @@ "description": "Plugin of type object or instanceof Function", "anyOf": [ { - "$ref": "#/definitions/common.pluginObject" + "$ref": "#/definitions/WebpackPluginInstance" }, { - "$ref": "#/definitions/common.pluginFunction" + "$ref": "#/definitions/WebpackPluginFunction" } ] } @@ -766,7 +1153,7 @@ } } }, - "ruleSet-condition": { + "RuleSetCondition": { "anyOf": [ { "instanceof": "RegExp" @@ -779,7 +1166,7 @@ "instanceof": "Function" }, { - "$ref": "#/definitions/ruleSet-conditions" + "$ref": "#/definitions/RuleSetConditions" }, { "type": "object", @@ -789,7 +1176,7 @@ "description": "Logical AND", "anyOf": [ { - "$ref": "#/definitions/ruleSet-conditions" + "$ref": "#/definitions/RuleSetConditions" } ] }, @@ -797,7 +1184,7 @@ "description": "Exclude all modules matching any of these conditions", "anyOf": [ { - "$ref": "#/definitions/ruleSet-condition-or-conditions" + "$ref": "#/definitions/RuleSetConditionOrConditions" } ] }, @@ -805,7 +1192,7 @@ "description": "Exclude all modules matching not any of these conditions", "anyOf": [ { - "$ref": "#/definitions/ruleSet-condition-or-conditions" + "$ref": "#/definitions/RuleSetConditionOrConditions" } ] }, @@ -813,7 +1200,7 @@ "description": "Logical NOT", "anyOf": [ { - "$ref": "#/definitions/ruleSet-conditions" + "$ref": "#/definitions/RuleSetConditions" } ] }, @@ -821,7 +1208,7 @@ "description": "Logical OR", "anyOf": [ { - "$ref": "#/definitions/ruleSet-conditions" + "$ref": "#/definitions/RuleSetConditions" } ] }, @@ -829,7 +1216,7 @@ "description": "Exclude all modules matching any of these conditions", "anyOf": [ { - "$ref": "#/definitions/ruleSet-condition-or-conditions" + "$ref": "#/definitions/RuleSetConditionOrConditions" } ] } @@ -837,34 +1224,34 @@ } ] }, - "ruleSet-condition-or-conditions": { + "RuleSetConditionOrConditions": { "description": "One or multiple rule conditions", "anyOf": [ { - "$ref": "#/definitions/ruleSet-condition" + "$ref": "#/definitions/RuleSetCondition" }, { - "$ref": "#/definitions/ruleSet-conditions" + "$ref": "#/definitions/RuleSetConditions" } ] }, - "ruleSet-conditions": { + "RuleSetConditions": { "type": "array", "items": { "description": "A rule condition", "anyOf": [ { - "$ref": "#/definitions/ruleSet-condition" + "$ref": "#/definitions/RuleSetCondition" } ] }, "tsType": "RuleSetConditionsRecursive" }, - "ruleSet-loader": { + "RuleSetLoader": { "type": "string", "minLength": 1 }, - "ruleSet-query": { + "RuleSetQuery": { "anyOf": [ { "type": "object" @@ -874,7 +1261,7 @@ } ] }, - "ruleSet-rule": { + "RuleSetRule": { "type": "object", "additionalProperties": false, "properties": { @@ -882,7 +1269,7 @@ "description": "Match the child compiler name", "anyOf": [ { - "$ref": "#/definitions/ruleSet-condition-or-conditions" + "$ref": "#/definitions/RuleSetConditionOrConditions" } ] }, @@ -894,7 +1281,7 @@ "description": "Shortcut for resource.exclude", "allOf": [ { - "$ref": "#/definitions/ruleSet-condition-or-conditions" + "$ref": "#/definitions/RuleSetConditionOrConditions" }, { "absolutePath": true @@ -905,7 +1292,7 @@ "description": "Shortcut for resource.include", "allOf": [ { - "$ref": "#/definitions/ruleSet-condition-or-conditions" + "$ref": "#/definitions/RuleSetConditionOrConditions" }, { "absolutePath": true @@ -916,7 +1303,7 @@ "description": "Match the issuer of the module (The module pointing to this module)", "allOf": [ { - "$ref": "#/definitions/ruleSet-condition-or-conditions" + "$ref": "#/definitions/RuleSetConditionOrConditions" }, { "absolutePath": true @@ -927,10 +1314,10 @@ "description": "Shortcut for use.loader", "anyOf": [ { - "$ref": "#/definitions/ruleSet-loader" + "$ref": "#/definitions/RuleSetLoader" }, { - "$ref": "#/definitions/ruleSet-use" + "$ref": "#/definitions/RuleSetUse" } ] }, @@ -938,7 +1325,7 @@ "description": "Shortcut for use.loader", "anyOf": [ { - "$ref": "#/definitions/ruleSet-use" + "$ref": "#/definitions/RuleSetUse" } ] }, @@ -946,7 +1333,7 @@ "description": "Only execute the first matching rule in this array", "anyOf": [ { - "$ref": "#/definitions/ruleSet-rules" + "$ref": "#/definitions/RuleSetRules" } ] }, @@ -954,7 +1341,7 @@ "description": "Shortcut for use.options", "anyOf": [ { - "$ref": "#/definitions/ruleSet-query" + "$ref": "#/definitions/RuleSetQuery" } ] }, @@ -967,7 +1354,7 @@ "description": "Shortcut for use.query", "anyOf": [ { - "$ref": "#/definitions/ruleSet-query" + "$ref": "#/definitions/RuleSetQuery" } ] }, @@ -976,7 +1363,7 @@ "type": "object", "anyOf": [ { - "$ref": "#/definitions/resolve" + "$ref": "#/definitions/ResolveOptions" } ] }, @@ -984,7 +1371,7 @@ "description": "Match the resource path of the module", "allOf": [ { - "$ref": "#/definitions/ruleSet-condition-or-conditions" + "$ref": "#/definitions/RuleSetConditionOrConditions" }, { "absolutePath": true @@ -995,7 +1382,7 @@ "description": "Match the resource query of the module", "anyOf": [ { - "$ref": "#/definitions/ruleSet-condition-or-conditions" + "$ref": "#/definitions/RuleSetConditionOrConditions" } ] }, @@ -1003,7 +1390,7 @@ "description": "Match and execute these rules when this rule is matched", "anyOf": [ { - "$ref": "#/definitions/ruleSet-rules" + "$ref": "#/definitions/RuleSetRules" } ] }, @@ -1015,7 +1402,7 @@ "description": "Shortcut for resource.test", "allOf": [ { - "$ref": "#/definitions/ruleSet-condition-or-conditions" + "$ref": "#/definitions/RuleSetConditionOrConditions" }, { "absolutePath": true @@ -1036,27 +1423,27 @@ "description": "Modifiers applied to the module when rule is matched", "anyOf": [ { - "$ref": "#/definitions/ruleSet-use" + "$ref": "#/definitions/RuleSetUse" } ] } } }, - "ruleSet-rules": { + "RuleSetRules": { "type": "array", "items": { "description": "A rule", "anyOf": [ { - "$ref": "#/definitions/ruleSet-rule" + "$ref": "#/definitions/RuleSetRule" } ] } }, - "ruleSet-use": { + "RuleSetUse": { "anyOf": [ { - "$ref": "#/definitions/ruleSet-use-item" + "$ref": "#/definitions/RuleSetUseItem" }, { "instanceof": "Function" @@ -1067,17 +1454,17 @@ "description": "An use item", "anyOf": [ { - "$ref": "#/definitions/ruleSet-use-item" + "$ref": "#/definitions/RuleSetUseItem" } ] } } ] }, - "ruleSet-use-item": { + "RuleSetUseItem": { "anyOf": [ { - "$ref": "#/definitions/ruleSet-loader" + "$ref": "#/definitions/RuleSetLoader" }, { "instanceof": "Function" @@ -1094,7 +1481,7 @@ "description": "Loader name", "anyOf": [ { - "$ref": "#/definitions/ruleSet-loader" + "$ref": "#/definitions/RuleSetLoader" } ] }, @@ -1102,7 +1489,7 @@ "description": "Loader options", "anyOf": [ { - "$ref": "#/definitions/ruleSet-query" + "$ref": "#/definitions/RuleSetQuery" } ] }, @@ -1110,13 +1497,267 @@ "description": "Loader query", "anyOf": [ { - "$ref": "#/definitions/ruleSet-query" + "$ref": "#/definitions/RuleSetQuery" } ] } } } ] + }, + "StatsOptions": { + "type": "object", + "additionalProperties": false, + "properties": { + "all": { + "description": "fallback value for stats options when an option is not defined (has precedence over local webpack defaults)", + "type": "boolean" + }, + "assets": { + "description": "add assets information", + "type": "boolean" + }, + "assetsSort": { + "description": "sort the assets by that field", + "type": "string" + }, + "builtAt": { + "description": "add built at time information", + "type": "boolean" + }, + "cached": { + "description": "add also information about cached (not built) modules", + "type": "boolean" + }, + "cachedAssets": { + "description": "Show cached assets (setting this to `false` only shows emitted files)", + "type": "boolean" + }, + "children": { + "description": "add children information", + "type": "boolean" + }, + "chunkGroups": { + "description": "Display all chunk groups with the corresponding bundles", + "type": "boolean" + }, + "chunkModules": { + "description": "add built modules information to chunk information", + "type": "boolean" + }, + "chunkOrigins": { + "description": "add the origins of chunks and chunk merging info", + "type": "boolean" + }, + "chunks": { + "description": "add chunk information", + "type": "boolean" + }, + "chunksSort": { + "description": "sort the chunks by that field", + "type": "string" + }, + "colors": { + "description": "Enables/Disables colorful output", + "oneOf": [ + { + "description": "`webpack --colors` equivalent", + "type": "boolean" + }, + { + "type": "object", + "additionalProperties": false, + "properties": { + "bold": { + "description": "Custom color for bold text", + "type": "string" + }, + "cyan": { + "description": "Custom color for cyan text", + "type": "string" + }, + "green": { + "description": "Custom color for green text", + "type": "string" + }, + "magenta": { + "description": "Custom color for magenta text", + "type": "string" + }, + "red": { + "description": "Custom color for red text", + "type": "string" + }, + "yellow": { + "description": "Custom color for yellow text", + "type": "string" + } + } + } + ] + }, + "context": { + "description": "context directory for request shortening", + "type": "string", + "absolutePath": true + }, + "depth": { + "description": "add module depth in module graph", + "type": "boolean" + }, + "entrypoints": { + "description": "Display the entry points with the corresponding bundles", + "type": "boolean" + }, + "env": { + "description": "add --env information", + "type": "boolean" + }, + "errorDetails": { + "description": "add details to errors (like resolving log)", + "type": "boolean" + }, + "errors": { + "description": "add errors", + "type": "boolean" + }, + "exclude": { + "description": "Please use excludeModules instead.", + "anyOf": [ + { + "$ref": "#/definitions/FilterTypes" + }, + { + "type": "boolean" + } + ] + }, + "excludeAssets": { + "description": "Suppress assets that match the specified filters. Filters can be Strings, RegExps or Functions", + "anyOf": [ + { + "$ref": "#/definitions/FilterTypes" + } + ] + }, + "excludeModules": { + "description": "Suppress modules that match the specified filters. Filters can be Strings, RegExps, Booleans or Functions", + "anyOf": [ + { + "$ref": "#/definitions/FilterTypes" + }, + { + "type": "boolean" + } + ] + }, + "hash": { + "description": "add the hash of the compilation", + "type": "boolean" + }, + "maxModules": { + "description": "Set the maximum number of modules to be shown", + "type": "number" + }, + "moduleAssets": { + "description": "add information about assets inside modules", + "type": "boolean" + }, + "moduleTrace": { + "description": "add dependencies and origin of warnings/errors", + "type": "boolean" + }, + "modules": { + "description": "add built modules information", + "type": "boolean" + }, + "modulesSort": { + "description": "sort the modules by that field", + "type": "string" + }, + "nestedModules": { + "description": "add information about modules nested in other modules (like with module concatenation)", + "type": "boolean" + }, + "optimizationBailout": { + "description": "show reasons why optimization bailed out for modules", + "type": "boolean" + }, + "outputPath": { + "description": "Add output path information", + "type": "boolean" + }, + "performance": { + "description": "add performance hint flags", + "type": "boolean" + }, + "providedExports": { + "description": "show exports provided by modules", + "type": "boolean" + }, + "publicPath": { + "description": "Add public path information", + "type": "boolean" + }, + "reasons": { + "description": "add information about the reasons why modules are included", + "type": "boolean" + }, + "source": { + "description": "add the source code of modules", + "type": "boolean" + }, + "timings": { + "description": "add timing information", + "type": "boolean" + }, + "usedExports": { + "description": "show exports used by modules", + "type": "boolean" + }, + "version": { + "description": "add webpack version information", + "type": "boolean" + }, + "warnings": { + "description": "add warnings", + "type": "boolean" + }, + "warningsFilter": { + "description": "Suppress warnings that match the specified filters. Filters can be Strings, RegExps or Functions", + "anyOf": [ + { + "$ref": "#/definitions/FilterTypes" + } + ] + } + } + }, + "WebpackPluginFunction": { + "description": "Function acting as plugin", + "additionalProperties": true, + "properties": { + "apply": { + "description": "The run point of the plugin, required method.", + "instanceof": "Function" + } + }, + "required": ["apply"], + "instanceof": "Function", + "tsType": "(compiler: import('../lib/Compiler')) => void" + }, + "WebpackPluginInstance": { + "description": "Plugin instance", + "type": "object", + "additionalProperties": true, + "properties": { + "apply": { + "description": "The run point of the plugin, required method.", + "instanceof": "Function", + "tsType": "(compiler: import('../lib/Compiler')) => void" + } + }, + "required": ["apply"] } }, "type": "object", @@ -1174,7 +1815,7 @@ "description": "The entry point(s) of the compilation.", "anyOf": [ { - "$ref": "#/definitions/entry" + "$ref": "#/definitions/Entry" } ] }, @@ -1182,7 +1823,7 @@ "description": "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`.", "anyOf": [ { - "$ref": "#/definitions/externals" + "$ref": "#/definitions/Externals" } ] }, @@ -1198,7 +1839,7 @@ "description": "Options affecting the normal modules (`NormalModuleFactory`).", "anyOf": [ { - "$ref": "#/definitions/module" + "$ref": "#/definitions/ModuleOptions" } ] }, @@ -1213,399 +1854,27 @@ "enum": [false] }, { - "type": "object", - "additionalProperties": { - "description": "Include a polyfill for the node.js module", - "enum": [false, true, "mock", "empty"] - }, - "properties": { - "Buffer": { - "description": "Include a polyfill for the 'Buffer' variable", - "enum": [false, true, "mock"] - }, - "__dirname": { - "description": "Include a polyfill for the '__dirname' variable", - "enum": [false, true, "mock"] - }, - "__filename": { - "description": "Include a polyfill for the '__filename' variable", - "enum": [false, true, "mock"] - }, - "console": { - "description": "Include a polyfill for the 'console' variable", - "enum": [false, true, "mock"] - }, - "global": { - "description": "Include a polyfill for the 'global' variable", - "type": "boolean" - }, - "process": { - "description": "Include a polyfill for the 'process' variable", - "enum": [false, true, "mock"] - } - } + "$ref": "#/definitions/NodeOptions" } ] }, "optimization": { "description": "Enables/Disables integrated optimizations", - "type": "object", - "additionalProperties": false, - "properties": { - "checkWasmTypes": { - "description": "Check for incompatible wasm types when importing/exporting from/to ESM", - "type": "boolean" - }, - "chunkIds": { - "description": "Define the algorithm to choose chunk ids (named: readable ids for better debugging, size: numeric ids focused on minimal initial download size, total-size: numeric ids focused on minimal total download size, false: no algorithm used, as custom one can be provided via plugin)", - "enum": ["natural", "named", "size", "total-size", false] - }, - "concatenateModules": { - "description": "Concatenate modules when possible to generate less modules, more efficient code and enable more optimizations by the minimizer", - "type": "boolean" - }, - "flagIncludedChunks": { - "description": "Also flag chunks as loaded which contain a subset of the modules", - "type": "boolean" - }, - "hashedModuleIds": { - "description": "Use hashed module id instead module identifiers for better long term caching (deprecated, used moduleIds: hashed instead)", - "type": "boolean" - }, - "mangleWasmImports": { - "description": "Reduce size of WASM by changing imports to shorter strings.", - "type": "boolean" - }, - "mergeDuplicateChunks": { - "description": "Merge chunks which contain the same modules", - "type": "boolean" - }, - "minimize": { - "description": "Enable minimizing the output. Uses optimization.minimizer.", - "type": "boolean" - }, - "minimizer": { - "description": "Minimizer(s) to use for minimizing the output", - "type": "array", - "items": { - "description": "Plugin of type object or instanceof Function", - "anyOf": [ - { - "$ref": "#/definitions/common.pluginObject" - }, - { - "$ref": "#/definitions/common.pluginFunction" - } - ] - } - }, - "moduleIds": { - "description": "Define the algorithm to choose module ids (natural: numeric ids in order of usage, named: readable ids for better debugging, hashed: short hashes as ids for better long term caching, size: numeric ids focused on minimal initial download size, total-size: numeric ids focused on minimal total download size, false: no algorithm used, as custom one can be provided via plugin)", - "enum": ["natural", "named", "hashed", "size", "total-size", false] - }, - "namedChunks": { - "description": "Use readable chunk identifiers for better debugging (deprecated, used chunkIds: named instead)", - "type": "boolean" - }, - "namedModules": { - "description": "Use readable module identifiers for better debugging (deprecated, used moduleIds: named instead)", - "type": "boolean" - }, - "noEmitOnErrors": { - "description": "Avoid emitting assets when errors occur", - "type": "boolean" - }, - "nodeEnv": { - "description": "Set process.env.NODE_ENV to a specific value", - "anyOf": [ - { - "enum": [false] - }, - { - "type": "string" - } - ] - }, - "occurrenceOrder": { - "description": "Figure out a order of modules which results in the smallest initial bundle", - "type": "boolean" - }, - "portableRecords": { - "description": "Generate records with relative paths to be able to move the context folder", - "type": "boolean" - }, - "providedExports": { - "description": "Figure out which exports are provided by modules to generate more efficient code", - "type": "boolean" - }, - "removeAvailableModules": { - "description": "Removes modules from chunks when these modules are already included in all parents", - "type": "boolean" - }, - "removeEmptyChunks": { - "description": "Remove chunks which are empty", - "type": "boolean" - }, - "runtimeChunk": { - "description": "Create an additional chunk which contains only the webpack runtime and chunk hash maps", - "oneOf": [ - { - "type": "boolean" - }, - { - "enum": ["single", "multiple"] - }, - { - "type": "object", - "additionalProperties": false, - "properties": { - "name": { - "description": "The name or name factory for the runtime chunks", - "oneOf": [ - { - "type": "string" - }, - { - "instanceof": "Function" - } - ] - } - } - } - ] - }, - "sideEffects": { - "description": "Skip over modules which are flagged to contain no side effects when exports are not used", - "type": "boolean" - }, - "splitChunks": { - "description": "Optimize duplication and caching by splitting chunks by shared modules and cache group", - "oneOf": [ - { - "enum": [false] - }, - { - "type": "object", - "additionalProperties": false, - "properties": { - "automaticNameDelimiter": { - "description": "Sets the name delimiter for created chunks", - "type": "string", - "minLength": 1 - }, - "cacheGroups": { - "description": "Assign modules to a cache group (modules from different cache groups are tried to keep in separate chunks)", - "type": "object", - "additionalProperties": { - "description": "Configuration for a cache group", - "anyOf": [ - { - "enum": [false] - }, - { - "instanceof": "Function" - }, - { - "type": "string" - }, - { - "instanceof": "RegExp" - }, - { - "type": "object", - "additionalProperties": false, - "properties": { - "automaticNameDelimiter": { - "description": "Sets the name delimiter for created chunks", - "type": "string", - "minLength": 1 - }, - "automaticNamePrefix": { - "description": "Sets the name prefix for created chunks", - "type": "string" - }, - "chunks": { - "description": "Select chunks for determining cache group content (defaults to \"initial\", \"initial\" and \"all\" requires adding these chunks to the HTML)", - "oneOf": [ - { - "enum": ["initial", "async", "all"] - }, - { - "instanceof": "Function" - } - ] - }, - "enforce": { - "description": "Ignore minimum size, minimum chunks and maximum requests and always create chunks for this cache group", - "type": "boolean" - }, - "filename": { - "description": "Sets the template for the filename for created chunks (Only works for initial chunks)", - "type": "string", - "minLength": 1 - }, - "maxAsyncRequests": { - "description": "Maximum number of requests which are accepted for on-demand loading", - "type": "number", - "minimum": 1 - }, - "maxInitialRequests": { - "description": "Maximum number of initial chunks which are accepted for an entry point", - "type": "number", - "minimum": 1 - }, - "maxSize": { - "description": "Maximal size hint for the created chunks", - "type": "number", - "minimum": 0 - }, - "minChunks": { - "description": "Minimum number of times a module has to be duplicated until it's considered for splitting", - "type": "number", - "minimum": 1 - }, - "minSize": { - "description": "Minimal size for the created chunk", - "type": "number", - "minimum": 0 - }, - "name": { - "description": "Give chunks for this cache group a name (chunks with equal name are merged)", - "oneOf": [ - { - "type": "boolean" - }, - { - "instanceof": "Function" - }, - { - "type": "string" - } - ] - }, - "priority": { - "description": "Priority of this cache group", - "type": "number" - }, - "reuseExistingChunk": { - "description": "Try to reuse existing chunk (with name) when it has matching modules", - "type": "boolean" - }, - "test": { - "description": "Assign modules to a cache group", - "oneOf": [ - { - "instanceof": "Function" - }, - { - "type": "string" - }, - { - "instanceof": "RegExp" - } - ] - } - } - } - ] - } - }, - "chunks": { - "description": "Select chunks for determining shared modules (defaults to \"async\", \"initial\" and \"all\" requires adding these chunks to the HTML)", - "oneOf": [ - { - "enum": ["initial", "async", "all"] - }, - { - "instanceof": "Function" - } - ] - }, - "fallbackCacheGroup": { - "description": "Options for modules not selected by any other cache group", - "type": "object", - "additionalProperties": false, - "properties": { - "automaticNameDelimiter": { - "description": "Sets the name delimiter for created chunks", - "type": "string", - "minLength": 1 - }, - "maxSize": { - "description": "Maximal size hint for the created chunks", - "type": "number", - "minimum": 0 - }, - "minSize": { - "description": "Minimal size for the created chunk", - "type": "number", - "minimum": 0 - } - } - }, - "filename": { - "description": "Sets the template for the filename for created chunks (Only works for initial chunks)", - "type": "string", - "minLength": 1 - }, - "hidePathInfo": { - "description": "Prevents exposing path info when creating names for parts splitted by maxSize", - "type": "boolean" - }, - "maxAsyncRequests": { - "description": "Maximum number of requests which are accepted for on-demand loading", - "type": "number", - "minimum": 1 - }, - "maxInitialRequests": { - "description": "Maximum number of initial chunks which are accepted for an entry point", - "type": "number", - "minimum": 1 - }, - "maxSize": { - "description": "Maximal size hint for the created chunks", - "type": "number", - "minimum": 0 - }, - "minChunks": { - "description": "Minimum number of times a module has to be duplicated until it's considered for splitting", - "type": "number", - "minimum": 1 - }, - "minSize": { - "description": "Minimal size for the created chunks", - "type": "number", - "minimum": 0 - }, - "name": { - "description": "Give chunks created a name (chunks with equal name are merged)", - "oneOf": [ - { - "type": "boolean" - }, - { - "instanceof": "Function" - }, - { - "type": "string" - } - ] - } - } - } - ] - }, - "usedExports": { - "description": "Figure out which exports are used by modules to mangle export names, omit unused exports and generate more efficient code", - "type": "boolean" + "anyOf": [ + { + "$ref": "#/definitions/OptimizationOptions" } - } + ] }, "output": { "description": "Options affecting the output of the compilation. `output` options tell webpack how to write the compiled files to disk.", "anyOf": [ { - "$ref": "#/definitions/output" + "type": "string", + "absolutePath": true + }, + { + "$ref": "#/definitions/OutputOptions" } ] }, @@ -1621,26 +1890,7 @@ "enum": [false] }, { - "type": "object", - "additionalProperties": false, - "properties": { - "assetFilter": { - "description": "Filter function to select assets that are checked", - "instanceof": "Function" - }, - "hints": { - "description": "Sets the format of the hints: warnings, errors or nothing at all", - "enum": [false, "warning", "error"] - }, - "maxAssetSize": { - "description": "Filesize limit (in bytes) when exceeded, that webpack will provide performance hints", - "type": "number" - }, - "maxEntrypointSize": { - "description": "Total size of an entry point (in bytes)", - "type": "number" - } - } + "$ref": "#/definitions/PerformanceOptions" } ] }, @@ -1651,10 +1901,10 @@ "description": "Plugin of type object or instanceof Function", "anyOf": [ { - "$ref": "#/definitions/common.pluginObject" + "$ref": "#/definitions/WebpackPluginInstance" }, { - "$ref": "#/definitions/common.pluginFunction" + "$ref": "#/definitions/WebpackPluginFunction" } ] } @@ -1682,7 +1932,7 @@ "description": "Options for the resolver", "anyOf": [ { - "$ref": "#/definitions/resolve" + "$ref": "#/definitions/ResolveOptions" } ] }, @@ -1690,7 +1940,7 @@ "description": "Options for the resolver when resolving loaders", "anyOf": [ { - "$ref": "#/definitions/resolve" + "$ref": "#/definitions/ResolveOptions" } ] }, @@ -1702,232 +1952,7 @@ "description": "Used by the webpack CLI program to pass stats options.", "anyOf": [ { - "type": "object", - "additionalProperties": false, - "properties": { - "all": { - "description": "fallback value for stats options when an option is not defined (has precedence over local webpack defaults)", - "type": "boolean" - }, - "assets": { - "description": "add assets information", - "type": "boolean" - }, - "assetsSort": { - "description": "sort the assets by that field", - "type": "string" - }, - "builtAt": { - "description": "add built at time information", - "type": "boolean" - }, - "cached": { - "description": "add also information about cached (not built) modules", - "type": "boolean" - }, - "cachedAssets": { - "description": "Show cached assets (setting this to `false` only shows emitted files)", - "type": "boolean" - }, - "children": { - "description": "add children information", - "type": "boolean" - }, - "chunkGroups": { - "description": "Display all chunk groups with the corresponding bundles", - "type": "boolean" - }, - "chunkModules": { - "description": "add built modules information to chunk information", - "type": "boolean" - }, - "chunkOrigins": { - "description": "add the origins of chunks and chunk merging info", - "type": "boolean" - }, - "chunks": { - "description": "add chunk information", - "type": "boolean" - }, - "chunksSort": { - "description": "sort the chunks by that field", - "type": "string" - }, - "colors": { - "description": "Enables/Disables colorful output", - "oneOf": [ - { - "description": "`webpack --colors` equivalent", - "type": "boolean" - }, - { - "type": "object", - "additionalProperties": false, - "properties": { - "bold": { - "description": "Custom color for bold text", - "type": "string" - }, - "cyan": { - "description": "Custom color for cyan text", - "type": "string" - }, - "green": { - "description": "Custom color for green text", - "type": "string" - }, - "magenta": { - "description": "Custom color for magenta text", - "type": "string" - }, - "red": { - "description": "Custom color for red text", - "type": "string" - }, - "yellow": { - "description": "Custom color for yellow text", - "type": "string" - } - } - } - ] - }, - "context": { - "description": "context directory for request shortening", - "type": "string", - "absolutePath": true - }, - "depth": { - "description": "add module depth in module graph", - "type": "boolean" - }, - "entrypoints": { - "description": "Display the entry points with the corresponding bundles", - "type": "boolean" - }, - "env": { - "description": "add --env information", - "type": "boolean" - }, - "errorDetails": { - "description": "add details to errors (like resolving log)", - "type": "boolean" - }, - "errors": { - "description": "add errors", - "type": "boolean" - }, - "exclude": { - "description": "Please use excludeModules instead.", - "anyOf": [ - { - "$ref": "#/definitions/filter-types" - }, - { - "type": "boolean" - } - ] - }, - "excludeAssets": { - "description": "Suppress assets that match the specified filters. Filters can be Strings, RegExps or Functions", - "anyOf": [ - { - "$ref": "#/definitions/filter-types" - } - ] - }, - "excludeModules": { - "description": "Suppress modules that match the specified filters. Filters can be Strings, RegExps, Booleans or Functions", - "anyOf": [ - { - "$ref": "#/definitions/filter-types" - }, - { - "type": "boolean" - } - ] - }, - "hash": { - "description": "add the hash of the compilation", - "type": "boolean" - }, - "maxModules": { - "description": "Set the maximum number of modules to be shown", - "type": "number" - }, - "moduleAssets": { - "description": "add information about assets inside modules", - "type": "boolean" - }, - "moduleTrace": { - "description": "add dependencies and origin of warnings/errors", - "type": "boolean" - }, - "modules": { - "description": "add built modules information", - "type": "boolean" - }, - "modulesSort": { - "description": "sort the modules by that field", - "type": "string" - }, - "nestedModules": { - "description": "add information about modules nested in other modules (like with module concatenation)", - "type": "boolean" - }, - "optimizationBailout": { - "description": "show reasons why optimization bailed out for modules", - "type": "boolean" - }, - "outputPath": { - "description": "Add output path information", - "type": "boolean" - }, - "performance": { - "description": "add performance hint flags", - "type": "boolean" - }, - "providedExports": { - "description": "show exports provided by modules", - "type": "boolean" - }, - "publicPath": { - "description": "Add public path information", - "type": "boolean" - }, - "reasons": { - "description": "add information about the reasons why modules are included", - "type": "boolean" - }, - "source": { - "description": "add the source code of modules", - "type": "boolean" - }, - "timings": { - "description": "add timing information", - "type": "boolean" - }, - "usedExports": { - "description": "show exports used by modules", - "type": "boolean" - }, - "version": { - "description": "add webpack version information", - "type": "boolean" - }, - "warnings": { - "description": "add warnings", - "type": "boolean" - }, - "warningsFilter": { - "description": "Suppress warnings that match the specified filters. Filters can be Strings, RegExps or Functions", - "anyOf": [ - { - "$ref": "#/definitions/filter-types" - } - ] - } - } + "$ref": "#/definitions/StatsOptions" }, { "type": "boolean" From 49a271d9a87ee3c8ac4e4416cfc99ce50d45dd32 Mon Sep 17 00:00:00 2001 From: Tobias Koppers Date: Wed, 19 Sep 2018 10:46:37 +0200 Subject: [PATCH 14/29] fixup: output options --- declarations/WebpackOptions.d.ts | 2 +- schemas/WebpackOptions.json | 4 ---- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/declarations/WebpackOptions.d.ts b/declarations/WebpackOptions.d.ts index a1bf99f57..fdbe05629 100644 --- a/declarations/WebpackOptions.d.ts +++ b/declarations/WebpackOptions.d.ts @@ -263,7 +263,7 @@ export interface WebpackOptions { /** * Options affecting the output of the compilation. `output` options tell webpack how to write the compiled files to disk. */ - output?: string | OutputOptions; + output?: OutputOptions; /** * The number of parallel processed modules in the compilation. */ diff --git a/schemas/WebpackOptions.json b/schemas/WebpackOptions.json index 58b4d01a9..bc49191c3 100644 --- a/schemas/WebpackOptions.json +++ b/schemas/WebpackOptions.json @@ -1869,10 +1869,6 @@ "output": { "description": "Options affecting the output of the compilation. `output` options tell webpack how to write the compiled files to disk.", "anyOf": [ - { - "type": "string", - "absolutePath": true - }, { "$ref": "#/definitions/OutputOptions" } From b6e81cd00e8ec1eba8c0ff0808941fa338841d1a Mon Sep 17 00:00:00 2001 From: Tobias Koppers Date: Wed, 19 Sep 2018 12:59:48 +0200 Subject: [PATCH 15/29] improve schema --- declarations/WebpackOptions.d.ts | 204 ++++++++++++++----------------- schemas/WebpackOptions.json | 201 +++++++++++++++++++----------- 2 files changed, 216 insertions(+), 189 deletions(-) diff --git a/declarations/WebpackOptions.d.ts b/declarations/WebpackOptions.d.ts index fdbe05629..7ad48adb9 100644 --- a/declarations/WebpackOptions.d.ts +++ b/declarations/WebpackOptions.d.ts @@ -8,28 +8,47 @@ * This interface was referenced by `WebpackOptions`'s JSON-Schema * via the `definition` "Entry". */ -export type Entry = - | { - /** - * An entry point with name - */ - [k: string]: string | NonEmptyArrayOfUniqueStringValues; - } - | string - | NonEmptyArrayOfUniqueStringValues - | { - [k: string]: any; - }; +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); +/** + * This interface was referenced by `WebpackOptions`'s JSON-Schema + * via the `definition` "EntryStatic". + */ +export type EntryStatic = EntryObject | EntryItem; /** * This interface was referenced by `WebpackOptions`'s JSON-Schema * via the `definition` "NonEmptyArrayOfUniqueStringValues". */ export type NonEmptyArrayOfUniqueStringValues = string[]; +/** + * This interface was referenced by `WebpackOptions`'s JSON-Schema + * via the `definition` "EntryItem". + */ +export type EntryItem = string | NonEmptyArrayOfUniqueStringValues; /** * This interface was referenced by `WebpackOptions`'s JSON-Schema * via the `definition` "Externals". */ -export type Externals = ExternalItem | ExternalItem[]; +export type Externals = + | (( + context: string, + request: string, + callback: (err?: Error, result?: string) => void + ) => void) + | ExternalItem + | ( + | (( + context: string, + request: string, + callback: (err?: Error, result?: string) => void + ) => void) + | ExternalItem)[]; /** * This interface was referenced by `WebpackOptions`'s JSON-Schema * via the `definition` "ExternalItem". @@ -72,7 +91,7 @@ export type RuleSetCondition = [k: string]: any; } | string - | RuleSetConditions + | Function | { /** * Logical AND @@ -113,21 +132,14 @@ export type RuleSetLoader = string; * This interface was referenced by `WebpackOptions`'s JSON-Schema * via the `definition` "RuleSetUse". */ -export type RuleSetUse = - | RuleSetUseItem - | { - [k: string]: any; - } - | RuleSetUseItem[]; +export type RuleSetUse = RuleSetUseItem | Function | RuleSetUseItem[]; /** * This interface was referenced by `WebpackOptions`'s JSON-Schema * via the `definition` "RuleSetUseItem". */ export type RuleSetUseItem = | RuleSetLoader - | { - [k: string]: any; - } + | Function | { /** * Unique loader identifier @@ -187,7 +199,8 @@ export type FilterItemTypes = | { [k: string]: any; } - | string; + | string + | Function; export interface WebpackOptions { /** @@ -325,9 +338,7 @@ export interface WebpackOptions { | "node-webkit" | "electron-main" | "electron-renderer") - | { - [k: string]: any; - }; + | ((compiler: import("../lib/Compiler")) => void); /** * Enter watch mode, which rebuilds on file change. */ @@ -356,6 +367,18 @@ export interface WebpackOptions { stdin?: boolean; }; } +/** + * Multiple entry bundles are created. The key is the chunk name. The value can be a string or an array. + * + * This interface was referenced by `WebpackOptions`'s JSON-Schema + * via the `definition` "EntryObject". + */ +export interface EntryObject { + /** + * An entry point with name + */ + [k: string]: string | NonEmptyArrayOfUniqueStringValues; +} /** * This interface was referenced by `WebpackOptions`'s JSON-Schema * via the `definition` "ModuleOptions". @@ -395,6 +418,7 @@ export interface ModuleOptions { | { [k: string]: any; } + | Function | string[] | string; /** @@ -432,11 +456,7 @@ export interface ModuleOptions { /** * Cache the resolving of module requests */ - unsafeCache?: - | boolean - | { - [k: string]: any; - }; + unsafeCache?: boolean | Function; /** * Enable warnings for partial dynamic dependencies */ @@ -587,9 +607,7 @@ export interface ResolveOptions { /** * Predicate function to decide which requests should be cached */ - cachePredicate?: { - [k: string]: any; - }; + cachePredicate?: Function; /** * Include the context information in the cache identifier when caching */ @@ -803,11 +821,7 @@ export interface OptimizationOptions { /** * The name or name factory for the runtime chunks */ - name?: - | string - | { - [k: string]: any; - }; + name?: string | Function; }; /** * Skip over modules which are flagged to contain no side effects when exports are not used @@ -840,10 +854,11 @@ export interface OptimizationSplitChunksOptions { */ [k: string]: | false + | Function + | string | { [k: string]: any; } - | string | { /** * Sets the name delimiter for created chunks @@ -856,11 +871,7 @@ export interface OptimizationSplitChunksOptions { /** * Select chunks for determining cache group content (defaults to "initial", "initial" and "all" requires adding these chunks to the HTML) */ - chunks?: - | ("initial" | "async" | "all") - | { - [k: string]: any; - }; + chunks?: ("initial" | "async" | "all") | Function; /** * Ignore minimum size, minimum chunks and maximum requests and always create chunks for this cache group */ @@ -892,12 +903,7 @@ export interface OptimizationSplitChunksOptions { /** * Give chunks for this cache group a name (chunks with equal name are merged) */ - name?: - | boolean - | { - [k: string]: any; - } - | string; + name?: boolean | Function | string; /** * Priority of this cache group */ @@ -910,20 +916,17 @@ export interface OptimizationSplitChunksOptions { * Assign modules to a cache group */ test?: + | Function + | string | { [k: string]: any; - } - | string; + }; }; }; /** * Select chunks for determining shared modules (defaults to "async", "initial" and "all" requires adding these chunks to the HTML) */ - chunks?: - | ("initial" | "async" | "all") - | { - [k: string]: any; - }; + chunks?: ("initial" | "async" | "all") | Function; /** * Options for modules not selected by any other cache group */ @@ -972,12 +975,7 @@ export interface OptimizationSplitChunksOptions { /** * Give chunks created a name (chunks with equal name are merged) */ - name?: - | boolean - | { - [k: string]: any; - } - | string; + name?: boolean | Function | string; } /** * This interface was referenced by `WebpackOptions`'s JSON-Schema @@ -1026,11 +1024,7 @@ export interface OutputOptions { /** * Similar to `output.devtoolModuleFilenameTemplate`, but used in the case of duplicate module identifiers. */ - devtoolFallbackModuleFilenameTemplate?: - | string - | { - [k: string]: any; - }; + devtoolFallbackModuleFilenameTemplate?: string | Function; /** * Enable line to line mapped mode for all/specified modules. Line to line mapped mode uses a simple SourceMap where each line of the generated source is mapped to the same line of the original source. It’s a performance optimization. Only use it if your performance need to be better and you are sure that input lines match which generated lines. */ @@ -1042,11 +1036,7 @@ export interface OutputOptions { /** * Filename template string of function for the sources array in a generated SourceMap. */ - devtoolModuleFilenameTemplate?: - | string - | { - [k: string]: any; - }; + devtoolModuleFilenameTemplate?: string | Function; /** * Module namespace to use when interpolating filename template string for the sources array in a generated SourceMap. Defaults to `output.library` if not set. It's useful for avoiding runtime collisions in sourcemaps from multiple webpack projects built as libraries. */ @@ -1054,11 +1044,7 @@ export interface OutputOptions { /** * Specifies the name of each output file on disk. You must **not** specify an absolute path here! The `output.path` option determines the location on disk the files are written to, filename is used solely for naming the individual files. */ - filename?: - | string - | { - [k: string]: any; - }; + filename?: string | Function; /** * An expression which is used to address the global object/scope in runtime code */ @@ -1082,11 +1068,7 @@ export interface OutputOptions { /** * The filename of the Hot Update Chunks. They are inside the output.path directory. */ - hotUpdateChunkFilename?: - | string - | { - [k: string]: any; - }; + hotUpdateChunkFilename?: string | Function; /** * The JSONP function used by webpack for async loading of hot update chunks. */ @@ -1094,11 +1076,7 @@ export interface OutputOptions { /** * The filename of the Hot Update Main File. It is inside the `output.path` directory. */ - hotUpdateMainFilename?: - | string - | { - [k: string]: any; - }; + hotUpdateMainFilename?: string | Function; /** * The JSONP function used by webpack for async loading of chunks. */ @@ -1110,23 +1088,7 @@ export interface OutputOptions { /** * If set, export the bundle as library. `output.library` is the name. */ - library?: - | string - | string[] - | { - /** - * Name of the exposed AMD library in the UMD - */ - amd?: string; - /** - * Name of the exposed commonjs export in the UMD - */ - commonjs?: string; - /** - * Name of the property exposed globally by a UMD library - */ - root?: string | ArrayOfStringValues; - }; + library?: string | string[] | LibraryCustomUmdObject; /** * Specify which export should be exposed as library */ @@ -1159,11 +1121,7 @@ export interface OutputOptions { /** * The `publicPath` specifies the public URL address of the output files when referenced in a browser. */ - publicPath?: - | string - | { - [k: string]: any; - }; + publicPath?: string | Function; /** * The filename of the SourceMaps for the JavaScript files. They are inside the `output.path` directory. */ @@ -1185,6 +1143,24 @@ export interface OutputOptions { */ webassemblyModuleFilename?: string; } +/** + * This interface was referenced by `WebpackOptions`'s JSON-Schema + * via the `definition` "LibraryCustomUmdObject". + */ +export interface LibraryCustomUmdObject { + /** + * Name of the exposed AMD library in the UMD + */ + amd?: string; + /** + * Name of the exposed commonjs export in the UMD + */ + commonjs?: string; + /** + * Name of the property exposed globally by a UMD library + */ + root?: string | ArrayOfStringValues; +} /** * This interface was referenced by `WebpackOptions`'s JSON-Schema * via the `definition` "PerformanceOptions". @@ -1193,9 +1169,7 @@ export interface PerformanceOptions { /** * Filter function to select assets that are checked */ - assetFilter?: { - [k: string]: any; - }; + assetFilter?: Function; /** * Sets the format of the hints: warnings, errors or nothing at all */ diff --git a/schemas/WebpackOptions.json b/schemas/WebpackOptions.json index bc49191c3..1c7c376c9 100644 --- a/schemas/WebpackOptions.json +++ b/schemas/WebpackOptions.json @@ -29,30 +29,22 @@ } }, "Entry": { - "oneOf": [ + "anyOf": [ { - "description": "Multiple entry bundles are created. The key is the chunk name. The value can be a string or an array.", - "type": "object", - "additionalProperties": { - "description": "An entry point with name", - "oneOf": [ - { - "description": "The string is resolved to a module which is loaded upon startup.", - "type": "string", - "minLength": 1 - }, - { - "description": "All modules are loaded upon startup. The last one is exported.", - "anyOf": [ - { - "$ref": "#/definitions/NonEmptyArrayOfUniqueStringValues" - } - ] - } - ] - }, - "minProperties": 1 + "$ref": "#/definitions/EntryDynamic" }, + { + "$ref": "#/definitions/EntryStatic" + } + ] + }, + "EntryDynamic": { + "description": "A Function returning an entry object, an entry string, an entry array or a promise to these things.", + "instanceof": "Function", + "tsType": "(() => EntryStatic | Promise)" + }, + "EntryItem": { + "oneOf": [ { "description": "An entry point without name. The string is resolved to a module which is loaded upon startup.", "type": "string", @@ -65,10 +57,39 @@ "$ref": "#/definitions/NonEmptyArrayOfUniqueStringValues" } ] + } + ] + }, + "EntryObject": { + "description": "Multiple entry bundles are created. The key is the chunk name. The value can be a string or an array.", + "type": "object", + "additionalProperties": { + "description": "An entry point with name", + "oneOf": [ + { + "description": "The string is resolved to a module which is loaded upon startup.", + "type": "string", + "minLength": 1 + }, + { + "description": "All modules are loaded upon startup. The last one is exported.", + "anyOf": [ + { + "$ref": "#/definitions/NonEmptyArrayOfUniqueStringValues" + } + ] + } + ] + }, + "minProperties": 1 + }, + "EntryStatic": { + "oneOf": [ + { + "$ref": "#/definitions/EntryObject" }, { - "description": "A Function returning an entry object, an entry string, an entry array or a promise to these things.", - "instanceof": "Function" + "$ref": "#/definitions/EntryItem" } ] }, @@ -99,10 +120,6 @@ ] } }, - { - "description": "`function(context, request, callback(err, result))` The function is called on each dependency.", - "instanceof": "Function" - }, { "description": "Every matched dependency becomes external.", "instanceof": "RegExp" @@ -111,6 +128,11 @@ }, "Externals": { "anyOf": [ + { + "description": "`function(context, request, callback(err, result))` The function is called on each dependency.", + "instanceof": "Function", + "tsType": "((context: string, request: string, callback: (err?: Error, result?: string) => void) => void)" + }, { "$ref": "#/definitions/ExternalItem" }, @@ -119,6 +141,11 @@ "items": { "description": "External configuration", "anyOf": [ + { + "description": "`function(context, request, callback(err, result))` The function is called on each dependency.", + "instanceof": "Function", + "tsType": "((context: string, request: string, callback: (err?: Error, result?: string) => void) => void)" + }, { "$ref": "#/definitions/ExternalItem" } @@ -136,7 +163,8 @@ "type": "string" }, { - "instanceof": "Function" + "instanceof": "Function", + "tsType": "Function" } ] }, @@ -158,6 +186,31 @@ } ] }, + "LibraryCustomUmdObject": { + "type": "object", + "additionalProperties": false, + "properties": { + "amd": { + "description": "Name of the exposed AMD library in the UMD", + "type": "string" + }, + "commonjs": { + "description": "Name of the exposed commonjs export in the UMD", + "type": "string" + }, + "root": { + "description": "Name of the property exposed globally by a UMD library", + "anyOf": [ + { + "type": "string" + }, + { + "$ref": "#/definitions/ArrayOfStringValues" + } + ] + } + } + }, "ModuleOptions": { "type": "object", "additionalProperties": false, @@ -208,7 +261,8 @@ "instanceof": "RegExp" }, { - "instanceof": "Function" + "instanceof": "Function", + "tsType": "Function" }, { "type": "array", @@ -271,7 +325,8 @@ "type": "boolean" }, { - "instanceof": "Function" + "instanceof": "Function", + "tsType": "Function" } ] }, @@ -451,7 +506,8 @@ "type": "string" }, { - "instanceof": "Function" + "instanceof": "Function", + "tsType": "Function" } ] } @@ -499,7 +555,8 @@ "enum": [false] }, { - "instanceof": "Function" + "instanceof": "Function", + "tsType": "Function" }, { "type": "string" @@ -527,7 +584,8 @@ "enum": ["initial", "async", "all"] }, { - "instanceof": "Function" + "instanceof": "Function", + "tsType": "Function" } ] }, @@ -572,7 +630,8 @@ "type": "boolean" }, { - "instanceof": "Function" + "instanceof": "Function", + "tsType": "Function" }, { "type": "string" @@ -591,7 +650,8 @@ "description": "Assign modules to a cache group", "oneOf": [ { - "instanceof": "Function" + "instanceof": "Function", + "tsType": "Function" }, { "type": "string" @@ -613,7 +673,8 @@ "enum": ["initial", "async", "all"] }, { - "instanceof": "Function" + "instanceof": "Function", + "tsType": "Function" } ] }, @@ -680,7 +741,8 @@ "type": "boolean" }, { - "instanceof": "Function" + "instanceof": "Function", + "tsType": "Function" }, { "type": "string" @@ -749,7 +811,8 @@ "type": "string" }, { - "instanceof": "Function" + "instanceof": "Function", + "tsType": "Function" } ] }, @@ -773,7 +836,8 @@ "type": "string" }, { - "instanceof": "Function" + "instanceof": "Function", + "tsType": "Function" } ] }, @@ -788,7 +852,8 @@ "type": "string" }, { - "instanceof": "Function" + "instanceof": "Function", + "tsType": "Function" } ], "absolutePath": false @@ -832,7 +897,8 @@ "type": "string" }, { - "instanceof": "Function" + "instanceof": "Function", + "tsType": "Function" } ], "absolutePath": false @@ -848,7 +914,8 @@ "type": "string" }, { - "instanceof": "Function" + "instanceof": "Function", + "tsType": "Function" } ], "absolutePath": false @@ -875,29 +942,7 @@ } }, { - "type": "object", - "additionalProperties": false, - "properties": { - "amd": { - "description": "Name of the exposed AMD library in the UMD", - "type": "string" - }, - "commonjs": { - "description": "Name of the exposed commonjs export in the UMD", - "type": "string" - }, - "root": { - "description": "Name of the property exposed globally by a UMD library", - "anyOf": [ - { - "type": "string" - }, - { - "$ref": "#/definitions/ArrayOfStringValues" - } - ] - } - } + "$ref": "#/definitions/LibraryCustomUmdObject" } ] }, @@ -946,7 +991,8 @@ "type": "string" }, { - "instanceof": "Function" + "instanceof": "Function", + "tsType": "Function" } ] }, @@ -980,7 +1026,8 @@ "properties": { "assetFilter": { "description": "Filter function to select assets that are checked", - "instanceof": "Function" + "instanceof": "Function", + "tsType": "Function" }, "hints": { "description": "Sets the format of the hints: warnings, errors or nothing at all", @@ -1044,7 +1091,8 @@ }, "cachePredicate": { "description": "Predicate function to decide which requests should be cached", - "instanceof": "Function" + "instanceof": "Function", + "tsType": "Function" }, "cacheWithContext": { "description": "Include the context information in the cache identifier when caching", @@ -1163,7 +1211,8 @@ "minLength": 1 }, { - "instanceof": "Function" + "instanceof": "Function", + "tsType": "Function" }, { "$ref": "#/definitions/RuleSetConditions" @@ -1446,7 +1495,8 @@ "$ref": "#/definitions/RuleSetUseItem" }, { - "instanceof": "Function" + "instanceof": "Function", + "tsType": "Function" }, { "type": "array", @@ -1467,7 +1517,8 @@ "$ref": "#/definitions/RuleSetLoader" }, { - "instanceof": "Function" + "instanceof": "Function", + "tsType": "Function" }, { "type": "object", @@ -1739,7 +1790,8 @@ "properties": { "apply": { "description": "The run point of the plugin, required method.", - "instanceof": "Function" + "instanceof": "Function", + "tsType": "Function" } }, "required": ["apply"], @@ -1980,7 +2032,8 @@ ] }, { - "instanceof": "Function" + "instanceof": "Function", + "tsType": "((compiler: import('../lib/Compiler')) => void)" } ] }, From d48975c948320d7983a928c4eeede93e8540c503 Mon Sep 17 00:00:00 2001 From: Tobias Koppers Date: Wed, 19 Sep 2018 13:05:22 +0200 Subject: [PATCH 16/29] use types from schema --- .eslintrc.js | 2 +- lib/AmdMainTemplatePlugin.js | 4 +-- lib/Compilation.js | 3 +- lib/Compiler.js | 18 ++++------ lib/DynamicEntryPlugin.js | 7 ++-- lib/EntryOptionPlugin.js | 3 +- lib/LibraryTemplatePlugin.js | 43 ++++++++++++++++++------ lib/UmdMainTemplatePlugin.js | 3 +- lib/WebpackOptionsApply.js | 20 +++++++++-- lib/web/JsonpExportMainTemplatePlugin.js | 3 ++ lib/webpack.js | 13 ++++++- 11 files changed, 85 insertions(+), 34 deletions(-) diff --git a/.eslintrc.js b/.eslintrc.js index 37b4be6f4..79cee6b11 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -23,7 +23,7 @@ module.exports = { yoda: "error", eqeqeq: "error", "global-require": "off", - "brace-style": "error", + "brace-style": "off", "eol-last": "error", "no-extra-bind": "warn", "no-process-exit": "warn", diff --git a/lib/AmdMainTemplatePlugin.js b/lib/AmdMainTemplatePlugin.js index ff715ec6c..2093edac6 100644 --- a/lib/AmdMainTemplatePlugin.js +++ b/lib/AmdMainTemplatePlugin.js @@ -12,10 +12,10 @@ const Template = require("./Template"); class AmdMainTemplatePlugin { /** - * @param {string} name the library name + * @param {string=} name the library name */ constructor(name) { - /** @type {string} */ + /** @type {string=} */ this.name = name; } diff --git a/lib/Compilation.js b/lib/Compilation.js index a420da696..ca14499c1 100644 --- a/lib/Compilation.js +++ b/lib/Compilation.js @@ -402,7 +402,8 @@ class Compilation extends Tapable { this.inputFileSystem = compiler.inputFileSystem; this.requestShortener = compiler.requestShortener; - const options = (this.options = compiler.options); + const options = compiler.options; + this.options = options; this.outputOptions = options && options.output; /** @type {boolean=} */ this.bail = options && options.bail; diff --git a/lib/Compiler.js b/lib/Compiler.js index bf7338fca..9b23e7269 100644 --- a/lib/Compiler.js +++ b/lib/Compiler.js @@ -27,6 +27,9 @@ const RequestShortener = require("./RequestShortener"); const { makePathsRelative } = require("./util/identifier"); const ConcurrentCompilationError = require("./ConcurrentCompilationError"); +/** @typedef {import("../declarations/WebpackOptions").Entry} Entry */ +/** @typedef {import("../declarations/WebpackOptions").WebpackOptions} WebpackOptions */ + /** * @typedef {Object} CompilationParams * @property {NormalModuleFactory} normalModuleFactory @@ -34,16 +37,6 @@ const ConcurrentCompilationError = require("./ConcurrentCompilationError"); * @property {Set} compilationDependencies */ -/** @typedef {string|string[]} EntryValues */ -/** @typedef {Record} EntryOptionValues */ - -/** - * @callback EntryOptionValuesFunction - * @returns {EntryOptionValues | EntryValues} the computed value - */ - -/** @typedef {EntryOptionValuesFunction | EntryOptionValues | EntryValues} EntryOptions */ - class Compiler extends Tapable { constructor(context) { super(); @@ -100,7 +93,7 @@ class Compiler extends Tapable { afterPlugins: new SyncHook(["compiler"]), /** @type {SyncHook} */ afterResolvers: new SyncHook(["compiler"]), - /** @type {SyncBailHook} */ + /** @type {SyncBailHook} */ entryOption: new SyncBailHook(["context", "entry"]) }; @@ -182,7 +175,8 @@ class Compiler extends Tapable { } }; - this.options = {}; + /** @type {WebpackOptions} */ + this.options = /** @type {WebpackOptions} */ ({}); this.context = context; diff --git a/lib/DynamicEntryPlugin.js b/lib/DynamicEntryPlugin.js index 99c1be2bf..be9b237b9 100644 --- a/lib/DynamicEntryPlugin.js +++ b/lib/DynamicEntryPlugin.js @@ -10,13 +10,14 @@ const MultiModuleFactory = require("./MultiModuleFactory"); const MultiEntryPlugin = require("./MultiEntryPlugin"); const SingleEntryPlugin = require("./SingleEntryPlugin"); +/** @typedef {import("../declarations/WebpackOptions").EntryDynamic} EntryDynamic */ +/** @typedef {import("../declarations/WebpackOptions").EntryStatic} EntryStatic */ /** @typedef {import("./Compiler")} Compiler */ -/** @typedef {import("./Compiler").EntryOptionValuesFunction} EntryOptionValuesFunction */ class DynamicEntryPlugin { /** * @param {string} context the context path - * @param {EntryOptionValuesFunction} entry the entry value + * @param {EntryDynamic} entry the entry value */ constructor(context, entry) { this.context = context; @@ -50,7 +51,7 @@ class DynamicEntryPlugin { /** * @param {string|string[]} entry entry value or array of entry values * @param {string} name name of entry - * @returns {Promise} returns the promise resolving the Compilation#addEntry function + * @returns {Promise} returns the promise resolving the Compilation#addEntry function */ const addEntry = (entry, name) => { const dep = DynamicEntryPlugin.createDependency(entry, name); diff --git a/lib/EntryOptionPlugin.js b/lib/EntryOptionPlugin.js index e992bc2c9..ddda157fe 100644 --- a/lib/EntryOptionPlugin.js +++ b/lib/EntryOptionPlugin.js @@ -8,11 +8,12 @@ const SingleEntryPlugin = require("./SingleEntryPlugin"); const MultiEntryPlugin = require("./MultiEntryPlugin"); const DynamicEntryPlugin = require("./DynamicEntryPlugin"); +/** @typedef {import("../declarations/WebpackOptions").EntryItem} EntryItem */ /** @typedef {import("./Compiler")} Compiler */ /** * @param {string} context context path - * @param {string | string[]} item entry array or single path + * @param {EntryItem} item entry array or single path * @param {string} name entry key name * @returns {SingleEntryPlugin | MultiEntryPlugin} returns either a single or multi entry plugin */ diff --git a/lib/LibraryTemplatePlugin.js b/lib/LibraryTemplatePlugin.js index c871994fa..fe4307916 100644 --- a/lib/LibraryTemplatePlugin.js +++ b/lib/LibraryTemplatePlugin.js @@ -6,6 +6,7 @@ const SetVarMainTemplatePlugin = require("./SetVarMainTemplatePlugin"); +/** @typedef {import("../declarations/WebpackOptions").LibraryCustomUmdObject} LibraryCustomUmdObject */ /** @typedef {import("./Compiler")} Compiler */ /** @@ -18,12 +19,17 @@ const accessorToObjectAccess = accessor => { /** * @param {string=} base the path prefix - * @param {string|string[]} accessor the accessor + * @param {string|string[]|LibraryCustomUmdObject} accessor the accessor + * @param {"amd" | "commonjs" | "root"} umdProperty property used when a custom umd object is provided * @param {string=} joinWith the element separator * @returns {string} the path */ -const accessorAccess = (base, accessor, joinWith = "; ") => { - const accessors = Array.isArray(accessor) ? accessor : [accessor]; +const accessorAccess = (base, accessor, umdProperty, joinWith = "; ") => { + const normalizedAccessor = + typeof accessor === "object" ? accessor[umdProperty] : accessor; + const accessors = Array.isArray(normalizedAccessor) + ? normalizedAccessor + : [normalizedAccessor]; return accessors .map((_, idx) => { const a = base @@ -40,7 +46,7 @@ const accessorAccess = (base, accessor, joinWith = "; ") => { class LibraryTemplatePlugin { /** - * @param {string} name name of library + * @param {string|string[]|LibraryCustomUmdObject} name name of library * @param {string} target type of library * @param {boolean} umdNamedDefine setting this to true will name the UMD module * @param {string|TODO} auxiliaryComment comment in the UMD wrapper @@ -68,14 +74,22 @@ class LibraryTemplatePlugin { } switch (this.target) { case "var": + if ( + !this.name || + (typeof this.name === "object" && !Array.isArray(this.name)) + ) { + throw new Error( + "library name must be set and not an UMD custom object for non-UMD target" + ); + } new SetVarMainTemplatePlugin( - `var ${accessorAccess(undefined, this.name)}`, + `var ${accessorAccess(undefined, this.name, "root")}`, false ).apply(compilation); break; case "assign": new SetVarMainTemplatePlugin( - accessorAccess(undefined, this.name), + accessorAccess(undefined, this.name, "root"), false ).apply(compilation); break; @@ -84,7 +98,7 @@ class LibraryTemplatePlugin { case "window": if (this.name) { new SetVarMainTemplatePlugin( - accessorAccess(this.target, this.name), + accessorAccess(this.target, this.name, "root"), false ).apply(compilation); } else { @@ -96,7 +110,8 @@ class LibraryTemplatePlugin { new SetVarMainTemplatePlugin( accessorAccess( compilation.runtimeTemplate.outputOptions.globalObject, - this.name + this.name, + "root" ), false ).apply(compilation); @@ -110,7 +125,7 @@ class LibraryTemplatePlugin { case "commonjs": if (this.name) { new SetVarMainTemplatePlugin( - accessorAccess("exports", this.name), + accessorAccess("exports", this.name, "commonjs"), false ).apply(compilation); } else { @@ -125,7 +140,13 @@ class LibraryTemplatePlugin { break; case "amd": { const AmdMainTemplatePlugin = require("./AmdMainTemplatePlugin"); - new AmdMainTemplatePlugin(this.name).apply(compilation); + if (this.name) { + if (typeof this.name !== "string") + throw new Error("library name must be a string for amd target"); + new AmdMainTemplatePlugin(this.name).apply(compilation); + } else { + new AmdMainTemplatePlugin().apply(compilation); + } break; } case "umd": @@ -140,6 +161,8 @@ class LibraryTemplatePlugin { } case "jsonp": { const JsonpExportMainTemplatePlugin = require("./web/JsonpExportMainTemplatePlugin"); + if (typeof this.name !== "string") + throw new Error("library name must be a string for jsonp target"); new JsonpExportMainTemplatePlugin(this.name).apply(compilation); break; } diff --git a/lib/UmdMainTemplatePlugin.js b/lib/UmdMainTemplatePlugin.js index 551ac76f8..ba5d24a2b 100644 --- a/lib/UmdMainTemplatePlugin.js +++ b/lib/UmdMainTemplatePlugin.js @@ -7,6 +7,7 @@ const { ConcatSource, OriginalSource } = require("webpack-sources"); const Template = require("./Template"); +/** @typedef {import("../declarations/WebpackOptions").LibraryCustomUmdObject} LibraryCustomUmdObject */ /** @typedef {import("./Compilation")} Compilation */ /** @@ -38,7 +39,7 @@ const accessorAccess = (base, accessor, joinWith = ", ") => { .join(joinWith); }; -/** @typedef {string | string[] | Record} UmdMainTemplatePluginName */ +/** @typedef {string | string[] | LibraryCustomUmdObject} UmdMainTemplatePluginName */ /** * @typedef {Object} AuxiliaryCommentObject diff --git a/lib/WebpackOptionsApply.js b/lib/WebpackOptionsApply.js index 2456a7bd7..6593d492a 100644 --- a/lib/WebpackOptionsApply.js +++ b/lib/WebpackOptionsApply.js @@ -63,11 +63,19 @@ const DefinePlugin = require("./DefinePlugin"); const SizeLimitsPlugin = require("./performance/SizeLimitsPlugin"); const WasmFinalizeExportsPlugin = require("./wasm/WasmFinalizeExportsPlugin"); +/** @typedef {import("../declarations/WebpackOptions").WebpackOptions} WebpackOptions */ +/** @typedef {import("./Compiler")} Compiler */ + class WebpackOptionsApply extends OptionsApply { constructor() { super(); } + /** + * @param {WebpackOptions} options options object + * @param {Compiler} compiler compiler object + * @returns {WebpackOptions} options object + */ process(options, compiler) { let ExternalsPlugin; compiler.outputPath = options.output.path; @@ -75,6 +83,8 @@ class WebpackOptionsApply extends OptionsApply { compiler.recordsOutputPath = options.recordsOutputPath || options.recordsPath; compiler.name = options.name; + // TODO webpack 5 refactor this to MultiCompiler.setDependencies() with a WeakMap + // @ts-ignore TODO compiler.dependencies = options.dependencies; if (typeof options.target === "string") { let JsonpTemplatePlugin; @@ -201,7 +211,9 @@ class WebpackOptionsApply extends OptionsApply { default: throw new Error("Unsupported target '" + options.target + "'."); } - } else if (options.target !== false) { + } + // @ts-ignore This is always true, which is good this way + else if (options.target !== false) { options.target(compiler); } else { throw new Error("Unsupported target '" + options.target + "'."); @@ -450,7 +462,11 @@ class WebpackOptionsApply extends OptionsApply { } if (options.optimization.minimize) { for (const minimizer of options.optimization.minimizer) { - minimizer.apply(compiler); + if (typeof minimizer === "function") { + minimizer.apply(compiler); + } else { + minimizer.apply(compiler); + } } } diff --git a/lib/web/JsonpExportMainTemplatePlugin.js b/lib/web/JsonpExportMainTemplatePlugin.js index c29740493..064b249e3 100644 --- a/lib/web/JsonpExportMainTemplatePlugin.js +++ b/lib/web/JsonpExportMainTemplatePlugin.js @@ -7,6 +7,9 @@ const { ConcatSource } = require("webpack-sources"); class JsonpExportMainTemplatePlugin { + /** + * @param {string} name jsonp function name + */ constructor(name) { this.name = name; } diff --git a/lib/webpack.js b/lib/webpack.js index 61357818e..58c96d15b 100644 --- a/lib/webpack.js +++ b/lib/webpack.js @@ -15,6 +15,13 @@ const webpackOptionsSchema = require("../schemas/WebpackOptions.json"); const RemovedPluginError = require("./RemovedPluginError"); const version = require("../package.json").version; +/** @typedef {import("../declarations/WebpackOptions").WebpackOptions} WebpackOptions */ + +/** + * @param {WebpackOptions} options options object + * @param {function(Error=, Stats=): void=} callback callback + * @returns {Compiler | MultiCompiler} the compiler object + */ const webpack = (options, callback) => { const webpackOptionsValidationErrors = validateSchema( webpackOptionsSchema, @@ -34,7 +41,11 @@ const webpack = (options, callback) => { new NodeEnvironmentPlugin().apply(compiler); if (options.plugins && Array.isArray(options.plugins)) { for (const plugin of options.plugins) { - plugin.apply(compiler); + if (typeof plugin === "function") { + plugin.apply(compiler); + } else { + plugin.apply(compiler); + } } } compiler.hooks.environment.call(); From 6023bb7a11de3db0c6ad542e9b75ee217b3a3a35 Mon Sep 17 00:00:00 2001 From: Tobias Koppers Date: Wed, 19 Sep 2018 23:45:43 +0200 Subject: [PATCH 17/29] fix Validation test --- test/Validation.test.js | 44 ++++++++++++++++++++--------------------- 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/test/Validation.test.js b/test/Validation.test.js index 6f29d6a9e..543a3cffa 100644 --- a/test/Validation.test.js +++ b/test/Validation.test.js @@ -22,17 +22,17 @@ describe("Validation", () => { }, message: [ " - configuration.entry should be one of these:", - " object { : non-empty string | [non-empty string] } | non-empty string | [non-empty string] | function", + " function | object { : non-empty string | [non-empty string] } | non-empty string | [non-empty string]", " -> The entry point(s) of the compilation.", " Details:", + " * configuration.entry should be an instance of function", + " -> A Function returning an entry object, an entry string, an entry array or a promise to these things.", " * configuration.entry should be an object.", " -> Multiple entry bundles are created. The key is the chunk name. The value can be a string or an array.", " * configuration.entry should not be empty.", " -> An entry point without name. The string is resolved to a module which is loaded upon startup.", " * configuration.entry should be an array:", - " [non-empty string]", - " * configuration.entry should be an instance of function", - " -> A Function returning an entry object, an entry string, an entry array or a promise to these things." + " [non-empty string]" ] }, { @@ -44,18 +44,18 @@ describe("Validation", () => { }, message: [ " - configuration.entry should be one of these:", - " object { : non-empty string | [non-empty string] } | non-empty string | [non-empty string] | function", + " function | object { : non-empty string | [non-empty string] } | non-empty string | [non-empty string]", " -> The entry point(s) of the compilation.", " Details:", + " * configuration.entry should be an instance of function", + " -> A Function returning an entry object, an entry string, an entry array or a promise to these things.", " * configuration.entry['bundle'] should be a string.", " -> The string is resolved to a module which is loaded upon startup.", " * configuration.entry['bundle'] should not be empty.", " * configuration.entry should be a string.", " -> An entry point without name. The string is resolved to a module which is loaded upon startup.", " * configuration.entry should be an array:", - " [non-empty string]", - " * configuration.entry should be an instance of function", - " -> A Function returning an entry object, an entry string, an entry array or a promise to these things." + " [non-empty string]" ] }, { @@ -89,16 +89,16 @@ describe("Validation", () => { }, message: [ " - configuration.entry should be one of these:", - " object { : non-empty string | [non-empty string] } | non-empty string | [non-empty string] | function", + " function | object { : non-empty string | [non-empty string] } | non-empty string | [non-empty string]", " -> The entry point(s) of the compilation.", " Details:", + " * configuration.entry should be an instance of function", + " -> A Function returning an entry object, an entry string, an entry array or a promise to these things.", " * configuration.entry should be an object.", " -> Multiple entry bundles are created. The key is the chunk name. The value can be a string or an array.", " * configuration.entry should be a string.", " -> An entry point without name. The string is resolved to a module which is loaded upon startup.", - " * configuration.entry should not contain the item 'abc' twice.", - " * configuration.entry should be an instance of function", - " -> A Function returning an entry object, an entry string, an entry array or a promise to these things." + " * configuration.entry should not contain the item 'abc' twice." ] }, { @@ -111,17 +111,17 @@ describe("Validation", () => { }, message: [ " - configuration.entry should be one of these:", - " object { : non-empty string | [non-empty string] } | non-empty string | [non-empty string] | function", + " function | object { : non-empty string | [non-empty string] } | non-empty string | [non-empty string]", " -> The entry point(s) of the compilation.", " Details:", + " * configuration.entry should be an instance of function", + " -> A Function returning an entry object, an entry string, an entry array or a promise to these things.", " * configuration.entry should be an object.", " -> Multiple entry bundles are created. The key is the chunk name. The value can be a string or an array.", " * configuration.entry should be a string.", " -> An entry point without name. The string is resolved to a module which is loaded upon startup.", " * configuration.entry[0] should be a string.", " -> A non-empty string", - " * configuration.entry should be an instance of function", - " -> A Function returning an entry object, an entry string, an entry array or a promise to these things.", " - configuration.output.filename should be one of these:", " string | function", " -> Specifies the name of each output file on disk. You must **not** specify an absolute path here! The `output.path` option determines the location on disk the files are written to, filename is used solely for naming the individual files.", @@ -145,17 +145,17 @@ describe("Validation", () => { ], message: [ " - configuration[0].entry should be one of these:", - " object { : non-empty string | [non-empty string] } | non-empty string | [non-empty string] | function", + " function | object { : non-empty string | [non-empty string] } | non-empty string | [non-empty string]", " -> The entry point(s) of the compilation.", " Details:", + " * configuration[0].entry should be an instance of function", + " -> A Function returning an entry object, an entry string, an entry array or a promise to these things.", " * configuration[0].entry should be an object.", " -> Multiple entry bundles are created. The key is the chunk name. The value can be a string or an array.", " * configuration[0].entry should be a string.", " -> An entry point without name. The string is resolved to a module which is loaded upon startup.", " * configuration[0].entry[0] should be a string.", " -> A non-empty string", - " * configuration[0].entry should be an instance of function", - " -> A Function returning an entry object, an entry string, an entry array or a promise to these things.", " - configuration[1].output.filename should be one of these:", " string | function", " -> Specifies the name of each output file on disk. You must **not** specify an absolute path here! The `output.path` option determines the location on disk the files are written to, filename is used solely for naming the individual files.", @@ -185,7 +185,7 @@ describe("Validation", () => { }, message: [ " - configuration.module.rules[0].oneOf[0] has an unknown property 'passer'. These properties are valid:", - " object { enforce?, exclude?, include?, issuer?, loader?, loaders?, oneOf?, options?, parser?, resolve?, sideEffects?, query?, type?, resource?, resourceQuery?, compiler?, rules?, test?, use? }", + " object { compiler?, enforce?, exclude?, include?, issuer?, loader?, loaders?, oneOf?, options?, parser?, query?, resolve?, resource?, resourceQuery?, rules?, sideEffects?, test?, type?, use? }", " -> A rule" ] }, @@ -197,9 +197,9 @@ describe("Validation", () => { }, message: [ " - configuration has an unknown property 'postcss'. These properties are valid:", - " object { mode?, amd?, bail?, cache?, context?, dependencies?, devServer?, devtool?, entry?, externals?, " + - "loader?, module?, name?, node?, output?, optimization?, parallelism?, performance?, plugins?, profile?, recordsInputPath?, " + - "recordsOutputPath?, recordsPath?, resolve?, resolveLoader?, serve?, stats?, target?, watch?, watchOptions? }", + " object { amd?, bail?, cache?, context?, dependencies?, devServer?, devtool?, entry?, externals?, loader?, mode?, module?, " + + "name?, node?, optimization?, output?, parallelism?, performance?, plugins?, profile?, recordsInputPath?, recordsOutputPath?, " + + "recordsPath?, resolve?, resolveLoader?, serve?, stats?, target?, watch?, watchOptions? }", " For typos: please correct them.", " For loader options: webpack >= v2.0.0 no longer allows custom properties in configuration.", " Loaders should be updated to allow passing options via loader options in module.rules.", From d064fbe79f8dd6e0c583812a0075dd7b114ef652 Mon Sep 17 00:00:00 2001 From: Tobias Koppers Date: Thu, 20 Sep 2018 10:12:48 +0200 Subject: [PATCH 18/29] add support for title in schema --- test/Schemas.lint.js | 3 ++- tooling/format-schemas.js | 2 ++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/test/Schemas.lint.js b/test/Schemas.lint.js index e0a8984f2..66503cd00 100644 --- a/test/Schemas.lint.js +++ b/test/Schemas.lint.js @@ -32,7 +32,8 @@ describe("Schemas", () => { const allowedProperties = [ "definitions", "$ref", - "id", + "$id", + "title", "items", "properties", "additionalProperties", diff --git a/tooling/format-schemas.js b/tooling/format-schemas.js index 59bfdcef3..ab71d3162 100644 --- a/tooling/format-schemas.js +++ b/tooling/format-schemas.js @@ -37,7 +37,9 @@ const PROPERTIES = [ "$ref", "definitions", + "$id", "id", + "title", "description", "type", From a91f7366dcfabd5f618cf057af3bd611484c86e3 Mon Sep 17 00:00:00 2001 From: Tobias Koppers Date: Thu, 20 Sep 2018 10:13:38 +0200 Subject: [PATCH 19/29] fix plugin schemas and give them names --- declarations/plugins/BannerPlugin.d.ts | 76 ++++++++++--------- declarations/plugins/DllPlugin.d.ts | 2 +- declarations/plugins/DllReferencePlugin.d.ts | 2 +- .../plugins/HashedModuleIdsPlugin.d.ts | 6 +- declarations/plugins/IgnorePlugin.d.ts | 10 +-- declarations/plugins/LoaderOptionsPlugin.d.ts | 2 +- .../plugins/SourceMapDevToolPlugin.d.ts | 18 ++--- declarations/plugins/WatchIgnorePlugin.d.ts | 6 +- .../plugins/debug/ProfilingPlugin.d.ts | 2 +- .../optimize/AggressiveSplittingPlugin.d.ts | 2 +- .../optimize/LimitChunkCountPlugin.d.ts | 2 +- .../plugins/optimize/MinChunkSizePlugin.d.ts | 2 +- .../OccurrenceOrderChunkIdsPlugin.d.ts | 2 +- .../OccurrenceOrderModuleIdsPlugin.d.ts | 2 +- schemas/plugins/BannerPlugin.json | 26 ++++--- schemas/plugins/DllPlugin.json | 1 + schemas/plugins/DllReferencePlugin.json | 1 + schemas/plugins/HashedModuleIdsPlugin.json | 6 ++ schemas/plugins/IgnorePlugin.json | 10 ++- schemas/plugins/LoaderOptionsPlugin.json | 1 + schemas/plugins/SourceMapDevToolPlugin.json | 7 +- schemas/plugins/WatchIgnorePlugin.json | 4 +- schemas/plugins/debug/ProfilingPlugin.json | 1 + .../optimize/AggressiveSplittingPlugin.json | 1 + .../optimize/LimitChunkCountPlugin.json | 1 + .../plugins/optimize/MinChunkSizePlugin.json | 1 + .../OccurrenceOrderChunkIdsPlugin.json | 1 + .../OccurrenceOrderModuleIdsPlugin.json | 1 + 28 files changed, 111 insertions(+), 85 deletions(-) diff --git a/declarations/plugins/BannerPlugin.d.ts b/declarations/plugins/BannerPlugin.d.ts index b511c8873..d27bd6230 100644 --- a/declarations/plugins/BannerPlugin.d.ts +++ b/declarations/plugins/BannerPlugin.d.ts @@ -4,44 +4,52 @@ * Run `yarn special-lint-fix` to update */ -export type BannerPlugin = - | { - /** - * Specifies the banner - */ - banner: - | { - [k: string]: any; - } - | string; - /** - * If true, the banner will only be added to the entry chunks - */ - entryOnly?: boolean; - /** - * Exclude all modules matching any of these conditions - */ - exclude?: Rules; - /** - * Include all modules matching any of these conditions - */ - include?: Rules; - /** - * If true, banner will not be wrapped in a comment - */ - raw?: boolean; - /** - * Include all modules that pass test assertion - */ - test?: Rules; - } - | { - [k: string]: any; - } +export type BannerPluginArgument = + | BannerPluginOptions + | BannerFunction | string; +/** + * The banner as function, it will be wrapped in a comment + */ +export type BannerFunction = ( + data: { + hash: string; + chunk: import("../../lib/Chunk"); + filename: string; + basename: string; + query: string; + } +) => string; export type Rules = Rule[] | Rule; export type Rule = | { [k: string]: any; } | string; + +export interface BannerPluginOptions { + /** + * Specifies the banner + */ + banner: BannerFunction | string; + /** + * If true, the banner will only be added to the entry chunks + */ + entryOnly?: boolean; + /** + * Exclude all modules matching any of these conditions + */ + exclude?: Rules; + /** + * Include all modules matching any of these conditions + */ + include?: Rules; + /** + * If true, banner will not be wrapped in a comment + */ + raw?: boolean; + /** + * Include all modules that pass test assertion + */ + test?: Rules; +} diff --git a/declarations/plugins/DllPlugin.d.ts b/declarations/plugins/DllPlugin.d.ts index 136cbe18d..f7264c2da 100644 --- a/declarations/plugins/DllPlugin.d.ts +++ b/declarations/plugins/DllPlugin.d.ts @@ -4,7 +4,7 @@ * Run `yarn special-lint-fix` to update */ -export interface DllPlugin { +export interface DllPluginOptions { /** * Context of requests in the manifest file (defaults to the webpack context) */ diff --git a/declarations/plugins/DllReferencePlugin.d.ts b/declarations/plugins/DllReferencePlugin.d.ts index 192d154f7..c9cde96a5 100644 --- a/declarations/plugins/DllReferencePlugin.d.ts +++ b/declarations/plugins/DllReferencePlugin.d.ts @@ -4,6 +4,6 @@ * Run `yarn special-lint-fix` to update */ -export type DllReferencePlugin = { +export type DllReferencePluginOptions = { [k: string]: any; }; diff --git a/declarations/plugins/HashedModuleIdsPlugin.d.ts b/declarations/plugins/HashedModuleIdsPlugin.d.ts index 8175918c5..571ab60a4 100644 --- a/declarations/plugins/HashedModuleIdsPlugin.d.ts +++ b/declarations/plugins/HashedModuleIdsPlugin.d.ts @@ -4,7 +4,11 @@ * Run `yarn special-lint-fix` to update */ -export interface HashedModuleIdsPlugin { +export interface HashedModuleIdsPluginOptions { + /** + * The context directory for creating names. + */ + context?: string; /** * The encoding to use when generating the hash, defaults to 'base64'. All encodings from Node.JS' hash.digest are supported. */ diff --git a/declarations/plugins/IgnorePlugin.d.ts b/declarations/plugins/IgnorePlugin.d.ts index 7b5685983..2aaf5061c 100644 --- a/declarations/plugins/IgnorePlugin.d.ts +++ b/declarations/plugins/IgnorePlugin.d.ts @@ -4,7 +4,7 @@ * Run `yarn special-lint-fix` to update */ -export type IgnorePlugin = +export type IgnorePluginOptions = | { /** * A RegExp to test the context (directory) against @@ -23,13 +23,9 @@ export type IgnorePlugin = /** * A filter function for context */ - checkContext?: { - [k: string]: any; - }; + checkContext?: ((context: string) => boolean); /** * A filter function for resource */ - checkResource?: { - [k: string]: any; - }; + checkResource?: ((resource: string) => boolean); }; diff --git a/declarations/plugins/LoaderOptionsPlugin.d.ts b/declarations/plugins/LoaderOptionsPlugin.d.ts index 61ab8d058..cb48ecc28 100644 --- a/declarations/plugins/LoaderOptionsPlugin.d.ts +++ b/declarations/plugins/LoaderOptionsPlugin.d.ts @@ -4,7 +4,7 @@ * Run `yarn special-lint-fix` to update */ -export interface LoaderOptionsPlugin { +export interface LoaderOptionsPluginOptions { /** * Whether loaders should be in debug mode or not. debug will be removed as of webpack 3 */ diff --git a/declarations/plugins/SourceMapDevToolPlugin.d.ts b/declarations/plugins/SourceMapDevToolPlugin.d.ts index c8957e1e5..cff6446ca 100644 --- a/declarations/plugins/SourceMapDevToolPlugin.d.ts +++ b/declarations/plugins/SourceMapDevToolPlugin.d.ts @@ -5,12 +5,12 @@ */ /** - * This interface was referenced by `SourceMapDevToolPlugin`'s JSON-Schema + * This interface was referenced by `SourceMapDevToolPluginOptions`'s JSON-Schema * via the `definition` "rules". */ export type Rules = Rule[] | Rule; /** - * This interface was referenced by `SourceMapDevToolPlugin`'s JSON-Schema + * This interface was referenced by `SourceMapDevToolPluginOptions`'s JSON-Schema * via the `definition` "rule". */ export type Rule = @@ -19,7 +19,7 @@ export type Rule = } | string; -export interface SourceMapDevToolPlugin { +export interface SourceMapDevToolPluginOptions { /** * Appends the given value to the original asset. Usually the #sourceMappingURL comment. [url] is replaced with a URL to the source map file. false disables the appending */ @@ -35,11 +35,7 @@ export interface SourceMapDevToolPlugin { /** * Generator string or function to create identifiers of modules for the 'sources' array in the SourceMap used only if 'moduleFilenameTemplate' would result in a conflict */ - fallbackModuleFilenameTemplate?: - | { - [k: string]: any; - } - | string; + fallbackModuleFilenameTemplate?: Function | string; /** * Path prefix to which the [file] placeholder is relative to */ @@ -78,11 +74,7 @@ export interface SourceMapDevToolPlugin { /** * Generator string or function to create identifiers of modules for the 'sources' array in the SourceMap */ - moduleFilenameTemplate?: - | { - [k: string]: any; - } - | string; + moduleFilenameTemplate?: Function | string; /** * Namespace prefix to allow multiple webpack roots in the devtools */ diff --git a/declarations/plugins/WatchIgnorePlugin.d.ts b/declarations/plugins/WatchIgnorePlugin.d.ts index 540269afd..05c857503 100644 --- a/declarations/plugins/WatchIgnorePlugin.d.ts +++ b/declarations/plugins/WatchIgnorePlugin.d.ts @@ -7,8 +7,4 @@ /** * A list of RegExps or absolute paths to directories or files that should be ignored */ -export type WatchIgnorePlugin = ( - | string - | { - [k: string]: any; - })[]; +export type WatchIgnorePluginOptions = (string | RegExp)[]; diff --git a/declarations/plugins/debug/ProfilingPlugin.d.ts b/declarations/plugins/debug/ProfilingPlugin.d.ts index d24395557..d3cd664ad 100644 --- a/declarations/plugins/debug/ProfilingPlugin.d.ts +++ b/declarations/plugins/debug/ProfilingPlugin.d.ts @@ -4,7 +4,7 @@ * Run `yarn special-lint-fix` to update */ -export interface ProfilingPlugin { +export interface ProfilingPluginOptions { /** * Path to the output file e.g. `profiling/events.json`. Defaults to `events.json`. */ diff --git a/declarations/plugins/optimize/AggressiveSplittingPlugin.d.ts b/declarations/plugins/optimize/AggressiveSplittingPlugin.d.ts index 4088b94d0..9f5360c49 100644 --- a/declarations/plugins/optimize/AggressiveSplittingPlugin.d.ts +++ b/declarations/plugins/optimize/AggressiveSplittingPlugin.d.ts @@ -4,7 +4,7 @@ * Run `yarn special-lint-fix` to update */ -export interface AggressiveSplittingPlugin { +export interface AggressiveSplittingPluginOptions { /** * Default: 0 */ diff --git a/declarations/plugins/optimize/LimitChunkCountPlugin.d.ts b/declarations/plugins/optimize/LimitChunkCountPlugin.d.ts index 38756335b..8cd59ed6e 100644 --- a/declarations/plugins/optimize/LimitChunkCountPlugin.d.ts +++ b/declarations/plugins/optimize/LimitChunkCountPlugin.d.ts @@ -4,7 +4,7 @@ * Run `yarn special-lint-fix` to update */ -export interface LimitChunkCountPlugin { +export interface LimitChunkCountPluginOptions { /** * Limit the maximum number of chunks using a value greater greater than or equal to 1 */ diff --git a/declarations/plugins/optimize/MinChunkSizePlugin.d.ts b/declarations/plugins/optimize/MinChunkSizePlugin.d.ts index 959b23ce5..61d20fd9c 100644 --- a/declarations/plugins/optimize/MinChunkSizePlugin.d.ts +++ b/declarations/plugins/optimize/MinChunkSizePlugin.d.ts @@ -4,7 +4,7 @@ * Run `yarn special-lint-fix` to update */ -export interface MinChunkSizePlugin { +export interface MinChunkSizePluginOptions { /** * Minimum number of characters */ diff --git a/declarations/plugins/optimize/OccurrenceOrderChunkIdsPlugin.d.ts b/declarations/plugins/optimize/OccurrenceOrderChunkIdsPlugin.d.ts index 3c3ad828d..0396f5547 100644 --- a/declarations/plugins/optimize/OccurrenceOrderChunkIdsPlugin.d.ts +++ b/declarations/plugins/optimize/OccurrenceOrderChunkIdsPlugin.d.ts @@ -4,7 +4,7 @@ * Run `yarn special-lint-fix` to update */ -export interface OccurrenceOrderChunkIdsPlugin { +export interface OccurrenceOrderChunkIdsPluginOptions { /** * Prioritise initial size over total size */ diff --git a/declarations/plugins/optimize/OccurrenceOrderModuleIdsPlugin.d.ts b/declarations/plugins/optimize/OccurrenceOrderModuleIdsPlugin.d.ts index 7c8f3b412..c29e0e956 100644 --- a/declarations/plugins/optimize/OccurrenceOrderModuleIdsPlugin.d.ts +++ b/declarations/plugins/optimize/OccurrenceOrderModuleIdsPlugin.d.ts @@ -4,7 +4,7 @@ * Run `yarn special-lint-fix` to update */ -export interface OccurrenceOrderModuleIdsPlugin { +export interface OccurrenceOrderModuleIdsPluginOptions { /** * Prioritise initial size over total size */ diff --git a/schemas/plugins/BannerPlugin.json b/schemas/plugins/BannerPlugin.json index 9c86c502e..555e29ed7 100644 --- a/schemas/plugins/BannerPlugin.json +++ b/schemas/plugins/BannerPlugin.json @@ -1,6 +1,11 @@ { "definitions": { - "rule": { + "BannerFunction": { + "description": "The banner as function, it will be wrapped in a comment", + "instanceof": "Function", + "tsType": "(data: { hash: string, chunk: import('../../lib/Chunk'), filename: string, basename: string, query: string}) => string" + }, + "Rule": { "oneOf": [ { "instanceof": "RegExp" @@ -11,7 +16,7 @@ } ] }, - "rules": { + "Rules": { "oneOf": [ { "type": "array", @@ -19,19 +24,21 @@ "description": "A rule condition", "anyOf": [ { - "$ref": "#/definitions/rule" + "$ref": "#/definitions/Rule" } ] } }, { - "$ref": "#/definitions/rule" + "$ref": "#/definitions/Rule" } ] } }, + "title": "BannerPluginArgument", "oneOf": [ { + "title": "BannerPluginOptions", "type": "object", "additionalProperties": false, "properties": { @@ -39,7 +46,7 @@ "description": "Specifies the banner", "anyOf": [ { - "instanceof": "Function" + "$ref": "#/definitions/BannerFunction" }, { "type": "string" @@ -54,7 +61,7 @@ "description": "Exclude all modules matching any of these conditions", "anyOf": [ { - "$ref": "#/definitions/rules" + "$ref": "#/definitions/Rules" } ] }, @@ -62,7 +69,7 @@ "description": "Include all modules matching any of these conditions", "anyOf": [ { - "$ref": "#/definitions/rules" + "$ref": "#/definitions/Rules" } ] }, @@ -74,7 +81,7 @@ "description": "Include all modules that pass test assertion", "anyOf": [ { - "$ref": "#/definitions/rules" + "$ref": "#/definitions/Rules" } ] } @@ -82,8 +89,7 @@ "required": ["banner"] }, { - "description": "The banner as function, it will be wrapped in a comment", - "instanceof": "Function" + "$ref": "#/definitions/BannerFunction" }, { "description": "The banner as string, it will be wrapped in a comment", diff --git a/schemas/plugins/DllPlugin.json b/schemas/plugins/DllPlugin.json index 18a0351bf..235b7b9ff 100644 --- a/schemas/plugins/DllPlugin.json +++ b/schemas/plugins/DllPlugin.json @@ -1,4 +1,5 @@ { + "title": "DllPluginOptions", "additionalProperties": false, "properties": { "context": { diff --git a/schemas/plugins/DllReferencePlugin.json b/schemas/plugins/DllReferencePlugin.json index 17587b186..87fa39e68 100644 --- a/schemas/plugins/DllReferencePlugin.json +++ b/schemas/plugins/DllReferencePlugin.json @@ -1,4 +1,5 @@ { + "title": "DllReferencePluginOptions", "additionalProperties": false, "properties": { "content": { diff --git a/schemas/plugins/HashedModuleIdsPlugin.json b/schemas/plugins/HashedModuleIdsPlugin.json index 5645bdd12..c4592ea65 100644 --- a/schemas/plugins/HashedModuleIdsPlugin.json +++ b/schemas/plugins/HashedModuleIdsPlugin.json @@ -1,7 +1,13 @@ { + "title": "HashedModuleIdsPluginOptions", "type": "object", "additionalProperties": false, "properties": { + "context": { + "description": "The context directory for creating names.", + "type": "string", + "absolutePath": true + }, "hashDigest": { "description": "The encoding to use when generating the hash, defaults to 'base64'. All encodings from Node.JS' hash.digest are supported.", "enum": ["hex", "latin1", "base64"] diff --git a/schemas/plugins/IgnorePlugin.json b/schemas/plugins/IgnorePlugin.json index e8319f1d1..924073868 100644 --- a/schemas/plugins/IgnorePlugin.json +++ b/schemas/plugins/IgnorePlugin.json @@ -1,7 +1,8 @@ { - "type": "object", + "title": "IgnorePluginOptions", "oneOf": [ { + "type": "object", "additionalProperties": false, "properties": { "contextRegExp": { @@ -15,15 +16,18 @@ } }, { + "type": "object", "additionalProperties": false, "properties": { "checkContext": { "description": "A filter function for context", - "instanceof": "Function" + "instanceof": "Function", + "tsType": "((context: string) => boolean)" }, "checkResource": { "description": "A filter function for resource", - "instanceof": "Function" + "instanceof": "Function", + "tsType": "((resource: string) => boolean)" } } } diff --git a/schemas/plugins/LoaderOptionsPlugin.json b/schemas/plugins/LoaderOptionsPlugin.json index 3a84e0347..67efca433 100644 --- a/schemas/plugins/LoaderOptionsPlugin.json +++ b/schemas/plugins/LoaderOptionsPlugin.json @@ -1,4 +1,5 @@ { + "title": "LoaderOptionsPluginOptions", "type": "object", "additionalProperties": true, "properties": { diff --git a/schemas/plugins/SourceMapDevToolPlugin.json b/schemas/plugins/SourceMapDevToolPlugin.json index 873e2aa98..49ca38cf4 100644 --- a/schemas/plugins/SourceMapDevToolPlugin.json +++ b/schemas/plugins/SourceMapDevToolPlugin.json @@ -30,6 +30,7 @@ ] } }, + "title": "SourceMapDevToolPluginOptions", "type": "object", "additionalProperties": false, "properties": { @@ -63,7 +64,8 @@ "oneOf": [ { "description": "Custom function generating the identifer", - "instanceof": "Function" + "instanceof": "Function", + "tsType": "Function" }, { "type": "string", @@ -145,7 +147,8 @@ "oneOf": [ { "description": "Custom function generating the identifer", - "instanceof": "Function" + "instanceof": "Function", + "tsType": "Function" }, { "type": "string", diff --git a/schemas/plugins/WatchIgnorePlugin.json b/schemas/plugins/WatchIgnorePlugin.json index a69c75529..b08d50ba6 100644 --- a/schemas/plugins/WatchIgnorePlugin.json +++ b/schemas/plugins/WatchIgnorePlugin.json @@ -1,4 +1,5 @@ { + "title": "WatchIgnorePluginOptions", "description": "A list of RegExps or absolute paths to directories or files that should be ignored", "type": "array", "items": { @@ -8,7 +9,8 @@ "type": "string" }, { - "instanceof": "RegExp" + "instanceof": "RegExp", + "tsType": "RegExp" } ] }, diff --git a/schemas/plugins/debug/ProfilingPlugin.json b/schemas/plugins/debug/ProfilingPlugin.json index 299762f58..e9a4bf18b 100644 --- a/schemas/plugins/debug/ProfilingPlugin.json +++ b/schemas/plugins/debug/ProfilingPlugin.json @@ -1,4 +1,5 @@ { + "title": "ProfilingPluginOptions", "type": "object", "additionalProperties": false, "properties": { diff --git a/schemas/plugins/optimize/AggressiveSplittingPlugin.json b/schemas/plugins/optimize/AggressiveSplittingPlugin.json index 31c439901..19bcdfd56 100644 --- a/schemas/plugins/optimize/AggressiveSplittingPlugin.json +++ b/schemas/plugins/optimize/AggressiveSplittingPlugin.json @@ -1,4 +1,5 @@ { + "title": "AggressiveSplittingPluginOptions", "type": "object", "additionalProperties": false, "properties": { diff --git a/schemas/plugins/optimize/LimitChunkCountPlugin.json b/schemas/plugins/optimize/LimitChunkCountPlugin.json index 5e2b67619..b2636eefd 100644 --- a/schemas/plugins/optimize/LimitChunkCountPlugin.json +++ b/schemas/plugins/optimize/LimitChunkCountPlugin.json @@ -1,4 +1,5 @@ { + "title": "LimitChunkCountPluginOptions", "type": "object", "additionalProperties": false, "properties": { diff --git a/schemas/plugins/optimize/MinChunkSizePlugin.json b/schemas/plugins/optimize/MinChunkSizePlugin.json index 0250ec5f3..03e17d65e 100644 --- a/schemas/plugins/optimize/MinChunkSizePlugin.json +++ b/schemas/plugins/optimize/MinChunkSizePlugin.json @@ -1,4 +1,5 @@ { + "title": "MinChunkSizePluginOptions", "type": "object", "additionalProperties": false, "properties": { diff --git a/schemas/plugins/optimize/OccurrenceOrderChunkIdsPlugin.json b/schemas/plugins/optimize/OccurrenceOrderChunkIdsPlugin.json index 98f12f132..12facf2f6 100644 --- a/schemas/plugins/optimize/OccurrenceOrderChunkIdsPlugin.json +++ b/schemas/plugins/optimize/OccurrenceOrderChunkIdsPlugin.json @@ -1,4 +1,5 @@ { + "title": "OccurrenceOrderChunkIdsPluginOptions", "type": "object", "additionalProperties": false, "properties": { diff --git a/schemas/plugins/optimize/OccurrenceOrderModuleIdsPlugin.json b/schemas/plugins/optimize/OccurrenceOrderModuleIdsPlugin.json index 98f12f132..d76ac14df 100644 --- a/schemas/plugins/optimize/OccurrenceOrderModuleIdsPlugin.json +++ b/schemas/plugins/optimize/OccurrenceOrderModuleIdsPlugin.json @@ -1,4 +1,5 @@ { + "title": "OccurrenceOrderModuleIdsPluginOptions", "type": "object", "additionalProperties": false, "properties": { From 1f6b92de3e5d8f2cd2e573de864258755e8f1efd Mon Sep 17 00:00:00 2001 From: Tobias Koppers Date: Thu, 20 Sep 2018 10:13:55 +0200 Subject: [PATCH 20/29] use declarations from schemas in plugins --- lib/BannerPlugin.js | 18 +++++++++++----- lib/DllPlugin.js | 5 +++++ lib/DllReferencePlugin.js | 5 +++++ lib/HashedModuleIdsPlugin.js | 14 +++++++++--- lib/IgnorePlugin.js | 24 +++++++++------------ lib/LoaderOptionsPlugin.js | 5 +++++ lib/SourceMapDevToolPlugin.js | 17 +++++++++++++-- lib/WatchIgnorePlugin.js | 5 +++++ lib/debug/ProfilingPlugin.js | 6 ++++++ lib/optimize/AggressiveSplittingPlugin.js | 11 ++++++++-- lib/optimize/LimitChunkCountPlugin.js | 11 ++++++++-- lib/optimize/MinChunkSizePlugin.js | 5 +++++ lib/optimize/OccurrenceChunkOrderPlugin.js | 5 +++++ lib/optimize/OccurrenceModuleOrderPlugin.js | 5 +++++ 14 files changed, 108 insertions(+), 28 deletions(-) diff --git a/lib/BannerPlugin.js b/lib/BannerPlugin.js index 1e9aa343c..80c66a5ac 100644 --- a/lib/BannerPlugin.js +++ b/lib/BannerPlugin.js @@ -12,6 +12,9 @@ const Template = require("./Template"); const validateOptions = require("schema-utils"); const schema = require("../schemas/plugins/BannerPlugin.json"); +/** @typedef {import("../declarations/plugins/BannerPlugin").BannerPluginArgument} BannerPluginArgument */ +/** @typedef {import("../declarations/plugins/BannerPlugin").BannerPluginOptions} BannerPluginOptions */ + const wrapComment = str => { if (!str.includes("\n")) { return Template.toComment(str); @@ -23,6 +26,9 @@ const wrapComment = str => { }; class BannerPlugin { + /** + * @param {BannerPluginArgument} options options object + */ constructor(options) { if (arguments.length > 1) { throw new Error( @@ -38,17 +44,19 @@ class BannerPlugin { }; } - this.options = options || {}; + /** @type {BannerPluginOptions} */ + this.options = options; - if (typeof options.banner === "function") { - const getBanner = this.options.banner; + const bannerOption = options.banner; + if (typeof bannerOption === "function") { + const getBanner = bannerOption; this.banner = this.options.raw ? getBanner : data => wrapComment(getBanner(data)); } else { const banner = this.options.raw - ? this.options.banner - : wrapComment(this.options.banner); + ? bannerOption + : wrapComment(bannerOption); this.banner = () => banner; } } diff --git a/lib/DllPlugin.js b/lib/DllPlugin.js index 554283371..884c21c58 100644 --- a/lib/DllPlugin.js +++ b/lib/DllPlugin.js @@ -11,7 +11,12 @@ const FlagInitialModulesAsUsedPlugin = require("./FlagInitialModulesAsUsedPlugin const validateOptions = require("schema-utils"); const schema = require("../schemas/plugins/DllPlugin.json"); +/** @typedef {import("../declarations/plugins/DllPlugin").DllPluginOptions} DllPluginOptions */ + class DllPlugin { + /** + * @param {DllPluginOptions} options options object + */ constructor(options) { validateOptions(schema, options, "Dll Plugin"); this.options = options; diff --git a/lib/DllReferencePlugin.js b/lib/DllReferencePlugin.js index 151862e5f..69f64ef0c 100644 --- a/lib/DllReferencePlugin.js +++ b/lib/DllReferencePlugin.js @@ -16,7 +16,12 @@ const WebpackError = require("./WebpackError"); const validateOptions = require("schema-utils"); const schema = require("../schemas/plugins/DllReferencePlugin.json"); +/** @typedef {import("../declarations/plugins/DllReferencePlugin").DllReferencePluginOptions} DllReferencePluginOptions */ + class DllReferencePlugin { + /** + * @param {DllReferencePluginOptions} options options object + */ constructor(options) { validateOptions(schema, options, "Dll Reference Plugin"); this.options = options; diff --git a/lib/HashedModuleIdsPlugin.js b/lib/HashedModuleIdsPlugin.js index aeb9f1d93..0c720c181 100644 --- a/lib/HashedModuleIdsPlugin.js +++ b/lib/HashedModuleIdsPlugin.js @@ -8,10 +8,18 @@ const createHash = require("./util/createHash"); const validateOptions = require("schema-utils"); const schema = require("../schemas/plugins/HashedModuleIdsPlugin.json"); -class HashedModuleIdsPlugin { - constructor(options) { - validateOptions(schema, options || {}, "Hashed Module Ids Plugin"); +/** @typedef {import("../declarations/plugins/HashedModuleIdsPlugin").HashedModuleIdsPluginOptions} HashedModuleIdsPluginOptions */ +class HashedModuleIdsPlugin { + /** + * @param {HashedModuleIdsPluginOptions=} options options object + */ + constructor(options) { + if (!options) options = {}; + + validateOptions(schema, options, "Hashed Module Ids Plugin"); + + /** @type {HashedModuleIdsPluginOptions} */ this.options = Object.assign( { context: null, diff --git a/lib/IgnorePlugin.js b/lib/IgnorePlugin.js index 6e803e8ff..7660aef0a 100644 --- a/lib/IgnorePlugin.js +++ b/lib/IgnorePlugin.js @@ -7,15 +7,12 @@ const validateOptions = require("schema-utils"); const schema = require("../schemas/plugins/IgnorePlugin.json"); +/** @typedef {import("../declarations/plugins/IgnorePlugin").IgnorePluginOptions} IgnorePluginOptions */ /** @typedef {import("./Compiler")} Compiler */ class IgnorePlugin { /** - * @param {object} options IgnorePlugin options - * @param {RegExp} options.resourceRegExp - A RegExp to test the request against - * @param {RegExp} options.contextRegExp - A RegExp to test the context (directory) against - * @param {function(string): boolean=} options.checkResource - A filter function for resource - * @param {function(string): boolean=} options.checkContext - A filter function for context + * @param {IgnorePluginOptions} options IgnorePlugin options */ constructor(options) { // TODO webpack 5 remove this compat-layer @@ -39,13 +36,13 @@ class IgnorePlugin { * and the resource given matches the regexp. */ checkResource(resource) { - if (this.options.checkResource) { + if ("checkResource" in this.options && this.options.checkResource) { return this.options.checkResource(resource); } - if (!this.options.resourceRegExp) { - return false; + if ("resourceRegExp" in this.options && this.options.resourceRegExp) { + return this.options.resourceRegExp.test(resource); } - return this.options.resourceRegExp.test(resource); + return false; } /** @@ -54,14 +51,13 @@ class IgnorePlugin { * or if context matches the given regexp. */ checkContext(context) { - if (this.options.checkContext) { + if ("checkContext" in this.options && this.options.checkContext) { return this.options.checkContext(context); } - - if (!this.options.contextRegExp) { - return true; + if ("contextRegExp" in this.options && this.options.contextRegExp) { + return this.options.contextRegExp.test(context); } - return this.options.contextRegExp.test(context); + return true; } /** diff --git a/lib/LoaderOptionsPlugin.js b/lib/LoaderOptionsPlugin.js index 5d13e2c06..651987b8d 100644 --- a/lib/LoaderOptionsPlugin.js +++ b/lib/LoaderOptionsPlugin.js @@ -9,7 +9,12 @@ const ModuleFilenameHelpers = require("./ModuleFilenameHelpers"); const validateOptions = require("schema-utils"); const schema = require("../schemas/plugins/LoaderOptionsPlugin.json"); +/** @typedef {import("../declarations/plugins/LoaderOptionsPlugin").LoaderOptionsPluginOptions} LoaderOptionsPluginOptions */ + class LoaderOptionsPlugin { + /** + * @param {LoaderOptionsPluginOptions} options options object + */ constructor(options) { validateOptions(schema, options || {}, "Loader Options Plugin"); diff --git a/lib/SourceMapDevToolPlugin.js b/lib/SourceMapDevToolPlugin.js index 315a9c22c..3c56d5210 100644 --- a/lib/SourceMapDevToolPlugin.js +++ b/lib/SourceMapDevToolPlugin.js @@ -13,6 +13,8 @@ const createHash = require("./util/createHash"); const validateOptions = require("schema-utils"); const schema = require("../schemas/plugins/SourceMapDevToolPlugin.json"); +/** @typedef {import("../declarations/plugins/SourceMapDevToolPlugin").SourceMapDevToolPluginOptions} SourceMapDevToolPluginOptions */ + const basename = name => { if (!name.includes("/")) return name; return name.substr(name.lastIndexOf("/") + 1); @@ -52,6 +54,9 @@ const getTaskForFile = (file, chunk, options, compilation) => { }; class SourceMapDevToolPlugin { + /** + * @param {SourceMapDevToolPluginOptions=} options options object + */ constructor(options) { if (arguments.length > 1) { throw new Error( @@ -59,10 +64,12 @@ class SourceMapDevToolPlugin { ); } - validateOptions(schema, options || {}, "SourceMap DevTool Plugin"); - if (!options) options = {}; + + validateOptions(schema, options, "SourceMap DevTool Plugin"); + this.sourceMapFilename = options.filename; + /** @type {string | false} */ this.sourceMappingURLComment = options.append === false ? false @@ -227,6 +234,7 @@ class SourceMapDevToolPlugin { sourceMap.sourceRoot = options.sourceRoot || ""; sourceMap.file = file; assetsCache.set(asset, { file, assets }); + /** @type {string | false} */ let currentSourceMappingURLComment = sourceMappingURLComment; if ( currentSourceMappingURLComment !== false && @@ -276,6 +284,11 @@ class SourceMapDevToolPlugin { ] = new RawSource(sourceMapString); chunk.files.push(sourceMapFile); } else { + if (currentSourceMappingURLComment === false) { + throw new Error( + "SourceMapDevToolPlugin: append can't be false when no filename is provided" + ); + } assets[file] = compilation.assets[file] = new ConcatSource( new RawSource(source), currentSourceMappingURLComment diff --git a/lib/WatchIgnorePlugin.js b/lib/WatchIgnorePlugin.js index 2f81ee839..ddff0da38 100644 --- a/lib/WatchIgnorePlugin.js +++ b/lib/WatchIgnorePlugin.js @@ -7,6 +7,8 @@ const validateOptions = require("schema-utils"); const schema = require("../schemas/plugins/WatchIgnorePlugin.json"); +/** @typedef {import("../declarations/plugins/WatchIgnorePlugin").WatchIgnorePluginOptions} WatchIgnorePluginOptions */ + class IgnoringWatchFileSystem { constructor(wfs, paths) { this.wfs = wfs; @@ -82,6 +84,9 @@ class IgnoringWatchFileSystem { } class WatchIgnorePlugin { + /** + * @param {WatchIgnorePluginOptions} paths list of paths + */ constructor(paths) { validateOptions(schema, paths, "Watch Ignore Plugin"); this.paths = paths; diff --git a/lib/debug/ProfilingPlugin.js b/lib/debug/ProfilingPlugin.js index d3e4dc4d6..1629baaa9 100644 --- a/lib/debug/ProfilingPlugin.js +++ b/lib/debug/ProfilingPlugin.js @@ -2,6 +2,9 @@ const fs = require("fs"); const { Tracer } = require("chrome-trace-event"); const validateOptions = require("schema-utils"); const schema = require("../../schemas/plugins/debug/ProfilingPlugin.json"); + +/** @typedef {import("../../declarations/plugins/debug/ProfilingPlugin").ProfilingPluginOptions} ProfilingPluginOptions */ + let inspector = undefined; try { @@ -145,6 +148,9 @@ const createTrace = outputPath => { const pluginName = "ProfilingPlugin"; class ProfilingPlugin { + /** + * @param {ProfilingPluginOptions=} opts options object + */ constructor(opts) { validateOptions(schema, opts || {}, "Profiling plugin"); opts = opts || {}; diff --git a/lib/optimize/AggressiveSplittingPlugin.js b/lib/optimize/AggressiveSplittingPlugin.js index 9aec3644b..384387853 100644 --- a/lib/optimize/AggressiveSplittingPlugin.js +++ b/lib/optimize/AggressiveSplittingPlugin.js @@ -9,6 +9,8 @@ const { intersect } = require("../util/SetHelpers"); const validateOptions = require("schema-utils"); const schema = require("../../schemas/plugins/optimize/AggressiveSplittingPlugin.json"); +/** @typedef {import("../../declarations/plugins/optimize/AggressiveSplittingPlugin").AggressiveSplittingPluginOptions} AggressiveSplittingPluginOptions */ + const moveModuleBetween = (oldChunk, newChunk) => { return module => { oldChunk.moveModule(module, newChunk); @@ -22,10 +24,15 @@ const isNotAEntryModule = entryModule => { }; class AggressiveSplittingPlugin { + /** + * @param {AggressiveSplittingPluginOptions=} options options object + */ constructor(options) { - validateOptions(schema, options || {}, "Aggressive Splitting Plugin"); + if (!options) options = {}; - this.options = options || {}; + validateOptions(schema, options, "Aggressive Splitting Plugin"); + + this.options = options; if (typeof this.options.minSize !== "number") { this.options.minSize = 30 * 1024; } diff --git a/lib/optimize/LimitChunkCountPlugin.js b/lib/optimize/LimitChunkCountPlugin.js index f38b942b1..a271191bf 100644 --- a/lib/optimize/LimitChunkCountPlugin.js +++ b/lib/optimize/LimitChunkCountPlugin.js @@ -7,10 +7,17 @@ const validateOptions = require("schema-utils"); const schema = require("../../schemas/plugins/optimize/LimitChunkCountPlugin.json"); +/** @typedef {import("../../declarations/plugins/optimize/LimitChunkCountPlugin").LimitChunkCountPluginOptions} LimitChunkCountPluginOptions */ + class LimitChunkCountPlugin { + /** + * @param {LimitChunkCountPluginOptions=} options options object + */ constructor(options) { - validateOptions(schema, options || {}, "Limit Chunk Count Plugin"); - this.options = options || {}; + if (!options) options = {}; + + validateOptions(schema, options, "Limit Chunk Count Plugin"); + this.options = options; } apply(compiler) { const options = this.options; diff --git a/lib/optimize/MinChunkSizePlugin.js b/lib/optimize/MinChunkSizePlugin.js index 0f3893910..144af278a 100644 --- a/lib/optimize/MinChunkSizePlugin.js +++ b/lib/optimize/MinChunkSizePlugin.js @@ -7,7 +7,12 @@ const validateOptions = require("schema-utils"); const schema = require("../../schemas/plugins/optimize/MinChunkSizePlugin.json"); +/** @typedef {import("../../declarations/plugins/optimize/MinChunkSizePlugin").MinChunkSizePluginOptions} MinChunkSizePluginOptions */ + class MinChunkSizePlugin { + /** + * @param {MinChunkSizePluginOptions} options options object + */ constructor(options) { validateOptions(schema, options, "Min Chunk Size Plugin"); this.options = options; diff --git a/lib/optimize/OccurrenceChunkOrderPlugin.js b/lib/optimize/OccurrenceChunkOrderPlugin.js index 4730654fe..4f7ec9a4f 100644 --- a/lib/optimize/OccurrenceChunkOrderPlugin.js +++ b/lib/optimize/OccurrenceChunkOrderPlugin.js @@ -7,7 +7,12 @@ const validateOptions = require("schema-utils"); const schema = require("../../schemas/plugins/optimize/OccurrenceOrderChunkIdsPlugin.json"); +/** @typedef {import("../../declarations/plugins/optimize/OccurrenceOrderChunkIdsPlugin").OccurrenceOrderChunkIdsPluginOptions} OccurrenceOrderChunkIdsPluginOptions */ + class OccurrenceOrderChunkIdsPlugin { + /** + * @param {OccurrenceOrderChunkIdsPluginOptions=} options options object + */ constructor(options = {}) { validateOptions(schema, options, "Occurrence Order Chunk Ids Plugin"); this.options = options; diff --git a/lib/optimize/OccurrenceModuleOrderPlugin.js b/lib/optimize/OccurrenceModuleOrderPlugin.js index 25561aea7..d17c8d92f 100644 --- a/lib/optimize/OccurrenceModuleOrderPlugin.js +++ b/lib/optimize/OccurrenceModuleOrderPlugin.js @@ -7,7 +7,12 @@ const validateOptions = require("schema-utils"); const schema = require("../../schemas/plugins/optimize/OccurrenceOrderModuleIdsPlugin.json"); +/** @typedef {import("../../declarations/plugins/optimize/OccurrenceOrderModuleIdsPlugin").OccurrenceOrderModuleIdsPluginOptions} OccurrenceOrderModuleIdsPluginOptions */ + class OccurrenceOrderModuleIdsPlugin { + /** + * @param {OccurrenceOrderModuleIdsPluginOptions=} options options object + */ constructor(options = {}) { validateOptions(schema, options, "Occurrence Order Module Ids Plugin"); this.options = options; From 44955b760066cdfe4a10ebb183e2d9ffddbb3df4 Mon Sep 17 00:00:00 2001 From: Tobias Koppers Date: Thu, 20 Sep 2018 18:00:11 +0200 Subject: [PATCH 21/29] emit exit code only in lint mode --- tooling/compile-to-definitions.js | 2 +- tooling/format-schemas.js | 2 +- tooling/inherit-types.js | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/tooling/compile-to-definitions.js b/tooling/compile-to-definitions.js index 994293b1e..a19aca0c5 100644 --- a/tooling/compile-to-definitions.js +++ b/tooling/compile-to-definitions.js @@ -65,8 +65,8 @@ const makeDefinitionsForSchema = absSchemaPath => { "/" )}.d.ts need to be updated` ); + process.exitCode = 1; } - process.exitCode = 1; } }, err => { diff --git a/tooling/format-schemas.js b/tooling/format-schemas.js index ab71d3162..803acd5a1 100644 --- a/tooling/format-schemas.js +++ b/tooling/format-schemas.js @@ -124,8 +124,8 @@ const formatSchema = schemaPath => { console.error( `schemas/${basename.replace(/\\/g, "/")} need to be updated` ); + process.exitCode = 1; } - process.exitCode = 1; } }); }; diff --git a/tooling/inherit-types.js b/tooling/inherit-types.js index 79bcdcdd0..03963b5a4 100644 --- a/tooling/inherit-types.js +++ b/tooling/inherit-types.js @@ -137,8 +137,8 @@ for (const sourceFile of program.getSourceFiles()) { ); } console.log(); + process.exitCode = 1; } - process.exitCode = 1; } } } From 8c31f2a7080fc7b07c4743ba6784e7f57f207c2f Mon Sep 17 00:00:00 2001 From: Tobias Koppers Date: Fri, 21 Sep 2018 08:39:15 +0200 Subject: [PATCH 22/29] fixes for RegExp in schema --- declarations/WebpackOptions.d.ts | 54 ++++--------------- declarations/plugins/BannerPlugin.d.ts | 6 +-- declarations/plugins/IgnorePlugin.d.ts | 8 +-- .../plugins/SourceMapDevToolPlugin.d.ts | 6 +-- package.json | 2 +- schemas/WebpackOptions.json | 30 +++++++---- schemas/plugins/BannerPlugin.json | 3 +- schemas/plugins/IgnorePlugin.json | 6 ++- schemas/plugins/SourceMapDevToolPlugin.json | 3 +- test/Schemas.lint.js | 10 +++- yarn.lock | 6 +-- 11 files changed, 55 insertions(+), 79 deletions(-) diff --git a/declarations/WebpackOptions.d.ts b/declarations/WebpackOptions.d.ts index 7ad48adb9..4e218ee27 100644 --- a/declarations/WebpackOptions.d.ts +++ b/declarations/WebpackOptions.d.ts @@ -67,9 +67,7 @@ export type ExternalItem = | ArrayOfStringValues | boolean; } - | { - [k: string]: any; - }; + | RegExp; /** * This interface was referenced by `WebpackOptions`'s JSON-Schema * via the `definition` "ArrayOfStringValues". @@ -87,11 +85,10 @@ export type RuleSetConditionOrConditions = RuleSetCondition | RuleSetConditions; * via the `definition` "RuleSetCondition". */ export type RuleSetCondition = - | { - [k: string]: any; - } + | RegExp | string | Function + | RuleSetConditions | { /** * Logical AND @@ -195,12 +192,7 @@ export type FilterTypes = FilterItemTypes | FilterItemTypes[]; * This interface was referenced by `WebpackOptions`'s JSON-Schema * via the `definition` "FilterItemTypes". */ -export type FilterItemTypes = - | { - [k: string]: any; - } - | string - | Function; +export type FilterItemTypes = RegExp | string | Function; export interface WebpackOptions { /** @@ -399,11 +391,7 @@ export interface ModuleOptions { /** * Sets the default regular expression for full dynamic dependencies */ - exprContextRegExp?: - | boolean - | { - [k: string]: any; - }; + exprContextRegExp?: boolean | RegExp; /** * Set the default request for full dynamic dependencies */ @@ -411,16 +399,7 @@ export interface ModuleOptions { /** * Don't parse files matching. It's matched against the full resolved request. */ - noParse?: - | { - [k: string]: any; - }[] - | { - [k: string]: any; - } - | Function - | string[] - | string; + noParse?: RegExp[] | RegExp | Function | string[] | string; /** * An array of rules applied for modules. */ @@ -444,11 +423,7 @@ export interface ModuleOptions { /** * Sets the regular expression when using the require function in a not statically analyse-able way */ - unknownContextRegExp?: - | boolean - | { - [k: string]: any; - }; + unknownContextRegExp?: boolean | RegExp; /** * Sets the request when using the require function in a not statically analyse-able way */ @@ -468,9 +443,7 @@ export interface ModuleOptions { /** * Set the inner regular expression for partial dynamic dependencies */ - wrappedContextRegExp?: { - [k: string]: any; - }; + wrappedContextRegExp?: RegExp; } /** * This interface was referenced by `WebpackOptions`'s JSON-Schema @@ -856,9 +829,7 @@ export interface OptimizationSplitChunksOptions { | false | Function | string - | { - [k: string]: any; - } + | RegExp | { /** * Sets the name delimiter for created chunks @@ -915,12 +886,7 @@ export interface OptimizationSplitChunksOptions { /** * Assign modules to a cache group */ - test?: - | Function - | string - | { - [k: string]: any; - }; + test?: Function | string | RegExp; }; }; /** diff --git a/declarations/plugins/BannerPlugin.d.ts b/declarations/plugins/BannerPlugin.d.ts index d27bd6230..4b3810596 100644 --- a/declarations/plugins/BannerPlugin.d.ts +++ b/declarations/plugins/BannerPlugin.d.ts @@ -21,11 +21,7 @@ export type BannerFunction = ( } ) => string; export type Rules = Rule[] | Rule; -export type Rule = - | { - [k: string]: any; - } - | string; +export type Rule = RegExp | string; export interface BannerPluginOptions { /** diff --git a/declarations/plugins/IgnorePlugin.d.ts b/declarations/plugins/IgnorePlugin.d.ts index 2aaf5061c..01ac08139 100644 --- a/declarations/plugins/IgnorePlugin.d.ts +++ b/declarations/plugins/IgnorePlugin.d.ts @@ -9,15 +9,11 @@ export type IgnorePluginOptions = /** * A RegExp to test the context (directory) against */ - contextRegExp?: { - [k: string]: any; - }; + contextRegExp?: RegExp; /** * A RegExp to test the request against */ - resourceRegExp?: { - [k: string]: any; - }; + resourceRegExp?: RegExp; } | { /** diff --git a/declarations/plugins/SourceMapDevToolPlugin.d.ts b/declarations/plugins/SourceMapDevToolPlugin.d.ts index cff6446ca..76421b508 100644 --- a/declarations/plugins/SourceMapDevToolPlugin.d.ts +++ b/declarations/plugins/SourceMapDevToolPlugin.d.ts @@ -13,11 +13,7 @@ export type Rules = Rule[] | Rule; * This interface was referenced by `SourceMapDevToolPluginOptions`'s JSON-Schema * via the `definition` "rule". */ -export type Rule = - | { - [k: string]: any; - } - | string; +export type Rule = RegExp | string; export interface SourceMapDevToolPluginOptions { /** diff --git a/package.json b/package.json index f91dab308..bf0d35c07 100644 --- a/package.json +++ b/package.json @@ -17,7 +17,7 @@ "enhanced-resolve": "^4.1.0", "eslint-scope": "^4.0.0", "json-parse-better-errors": "^1.0.2", - "json-schema-to-typescript": "^5.7.0", + "json-schema-to-typescript": "^6.0.1", "loader-runner": "^2.3.0", "loader-utils": "^1.1.0", "memory-fs": "~0.4.1", diff --git a/schemas/WebpackOptions.json b/schemas/WebpackOptions.json index 1c7c376c9..0aa38261f 100644 --- a/schemas/WebpackOptions.json +++ b/schemas/WebpackOptions.json @@ -122,7 +122,8 @@ }, { "description": "Every matched dependency becomes external.", - "instanceof": "RegExp" + "instanceof": "RegExp", + "tsType": "RegExp" } ] }, @@ -157,7 +158,8 @@ "FilterItemTypes": { "anyOf": [ { - "instanceof": "RegExp" + "instanceof": "RegExp", + "tsType": "RegExp" }, { "type": "string" @@ -238,7 +240,8 @@ "type": "boolean" }, { - "instanceof": "RegExp" + "instanceof": "RegExp", + "tsType": "RegExp" } ] }, @@ -253,12 +256,14 @@ "type": "array", "items": { "description": "A regular expression, when matched the module is not parsed", - "instanceof": "RegExp" + "instanceof": "RegExp", + "tsType": "RegExp" }, "minItems": 1 }, { - "instanceof": "RegExp" + "instanceof": "RegExp", + "tsType": "RegExp" }, { "instanceof": "Function", @@ -310,7 +315,8 @@ "type": "boolean" }, { - "instanceof": "RegExp" + "instanceof": "RegExp", + "tsType": "RegExp" } ] }, @@ -340,7 +346,8 @@ }, "wrappedContextRegExp": { "description": "Set the inner regular expression for partial dynamic dependencies", - "instanceof": "RegExp" + "instanceof": "RegExp", + "tsType": "RegExp" } } }, @@ -562,7 +569,8 @@ "type": "string" }, { - "instanceof": "RegExp" + "instanceof": "RegExp", + "tsType": "RegExp" }, { "type": "object", @@ -657,7 +665,8 @@ "type": "string" }, { - "instanceof": "RegExp" + "instanceof": "RegExp", + "tsType": "RegExp" } ] } @@ -1204,7 +1213,8 @@ "RuleSetCondition": { "anyOf": [ { - "instanceof": "RegExp" + "instanceof": "RegExp", + "tsType": "RegExp" }, { "type": "string", diff --git a/schemas/plugins/BannerPlugin.json b/schemas/plugins/BannerPlugin.json index 555e29ed7..af313b90d 100644 --- a/schemas/plugins/BannerPlugin.json +++ b/schemas/plugins/BannerPlugin.json @@ -8,7 +8,8 @@ "Rule": { "oneOf": [ { - "instanceof": "RegExp" + "instanceof": "RegExp", + "tsType": "RegExp" }, { "type": "string", diff --git a/schemas/plugins/IgnorePlugin.json b/schemas/plugins/IgnorePlugin.json index 924073868..83cd78ad8 100644 --- a/schemas/plugins/IgnorePlugin.json +++ b/schemas/plugins/IgnorePlugin.json @@ -7,11 +7,13 @@ "properties": { "contextRegExp": { "description": "A RegExp to test the context (directory) against", - "instanceof": "RegExp" + "instanceof": "RegExp", + "tsType": "RegExp" }, "resourceRegExp": { "description": "A RegExp to test the request against", - "instanceof": "RegExp" + "instanceof": "RegExp", + "tsType": "RegExp" } } }, diff --git a/schemas/plugins/SourceMapDevToolPlugin.json b/schemas/plugins/SourceMapDevToolPlugin.json index 49ca38cf4..dd9d31090 100644 --- a/schemas/plugins/SourceMapDevToolPlugin.json +++ b/schemas/plugins/SourceMapDevToolPlugin.json @@ -3,7 +3,8 @@ "rule": { "oneOf": [ { - "instanceof": "RegExp" + "instanceof": "RegExp", + "tsType": "RegExp" }, { "type": "string", diff --git a/test/Schemas.lint.js b/test/Schemas.lint.js index 66503cd00..30fc1b52f 100644 --- a/test/Schemas.lint.js +++ b/test/Schemas.lint.js @@ -76,7 +76,7 @@ describe("Schemas", () => { } }); - if (Object.keys(item).indexOf("$ref") >= 0) { + if ("$ref" in item) { it("should not have other properties next to $ref", () => { const otherProperties = Object.keys(item).filter( p => p !== "$ref" @@ -91,6 +91,14 @@ describe("Schemas", () => { }); } + if ("instanceof" in item) { + it("should have tsType specified when using instanceof", () => { + if (!("tsType" in item)) { + throw new Error("When using instanceof, tsType is required"); + } + }); + } + arrayProperties.forEach(prop => { if (prop in item) { describe(prop, () => { diff --git a/yarn.lock b/yarn.lock index aa7cddfd8..3c148e95e 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3811,9 +3811,9 @@ json-schema-ref-parser@^5.1.3: js-yaml "^3.12.0" ono "^4.0.6" -json-schema-to-typescript@^5.7.0: - version "5.7.0" - resolved "https://registry.yarnpkg.com/json-schema-to-typescript/-/json-schema-to-typescript-5.7.0.tgz#8a22356896abcf6148a4e99bacd93f0d8792befe" +json-schema-to-typescript@^6.0.1: + version "6.0.1" + resolved "https://registry.yarnpkg.com/json-schema-to-typescript/-/json-schema-to-typescript-6.0.1.tgz#31baac45a124b586d4021d12a5ea0ec07fddf294" dependencies: "@types/cli-color" "^0.3.29" "@types/json-schema" "^7.0.0" From c7681825f868cddff0a6aa840330354a588188ff Mon Sep 17 00:00:00 2001 From: Tobias Koppers Date: Fri, 21 Sep 2018 11:00:44 +0200 Subject: [PATCH 23/29] fix issues with absolutePath, allOf and anyOf make DllReferencePlugin schema more expressive typing fixes --- declarations.d.ts | 4 + declarations/WebpackOptions.d.ts | 71 ++++-- declarations/plugins/DllReferencePlugin.d.ts | 122 +++++++++- lib/DllReferencePlugin.js | 111 +++++---- schemas/WebpackOptions.json | 162 +++++++++---- schemas/plugins/DllPlugin.json | 1 + schemas/plugins/DllReferencePlugin.json | 235 ++++++++++++++----- test/Schemas.lint.js | 21 +- 8 files changed, 554 insertions(+), 173 deletions(-) diff --git a/declarations.d.ts b/declarations.d.ts index 719b6ebad..250601bc9 100644 --- a/declarations.d.ts +++ b/declarations.d.ts @@ -224,6 +224,10 @@ declare module "@webassemblyjs/ast" { // It's referenced from "ruleSet-conditions" in schemas/WebpackOptions.json interface RuleSetConditionsRecursive extends Array {} +interface RuleSetConditionsAbsoluteRecursive + extends Array< + import("./declarations/WebpackOptions").RuleSetConditionAbsolute + > {} /** * Global variable declarations diff --git a/declarations/WebpackOptions.d.ts b/declarations/WebpackOptions.d.ts index 4e218ee27..8baa91306 100644 --- a/declarations/WebpackOptions.d.ts +++ b/declarations/WebpackOptions.d.ts @@ -87,7 +87,7 @@ export type RuleSetConditionOrConditions = RuleSetCondition | RuleSetConditions; export type RuleSetCondition = | RegExp | string - | Function + | ((value: string) => boolean) | RuleSetConditions | { /** @@ -120,6 +120,55 @@ export type RuleSetCondition = * via the `definition` "RuleSetConditions". */ export type RuleSetConditions = RuleSetConditionsRecursive; +/** + * One or multiple rule conditions + * + * This interface was referenced by `WebpackOptions`'s JSON-Schema + * via the `definition` "RuleSetConditionOrConditionsAbsolute". + */ +export type RuleSetConditionOrConditionsAbsolute = + | RuleSetConditionAbsolute + | RuleSetConditionsAbsolute; +/** + * This interface was referenced by `WebpackOptions`'s JSON-Schema + * via the `definition` "RuleSetConditionAbsolute". + */ +export type RuleSetConditionAbsolute = + | RegExp + | string + | ((value: string) => boolean) + | RuleSetConditionsAbsolute + | { + /** + * Logical AND + */ + and?: RuleSetConditionsAbsolute; + /** + * Exclude all modules matching any of these conditions + */ + exclude?: RuleSetConditionOrConditionsAbsolute; + /** + * Exclude all modules matching not any of these conditions + */ + include?: RuleSetConditionOrConditionsAbsolute; + /** + * Logical NOT + */ + not?: RuleSetConditionsAbsolute; + /** + * Logical OR + */ + or?: RuleSetConditionsAbsolute; + /** + * Exclude all modules matching any of these conditions + */ + test?: RuleSetConditionOrConditionsAbsolute; + }; +/** + * This interface was referenced by `WebpackOptions`'s JSON-Schema + * via the `definition` "RuleSetConditionsAbsolute". + */ +export type RuleSetConditionsAbsolute = RuleSetConditionsAbsoluteRecursive; /** * This interface was referenced by `WebpackOptions`'s JSON-Schema * via the `definition` "RuleSetLoader". @@ -461,21 +510,15 @@ export interface RuleSetRule { /** * Shortcut for resource.exclude */ - exclude?: RuleSetConditionOrConditions & { - [k: string]: any; - }; + exclude?: RuleSetConditionOrConditionsAbsolute; /** * Shortcut for resource.include */ - include?: RuleSetConditionOrConditions & { - [k: string]: any; - }; + include?: RuleSetConditionOrConditionsAbsolute; /** * Match the issuer of the module (The module pointing to this module) */ - issuer?: RuleSetConditionOrConditions & { - [k: string]: any; - }; + issuer?: RuleSetConditionOrConditionsAbsolute; /** * Shortcut for use.loader */ @@ -509,9 +552,7 @@ export interface RuleSetRule { /** * Match the resource path of the module */ - resource?: RuleSetConditionOrConditions & { - [k: string]: any; - }; + resource?: RuleSetConditionOrConditionsAbsolute; /** * Match the resource query of the module */ @@ -527,9 +568,7 @@ export interface RuleSetRule { /** * Shortcut for resource.test */ - test?: RuleSetConditionOrConditions & { - [k: string]: any; - }; + test?: RuleSetConditionOrConditionsAbsolute; /** * Module type to use for the module */ diff --git a/declarations/plugins/DllReferencePlugin.d.ts b/declarations/plugins/DllReferencePlugin.d.ts index c9cde96a5..2354a7e63 100644 --- a/declarations/plugins/DllReferencePlugin.d.ts +++ b/declarations/plugins/DllReferencePlugin.d.ts @@ -4,6 +4,122 @@ * Run `yarn special-lint-fix` to update */ -export type DllReferencePluginOptions = { - [k: string]: any; -}; +export type DllReferencePluginOptions = + | { + /** + * (absolute path) context of requests in the manifest (or content property) + */ + context?: string; + /** + * Extensions used to resolve modules in the dll bundle (only used when using 'scope') + */ + extensions?: string[]; + /** + * An object containing content and name or a string to the absolute path of the JSON manifest to be loaded upon compilation + */ + manifest: DllReferencePluginOptionsManifest | string; + /** + * The name where the dll is exposed (external name, defaults to manifest.name) + */ + name?: string; + /** + * Prefix which is used for accessing the content of the dll + */ + scope?: string; + /** + * How the dll is exposed (libraryTarget, defaults to manifest.type) + */ + sourceType?: DllReferencePluginOptionsSourceType; + /** + * The way how the export of the dll bundle is used + */ + type?: "require" | "object"; + } + | { + /** + * The mappings from request to module info + */ + content: DllReferencePluginOptionsContent; + /** + * (absolute path) context of requests in the manifest (or content property) + */ + context?: string; + /** + * Extensions used to resolve modules in the dll bundle (only used when using 'scope') + */ + extensions?: string[]; + /** + * The name where the dll is exposed (external name) + */ + name: string; + /** + * Prefix which is used for accessing the content of the dll + */ + scope?: string; + /** + * How the dll is exposed (libraryTarget) + */ + sourceType?: DllReferencePluginOptionsSourceType; + /** + * The way how the export of the dll bundle is used + */ + type?: "require" | "object"; + }; +/** + * The type how the dll is exposed (external type) + */ +export type DllReferencePluginOptionsSourceType = + | "var" + | "assign" + | "this" + | "window" + | "global" + | "commonjs" + | "commonjs2" + | "commonjs-module" + | "amd" + | "umd" + | "umd2" + | "jsonp"; + +/** + * An object containing content, name and type + */ +export interface DllReferencePluginOptionsManifest { + /** + * The mappings from request to module info + */ + content: DllReferencePluginOptionsContent; + /** + * The name where the dll is exposed (external name) + */ + name?: string; + /** + * The type how the dll is exposed (external type) + */ + type?: DllReferencePluginOptionsSourceType; +} +/** + * The mappings from request to module info + */ +export interface DllReferencePluginOptionsContent { + /** + * Module info + */ + [k: string]: { + /** + * Meta information about the module + */ + buildMeta?: { + [k: string]: any; + }; + /** + * Information about the provided exports of the module + */ + exports?: true | string[]; + /** + * Module ID + */ + id: number | string; + }; +} diff --git a/lib/DllReferencePlugin.js b/lib/DllReferencePlugin.js index 69f64ef0c..62e26d893 100644 --- a/lib/DllReferencePlugin.js +++ b/lib/DllReferencePlugin.js @@ -17,6 +17,7 @@ const validateOptions = require("schema-utils"); const schema = require("../schemas/plugins/DllReferencePlugin.json"); /** @typedef {import("../declarations/plugins/DllReferencePlugin").DllReferencePluginOptions} DllReferencePluginOptions */ +/** @typedef {import("../declarations/plugins/DllReferencePlugin").DllReferencePluginOptionsManifest} DllReferencePluginOptionsManifest */ class DllReferencePlugin { /** @@ -45,55 +46,71 @@ class DllReferencePlugin { compiler.hooks.beforeCompile.tapAsync( "DllReferencePlugin", (params, callback) => { - const manifest = this.options.manifest; - if (typeof manifest === "string") { - params.compilationDependencies.add(manifest); - compiler.inputFileSystem.readFile(manifest, (err, result) => { - if (err) return callback(err); - // Catch errors parsing the manifest so that blank - // or malformed manifest files don't kill the process. - try { - params["dll reference " + manifest] = parseJson( - result.toString("utf-8") - ); - } catch (e) { - // Store the error in the params so that it can - // be added as a compilation error later on. - const manifestPath = makePathsRelative( - compiler.options.context, - manifest - ); - params[ - "dll reference parse error " + manifest - ] = new DllManifestError(manifestPath, e.message); - } - return callback(); - }); - } else { - return callback(); + if ("manifest" in this.options) { + const manifest = this.options.manifest; + if (typeof manifest === "string") { + params.compilationDependencies.add(manifest); + compiler.inputFileSystem.readFile(manifest, (err, result) => { + if (err) return callback(err); + // Catch errors parsing the manifest so that blank + // or malformed manifest files don't kill the process. + try { + params["dll reference " + manifest] = parseJson( + result.toString("utf-8") + ); + } catch (e) { + // Store the error in the params so that it can + // be added as a compilation error later on. + const manifestPath = makePathsRelative( + compiler.options.context, + manifest + ); + params[ + "dll reference parse error " + manifest + ] = new DllManifestError(manifestPath, e.message); + } + return callback(); + }); + return; + } } + return callback(); } ); compiler.hooks.compile.tap("DllReferencePlugin", params => { - let manifest = this.options.manifest; - if (typeof manifest === "string") { - // If there was an error parsing the manifest - // file, exit now because the error will be added - // as a compilation error in the "compilation" hook. - if (params["dll reference parse error " + manifest]) { - return; + let name = this.options.name; + let sourceType = this.options.sourceType; + let content = + "content" in this.options ? this.options.content : undefined; + if ("manifest" in this.options) { + let manifestParameter = this.options.manifest; + let manifest; + if (typeof manifestParameter === "string") { + // If there was an error parsing the manifest + // file, exit now because the error will be added + // as a compilation error in the "compilation" hook. + if (params["dll reference parse error " + manifestParameter]) { + return; + } + manifest = + /** @type {DllReferencePluginOptionsManifest} */ (params[ + "dll reference " + manifestParameter + ]); + } else { + manifest = manifestParameter; + } + if (manifest) { + if (!name) name = manifest.name; + if (!sourceType) sourceType = manifest.type; + if (!content) content = manifest.content; } - manifest = params["dll reference " + manifest]; } - const name = this.options.name || manifest.name; - const sourceType = - this.options.sourceType || (manifest && manifest.type) || "var"; const externals = {}; const source = "dll-reference " + name; externals[source] = name; const normalModuleFactory = params.normalModuleFactory; - new ExternalModuleFactoryPlugin(sourceType, externals).apply( + new ExternalModuleFactoryPlugin(sourceType || "var", externals).apply( normalModuleFactory ); new DelegatedModuleFactoryPlugin({ @@ -101,7 +118,7 @@ class DllReferencePlugin { type: this.options.type, scope: this.options.scope, context: this.options.context || compiler.options.context, - content: this.options.content || manifest.content, + content, extensions: this.options.extensions }).apply(normalModuleFactory); }); @@ -109,13 +126,15 @@ class DllReferencePlugin { compiler.hooks.compilation.tap( "DllReferencePlugin", (compilation, params) => { - let manifest = this.options.manifest; - if (typeof manifest === "string") { - // If there was an error parsing the manifest file, add the - // error as a compilation error to make the compilation fail. - let e = params["dll reference parse error " + manifest]; - if (e) { - compilation.errors.push(e); + if ("manifest" in this.options) { + let manifest = this.options.manifest; + if (typeof manifest === "string") { + // If there was an error parsing the manifest file, add the + // error as a compilation error to make the compilation fail. + let e = params["dll reference parse error " + manifest]; + if (e) { + compilation.errors.push(e); + } } } } diff --git a/schemas/WebpackOptions.json b/schemas/WebpackOptions.json index 0aa38261f..ad8d994c7 100644 --- a/schemas/WebpackOptions.json +++ b/schemas/WebpackOptions.json @@ -286,7 +286,7 @@ }, "rules": { "description": "An array of rules applied for modules.", - "allOf": [ + "anyOf": [ { "$ref": "#/definitions/RuleSetRules" } @@ -858,14 +858,14 @@ "description": "Specifies the name of each output file on disk. You must **not** specify an absolute path here! The `output.path` option determines the location on disk the files are written to, filename is used solely for naming the individual files.", "anyOf": [ { - "type": "string" + "type": "string", + "absolutePath": false }, { "instanceof": "Function", "tsType": "Function" } - ], - "absolutePath": false + ] }, "globalObject": { "description": "An expression which is used to address the global object/scope in runtime code", @@ -903,14 +903,14 @@ "description": "The filename of the Hot Update Chunks. They are inside the output.path directory.", "anyOf": [ { - "type": "string" + "type": "string", + "absolutePath": false }, { "instanceof": "Function", "tsType": "Function" } - ], - "absolutePath": false + ] }, "hotUpdateFunction": { "description": "The JSONP function used by webpack for async loading of hot update chunks.", @@ -920,14 +920,14 @@ "description": "The filename of the Hot Update Main File. It is inside the `output.path` directory.", "anyOf": [ { - "type": "string" + "type": "string", + "absolutePath": false }, { "instanceof": "Function", "tsType": "Function" } - ], - "absolutePath": false + ] }, "jsonpFunction": { "description": "The JSONP function used by webpack for async loading of chunks.", @@ -1222,7 +1222,7 @@ }, { "instanceof": "Function", - "tsType": "Function" + "tsType": "((value: string) => boolean)" }, { "$ref": "#/definitions/RuleSetConditions" @@ -1283,6 +1283,79 @@ } ] }, + "RuleSetConditionAbsolute": { + "anyOf": [ + { + "instanceof": "RegExp", + "tsType": "RegExp" + }, + { + "type": "string", + "absolutePath": true + }, + { + "instanceof": "Function", + "tsType": "((value: string) => boolean)" + }, + { + "$ref": "#/definitions/RuleSetConditionsAbsolute" + }, + { + "type": "object", + "additionalProperties": false, + "properties": { + "and": { + "description": "Logical AND", + "anyOf": [ + { + "$ref": "#/definitions/RuleSetConditionsAbsolute" + } + ] + }, + "exclude": { + "description": "Exclude all modules matching any of these conditions", + "anyOf": [ + { + "$ref": "#/definitions/RuleSetConditionOrConditionsAbsolute" + } + ] + }, + "include": { + "description": "Exclude all modules matching not any of these conditions", + "anyOf": [ + { + "$ref": "#/definitions/RuleSetConditionOrConditionsAbsolute" + } + ] + }, + "not": { + "description": "Logical NOT", + "anyOf": [ + { + "$ref": "#/definitions/RuleSetConditionsAbsolute" + } + ] + }, + "or": { + "description": "Logical OR", + "anyOf": [ + { + "$ref": "#/definitions/RuleSetConditionsAbsolute" + } + ] + }, + "test": { + "description": "Exclude all modules matching any of these conditions", + "anyOf": [ + { + "$ref": "#/definitions/RuleSetConditionOrConditionsAbsolute" + } + ] + } + } + } + ] + }, "RuleSetConditionOrConditions": { "description": "One or multiple rule conditions", "anyOf": [ @@ -1294,6 +1367,17 @@ } ] }, + "RuleSetConditionOrConditionsAbsolute": { + "description": "One or multiple rule conditions", + "anyOf": [ + { + "$ref": "#/definitions/RuleSetConditionAbsolute" + }, + { + "$ref": "#/definitions/RuleSetConditionsAbsolute" + } + ] + }, "RuleSetConditions": { "type": "array", "items": { @@ -1306,6 +1390,18 @@ }, "tsType": "RuleSetConditionsRecursive" }, + "RuleSetConditionsAbsolute": { + "type": "array", + "items": { + "description": "A rule condition", + "anyOf": [ + { + "$ref": "#/definitions/RuleSetConditionAbsolute" + } + ] + }, + "tsType": "RuleSetConditionsAbsoluteRecursive" + }, "RuleSetLoader": { "type": "string", "minLength": 1 @@ -1338,34 +1434,25 @@ }, "exclude": { "description": "Shortcut for resource.exclude", - "allOf": [ + "anyOf": [ { - "$ref": "#/definitions/RuleSetConditionOrConditions" - }, - { - "absolutePath": true + "$ref": "#/definitions/RuleSetConditionOrConditionsAbsolute" } ] }, "include": { "description": "Shortcut for resource.include", - "allOf": [ + "anyOf": [ { - "$ref": "#/definitions/RuleSetConditionOrConditions" - }, - { - "absolutePath": true + "$ref": "#/definitions/RuleSetConditionOrConditionsAbsolute" } ] }, "issuer": { "description": "Match the issuer of the module (The module pointing to this module)", - "allOf": [ + "anyOf": [ { - "$ref": "#/definitions/RuleSetConditionOrConditions" - }, - { - "absolutePath": true + "$ref": "#/definitions/RuleSetConditionOrConditionsAbsolute" } ] }, @@ -1428,12 +1515,9 @@ }, "resource": { "description": "Match the resource path of the module", - "allOf": [ + "anyOf": [ { - "$ref": "#/definitions/RuleSetConditionOrConditions" - }, - { - "absolutePath": true + "$ref": "#/definitions/RuleSetConditionOrConditionsAbsolute" } ] }, @@ -1459,12 +1543,9 @@ }, "test": { "description": "Shortcut for resource.test", - "allOf": [ + "anyOf": [ { - "$ref": "#/definitions/RuleSetConditionOrConditions" - }, - { - "absolutePath": true + "$ref": "#/definitions/RuleSetConditionOrConditionsAbsolute" } ] }, @@ -1796,15 +1877,6 @@ }, "WebpackPluginFunction": { "description": "Function acting as plugin", - "additionalProperties": true, - "properties": { - "apply": { - "description": "The run point of the plugin, required method.", - "instanceof": "Function", - "tsType": "Function" - } - }, - "required": ["apply"], "instanceof": "Function", "tsType": "(compiler: import('../lib/Compiler')) => void" }, diff --git a/schemas/plugins/DllPlugin.json b/schemas/plugins/DllPlugin.json index 235b7b9ff..8d9961e89 100644 --- a/schemas/plugins/DllPlugin.json +++ b/schemas/plugins/DllPlugin.json @@ -1,5 +1,6 @@ { "title": "DllPluginOptions", + "type": "object", "additionalProperties": false, "properties": { "context": { diff --git a/schemas/plugins/DllReferencePlugin.json b/schemas/plugins/DllReferencePlugin.json index 87fa39e68..a79255405 100644 --- a/schemas/plugins/DllReferencePlugin.json +++ b/schemas/plugins/DllReferencePlugin.json @@ -1,67 +1,83 @@ { - "title": "DllReferencePluginOptions", - "additionalProperties": false, - "properties": { - "content": { - "description": "The mappings from request to module id (defaults to manifest.content)", + "definitions": { + "DllReferencePluginOptionsContent": { + "description": "The mappings from request to module info", "type": "object", - "minLength": 1 - }, - "context": { - "description": "(absolute path) context of requests in the manifest (or content property)", - "type": "string", - "absolutePath": true - }, - "extensions": { - "description": "Extensions used to resolve modules in the dll bundle (only used when using 'scope')", - "type": "array", - "items": { - "description": "An extension", - "type": "string" - } - }, - "manifest": { - "description": "An object containing content and name or a string to the absolute path of the JSON manifest to be loaded upon compilation", - "oneOf": [ - { - "type": "object", - "additionalProperties": false, - "properties": { - "content": { - "description": "The mappings from request to module id", - "type": "object", - "minLength": 1 - }, - "name": { - "description": "The name where the dll is exposed (external name)", - "type": "string", - "minLength": 1 - }, - "type": { - "description": "The type how the dll is exposed (external type)", - "type": "string", - "minLength": 1 - } + "additionalProperties": { + "description": "Module info", + "type": "object", + "additionalProperties": false, + "properties": { + "buildMeta": { + "description": "Meta information about the module", + "type": "object" + }, + "exports": { + "description": "Information about the provided exports of the module", + "anyOf": [ + { + "description": "Exports unknown/dynamic", + "enum": [true] + }, + { + "description": "List of provided exports of the module", + "type": "array", + "items": { + "description": "Name of the export", + "type": "string", + "minLength": 1 + } + } + ] + }, + "id": { + "description": "Module ID", + "anyOf": [ + { + "type": "number" + }, + { + "type": "string", + "minLength": 1 + } + ] } }, - { + "required": ["id"] + }, + "minProperties": 1 + }, + "DllReferencePluginOptionsManifest": { + "description": "An object containing content, name and type", + "type": "object", + "additionalProperties": false, + "properties": { + "content": { + "description": "The mappings from request to module info", + "anyOf": [ + { + "$ref": "#/definitions/DllReferencePluginOptionsContent" + } + ] + }, + "name": { + "description": "The name where the dll is exposed (external name)", "type": "string", - "absolutePath": true + "minLength": 1 + }, + "type": { + "description": "The type how the dll is exposed (external type)", + "anyOf": [ + { + "$ref": "#/definitions/DllReferencePluginOptionsSourceType" + } + ] } - ] + }, + "required": ["content"] }, - "name": { - "description": "The name where the dll is exposed (external name, defaults to manifest.name)", - "type": "string", - "minLength": 1 - }, - "scope": { - "description": "Prefix which is used for accessing the content of the dll", - "type": "string", - "minLength": 1 - }, - "sourceType": { - "description": "How the dll is exposed (libraryTarget, defaults to manifest.type)", + "DllReferencePluginOptionsSourceType": { + "description": "The type how the dll is exposed (external type)", "enum": [ "var", "assign", @@ -76,18 +92,113 @@ "umd2", "jsonp" ] - }, - "type": { - "description": "The way how the export of the dll bundle is used", - "enum": ["require", "object"] } }, + "title": "DllReferencePluginOptions", "anyOf": [ { + "type": "object", + "additionalProperties": false, + "properties": { + "context": { + "description": "(absolute path) context of requests in the manifest (or content property)", + "type": "string", + "absolutePath": true + }, + "extensions": { + "description": "Extensions used to resolve modules in the dll bundle (only used when using 'scope')", + "type": "array", + "items": { + "description": "An extension", + "type": "string" + } + }, + "manifest": { + "description": "An object containing content and name or a string to the absolute path of the JSON manifest to be loaded upon compilation", + "oneOf": [ + { + "$ref": "#/definitions/DllReferencePluginOptionsManifest" + }, + { + "type": "string", + "absolutePath": true + } + ] + }, + "name": { + "description": "The name where the dll is exposed (external name, defaults to manifest.name)", + "type": "string", + "minLength": 1 + }, + "scope": { + "description": "Prefix which is used for accessing the content of the dll", + "type": "string", + "minLength": 1 + }, + "sourceType": { + "description": "How the dll is exposed (libraryTarget, defaults to manifest.type)", + "anyOf": [ + { + "$ref": "#/definitions/DllReferencePluginOptionsSourceType" + } + ] + }, + "type": { + "description": "The way how the export of the dll bundle is used", + "enum": ["require", "object"] + } + }, "required": ["manifest"] }, { - "required": ["content"] + "type": "object", + "additionalProperties": false, + "properties": { + "content": { + "description": "The mappings from request to module info", + "anyOf": [ + { + "$ref": "#/definitions/DllReferencePluginOptionsContent" + } + ] + }, + "context": { + "description": "(absolute path) context of requests in the manifest (or content property)", + "type": "string", + "absolutePath": true + }, + "extensions": { + "description": "Extensions used to resolve modules in the dll bundle (only used when using 'scope')", + "type": "array", + "items": { + "description": "An extension", + "type": "string" + } + }, + "name": { + "description": "The name where the dll is exposed (external name)", + "type": "string", + "minLength": 1 + }, + "scope": { + "description": "Prefix which is used for accessing the content of the dll", + "type": "string", + "minLength": 1 + }, + "sourceType": { + "description": "How the dll is exposed (libraryTarget)", + "anyOf": [ + { + "$ref": "#/definitions/DllReferencePluginOptionsSourceType" + } + ] + }, + "type": { + "description": "The way how the export of the dll bundle is used", + "enum": ["require", "object"] + } + }, + "required": ["content", "name"] } ] } diff --git a/test/Schemas.lint.js b/test/Schemas.lint.js index 30fc1b52f..8908cfdc6 100644 --- a/test/Schemas.lint.js +++ b/test/Schemas.lint.js @@ -40,7 +40,6 @@ describe("Schemas", () => { "type", "oneOf", "anyOf", - "allOf", "absolutePath", "description", "enum", @@ -99,6 +98,26 @@ describe("Schemas", () => { }); } + if ("absolutePath" in item) { + it("should have type: 'string' specified when using absolutePath", () => { + if (item.type !== "string") { + throw new Error( + "When using absolutePath, type must be 'string'" + ); + } + }); + } + + if ("properties" in item || "additionalProperties" in item) { + it("should have type: 'object' specified when using properties or additionalProperties", () => { + if (item.type !== "object") { + throw new Error( + "When using properties or additionalProperties, type must be 'object'" + ); + } + }); + } + arrayProperties.forEach(prop => { if (prop in item) { describe(prop, () => { From 62b614260928b7b5b509a60628e0ee6495620ea8 Mon Sep 17 00:00:00 2001 From: Tobias Koppers Date: Fri, 21 Sep 2018 11:26:16 +0200 Subject: [PATCH 24/29] fix Validation test --- test/Validation.test.js | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/test/Validation.test.js b/test/Validation.test.js index 543a3cffa..676b4a3a5 100644 --- a/test/Validation.test.js +++ b/test/Validation.test.js @@ -252,9 +252,13 @@ describe("Validation", () => { } }, message: [ - ' - configuration.output.filename: A relative path is expected. However, the provided value "/bar" is an absolute path!', + " - configuration.output.filename should be one of these:", + " string | function", " -> Specifies the name of each output file on disk. You must **not** specify an absolute path here! The `output.path` option determines the location on disk the files are written to, filename is used solely for naming the individual files.", - " Please use output.path to specify absolute path and output.filename for the file name." + " Details:", + ' * configuration.output.filename: A relative path is expected. However, the provided value "/bar" is an absolute path!', + " Please use output.path to specify absolute path and output.filename for the file name.", + " * configuration.output.filename should be an instance of function" ] }, { @@ -368,9 +372,6 @@ describe("Validation", () => { " * configuration.plugins[0] misses the property 'apply'.", " function", " -> The run point of the plugin, required method.", - " * configuration.plugins[0] misses the property 'apply'.", - " function", - " -> The run point of the plugin, required method.", " * configuration.plugins[0] should be an instance of function", " -> Function acting as plugin" ] From f8bc2519db609adea81166c5935827183634fbcc Mon Sep 17 00:00:00 2001 From: Tobias Koppers Date: Fri, 21 Sep 2018 11:33:42 +0200 Subject: [PATCH 25/29] Reduce the appveyor CI tasks --- appveyor.yml | 19 +++---------------- 1 file changed, 3 insertions(+), 16 deletions(-) diff --git a/appveyor.yml b/appveyor.yml index bd61e1135..94ecae79a 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -13,21 +13,8 @@ cache: - "..\\.yarn-cache" - ".jest-cache" -# what combinations to test -environment: - matrix: - - nodejs_version: 10 - job_part: unit - jest: --maxWorkers=2 --cacheDirectory .jest-cache - - nodejs_version: 10 - job_part: integration - jest: --maxWorkers=2 --cacheDirectory .jest-cache - - nodejs_version: 6 - job_part: integration - jest: --maxWorkers=2 --cacheDirectory .jest-cache - install: - - ps: Install-Product node $env:nodejs_version x64 + - ps: Install-Product node 10 x64 - yarn --frozen-lockfile --preferred-cache-folder ..\\.yarn-cache - yarn link --frozen-lockfile --preferred-cache-folder ..\\.yarn-cache || yarn link --frozen-lockfile --preferred-cache-folder ..\\.yarn-cache - yarn link webpack --frozen-lockfile --preferred-cache-folder ..\\.yarn-cache @@ -40,8 +27,8 @@ matrix: test_script: - node --version - yarn --version - - cmd: set JEST=%jest% - - cmd: yarn appveyor:%job_part% + - cmd: set JEST=--maxWorkers=2 --cacheDirectory .jest-cache + - cmd: yarn appveyor:integration - cmd: yarn istanbul report --report lcovonly - cmd: yarn unlink webpack - cmd: yarn global add codecov && codecov -F %job_part% --disable=gcov From 762b1c906424efd2f4accd775b1becd312faa14c Mon Sep 17 00:00:00 2001 From: Tobias Koppers Date: Fri, 21 Sep 2018 14:58:06 +0200 Subject: [PATCH 26/29] move json-schema-to-typescript to devDependencies --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 7535d446d..315d98121 100644 --- a/package.json +++ b/package.json @@ -17,7 +17,6 @@ "enhanced-resolve": "^4.1.0", "eslint-scope": "^4.0.0", "json-parse-better-errors": "^1.0.2", - "json-schema-to-typescript": "^6.0.1", "loader-runner": "^2.3.0", "loader-utils": "^1.1.0", "memory-fs": "~0.4.1", @@ -59,6 +58,7 @@ "jest": "^23.4.1", "jest-silent-reporter": "^0.0.5", "json-loader": "^0.5.7", + "json-schema-to-typescript": "^6.0.1", "less": "^2.5.1", "less-loader": "^4.0.3", "lint-staged": "^7.2.0", From f8877e0819cd53a417eb11b738d3567bf65715e8 Mon Sep 17 00:00:00 2001 From: Chuck Dumont Date: Fri, 21 Sep 2018 11:39:15 -0400 Subject: [PATCH 27/29] Uncaught exception from renderers --- lib/Compilation.js | 38 ++++++++++--------- .../exception-in-chunk-renderer/errors.js | 4 ++ .../exception-in-chunk-renderer/index.js | 3 ++ .../webpack.config.js | 16 ++++++++ 4 files changed, 44 insertions(+), 17 deletions(-) create mode 100644 test/configCases/errors/exception-in-chunk-renderer/errors.js create mode 100644 test/configCases/errors/exception-in-chunk-renderer/index.js create mode 100644 test/configCases/errors/exception-in-chunk-renderer/webpack.config.js diff --git a/lib/Compilation.js b/lib/Compilation.js index ca14499c1..b182380b9 100644 --- a/lib/Compilation.js +++ b/lib/Compilation.js @@ -2254,24 +2254,28 @@ class Compilation extends Tapable { for (let i = 0; i < chunks.length; i++) { const chunk = chunks[i]; const chunkHash = createHash(hashFunction); - if (outputOptions.hashSalt) { - chunkHash.update(outputOptions.hashSalt); + try { + if (outputOptions.hashSalt) { + chunkHash.update(outputOptions.hashSalt); + } + chunk.updateHash(chunkHash); + const template = chunk.hasRuntime() + ? this.mainTemplate + : this.chunkTemplate; + template.updateHashForChunk( + chunkHash, + chunk, + this.moduleTemplates.javascript, + this.dependencyTemplates + ); + this.hooks.chunkHash.call(chunk, chunkHash); + chunk.hash = chunkHash.digest(hashDigest); + hash.update(chunk.hash); + chunk.renderedHash = chunk.hash.substr(0, hashDigestLength); + this.hooks.contentHash.call(chunk); + } catch (err) { + this.errors.push(new ChunkRenderError(chunk, "", err)); } - chunk.updateHash(chunkHash); - const template = chunk.hasRuntime() - ? this.mainTemplate - : this.chunkTemplate; - template.updateHashForChunk( - chunkHash, - chunk, - this.moduleTemplates.javascript, - this.dependencyTemplates - ); - this.hooks.chunkHash.call(chunk, chunkHash); - chunk.hash = chunkHash.digest(hashDigest); - hash.update(chunk.hash); - chunk.renderedHash = chunk.hash.substr(0, hashDigestLength); - this.hooks.contentHash.call(chunk); } this.fullHash = hash.digest(hashDigest); this.hash = this.fullHash.substr(0, hashDigestLength); diff --git a/test/configCases/errors/exception-in-chunk-renderer/errors.js b/test/configCases/errors/exception-in-chunk-renderer/errors.js new file mode 100644 index 000000000..d9088af16 --- /dev/null +++ b/test/configCases/errors/exception-in-chunk-renderer/errors.js @@ -0,0 +1,4 @@ +module.exports = [ + [/Test exception/], + [/Test exception/] +]; diff --git a/test/configCases/errors/exception-in-chunk-renderer/index.js b/test/configCases/errors/exception-in-chunk-renderer/index.js new file mode 100644 index 000000000..d4f42bbdd --- /dev/null +++ b/test/configCases/errors/exception-in-chunk-renderer/index.js @@ -0,0 +1,3 @@ +it("should not crash when renderer throws exception", function(done) { + done(); +}); diff --git a/test/configCases/errors/exception-in-chunk-renderer/webpack.config.js b/test/configCases/errors/exception-in-chunk-renderer/webpack.config.js new file mode 100644 index 000000000..6a98bf6eb --- /dev/null +++ b/test/configCases/errors/exception-in-chunk-renderer/webpack.config.js @@ -0,0 +1,16 @@ +class ThrowsExceptionInRender { + apply(compiler) { + compiler.hooks.compilation.tap("ThrowsException", compilation => { + compilation.mainTemplate.hooks.requireExtensions.tap( + "ThrowsException", + () => { + throw new Error("Test exception"); + } + ); + }); + } +} + +module.exports = { + plugins: [new ThrowsExceptionInRender()] +}; From 2671d88b379ca706e12030b68e9065c0d12bbc4d Mon Sep 17 00:00:00 2001 From: Tim Neutkens Date: Fri, 21 Sep 2018 23:24:18 +0200 Subject: [PATCH 28/29] Fix typo --- lib/dependencies/ImportParserPlugin.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/dependencies/ImportParserPlugin.js b/lib/dependencies/ImportParserPlugin.js index 86c6b7438..edabf5bb0 100644 --- a/lib/dependencies/ImportParserPlugin.js +++ b/lib/dependencies/ImportParserPlugin.js @@ -66,7 +66,7 @@ class ImportParserPlugin { ) ); } else { - // Do not instrument `import()` is `webpackIgnore` is `true` + // Do not instrument `import()` if `webpackIgnore` is `true` if (importOptions.webpackIgnore) { return false; } From c4d8a3c8d67239f6457fd7560d9bea14524ff4f0 Mon Sep 17 00:00:00 2001 From: Tobias Koppers Date: Tue, 25 Sep 2018 09:14:43 +0200 Subject: [PATCH 29/29] 4.20.0 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 315d98121..6423bdb91 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "webpack", - "version": "4.19.1", + "version": "4.20.0", "author": "Tobias Koppers @sokra", "description": "Packs CommonJs/AMD modules for the browser. Allows to split your codebase into multiple bundles, which can be loaded on demand. Support loaders to preprocess files, i.e. json, jsx, es7, css, less, ... and your custom stuff.", "license": "MIT",