MCPcopy
hub / github.com/webpack/webpack / finishEntryModule

Method finishEntryModule

lib/library/ModuleLibraryPlugin.js:200–234  ·  view source on GitHub ↗

* Finish entry module. * @param {Module} module the exporting entry module * @param {string} entryName the name of the entrypoint * @param {LibraryContext<T>} libraryContext context * @returns {void}

(
		module,
		entryName,
		{ options, compilation, compilation: { moduleGraph } }
	)

Source from the content-addressed store, hash-verified

198 * @returns {void}
199 */
200 finishEntryModule(
201 module,
202 entryName,
203 { options, compilation, compilation: { moduleGraph } }
204 ) {
205 const runtime = getEntryRuntime(compilation, entryName);
206 if (options.export) {
207 const exportsInfo = moduleGraph.getExportInfo(
208 module,
209 Array.isArray(options.export) ? options.export[0] : options.export
210 );
211 exportsInfo.setUsed(UsageState.Used, runtime);
212 exportsInfo.canMangleUse = false;
213 exportsInfo.canInlineUse = false;
214 } else {
215 const exportsInfo = moduleGraph.getExportsInfo(module);
216
217 if (
218 // If the entry module is commonjs, its exports cannot be mangled
219 (module.buildMeta &&
220 /** @type {JavascriptModuleBuildMeta} */ (module.buildMeta)
221 .treatAsCommonJs) ||
222 // The entry module provides unknown exports
223 exportsInfo._otherExportsInfo.provided === null
224 ) {
225 exportsInfo.setUsedInUnknownWay(runtime);
226 } else {
227 exportsInfo.setAllKnownExportsUsed(runtime);
228 for (const exportInfo of exportsInfo.ownedExports) {
229 exportInfo.canInlineUse = false;
230 }
231 }
232 }
233 moduleGraph.addExtraReason(module, "used as library export");
234 }
235
236 /**
237 * Returns preprocess as needed by overriding.

Callers

nothing calls this directly

Calls 8

getEntryRuntimeFunction · 0.85
isArrayMethod · 0.80
setUsedMethod · 0.80
getExportsInfoMethod · 0.80
addExtraReasonMethod · 0.80
getExportInfoMethod · 0.45
setUsedInUnknownWayMethod · 0.45

Tested by

no test coverage detected