
Security News
Vite Releases Technical Preview of Rolldown-Vite, a Rust-Based Bundler
Vite releases Rolldown-Vite, a Rust-based bundler preview offering faster builds and lower memory usage as a drop-in replacement for Vite.
import-move-codemod
Advanced tools
This babel plugin should be used as codemod for bulk import refactorings a.k.a module move refactorings
Codemod to move imports from one module to another. Super useful in huge monorepos or huge migrations of 3rd party packages.
Inside your project root run
For npm
npm i import-move-codemod --save-dev
or for yarn
yarn add import-move-codemod --dev
or for pnpm
pnpm add import-move-codemod --D
Before the run you need to create a file with a config, let say codemod.json
{
"module": {
"from": "one",
"to": "two"
},
"specifiers": ["One"]
}
Then for example to run codemod against all the files in /src
run
npx @codemod/cli -p import-move-codemod -o import-move-codemod=@codemod.json --printer prettier /src
{
module: {
from: "one",
to: "two"
},
specifiers: ["One"]
}
import { One } from 'one'
// ↓ ↓ ↓ ↓ ↓ ↓
import { One } from 'two';
{
module: {
from: "one",
to: "two"
},
specifiers: ["One", "Two"]
}
import { One, Two } from 'one'
// ↓ ↓ ↓ ↓ ↓ ↓
import { One, Two } from 'two';
import { One as OneA, Two as TwoA } from 'one'
// ↓ ↓ ↓ ↓ ↓ ↓
import { One as OneA, Two as TwoA } from 'two';
{
module: {
from: "one",
to: "two"
},
specifiers: ["Two"]
}
import { One, Two } from 'one'
// ↓ ↓ ↓ ↓ ↓ ↓
import { Two } from 'two';
import { One } from 'one';
{
module: {
from: "one",
to: "two"
},
specifiers: ["default", "One", "Two"]
}
import ADefault, { One, Two, Three } from 'one'
// ↓ ↓ ↓ ↓ ↓ ↓
import ADefault, { One, Two } from 'two';
import { Three } from 'one';
{
module: {
from: "one",
to: "two"
},
specifiers: ["default", "Two"]
}
import One, { Two } from 'one'
// ↓ ↓ ↓ ↓ ↓ ↓
import One, { Two } from 'two';
{
module: {
from: "one",
to: "two"
},
specifiers: ["*"]
}
import ADefault, { One, Two, Three } from 'one'
// ↓ ↓ ↓ ↓ ↓ ↓
import ADefault, { One, Two, Three } from 'two';
{
module: {
from: "one",
to: "two"
},
specifiers: {
One: "OneR",
Two: "TwoR"
}
}
import ADefault, { One, Two } from 'one'
// ↓ ↓ ↓ ↓ ↓ ↓
import { OneR, TwoR } from 'two';
import ADefault from 'one';
import { One, Two } from 'one'
// ↓ ↓ ↓ ↓ ↓ ↓
import { OneR, TwoR } from 'two';
{
module: {
from: "one",
to: "two"
},
specifiers: { default: "One" }
}
import One, { Two } from 'one'
// ↓ ↓ ↓ ↓ ↓ ↓
import { One } from 'two';
import { Two } from 'one';
import One from 'one'
// ↓ ↓ ↓ ↓ ↓ ↓
import { One } from 'two';
{
module: {
from: "one",
to: "two"
},
specifiers: ["default"]
}
import ADefault, { One, Two, Three } from 'one'
// ↓ ↓ ↓ ↓ ↓ ↓
import ADefault from 'two';
import { One, Two, Three } from 'one';
import One from 'one'
// ↓ ↓ ↓ ↓ ↓ ↓
import One from 'two';
{
module: {
from: "one",
to: "two"
},
specifiers: {
One: "default"
}
}
import { One } from 'one'
// ↓ ↓ ↓ ↓ ↓ ↓
import One from 'two';
FAQs
This babel plugin should be used as codemod for bulk import refactorings a.k.a module move refactorings
The npm package import-move-codemod receives a total of 3,042 weekly downloads. As such, import-move-codemod popularity was classified as popular.
We found that import-move-codemod demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Vite releases Rolldown-Vite, a Rust-based bundler preview offering faster builds and lower memory usage as a drop-in replacement for Vite.
Research
Security News
A malicious npm typosquat uses remote commands to silently delete entire project directories after a single mistyped install.
Research
Security News
Malicious PyPI package semantic-types steals Solana private keys via transitive dependency installs using monkey patching and blockchain exfiltration.