(moduleGraph, dep, runtimeKey)
| 307 | * @returns {ExportMode} the export mode |
| 308 | */ |
| 309 | const getMode = (moduleGraph, dep, runtimeKey) => { |
| 310 | const importedModule = moduleGraph.getModule(dep); |
| 311 | |
| 312 | if (!importedModule) { |
| 313 | const mode = new ExportMode("missing"); |
| 314 | |
| 315 | mode.userRequest = dep.userRequest; |
| 316 | |
| 317 | return mode; |
| 318 | } |
| 319 | |
| 320 | const name = dep.name; |
| 321 | const runtime = keyToRuntime(runtimeKey); |
| 322 | const parentModule = /** @type {Module} */ (moduleGraph.getParentModule(dep)); |
| 323 | const exportsInfo = moduleGraph.getExportsInfo(parentModule); |
| 324 | |
| 325 | if ( |
| 326 | name |
| 327 | ? exportsInfo.getUsed(name, runtime) === UsageState.Unused |
| 328 | : exportsInfo.isUsed(runtime) === false |
| 329 | ) { |
| 330 | const mode = new ExportMode("unused"); |
| 331 | |
| 332 | mode.name = name || "*"; |
| 333 | |
| 334 | return mode; |
| 335 | } |
| 336 | |
| 337 | const importedExportsType = importedModule.getExportsType( |
| 338 | moduleGraph, |
| 339 | /** @type {BuildMeta} */ |
| 340 | (parentModule.buildMeta).strictHarmonyModule |
| 341 | ); |
| 342 | |
| 343 | const ids = dep.getIds(moduleGraph); |
| 344 | |
| 345 | // Special handling for reexporting the default export |
| 346 | // from non-namespace modules |
| 347 | if (name && ids.length > 0 && ids[0] === "default") { |
| 348 | switch (importedExportsType) { |
| 349 | case "dynamic": { |
| 350 | const mode = new ExportMode("reexport-dynamic-default"); |
| 351 | |
| 352 | mode.name = name; |
| 353 | |
| 354 | return mode; |
| 355 | } |
| 356 | case "default-only": |
| 357 | case "default-with-named": { |
| 358 | const exportInfo = exportsInfo.getReadOnlyExportInfo(name); |
| 359 | const mode = new ExportMode("reexport-named-default"); |
| 360 | |
| 361 | mode.name = name; |
| 362 | mode.partialNamespaceExportInfo = exportInfo; |
| 363 | |
| 364 | return mode; |
| 365 | } |
| 366 | } |
nothing calls this directly
no test coverage detected