Skip to content

Commit 57f21c0

Browse files
committed
Add JSDoc types for ContextExclusionPlugin
1 parent bdd4442 commit 57f21c0

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed

lib/ContextExclusionPlugin.js

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,25 @@
11
"use strict";
22

3+
/** @typedef {import("./Compiler")} Compiler */
4+
/** @typedef {import("./ContextModuleFactory")} ContextModuleFactory */
5+
36
class ContextExclusionPlugin {
7+
/**
8+
* @param {RegExp} negativeMatcher Matcher regular expression
9+
*/
410
constructor(negativeMatcher) {
511
this.negativeMatcher = negativeMatcher;
612
}
713

14+
/**
15+
* Apply the plugin
16+
* @param {Compiler} compiler Webpack Compiler
17+
* @returns {void}
18+
*/
819
apply(compiler) {
9-
compiler.hooks.contextModuleFactory.tap("ContextExclusionPlugin", cmf => {
20+
compiler.hooks.contextModuleFactory.tap("ContextExclusionPlugin", (
21+
/** @type {ContextModuleFactory} */ cmf
22+
) => {
1023
cmf.hooks.contextModuleFiles.tap("ContextExclusionPlugin", files => {
1124
return files.filter(filePath => !this.negativeMatcher.test(filePath));
1225
});

lib/ContextModuleFactory.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,21 @@ const {
1515
const ContextModule = require("./ContextModule");
1616
const ContextElementDependency = require("./dependencies/ContextElementDependency");
1717

18+
/** @typedef {import("./Module")} Module */
19+
1820
const EMPTY_RESOLVE_OPTIONS = {};
1921

2022
module.exports = class ContextModuleFactory extends Tapable {
2123
constructor(resolverFactory) {
2224
super();
2325
this.hooks = {
26+
/** @type {AsyncSeriesWaterfallHook<TODO>} */
2427
beforeResolve: new AsyncSeriesWaterfallHook(["data"]),
28+
/** @type {AsyncSeriesWaterfallHook<TODO>} */
2529
afterResolve: new AsyncSeriesWaterfallHook(["data"]),
30+
/** @type {SyncWaterfallHook<string[]>} */
2631
contextModuleFiles: new SyncWaterfallHook(["files"]),
32+
/** @type {SyncWaterfallHook<TODO[]>} */
2733
alternatives: new AsyncSeriesWaterfallHook(["modules"])
2834
};
2935
this._pluginCompat.tap("ContextModuleFactory", options => {

0 commit comments

Comments
 (0)