MCPcopy
hub / github.com/webpack/webpack / getSourceString

Method getSourceString

lib/ContextModule.js:1287–1347  ·  view source on GitHub ↗

* @param {string} asyncMode module mode * @param {ImportPhaseType} phase import phase * @param {CodeGenerationContext} context context info * @returns {string} the source code

(asyncMode, phase, { runtimeTemplate, chunkGraph })

Source from the content-addressed store, hash-verified

1285 * @returns {string} the source code
1286 */
1287 getSourceString(asyncMode, phase, { runtimeTemplate, chunkGraph }) {
1288 const id = /** @type {ModuleId} */ (chunkGraph.getModuleId(this));
1289 if (asyncMode === "lazy") {
1290 if (this.blocks && this.blocks.length > 0) {
1291 return this.getLazySource(this.blocks, id, phase, {
1292 runtimeTemplate,
1293 chunkGraph
1294 });
1295 }
1296 return this.getSourceForEmptyAsyncContext(id, runtimeTemplate);
1297 }
1298 if (asyncMode === "eager") {
1299 if (this.dependencies && this.dependencies.length > 0) {
1300 return this.getEagerSource(this.dependencies, id, phase, {
1301 chunkGraph,
1302 runtimeTemplate
1303 });
1304 }
1305 return this.getSourceForEmptyAsyncContext(id, runtimeTemplate);
1306 }
1307 if (asyncMode === "lazy-once") {
1308 const block = this.blocks[0];
1309 if (block) {
1310 return this.getLazyOnceSource(block, block.dependencies, id, phase, {
1311 runtimeTemplate,
1312 chunkGraph
1313 });
1314 }
1315 return this.getSourceForEmptyAsyncContext(id, runtimeTemplate);
1316 }
1317 if (asyncMode === "async-weak") {
1318 if (this.dependencies && this.dependencies.length > 0) {
1319 return this.getAsyncWeakSource(this.dependencies, id, phase, {
1320 chunkGraph,
1321 runtimeTemplate
1322 });
1323 }
1324 return this.getSourceForEmptyAsyncContext(id, runtimeTemplate);
1325 }
1326 if (
1327 asyncMode === "weak" &&
1328 this.dependencies &&
1329 this.dependencies.length > 0
1330 ) {
1331 return this.getWeakSyncSource(
1332 this.dependencies,
1333 id,
1334 chunkGraph,
1335 runtimeTemplate
1336 );
1337 }
1338 if (this.dependencies && this.dependencies.length > 0) {
1339 return this.getSyncSource(
1340 this.dependencies,
1341 id,
1342 chunkGraph,
1343 runtimeTemplate
1344 );

Callers 1

codeGenerationMethod · 0.95

Calls 9

getLazySourceMethod · 0.95
getEagerSourceMethod · 0.95
getLazyOnceSourceMethod · 0.95
getAsyncWeakSourceMethod · 0.95
getWeakSyncSourceMethod · 0.95
getSyncSourceMethod · 0.95
getModuleIdMethod · 0.80

Tested by

no test coverage detected