Skip to content

Commit 7dd41b5

Browse files
committed
Replace deprecated Tapable#apply by Plugin#apply
1 parent e72c00f commit 7dd41b5

30 files changed

Lines changed: 189 additions & 614 deletions

lib/CachePlugin.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ class CachePlugin {
1515
apply(compiler) {
1616
if(Array.isArray(compiler.compilers)) {
1717
compiler.compilers.forEach((c, idx) => {
18-
c.apply(new CachePlugin(this.cache[idx] = this.cache[idx] || {}));
18+
new CachePlugin(this.cache[idx] = this.cache[idx] || {}).apply(c);
1919
});
2020
} else {
2121
const registerCacheToCompiler = (compiler, cache) => {

lib/Compiler.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -522,7 +522,7 @@ class Compiler extends Tapable {
522522
createChildCompiler(compilation, compilerName, compilerIndex, outputOptions, plugins) {
523523
const childCompiler = new Compiler(this.context);
524524
if(Array.isArray(plugins)) {
525-
plugins.forEach(plugin => childCompiler.apply(plugin));
525+
plugins.forEach(plugin => plugin.apply(childCompiler));
526526
}
527527
for(const name in this.hooks) {
528528
if(["make", "compile", "emit", "afterEmit", "invalid", "done", "thisCompilation"].indexOf(name) < 0) {

lib/DelegatedPlugin.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ class DelegatedPlugin {
2626
compiler.hooks.compile.tap("DelegatedPlugin", ({
2727
normalModuleFactory
2828
}) => {
29-
normalModuleFactory.apply(new DelegatedModuleFactoryPlugin(this.options));
29+
new DelegatedModuleFactoryPlugin(this.options).apply(normalModuleFactory);
3030
});
3131
}
3232
}

lib/DllPlugin.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,15 +27,15 @@ class DllPlugin {
2727
};
2828
if(typeof entry === "object" && !Array.isArray(entry)) {
2929
Object.keys(entry).forEach(name => {
30-
compiler.apply(itemToPlugin(entry[name], name));
30+
itemToPlugin(entry[name], name).apply(compiler);
3131
});
3232
} else {
33-
compiler.apply(itemToPlugin(entry, "main"));
33+
itemToPlugin(entry, "main").apply(compiler);
3434
}
3535
return true;
3636
});
37-
compiler.apply(new LibManifestPlugin(this.options));
38-
compiler.apply(new FlagInitialModulesAsUsedPlugin("DllPlugin"));
37+
new LibManifestPlugin(this.options).apply(compiler);
38+
new FlagInitialModulesAsUsedPlugin("DllPlugin").apply(compiler);
3939
}
4040
}
4141

lib/DllReferencePlugin.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,15 +51,16 @@ class DllReferencePlugin {
5151
const externals = {};
5252
const source = "dll-reference " + name;
5353
externals[source] = name;
54-
params.normalModuleFactory.apply(new ExternalModuleFactoryPlugin(sourceType, externals));
55-
params.normalModuleFactory.apply(new DelegatedModuleFactoryPlugin({
54+
const normalModuleFactory = params.normalModuleFactory;
55+
new ExternalModuleFactoryPlugin(sourceType, externals).apply(normalModuleFactory);
56+
new DelegatedModuleFactoryPlugin({
5657
source: source,
5758
type: this.options.type,
5859
scope: this.options.scope,
5960
context: this.options.context || compiler.options.context,
6061
content: this.options.content || manifest.content,
6162
extensions: this.options.extensions
62-
}));
63+
}).apply(normalModuleFactory);
6364
});
6465
}
6566
}

lib/EntryOptionPlugin.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,11 @@ module.exports = class EntryOptionPlugin {
1919
apply(compiler) {
2020
compiler.hooks.entryOption.tap("EntryOptionPlugin", (context, entry) => {
2121
if(typeof entry === "string" || Array.isArray(entry)) {
22-
compiler.apply(itemToPlugin(context, entry, "main"));
22+
itemToPlugin(context, entry, "main").apply(compiler);
2323
} else if(typeof entry === "object") {
24-
Object.keys(entry).forEach(name => compiler.apply(itemToPlugin(context, entry[name], name)));
24+
Object.keys(entry).forEach(name => itemToPlugin(context, entry[name], name).apply(compiler));
2525
} else if(typeof entry === "function") {
26-
compiler.apply(new DynamicEntryPlugin(context, entry));
26+
new DynamicEntryPlugin(context, entry).apply(compiler);
2727
}
2828
return true;
2929
});

lib/EnvironmentPlugin.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ class EnvironmentPlugin {
4343
return defs;
4444
}, {});
4545

46-
compiler.apply(new DefinePlugin(definitions));
46+
new DefinePlugin(definitions).apply(compiler);
4747
}
4848
}
4949

lib/EvalDevToolModulePlugin.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,11 @@ class EvalDevToolModulePlugin {
1515

1616
apply(compiler) {
1717
compiler.hooks.compilation.tap("EvalDevToolModulePlugin", (compilation) => {
18-
compilation.moduleTemplates.javascript.apply(new EvalDevToolModuleTemplatePlugin({
18+
new EvalDevToolModuleTemplatePlugin({
1919
sourceUrlComment: this.sourceUrlComment,
2020
moduleFilenameTemplate: this.moduleFilenameTemplate,
2121
namespace: this.namespace
22-
}));
22+
}).apply(compilation.moduleTemplates.javascript);
2323
});
2424
}
2525
}

lib/EvalSourceMapDevToolPlugin.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ class EvalSourceMapDevToolPlugin {
2424
const options = this.options;
2525
compiler.hooks.compilation.tap("EvalSourceMapDevToolPlugin", (compilation) => {
2626
new SourceMapDevToolModuleOptionsPlugin(options).apply(compilation);
27-
compilation.moduleTemplates.javascript.apply(new EvalSourceMapDevToolModuleTemplatePlugin(compilation, options));
27+
new EvalSourceMapDevToolModuleTemplatePlugin(compilation, options).apply(compilation.moduleTemplates.javascript);
2828
});
2929
}
3030
}

lib/ExternalsPlugin.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ class ExternalsPlugin {
1515
compiler.hooks.compile.tap("ExternalsPlugin", ({
1616
normalModuleFactory
1717
}) => {
18-
normalModuleFactory.apply(new ExternalModuleFactoryPlugin(this.type, this.externals));
18+
new ExternalModuleFactoryPlugin(this.type, this.externals).apply(normalModuleFactory);
1919
});
2020
}
2121
}

0 commit comments

Comments
 (0)