({ ast, usedDependencyMap })
| 289 | */ |
| 290 | const rewriteImports = |
| 291 | ({ ast, usedDependencyMap }) => |
| 292 | (bin) => |
| 293 | editWithAST(ast, bin, { |
| 294 | /** |
| 295 | * Processes the provided path. |
| 296 | * @param {NodePath<ModuleImport>} path path |
| 297 | */ |
| 298 | ModuleImport(path) { |
| 299 | const result = usedDependencyMap.get( |
| 300 | `${path.node.module}:${path.node.name}` |
| 301 | ); |
| 302 | |
| 303 | if (result !== undefined) { |
| 304 | path.node.module = result.module; |
| 305 | path.node.name = result.name; |
| 306 | } |
| 307 | } |
| 308 | }); |
| 309 | |
| 310 | /** |
| 311 | * Add an init function. |