MCPcopy
hub / github.com/webpack/webpack / handleModuleCreation

Method handleModuleCreation

lib/Compilation.js:2321–2458  ·  lib/Compilation.js::Compilation.handleModuleCreation

* Handle module creation. * @param {HandleModuleCreationOptions} options options object * @param {ModuleCallback} callback callback * @returns {void}

(
		{
			factory,
			dependencies,
			originModule,
			contextInfo,
			context,
			recursive = true,
			connectOrigin = recursive,
			checkCycle = !recursive
		},
		callback
	)

Source from the content-addressed store, hash-verified

2319 * @returns {void}
2320 */
2321 handleModuleCreation(
2322 {
2323 factory,
2324 dependencies,
2325 originModule,
2326 contextInfo,
2327 context,
2328 recursive = true,
2329 connectOrigin = recursive,
2330 checkCycle = !recursive
2331 },
2332 callback
2333 ) {
2334 const moduleGraph = this.moduleGraph;
2335
2336 const currentProfile = this.profile ? new ModuleProfile() : undefined;
2337
2338 this.factorizeModule(
2339 {
2340 currentProfile,
2341 factory,
2342 dependencies,
2343 factoryResult: true,
2344 originModule,
2345 contextInfo,
2346 context
2347 },
2348 (err, factoryResult) => {
2349 const applyFactoryResultDependencies = () => {
2350 const { fileDependencies, contextDependencies, missingDependencies } =
2351 /** @type {ModuleFactoryResult} */ (factoryResult);
2352 if (fileDependencies) {
2353 this.fileDependencies.addAll(fileDependencies);
2354 }
2355 if (contextDependencies) {
2356 this.contextDependencies.addAll(contextDependencies);
2357 }
2358 if (missingDependencies) {
2359 this.missingDependencies.addAll(missingDependencies);
2360 }
2361 };
2362 if (err) {
2363 if (factoryResult) applyFactoryResultDependencies();
2364 if (dependencies.every((d) => d.optional)) {
2365 this.warnings.push(err);
2366 return callback();
2367 }
2368 this.errors.push(err);
2369 return callback(err);
2370 }
2371
2372 const newModule =
2373 /** @type {ModuleFactoryResult} */
2374 (factoryResult).module;
2375
2376 if (!newModule) {
2377 applyFactoryResultDependencies();
2378 return callback();

Callers 5

onDependenciesSortedMethod · 0.95
addModuleTreeMethod · 0.95
applyMethod · 0.80
importModuleMethod · 0.80

Calls 13

factorizeModuleMethod · 0.95
addModuleMethod · 0.95
setProfileMethod · 0.80
setResolvedModuleMethod · 0.80
setIssuerIfUnsetMethod · 0.80
getProfileMethod · 0.80
mergeIntoMethod · 0.80
callbackFunction · 0.50
pushMethod · 0.45
setMethod · 0.45
hasMethod · 0.45

Tested by

no test coverage detected