MCPcopy
hub / github.com/webpack/webpack / build

Method build

lib/optimize/ConcatenatedModule.js:962–1081  ·  view source on GitHub ↗

* Builds the module using the provided compilation context. * @param {WebpackOptions} options webpack options * @param {Compilation} compilation the compilation * @param {ResolverWithOptions} resolver the resolver * @param {InputFileSystem} fs the file system * @param {BuildCallback} callb

(options, compilation, resolver, fs, callback)

Source from the content-addressed store, hash-verified

960 * @returns {void}
961 */
962 build(options, compilation, resolver, fs, callback) {
963 const { rootModule } = this;
964 const { moduleArgument, exportsArgument } =
965 /** @type {BuildInfo} */
966 (rootModule.buildInfo);
967 /** @type {ConcatenatedModuleBuildInfo} */
968 this.buildInfo = {
969 strict: true,
970 cacheable: true,
971 moduleArgument,
972 exportsArgument,
973 fileDependencies: new LazySet(),
974 contextDependencies: new LazySet(),
975 missingDependencies: new LazySet(),
976 topLevelDeclarations: new Set(),
977 assets: undefined,
978 inlineExports: /** @type {JavascriptModuleBuildInfo} */ (
979 rootModule.buildInfo
980 ).inlineExports
981 };
982 this.buildMeta = rootModule.buildMeta;
983 this.clearDependenciesAndBlocks();
984 this.clearWarningsAndErrors();
985
986 for (const m of this._modules) {
987 // populate cacheable
988 if (!(/** @type {BuildInfo} */ (m.buildInfo).cacheable)) {
989 this.buildInfo.cacheable = false;
990 }
991
992 // populate dependencies
993 for (const d of m.dependencies.filter(
994 (dep) =>
995 !Dependency.canConcatenate(dep) ||
996 !this._modules.has(
997 /** @type {Module} */
998 (compilation.moduleGraph.getModule(dep))
999 )
1000 )) {
1001 this.dependencies.push(d);
1002 }
1003 // populate codeGenerationDependencies — the inner modules'
1004 // templates are applied during ConcatenatedModule.codeGeneration,
1005 // so the referenced modules must have been code-generated by then.
1006 // Skip references that point back into the concat set itself.
1007 if (m.codeGenerationDependencies !== undefined) {
1008 for (const d of m.codeGenerationDependencies) {
1009 const referenced =
1010 /** @type {Module} */
1011 (compilation.moduleGraph.getModule(d));
1012 if (!this._modules.has(referenced)) {
1013 this.addCodeGenerationDependency(d);
1014 }
1015 }
1016 }
1017 // populate blocks
1018 for (const d of m.blocks) {
1019 this.blocks.push(d);

Callers

nothing calls this directly

Calls 15

addErrorMethod · 0.80
callbackFunction · 0.50
canConcatenateMethod · 0.45
hasMethod · 0.45
getModuleMethod · 0.45
pushMethod · 0.45
getWarningsMethod · 0.45
addWarningMethod · 0.45
getErrorsMethod · 0.45

Tested by

no test coverage detected