From 57f21c0d2094bef96582f17b28050657d5813fec Mon Sep 17 00:00:00 2001 From: Mohsen Azimi Date: Thu, 5 Jul 2018 08:20:24 +0300 Subject: [PATCH] Add JSDoc types for ContextExclusionPlugin --- lib/ContextExclusionPlugin.js | 15 ++++++++++++++- lib/ContextModuleFactory.js | 6 ++++++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/lib/ContextExclusionPlugin.js b/lib/ContextExclusionPlugin.js index 1333e9dbc..092ca04fe 100644 --- a/lib/ContextExclusionPlugin.js +++ b/lib/ContextExclusionPlugin.js @@ -1,12 +1,25 @@ "use strict"; +/** @typedef {import("./Compiler")} Compiler */ +/** @typedef {import("./ContextModuleFactory")} ContextModuleFactory */ + class ContextExclusionPlugin { + /** + * @param {RegExp} negativeMatcher Matcher regular expression + */ constructor(negativeMatcher) { this.negativeMatcher = negativeMatcher; } + /** + * Apply the plugin + * @param {Compiler} compiler Webpack Compiler + * @returns {void} + */ apply(compiler) { - compiler.hooks.contextModuleFactory.tap("ContextExclusionPlugin", cmf => { + compiler.hooks.contextModuleFactory.tap("ContextExclusionPlugin", ( + /** @type {ContextModuleFactory} */ cmf + ) => { cmf.hooks.contextModuleFiles.tap("ContextExclusionPlugin", files => { return files.filter(filePath => !this.negativeMatcher.test(filePath)); }); diff --git a/lib/ContextModuleFactory.js b/lib/ContextModuleFactory.js index 2a52a58f0..f59411288 100644 --- a/lib/ContextModuleFactory.js +++ b/lib/ContextModuleFactory.js @@ -15,15 +15,21 @@ const { const ContextModule = require("./ContextModule"); const ContextElementDependency = require("./dependencies/ContextElementDependency"); +/** @typedef {import("./Module")} Module */ + const EMPTY_RESOLVE_OPTIONS = {}; module.exports = class ContextModuleFactory extends Tapable { constructor(resolverFactory) { super(); this.hooks = { + /** @type {AsyncSeriesWaterfallHook} */ beforeResolve: new AsyncSeriesWaterfallHook(["data"]), + /** @type {AsyncSeriesWaterfallHook} */ afterResolve: new AsyncSeriesWaterfallHook(["data"]), + /** @type {SyncWaterfallHook} */ contextModuleFiles: new SyncWaterfallHook(["files"]), + /** @type {SyncWaterfallHook} */ alternatives: new AsyncSeriesWaterfallHook(["modules"]) }; this._pluginCompat.tap("ContextModuleFactory", options => {