MCPcopy
hub / github.com/webpack/webpack / apply

Method apply

lib/ids/NamedModuleIdsPlugin.js:42–67  ·  view source on GitHub ↗

* Applies the plugin by registering its hooks on the compiler. * @param {Compiler} compiler the compiler instance * @returns {void}

(compiler)

Source from the content-addressed store, hash-verified

40 * @returns {void}
41 */
42 apply(compiler) {
43 const { root } = compiler;
44 compiler.hooks.compilation.tap(PLUGIN_NAME, (compilation) => {
45 const hashFunction = compilation.outputOptions.hashFunction;
46 compilation.hooks.moduleIds.tap(PLUGIN_NAME, () => {
47 const chunkGraph = compilation.chunkGraph;
48 const context = this.options.context
49 ? this.options.context
50 : compiler.context;
51
52 const [usedIds, modules] = getUsedModuleIdsAndModules(compilation);
53 const unnamedModules = assignNames(
54 modules,
55 (m) => getShortModuleName(m, context, root),
56 (m, shortName) =>
57 getLongModuleName(shortName, m, context, hashFunction, root),
58 compareModulesByIdentifier,
59 usedIds,
60 (m, name) => chunkGraph.setModuleId(m, name)
61 );
62 if (unnamedModules.length > 0) {
63 assignAscendingModuleIds(usedIds, unnamedModules, compilation);
64 }
65 });
66 });
67 }
68}
69
70module.exports = NamedModuleIdsPlugin;

Callers

nothing calls this directly

Calls 7

assignNamesFunction · 0.85
getShortModuleNameFunction · 0.85
getLongModuleNameFunction · 0.85
assignAscendingModuleIdsFunction · 0.85
tapMethod · 0.80
setModuleIdMethod · 0.80

Tested by

no test coverage detected