. 25 - Analysis of event flow compilation of webback source code (3)

Run the next batch of plugin s in this section.

compiler.apply(
    new EnsureChunkConditionsPlugin(),
    new RemoveParentModulesPlugin(),
    new RemoveEmptyChunksPlugin(),
    new MergeDuplicateChunksPlugin(),
    new FlagIncludedChunksPlugin(),
    new OccurrenceOrderPlugin(true),
    new FlagDependencyExportsPlugin(),
    new FlagDependencyUsagePlugin()
);

I hope it's not the same as the last section. It's all plugin.

The flow chart is as shown in the figure (just look at the flow chart, there is nothing in the back):

 

 

EnsureChunkConditionsPlugin

class EnsureChunkConditionsPlugin {
    apply(compiler) {
        compiler.plugin("compilation", (compilation) => {
            const triesMap = new Map();
            compilation.plugin(["optimize-chunks-basic", "optimize-extracted-chunks-basic"], (chunks) => { /**/ });
        });
    }
}

Just look at this and you'll see. No explanation.

 

RemoveParentModulesPlugin

class RemoveParentModulesPlugin {
    apply(compiler) {
        compiler.plugin("compilation", (compilation) => {
            compilation.plugin(["optimize-chunks-basic", "optimize-extracted-chunks-basic"], (chunks) => { /**/ });
        });
    }
}

Is it another batch of plugin s

 

RemoveEmptyChunksPlugin

class RemoveEmptyChunksPlugin {
    apply(compiler) {
        compiler.plugin("compilation", (compilation) => {
            compilation.plugin(["optimize-chunks-basic", "optimize-extracted-chunks-basic"], (chunks) => { /**/ });
        });
    }
}

Yes.

 

MergeDuplicateChunksPlugin

class MergeDuplicateChunksPlugin {
    apply(compiler) {
        compiler.plugin("compilation", (compilation) => {
            compilation.plugin("optimize-chunks-basic", (chunks) => { /**/ });
        });
    }
}

 

FlagIncludedChunksPlugin

class FlagIncludedChunksPlugin {
    apply(compiler) {
        compiler.plugin("compilation", (compilation) => {
            compilation.plugin("optimize-chunk-ids", (chunks) => { /**/ });
        });
    }
}

 

OccurrenceOrderPlugin

class OccurrenceOrderPlugin {
    // true
    constructor(preferEntry) {
        if (preferEntry !== undefined && typeof preferEntry !== "boolean") {
            throw new Error("Argument should be a boolean.\nFor more info on this plugin, see https://webpack.js.org/plugins/");
        }
        this.preferEntry = preferEntry;
    }
    apply(compiler) {
        const preferEntry = this.preferEntry;
        compiler.plugin("compilation", (compilation) => {
            compilation.plugin("optimize-module-order", (modules) => { /**/ });
            compilation.plugin("optimize-chunk-order", (chunks) => { /**/ });
        });
    }
}

I want to laugh at the error prompt. Who can call this plug-in except yourself.

 

FlagDependencyExportsPlugin

class FlagDependencyExportsPlugin {
    apply(compiler) {
        compiler.plugin("compilation", (compilation) => {
            compilation.plugin("finish-modules", (modules) => { /**/ });

            function addToSet(a, b) { /**/ }
        });
    }
}

 

FlagDependencyUsagePlugin

class FlagDependencyUsagePlugin {
    apply(compiler) {
        compiler.plugin("compilation", compilation => {
            compilation.plugin("optimize-modules-advanced", modules => { /**/ });

            function addToSet(a, b) { /**/ }

            function isSubset(biggerSet, subset) { /**/ }
        });
    }
}

In general, this batch of plugin s is for modules, but there is still no actual behavior.

 

There are three left, too.

TemplatedPathPlugin

class TemplatedPathPlugin {
    apply(compiler) {
        compiler.plugin("compilation", compilation => {
            const mainTemplate = compilation.mainTemplate;
            mainTemplate.plugin("asset-path", replacePathVariables);
            mainTemplate.plugin("global-hash", function(chunk, paths) { /**/ });
            mainTemplate.plugin("hash-for-chunk", function(hash, chunk) { /**/ });
        });
    }
}

 

RecordIdsPlugin

class RecordIdsPlugin {
    apply(compiler) {
        compiler.plugin("compilation", compilation => {
            compilation.plugin("record-modules", (modules, records) => { /**/ });
            compilation.plugin("revive-modules", (modules, records) => { /**/ });

            function getDepBlockIdent(chunk, block) { /**/ }
            compilation.plugin("record-chunks", (chunks, records) => { /**/ });
            compilation.plugin("revive-chunks", (chunks, records) => { /**/ });
        });
    }
}

 

WarnCaseSensitiveModulesPlugin

class WarnCaseSensitiveModulesPlugin {
    apply(compiler) {
        compiler.plugin("compilation", compilation => {
            compilation.plugin("seal", () => { /**/ });
        });
    }
}

 

After triggering all the compilation event flows, the plugin is only used again for different stages, so the detailed process needs to continue to run.

Keywords: Javascript Webpack

Added by BETA on Sat, 02 May 2020 21:03:17 +0300