MCPcopy
hub / github.com/webpack/webpack / executeModule

Method executeModule

lib/Compilation.js:5808–6200  ·  view source on GitHub ↗

* Processes the provided module. * @param {Module} module the module * @param {ExecuteModuleOptions} options options * @param {ExecuteModuleCallback} callback callback

(module, options, callback)

Source from the content-addressed store, hash-verified

5806 * @param {ExecuteModuleCallback} callback callback
5807 */
5808 executeModule(module, options, callback) {
5809 // Aggregate all referenced modules and ensure they are ready
5810 const modules = new Set([module]);
5811 processAsyncTree(
5812 modules,
5813 10,
5814 (module, push, callback) => {
5815 this.buildQueue.waitFor(module, (err) => {
5816 if (err) return callback(err);
5817 this.processDependenciesQueue.waitFor(module, (err) => {
5818 if (err) return callback(err);
5819 for (const { module: m } of this.moduleGraph.getOutgoingConnections(
5820 module
5821 )) {
5822 const size = modules.size;
5823 modules.add(m);
5824 if (modules.size !== size) push(m);
5825 }
5826 callback();
5827 });
5828 });
5829 },
5830 (err) => {
5831 if (err) return callback(/** @type {WebpackError} */ (err));
5832
5833 // Create new chunk graph, chunk and entrypoint for the build time execution
5834 const chunkGraph = new ChunkGraph(
5835 this.moduleGraph,
5836 this.outputOptions.hashFunction
5837 );
5838 const runtime = "build time";
5839 const { hashFunction, hashDigest, hashDigestLength } =
5840 this.outputOptions;
5841 const runtimeTemplate = this.runtimeTemplate;
5842
5843 const chunk = new Chunk("build time chunk", this._backCompat);
5844 chunk.id = /** @type {ChunkId} */ (chunk.name);
5845 chunk.ids = [chunk.id];
5846 chunk.runtime = runtime;
5847
5848 const entrypoint = new Entrypoint({
5849 runtime,
5850 chunkLoading: false,
5851 ...options.entryOptions
5852 });
5853 chunkGraph.connectChunkAndEntryModule(chunk, module, entrypoint);
5854 if (entrypoint.pushChunk(chunk)) {
5855 chunk.addGroup(entrypoint);
5856 }
5857 entrypoint.setRuntimeChunk(chunk);
5858 entrypoint.setEntrypointChunk(chunk);
5859
5860 const chunks = new Set([chunk]);
5861
5862 // Assign ids to modules and modules to the chunk
5863 for (const module of modules) {
5864 const id = module.identifier();
5865 chunkGraph.setModuleId(module, id);

Callers 1

importModuleMethod · 0.80

Calls 15

addGroupMethod · 0.95
setRuntimeChunkMethod · 0.95
setEntrypointChunkMethod · 0.95
setModuleIdMethod · 0.95
connectChunkAndModuleMethod · 0.95
_createModuleHashMethod · 0.95
getMethod · 0.95
processAsyncTreeFunction · 0.85

Tested by

no test coverage detected