* Renders source with library export. * @param {Source} source source * @param {Module} module module * @param {StartupRenderContext} renderContext render context * @param {LibraryContext<T>} libraryContext context * @returns {Source} source with library export
(source, module, renderContext, { options, compilation })
| 359 | * @returns {Source} source with library export |
| 360 | */ |
| 361 | renderStartup(source, module, renderContext, { options, compilation }) { |
| 362 | const { |
| 363 | moduleGraph, |
| 364 | chunk, |
| 365 | codeGenerationResults, |
| 366 | inlined, |
| 367 | inlinedInIIFE, |
| 368 | runtimeTemplate |
| 369 | } = renderContext; |
| 370 | let result = new ConcatSource(source); |
| 371 | const exportInfos = options.export |
| 372 | ? [ |
| 373 | moduleGraph.getExportInfo( |
| 374 | module, |
| 375 | Array.isArray(options.export) ? options.export[0] : options.export |
| 376 | ) |
| 377 | ] |
| 378 | : moduleGraph.getExportsInfo(module).orderedExports; |
| 379 | |
| 380 | const exportsFinalNameByRuntime = |
| 381 | (module.buildMeta && |
| 382 | module.buildMeta.exportsFinalNameByRuntime && |
| 383 | module.buildMeta.exportsFinalNameByRuntime.get( |
| 384 | getRuntimeKey(chunk.runtime) |
| 385 | )) || |
| 386 | {}; |
| 387 | |
| 388 | const isInlinedEntryWithoutIIFE = inlined && !inlinedInIIFE; |
| 389 | // Direct export bindings from on-demand concatenation |
| 390 | const definitions = isInlinedEntryWithoutIIFE |
| 391 | ? exportsFinalNameByRuntime |
| 392 | : {}; |
| 393 | |
| 394 | /** @type {string[]} */ |
| 395 | const shortHandedExports = []; |
| 396 | /** @type {[string, string][]} */ |
| 397 | const exports = []; |
| 398 | /** @type {Set<string>} */ |
| 399 | const alreadyRenderedExports = new Set(); |
| 400 | |
| 401 | const isAsync = moduleGraph.isAsync(module); |
| 402 | |
| 403 | const treatAsCommonJs = |
| 404 | module.buildMeta && |
| 405 | /** @type {JavascriptModuleBuildMeta} */ (module.buildMeta) |
| 406 | .treatAsCommonJs; |
| 407 | const skipRenderDefaultExport = Boolean(treatAsCommonJs); |
| 408 | |
| 409 | const moduleExportsInfo = moduleGraph.getExportsInfo(module); |
| 410 | |
| 411 | // Define ESM compatibility flag will rely on `__webpack_exports__` |
| 412 | const needHarmonyCompatibilityFlag = |
| 413 | moduleExportsInfo.otherExportsInfo.getUsed(chunk.runtime) !== |
| 414 | UsageState.Unused || |
| 415 | moduleExportsInfo |
| 416 | .getReadOnlyExportInfo("__esModule") |
| 417 | .getUsed(chunk.runtime) !== UsageState.Unused; |
| 418 |
nothing calls this directly
no test coverage detected