MCPcopy
hub / github.com/webpack/webpack / generate

Method generate

lib/javascript/JavascriptGenerator.js:264–277  ·  view source on GitHub ↗

* Generates generated code for this runtime module. * @param {NormalModule} module module for which the code should be generated * @param {GenerateContext} generateContext context for generate * @returns {Source | null} generated code

(module, generateContext)

Source from the content-addressed store, hash-verified

262 * @returns {Source | null} generated code
263 */
264 generate(module, generateContext) {
265 const originalSource = module.originalSource();
266 if (!originalSource) {
267 return DEFAULT_SOURCE.source();
268 }
269
270 const source = new ReplaceSource(originalSource);
271 /** @type {InitFragment<GenerateContext>[]} */
272 const initFragments = [];
273
274 this.sourceModule(module, initFragments, source, generateContext);
275
276 return InitFragment.addToSource(source, initFragments, generateContext);
277 }
278
279 /**
280 * Generates fallback output for the provided error condition.

Callers

nothing calls this directly

Calls 4

sourceModuleMethod · 0.95
sourceMethod · 0.80
addToSourceMethod · 0.80
originalSourceMethod · 0.45

Tested by

no test coverage detected