mirror of https://github.com/webpack/webpack.git
Merge pull request #8592 from hulkish/hoist-plugin-logic
perf: hoist option logic, reduce code paths in handler
This commit is contained in:
commit
b133ebeb25
|
|
@ -23,6 +23,10 @@ class NodeTemplatePlugin {
|
||||||
* @returns {void}
|
* @returns {void}
|
||||||
*/
|
*/
|
||||||
apply(compiler) {
|
apply(compiler) {
|
||||||
|
const ChunkLoadingRuntimeModule = this.asyncChunkLoading
|
||||||
|
? ReadFileChunkLoadingRuntimeModule
|
||||||
|
: RequireChunkLoadingRuntimeModule;
|
||||||
|
|
||||||
compiler.hooks.thisCompilation.tap("NodeTemplatePlugin", compilation => {
|
compiler.hooks.thisCompilation.tap("NodeTemplatePlugin", compilation => {
|
||||||
new NodeChunkTemplatePlugin(compilation).apply(compilation.chunkTemplate);
|
new NodeChunkTemplatePlugin(compilation).apply(compilation.chunkTemplate);
|
||||||
|
|
||||||
|
|
@ -31,17 +35,10 @@ class NodeTemplatePlugin {
|
||||||
if (onceForChunkSet.has(chunk)) return;
|
if (onceForChunkSet.has(chunk)) return;
|
||||||
onceForChunkSet.add(chunk);
|
onceForChunkSet.add(chunk);
|
||||||
set.add(RuntimeGlobals.moduleFactories);
|
set.add(RuntimeGlobals.moduleFactories);
|
||||||
if (this.asyncChunkLoading) {
|
compilation.addRuntimeModule(
|
||||||
compilation.addRuntimeModule(
|
chunk,
|
||||||
chunk,
|
new ChunkLoadingRuntimeModule(chunk, set)
|
||||||
new ReadFileChunkLoadingRuntimeModule(chunk, set)
|
);
|
||||||
);
|
|
||||||
} else {
|
|
||||||
compilation.addRuntimeModule(
|
|
||||||
chunk,
|
|
||||||
new RequireChunkLoadingRuntimeModule(chunk, set)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
compilation.hooks.runtimeRequirementInTree
|
compilation.hooks.runtimeRequirementInTree
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue