MCPcopy
hub / github.com/webpack/webpack / renderChunk

Method renderChunk

lib/css/CssModulesPlugin.js:1037–1103  ·  view source on GitHub ↗

* Renders generated source. * @param {RenderContext} renderContext the render context * @param {CompilationHooks} hooks hooks * @returns {Source} generated source

(
		{
			undoPath,
			chunk,
			codeGenerationResults,
			modules,
			runtimeTemplate,
			chunkGraph,
			hash
		},
		hooks
	)

Source from the content-addressed store, hash-verified

1035 * @returns {Source} generated source
1036 */
1037 renderChunk(
1038 {
1039 undoPath,
1040 chunk,
1041 codeGenerationResults,
1042 modules,
1043 runtimeTemplate,
1044 chunkGraph,
1045 hash
1046 },
1047 hooks
1048 ) {
1049 const source = new ConcatSource();
1050
1051 /** @type {string | undefined} */
1052 let charset;
1053
1054 for (const module of modules) {
1055 if (
1056 typeof (
1057 /** @type {CssModuleBuildInfo} */ (module.buildInfo).charset
1058 ) !== "undefined" &&
1059 typeof charset === "undefined"
1060 ) {
1061 charset = /** @type {CssModuleBuildInfo} */ (module.buildInfo).charset;
1062 }
1063
1064 try {
1065 const codeGenResult = codeGenerationResults.get(module, chunk.runtime);
1066 const moduleSourceContent =
1067 /** @type {Source} */
1068 (
1069 codeGenResult.sources.get(CSS_TYPE) ||
1070 codeGenResult.sources.get(CSS_IMPORT_TYPE)
1071 );
1072 const moduleSource = CssModulesPlugin.renderModule(
1073 module,
1074 {
1075 undoPath,
1076 hash,
1077 chunk,
1078 chunkGraph,
1079 codeGenerationResults,
1080 moduleSourceContent,
1081 moduleFactoryCache: this._moduleFactoryCache,
1082 runtimeTemplate
1083 },
1084 hooks
1085 );
1086 if (moduleSource) {
1087 source.add(moduleSource);
1088 }
1089 } catch (err) {
1090 /** @type {Error} */
1091 (err).message += `\nduring rendering of css ${module.identifier()}`;
1092 throw err;
1093 }
1094 }

Callers 1

applyMethod · 0.95

Calls 4

getMethod · 0.45
renderModuleMethod · 0.45
addMethod · 0.45
identifierMethod · 0.45

Tested by

no test coverage detected