Change import
Recipe ID
org.openrewrite.javascript.change-importArtifact@openrewrite/rewriteChanges an import from one module/member to another, updating all type attributions.
Single recipeMSAL
Usage
You’ll need the Moderne CLI configured before running the command below.
mod run . --recipe org.openrewrite.javascript.change-import --recipe-option "oldModule=react-dom/test-utils" --recipe-option "oldMember=act" --recipe-option "newModule=react"If the recipe isn’t available locally, install it with:
mod config recipes npm install @openrewrite/rewriteOptions
| Name | Type | Description |
|---|---|---|
oldModulerequired | | The module to change imports from e.g. react-dom/test-utils |
oldMemberrequired | | The member to change (or 'default' for default imports, '*' for namespace imports) e.g. act |
newModulerequired | | The module to change imports to e.g. react |
newMember | | The new member name. If not specified, keeps the same member name. e.g. act |
newAlias | | The local name to bind the new member under. Defaults to the alias the import already had, or to the new member name where it had none. e.g. act |