| 255 | */ |
| 256 | const rewriteExportNames = |
| 257 | ({ ast, moduleGraph, module, externalExports, runtime }) => |
| 258 | (bin) => |
| 259 | editWithAST(ast, bin, { |
| 260 | /** |
| 261 | * Processes the provided path. |
| 262 | * @param {NodePath<ModuleExport>} path path |
| 263 | */ |
| 264 | ModuleExport(path) { |
| 265 | const isExternal = externalExports.has(path.node.name); |
| 266 | if (isExternal) { |
| 267 | path.remove(); |
| 268 | return; |
| 269 | } |
| 270 | const usedName = moduleGraph |
| 271 | .getExportsInfo(module) |
| 272 | .getUsedName(path.node.name, runtime); |
| 273 | if (!usedName) { |
| 274 | path.remove(); |
| 275 | return; |
| 276 | } |
| 277 | path.node.name = /** @type {string} */ (usedName); |
| 278 | } |
| 279 | }); |
| 280 | |
| 281 | /** @typedef {Map<string, UsedWasmDependency>} Mapping */ |
| 282 | |