Skip to content

Commit f737b26

Browse files
committed
Remove some plugin calls
1 parent 8bc82da commit f737b26

31 files changed

+95
-74
lines changed

lib/ContextExclusionPlugin.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ class ContextExclusionPlugin {
77

88
apply(compiler) {
99
compiler.hooks.contextModuleFactory.tap("ContextExclusionPlugin", (cmf) => {
10-
cmf.plugin("context-module-files", (files) => {
10+
cmf.hooks.contextModuleFiles.tap("ContextExclusionPlugin", (files) => {
1111
return files.filter(filePath => !this.negativeMatcher.test(filePath));
1212
});
1313
});

lib/ContextReplacementPlugin.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ class ContextReplacementPlugin {
4646
const newContentCreateContextMap = this.newContentCreateContextMap;
4747

4848
compiler.hooks.contextModuleFactory.tap("ContextReplacementPlugin", (cmf) => {
49-
cmf.plugin("before-resolve", (result, callback) => {
49+
cmf.hooks.beforeResolve.tapAsync("ContextReplacementPlugin", (result, callback) => {
5050
if(!result) return callback();
5151
if(resourceRegExp.test(result.request)) {
5252
if(typeof newContentResource !== "undefined")
@@ -66,7 +66,7 @@ class ContextReplacementPlugin {
6666
}
6767
return callback(null, result);
6868
});
69-
cmf.plugin("after-resolve", (result, callback) => {
69+
cmf.hooks.afterResolve.tapAsync("ContextReplacementPlugin", (result, callback) => {
7070
if(!result) return callback();
7171
if(resourceRegExp.test(result.resource)) {
7272
if(typeof newContentResource !== "undefined")

lib/DelegatedModuleFactoryPlugin.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ class DelegatedModuleFactoryPlugin {
2121
apply(normalModuleFactory) {
2222
const scope = this.options.scope;
2323
if(scope) {
24-
normalModuleFactory.plugin("factory", factory => (data, callback) => {
24+
normalModuleFactory.hooks.factory.tap("DelegatedModuleFactoryPlugin", factory => (data, callback) => {
2525
const dependency = data.dependencies[0];
2626
const request = dependency.request;
2727
if(request && request.indexOf(scope + "/") === 0) {
@@ -43,7 +43,7 @@ class DelegatedModuleFactoryPlugin {
4343
return factory(data, callback);
4444
});
4545
} else {
46-
normalModuleFactory.plugin("module", module => {
46+
normalModuleFactory.hooks.module.tap("DelegatedModuleFactoryPlugin", module => {
4747
if(module.libIdent) {
4848
const request = module.libIdent(this.options);
4949
if(request && request in this.options.content) {

lib/EvalDevToolModuleTemplatePlugin.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ class EvalDevToolModuleTemplatePlugin {
1616
}
1717

1818
apply(moduleTemplate) {
19-
moduleTemplate.plugin("module", (source, module) => {
19+
moduleTemplate.hooks.module.tap("EvalDevToolModuleTemplatePlugin", (source, module) => {
2020
const cacheEntry = cache.get(source);
2121
if(cacheEntry !== undefined) return cacheEntry;
2222
const content = source.source();
@@ -32,7 +32,7 @@ class EvalDevToolModuleTemplatePlugin {
3232
cache.set(source, result);
3333
return result;
3434
});
35-
moduleTemplate.plugin("hash", hash => {
35+
moduleTemplate.hooks.hash.tap("EvalDevToolModuleTemplatePlugin", hash => {
3636
hash.update("EvalDevToolModuleTemplatePlugin");
3737
hash.update("2");
3838
});

lib/EvalSourceMapDevToolModuleTemplatePlugin.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ class EvalSourceMapDevToolModuleTemplatePlugin {
1919
apply(moduleTemplate) {
2020
const self = this;
2121
const options = this.options;
22-
moduleTemplate.plugin("module", (source, module) => {
22+
moduleTemplate.hooks.module.tap("EvalSourceMapDevToolModuleTemplatePlugin", (source, module) => {
2323
if(source.__EvalSourceMapDevToolData)
2424
return source.__EvalSourceMapDevToolData;
2525
let sourceMap;
@@ -70,7 +70,7 @@ class EvalSourceMapDevToolModuleTemplatePlugin {
7070
source.__EvalSourceMapDevToolData = new RawSource(`eval(${JSON.stringify(content + footer)});`);
7171
return source.__EvalSourceMapDevToolData;
7272
});
73-
moduleTemplate.plugin("hash", hash => {
73+
moduleTemplate.hooks.hash.tap("EvalSourceMapDevToolModuleTemplatePlugin", hash => {
7474
hash.update("eval-source-map");
7575
hash.update("2");
7676
});

lib/ExportPropertyMainTemplatePlugin.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ class ExportPropertyMainTemplatePlugin {
2121
const postfix = `${accessorToObjectAccess([].concat(this.property))}`;
2222
return new ConcatSource(source, postfix);
2323
});
24-
mainTemplate.plugin("hash", hash => {
24+
mainTemplate.hooks.hash.tap("ExportPropertyMainTemplatePlugin", hash => {
2525
hash.update("export property");
2626
hash.update(`${this.property}`);
2727
});

lib/ExternalModuleFactoryPlugin.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ class ExternalModuleFactoryPlugin {
1414

1515
apply(normalModuleFactory) {
1616
const globalType = this.type;
17-
normalModuleFactory.plugin("factory", factory => (data, callback) => {
17+
normalModuleFactory.hooks.factory.tap("ExternalModuleFactoryPlugin", factory => (data, callback) => {
1818
const context = data.context;
1919
const dependency = data.dependencies[0];
2020

lib/FunctionModuleTemplatePlugin.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ const Template = require("./Template");
99

1010
class FunctionModuleTemplatePlugin {
1111
apply(moduleTemplate) {
12-
moduleTemplate.plugin("render", (moduleSource, module) => {
12+
moduleTemplate.hooks.render.tap("FunctionModuleTemplatePlugin", (moduleSource, module) => {
1313
const source = new ConcatSource();
1414
const args = [module.moduleArgument];
1515
// TODO remove HACK checking type for javascript
@@ -30,7 +30,7 @@ class FunctionModuleTemplatePlugin {
3030
return source;
3131
});
3232

33-
moduleTemplate.plugin("package", (moduleSource, module) => {
33+
moduleTemplate.hooks.package.tap("FunctionModuleTemplatePlugin", (moduleSource, module) => {
3434
if(moduleTemplate.runtimeTemplate.outputOptions.pathinfo) {
3535
const source = new ConcatSource();
3636
const req = module.readableIdentifier(moduleTemplate.runtimeTemplate.requestShortener);
@@ -61,7 +61,7 @@ class FunctionModuleTemplatePlugin {
6161
return moduleSource;
6262
});
6363

64-
moduleTemplate.plugin("hash", hash => {
64+
moduleTemplate.hooks.hash.tap("FunctionModuleTemplatePlugin", hash => {
6565
hash.update("FunctionModuleTemplatePlugin");
6666
hash.update("2");
6767
});

lib/IgnorePlugin.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,10 +58,10 @@ class IgnorePlugin {
5858

5959
apply(compiler) {
6060
compiler.hooks.normalModuleFactory.tap("IgnorePlugin", (nmf) => {
61-
nmf.plugin("before-resolve", this.checkIgnore);
61+
nmf.hooks.beforeResolve.tapAsync("IgnorePlugin", this.checkIgnore);
6262
});
6363
compiler.hooks.contextModuleFactory.tap("IgnorePlugin", (cmf) => {
64-
cmf.plugin("before-resolve", this.checkIgnore);
64+
cmf.hooks.beforeResolve.tapAsync("IgnorePlugin", this.checkIgnore);
6565
});
6666
}
6767
}

lib/MainTemplate.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -57,15 +57,15 @@ module.exports = class MainTemplate extends Tapable {
5757
// It's weird here
5858
hotBootstrap: new SyncWaterfallHook(["source", "chunk", "hash"])
5959
};
60-
this.plugin("startup", (source, chunk, hash) => {
60+
this.hooks.startup.tap("MainTemplate", (source, chunk, hash) => {
6161
const buf = [];
6262
if(chunk.entryModule) {
6363
buf.push("// Load entry module and return exports");
6464
buf.push(`return ${this.renderRequireFunctionForModule(hash, chunk, JSON.stringify(chunk.entryModule.id))}(${this.requireFn}.s = ${JSON.stringify(chunk.entryModule.id)});`);
6565
}
6666
return Template.asString(buf);
6767
});
68-
this.plugin("render", (bootstrapSource, chunk, hash, moduleTemplate, dependencyTemplates) => {
68+
this.hooks.render.tap("MainTemplate", (bootstrapSource, chunk, hash, moduleTemplate, dependencyTemplates) => {
6969
const source = new ConcatSource();
7070
source.add("/******/ (function(modules) { // webpackBootstrap\n");
7171
source.add(new PrefixSource("/******/", bootstrapSource));
@@ -77,14 +77,14 @@ module.exports = class MainTemplate extends Tapable {
7777
source.add(")");
7878
return source;
7979
});
80-
this.plugin("local-vars", (source, chunk, hash) => {
80+
this.hooks.localVars.tap("MainTemplate", (source, chunk, hash) => {
8181
return Template.asString([
8282
source,
8383
"// The module cache",
8484
"var installedModules = {};"
8585
]);
8686
});
87-
this.plugin("require", (source, chunk, hash) => {
87+
this.hooks.require.tap("MainTemplate", (source, chunk, hash) => {
8888
return Template.asString([
8989
source,
9090
"// Check if module is in cache",
@@ -121,14 +121,14 @@ module.exports = class MainTemplate extends Tapable {
121121
"return module.exports;"
122122
]);
123123
});
124-
this.plugin("module-obj", (source, chunk, hash, varModuleId) => {
124+
this.hooks.moduleObj.tap("MainTemplate", (source, chunk, hash, varModuleId) => {
125125
return Template.asString([
126126
"i: moduleId,",
127127
"l: false,",
128128
"exports: {}"
129129
]);
130130
});
131-
this.plugin("require-extensions", (source, chunk, hash) => {
131+
this.hooks.requireExtensions.tap("MainTemplate", (source, chunk, hash) => {
132132
const buf = [];
133133
if(chunk.getNumberOfChunks() > 0) {
134134
buf.push("// This file contains only the entry chunk.");

lib/MultiCompiler.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ module.exports = class MultiCompiler extends Tapable {
2929
let compilerStats = [];
3030
this.compilers.forEach((compiler, idx) => {
3131
let compilerDone = false;
32-
compiler.plugin("done", stats => {
32+
compiler.hooks.done.tap("MultiCompiler", stats => {
3333
if(!compilerDone) {
3434
compilerDone = true;
3535
doneCompilers++;
@@ -39,7 +39,7 @@ module.exports = class MultiCompiler extends Tapable {
3939
this.hooks.done.call(new MultiStats(compilerStats));
4040
}
4141
});
42-
compiler.plugin("invalid", () => {
42+
compiler.hooks.invalid.tap("MultiCompiler", () => {
4343
if(compilerDone) {
4444
compilerDone = false;
4545
doneCompilers--;

lib/NormalModuleFactory.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ class NormalModuleFactory extends Tapable {
8989
this.cachePredicate = typeof options.unsafeCache === "function" ? options.unsafeCache : Boolean.bind(null, options.unsafeCache);
9090
this.context = context || "";
9191
this.parserCache = {};
92-
this.plugin("factory", () => (result, callback) => {
92+
this.hooks.factory.tap("NormalModuleFactory", () => (result, callback) => {
9393
let resolver = this.hooks.resolver.call(null);
9494

9595
// Ignored
@@ -136,7 +136,7 @@ class NormalModuleFactory extends Tapable {
136136
});
137137
});
138138
});
139-
this.plugin("resolver", () => (data, callback) => {
139+
this.hooks.resolver.tap("NormalModuleFactory", () => (data, callback) => {
140140
const contextInfo = data.contextInfo;
141141
const context = data.context;
142142
const request = data.request;

lib/NormalModuleReplacementPlugin.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ class NormalModuleReplacementPlugin {
1616
const resourceRegExp = this.resourceRegExp;
1717
const newResource = this.newResource;
1818
compiler.hooks.normalModuleFactory.tap("NormalModuleReplacementPlugin", (nmf) => {
19-
nmf.plugin("before-resolve", (result, callback) => {
19+
nmf.hooks.beforeResolve.tapAsync("NormalModuleReplacementPlugin", (result, callback) => {
2020
if(!result) return callback();
2121
if(resourceRegExp.test(result.request)) {
2222
if(typeof newResource === "function") {
@@ -27,7 +27,7 @@ class NormalModuleReplacementPlugin {
2727
}
2828
return callback(null, result);
2929
});
30-
nmf.plugin("after-resolve", (result, callback) => {
30+
nmf.hooks.afterResolve.tapAsync("NormalModuleReplacementPlugin", (result, callback) => {
3131
if(!result) return callback();
3232
if(resourceRegExp.test(result.resource)) {
3333
if(typeof newResource === "function") {

lib/TemplatedPathPlugin.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,9 +79,9 @@ class TemplatedPathPlugin {
7979
compiler.hooks.compilation.tap("TemplatedPathPlugin", (compilation) => {
8080
const mainTemplate = compilation.mainTemplate;
8181

82-
mainTemplate.plugin("asset-path", replacePathVariables);
82+
mainTemplate.hooks.assetPath.tap("TemplatedPathPlugin", replacePathVariables);
8383

84-
mainTemplate.plugin("global-hash", (chunk, paths) => {
84+
mainTemplate.hooks.globalHash.tap("TemplatedPathPlugin", (chunk, paths) => {
8585
const outputOptions = mainTemplate.outputOptions;
8686
const publicPath = outputOptions.publicPath || "";
8787
const filename = outputOptions.filename || "";
@@ -96,7 +96,7 @@ class TemplatedPathPlugin {
9696
return true;
9797
});
9898

99-
mainTemplate.plugin("hash-for-chunk", (hash, chunk) => {
99+
mainTemplate.hooks.hashForChunk.tap("TemplatedPathPlugin", (hash, chunk) => {
100100
const outputOptions = mainTemplate.outputOptions;
101101
const chunkFilename = outputOptions.chunkFilename || outputOptions.filename;
102102
if(REGEXP_CHUNKHASH_FOR_TEST.test(chunkFilename))

lib/UseStrictPlugin.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ class UseStrictPlugin {
1313
}) => {
1414
normalModuleFactory.plugin(["parser javascript/auto", "parser javascript/dynamic", "parser javascript/esm"], (parser) => {
1515
const parserInstance = parser;
16-
parser.plugin("program", (ast) => {
16+
parser.hooks.program.tap("UseStrictPlugin", (ast) => {
1717
const firstNode = ast.body[0];
1818
if(firstNode &&
1919
firstNode.type === "ExpressionStatement" &&

lib/dependencies/RequireContextPlugin.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ class RequireContextPlugin {
3838
parser.apply(new RequireContextDependencyParserPlugin());
3939
});
4040

41-
contextModuleFactory.plugin("alternatives", (items, callback) => {
41+
contextModuleFactory.hooks.alternatives.tapAsync("RequireContextPlugin", (items, callback) => {
4242
if(items.length === 0) return callback(null, items);
4343

4444
callback(null, items.map((obj) => {
@@ -55,7 +55,7 @@ class RequireContextPlugin {
5555
}).reduce((a, b) => a.concat(b), []));
5656
});
5757

58-
contextModuleFactory.plugin("alternatives", (items, callback) => {
58+
contextModuleFactory.hooks.alternatives.tapAsync("RequireContextPlugin", (items, callback) => {
5959
if(items.length === 0) return callback(null, items);
6060

6161
callback(null, items.map((obj) => {
@@ -75,7 +75,7 @@ class RequireContextPlugin {
7575
}).reduce((a, b) => a.concat(b), []));
7676
});
7777

78-
contextModuleFactory.plugin("alternatives", (items, callback) => {
78+
contextModuleFactory.hooks.alternatives.tapAsync("RequireContextPlugin", (items, callback) => {
7979
if(items.length === 0) return callback(null, items);
8080

8181
callback(null, items.map((obj) => {

lib/node/NodeChunkTemplatePlugin.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,14 @@ const ConcatSource = require("webpack-sources").ConcatSource;
1010
class NodeChunkTemplatePlugin {
1111

1212
apply(chunkTemplate) {
13-
chunkTemplate.plugin("render", (modules, chunk) => {
13+
chunkTemplate.hooks.render.tap("NodeChunkTemplatePlugin", (modules, chunk) => {
1414
const source = new ConcatSource();
1515
source.add(`exports.ids = ${JSON.stringify(chunk.ids)};\nexports.modules = `);
1616
source.add(modules);
1717
source.add(";");
1818
return source;
1919
});
20-
chunkTemplate.plugin("hash", hash => {
20+
chunkTemplate.hooks.hash.tap("NodeChunkTemplatePlugin", hash => {
2121
hash.update("node");
2222
hash.update("3");
2323
});

lib/node/NodeHotUpdateChunkTemplatePlugin.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,14 @@ const ConcatSource = require("webpack-sources").ConcatSource;
99
class NodeHotUpdateChunkTemplatePlugin {
1010

1111
apply(hotUpdateChunkTemplate) {
12-
hotUpdateChunkTemplate.plugin("render", (modulesSource, modules, removedModules, hash, id) => {
12+
hotUpdateChunkTemplate.hooks.render.tap("NodeHotUpdateChunkTemplatePlugin", (modulesSource, modules, removedModules, hash, id) => {
1313
const source = new ConcatSource();
1414
source.add("exports.id = " + JSON.stringify(id) + ";\nexports.modules = ");
1515
source.add(modulesSource);
1616
source.add(";");
1717
return source;
1818
});
19-
hotUpdateChunkTemplate.plugin("hash", hash => {
19+
hotUpdateChunkTemplate.hooks.hash.tap("NodeHotUpdateChunkTemplatePlugin", hash => {
2020
hash.update("NodeHotUpdateChunkTemplatePlugin");
2121
hash.update("3");
2222
hash.update(hotUpdateChunkTemplate.outputOptions.hotUpdateFunction + "");

lib/node/NodeMainTemplatePlugin.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ module.exports = class NodeMainTemplatePlugin {
1313

1414
apply(mainTemplate) {
1515
const asyncChunkLoading = this.asyncChunkLoading;
16-
mainTemplate.plugin("local-vars", (source, chunk) => {
16+
mainTemplate.hooks.localVars.tap("NodeMainTemplatePlugin", (source, chunk) => {
1717
if(chunk.getNumberOfChunks() > 0) {
1818
return Template.asString([
1919
source,
@@ -27,7 +27,7 @@ module.exports = class NodeMainTemplatePlugin {
2727
}
2828
return source;
2929
});
30-
mainTemplate.plugin("require-extensions", (source, chunk) => {
30+
mainTemplate.hooks.requireExtensions.tap("NodeMainTemplatePlugin", (source, chunk) => {
3131
if(chunk.getNumberOfChunks() > 0) {
3232
return Template.asString([
3333
source,
@@ -44,7 +44,7 @@ module.exports = class NodeMainTemplatePlugin {
4444
}
4545
return source;
4646
});
47-
mainTemplate.plugin("require-ensure", (source, chunk, hash) => {
47+
mainTemplate.hooks.requireEnsure.tap("NodeMainTemplatePlugin", (source, chunk, hash) => {
4848
const chunkFilename = mainTemplate.outputOptions.chunkFilename;
4949
const chunkMaps = chunk.getChunkMaps();
5050
const insertMoreModules = [
@@ -154,7 +154,7 @@ module.exports = class NodeMainTemplatePlugin {
154154
]);
155155
}
156156
});
157-
mainTemplate.plugin("hot-bootstrap", (source, chunk, hash) => {
157+
mainTemplate.hooks.hotBootstrap.tap("NodeMainTemplatePlugin", (source, chunk, hash) => {
158158
const hotUpdateChunkFilename = mainTemplate.outputOptions.hotUpdateChunkFilename;
159159
const hotUpdateMainFilename = mainTemplate.outputOptions.hotUpdateMainFilename;
160160
const chunkMaps = chunk.getChunkMaps();
@@ -184,7 +184,7 @@ module.exports = class NodeMainTemplatePlugin {
184184
.replace(/\$hotMainFilename\$/g, currentHotUpdateMainFilename)
185185
.replace(/\$hotChunkFilename\$/g, currentHotUpdateChunkFilename);
186186
});
187-
mainTemplate.plugin("hash", hash => {
187+
mainTemplate.hooks.hash.tap("NodeMainTemplatePlugin", hash => {
188188
hash.update("node");
189189
hash.update("3");
190190
hash.update(mainTemplate.outputOptions.filename + "");

0 commit comments

Comments
 (0)