diff --git a/lib/APIPlugin.js b/lib/APIPlugin.js index 0a7e6888f..bfefb29a1 100644 --- a/lib/APIPlugin.js +++ b/lib/APIPlugin.js @@ -10,9 +10,10 @@ const { toConstantDependencyWithWebpackRequire, evaluateToString } = require("./JavascriptParserHelpers"); +const NullFactory = require("./NullFactory"); const ConstDependency = require("./dependencies/ConstDependency"); -const NullFactory = require("./NullFactory"); +/** @typedef {import("./Compiler")} Compiler */ /* eslint-disable camelcase */ const REPLACEMENTS = { @@ -37,6 +38,11 @@ const REPLACEMENT_TYPES = { /* eslint-enable camelcase */ class APIPlugin { + /** + * Apply the plugin + * @param {Compiler} compiler the compiler instance + * @returns {void} + */ apply(compiler) { compiler.hooks.compilation.tap( "APIPlugin", diff --git a/lib/AutomaticPrefetchPlugin.js b/lib/AutomaticPrefetchPlugin.js index 1422185a5..84c76aa79 100644 --- a/lib/AutomaticPrefetchPlugin.js +++ b/lib/AutomaticPrefetchPlugin.js @@ -14,7 +14,7 @@ const PrefetchDependency = require("./dependencies/PrefetchDependency"); class AutomaticPrefetchPlugin { /** * Apply the plugin - * @param {Compiler} compiler Webpack Compiler + * @param {Compiler} compiler the compiler instance * @returns {void} */ apply(compiler) { diff --git a/lib/CompatibilityPlugin.js b/lib/CompatibilityPlugin.js index 35aa6c782..909ca200a 100644 --- a/lib/CompatibilityPlugin.js +++ b/lib/CompatibilityPlugin.js @@ -14,7 +14,7 @@ const NullFactory = require("./NullFactory"); class CompatibilityPlugin { /** * Apply the plugin - * @param {Compiler} compiler Webpack Compiler + * @param {Compiler} compiler the compiler instance * @returns {void} */ apply(compiler) { diff --git a/lib/ContextExclusionPlugin.js b/lib/ContextExclusionPlugin.js index d46512f66..da51e30b2 100644 --- a/lib/ContextExclusionPlugin.js +++ b/lib/ContextExclusionPlugin.js @@ -17,7 +17,7 @@ class ContextExclusionPlugin { /** * Apply the plugin - * @param {Compiler} compiler Webpack Compiler + * @param {Compiler} compiler the compiler instance * @returns {void} */ apply(compiler) { diff --git a/lib/DelegatedPlugin.js b/lib/DelegatedPlugin.js index 46037ad92..e79a8e088 100644 --- a/lib/DelegatedPlugin.js +++ b/lib/DelegatedPlugin.js @@ -10,11 +10,18 @@ const NullFactory = require("./NullFactory"); const DelegatedExportsDependency = require("./dependencies/DelegatedExportsDependency"); const DelegatedSourceDependency = require("./dependencies/DelegatedSourceDependency"); +/** @typedef {import("./Compiler")} Compiler */ + class DelegatedPlugin { constructor(options) { this.options = options; } + /** + * Apply the plugin + * @param {Compiler} compiler the compiler instance + * @returns {void} + */ apply(compiler) { compiler.hooks.compilation.tap( "DelegatedPlugin", diff --git a/lib/EvalSourceMapDevToolPlugin.js b/lib/EvalSourceMapDevToolPlugin.js index 314f9f763..6de6b8075 100644 --- a/lib/EvalSourceMapDevToolPlugin.js +++ b/lib/EvalSourceMapDevToolPlugin.js @@ -24,7 +24,7 @@ class EvalSourceMapDevToolPlugin { } /** - * @param {Compiler} compiler Webpack Compiler + * @param {Compiler} compiler the compiler instance * @returns {void} */ apply(compiler) { diff --git a/lib/ExternalsPlugin.js b/lib/ExternalsPlugin.js index 6b28a6b95..ec22929c1 100644 --- a/lib/ExternalsPlugin.js +++ b/lib/ExternalsPlugin.js @@ -7,11 +7,18 @@ const ExternalModuleFactoryPlugin = require("./ExternalModuleFactoryPlugin"); +/** @typedef {import("./Compiler")} Compiler */ + class ExternalsPlugin { constructor(type, externals) { this.type = type; this.externals = externals; } + + /** + * @param {Compiler} compiler the compiler instance + * @returns {void} + */ apply(compiler) { compiler.hooks.compile.tap("ExternalsPlugin", ({ normalModuleFactory }) => { new ExternalModuleFactoryPlugin(this.type, this.externals).apply( diff --git a/lib/FunctionModulePlugin.js b/lib/FunctionModulePlugin.js index 16d8fbfc6..112fc6e6b 100644 --- a/lib/FunctionModulePlugin.js +++ b/lib/FunctionModulePlugin.js @@ -7,7 +7,14 @@ const FunctionModuleTemplatePlugin = require("./FunctionModuleTemplatePlugin"); +/** @typedef {import("./Compiler")} Compiler */ + class FunctionModulePlugin { + /** + * Apply the plugin + * @param {Compiler} compiler the compiler instance + * @returns {void} + */ apply(compiler) { compiler.hooks.compilation.tap("FunctionModulePlugin", compilation => { new FunctionModuleTemplatePlugin({ diff --git a/lib/IgnorePlugin.js b/lib/IgnorePlugin.js index 31b449a6f..20fb0c04e 100644 --- a/lib/IgnorePlugin.js +++ b/lib/IgnorePlugin.js @@ -82,7 +82,7 @@ class IgnorePlugin { } /** - * @param {Compiler} compiler Webpack Compiler + * @param {Compiler} compiler the compiler instance * @returns {void} */ apply(compiler) { diff --git a/lib/JsonModulesPlugin.js b/lib/JsonModulesPlugin.js index 9aa77d086..f52387685 100644 --- a/lib/JsonModulesPlugin.js +++ b/lib/JsonModulesPlugin.js @@ -9,7 +9,14 @@ const JavascriptModulesPlugin = require("./JavascriptModulesPlugin"); const JsonGenerator = require("./JsonGenerator"); const JsonParser = require("./JsonParser"); +/** @typedef {import("./Compiler")} Compiler */ + class JsonModulesPlugin { + /** + * Apply the plugin + * @param {Compiler} compiler the compiler instance + * @returns {void} + */ apply(compiler) { compiler.hooks.compilation.tap( "JsonModulesPlugin", diff --git a/lib/ModuleProfile.js b/lib/ModuleProfile.js index c2e64ef95..86d651c6f 100644 --- a/lib/ModuleProfile.js +++ b/lib/ModuleProfile.js @@ -62,12 +62,16 @@ class ModuleProfile { this.storing = this.storingEndTime - this.storingStartTime; } + /** + * Merge this profile into another one + * @param {ModuleProfile} realProfile the profile to merge into + * @returns {void} + */ mergeInto(realProfile) { if (this.factory > realProfile.additionalFactories) realProfile.additionalFactories = this.factory; if (this.integration > realProfile.additionalIntegration) realProfile.additionalIntegration = this.integration; - return realProfile; } } diff --git a/lib/NoEmitOnErrorsPlugin.js b/lib/NoEmitOnErrorsPlugin.js index 9b02526a1..a84eb56c7 100644 --- a/lib/NoEmitOnErrorsPlugin.js +++ b/lib/NoEmitOnErrorsPlugin.js @@ -5,7 +5,14 @@ "use strict"; +/** @typedef {import("./Compiler")} Compiler */ + class NoEmitOnErrorsPlugin { + /** + * Apply the plugin + * @param {Compiler} compiler the compiler instance + * @returns {void} + */ apply(compiler) { compiler.hooks.shouldEmit.tap("NoEmitOnErrorsPlugin", compilation => { if (compilation.getStats().hasErrors()) return false; diff --git a/lib/NodeStuffPlugin.js b/lib/NodeStuffPlugin.js index e50ed4f13..5b63cc3a6 100644 --- a/lib/NodeStuffPlugin.js +++ b/lib/NodeStuffPlugin.js @@ -18,6 +18,7 @@ const CachedConstDependency = require("./dependencies/CachedConstDependency"); const ModuleDecoratorDependency = require("./dependencies/ModuleDecoratorDependency"); /** @typedef {import("webpack-sources").ReplaceSource} ReplaceSource */ +/** @typedef {import("./Compiler")} Compiler */ /** @typedef {import("./Dependency")} Dependency */ /** @typedef {import("./DependencyTemplates")} DependencyTemplates */ /** @typedef {import("./RuntimeTemplate")} RuntimeTemplate */ @@ -30,6 +31,11 @@ class NodeStuffPlugin { this.options = options; } + /** + * Apply the plugin + * @param {Compiler} compiler the compiler instance + * @returns {void} + */ apply(compiler) { const options = this.options; compiler.hooks.compilation.tap( diff --git a/lib/NormalModuleReplacementPlugin.js b/lib/NormalModuleReplacementPlugin.js index 5fcd5a0b4..e7eb9ec35 100644 --- a/lib/NormalModuleReplacementPlugin.js +++ b/lib/NormalModuleReplacementPlugin.js @@ -7,12 +7,25 @@ const path = require("path"); +/** @typedef {import("./Compiler")} Compiler */ +/** @typedef {function(TODO): void} ModuleReplacer */ + class NormalModuleReplacementPlugin { + /** + * Create an instance of the plugin + * @param {RegExp} resourceRegExp the resource matcher + * @param {string|ModuleReplacer} newResource the resource replacement + */ constructor(resourceRegExp, newResource) { this.resourceRegExp = resourceRegExp; this.newResource = newResource; } + /** + * Apply the plugin + * @param {Compiler} compiler the compiler instance + * @returns {void} + */ apply(compiler) { const resourceRegExp = this.resourceRegExp; const newResource = this.newResource; diff --git a/lib/PrefetchPlugin.js b/lib/PrefetchPlugin.js index 01af601f3..b0648c744 100644 --- a/lib/PrefetchPlugin.js +++ b/lib/PrefetchPlugin.js @@ -7,16 +7,24 @@ const PrefetchDependency = require("./dependencies/PrefetchDependency"); +/** @typedef {import("./Compiler")} Compiler */ + class PrefetchPlugin { constructor(context, request) { - if (!request) { - this.request = context; - } else { + if (request) { this.context = context; this.request = request; + } else { + this.context = null; + this.request = context; } } + /** + * Apply the plugin + * @param {Compiler} compiler the compiler instance + * @returns {void} + */ apply(compiler) { compiler.hooks.compilation.tap( "PrefetchPlugin", diff --git a/lib/RequireJsStuffPlugin.js b/lib/RequireJsStuffPlugin.js index c963d4095..976382d1a 100644 --- a/lib/RequireJsStuffPlugin.js +++ b/lib/RequireJsStuffPlugin.js @@ -12,7 +12,14 @@ const { const NullFactory = require("./NullFactory"); const ConstDependency = require("./dependencies/ConstDependency"); +/** @typedef {import("./Compiler")} Compiler */ + module.exports = class RequireJsStuffPlugin { + /** + * Apply the plugin + * @param {Compiler} compiler the compiler instance + * @returns {void} + */ apply(compiler) { compiler.hooks.compilation.tap( "RequireJsStuffPlugin", diff --git a/lib/TemplatedPathPlugin.js b/lib/TemplatedPathPlugin.js index b78935c5f..817e570e8 100644 --- a/lib/TemplatedPathPlugin.js +++ b/lib/TemplatedPathPlugin.js @@ -8,6 +8,7 @@ const Module = require("./Module"); /** @typedef {import("./Compilation").PathData} PathData */ +/** @typedef {import("./Compiler")} Compiler */ const REGEXP_HASH = /\[hash(?::(\d+))?\]/gi, REGEXP_CHUNKHASH = /\[chunkhash(?::(\d+))?\]/gi, @@ -131,6 +132,11 @@ const replacePathVariables = (path, data) => { }; class TemplatedPathPlugin { + /** + * Apply the plugin + * @param {Compiler} compiler the compiler instance + * @returns {void} + */ apply(compiler) { compiler.hooks.compilation.tap("TemplatedPathPlugin", compilation => { const mainTemplate = compilation.mainTemplate; diff --git a/lib/UseStrictPlugin.js b/lib/UseStrictPlugin.js index a46641b48..d2bfd6fe7 100644 --- a/lib/UseStrictPlugin.js +++ b/lib/UseStrictPlugin.js @@ -11,7 +11,7 @@ const ConstDependency = require("./dependencies/ConstDependency"); class UseStrictPlugin { /** - * @param {Compiler} compiler Webpack Compiler + * @param {Compiler} compiler the compiler instance * @returns {void} */ apply(compiler) { diff --git a/lib/WarnCaseSensitiveModulesPlugin.js b/lib/WarnCaseSensitiveModulesPlugin.js index ad51a0e37..0be4f258c 100644 --- a/lib/WarnCaseSensitiveModulesPlugin.js +++ b/lib/WarnCaseSensitiveModulesPlugin.js @@ -7,7 +7,14 @@ const CaseSensitiveModulesWarning = require("./CaseSensitiveModulesWarning"); +/** @typedef {import("./Compiler")} Compiler */ + class WarnCaseSensitiveModulesPlugin { + /** + * Apply the plugin + * @param {Compiler} compiler the compiler instance + * @returns {void} + */ apply(compiler) { compiler.hooks.compilation.tap( "WarnCaseSensitiveModulesPlugin", diff --git a/lib/WarnDeprecatedOptionPlugin.js b/lib/WarnDeprecatedOptionPlugin.js index 331c8b086..518e33455 100644 --- a/lib/WarnDeprecatedOptionPlugin.js +++ b/lib/WarnDeprecatedOptionPlugin.js @@ -7,13 +7,26 @@ const WebpackError = require("./WebpackError"); +/** @typedef {import("./Compiler")} Compiler */ + class WarnDeprecatedOptionPlugin { + /** + * Create an instance of the plugin + * @param {string} option the target option + * @param {string | number} value the deprecated option value + * @param {string} suggestion the suggestion replacement + */ constructor(option, value, suggestion) { this.option = option; this.value = value; this.suggestion = suggestion; } + /** + * Apply the plugin + * @param {Compiler} compiler the compiler instance + * @returns {void} + */ apply(compiler) { compiler.hooks.thisCompilation.tap( "WarnDeprecatedOptionPlugin", diff --git a/lib/WarnNoModeSetPlugin.js b/lib/WarnNoModeSetPlugin.js index 2d5ce404d..b8685f039 100644 --- a/lib/WarnNoModeSetPlugin.js +++ b/lib/WarnNoModeSetPlugin.js @@ -7,7 +7,14 @@ const NoModeWarning = require("./NoModeWarning"); +/** @typedef {import("./Compiler")} Compiler */ + class WarnNoModeSetPlugin { + /** + * Apply the plugin + * @param {Compiler} compiler the compiler instance + * @returns {void} + */ apply(compiler) { compiler.hooks.thisCompilation.tap("WarnNoModeSetPlugin", compilation => { compilation.warnings.push(new NoModeWarning());