
Product
Rust Support Now in Beta
Socket's Rust support is moving to Beta: all users can scan Cargo projects and generate SBOMs, including Cargo.toml-only crates, with Rust-aware supply chain checks.
@itlabs/ts-import-move
Advanced tools
It can be a lot of work to update all imports, if you moved a class, function, component or whatever from one library of your monorepo to another. If you are using relative paths for the imports, tools like visual studio code would ask you to perform these import updates for you. But not if you are using typescript paths aliases in your monorepo e.g.
"paths": {
"@itlabs/my-package": ["packages/my-package/src/index.ts"],
"@itlabs/my-new-package": ["packages/my-new-package/src/index.ts"]
}
In this case, you just found the tool that will helps you :)
A CLI is coming soon.
Just install those two packages npm i -D @itlabs/ts-import-move ts-morph
. And copy and adapt this snippet somewhere to your tooling scripts.
import { Project } from 'ts-morph';
import { tsImportMove } from '@itlabs/ts-import-move';
async function move(): Promise<void> {
const project = new Project({ tsConfigFilePath: 'path/to/tsconfig.json' });
tsImportMove(project, {
imports: ['ObjectToMove'],
sourcePackage: '@itlabs/my-package',
targetPackage: '@itlabs/my-new-package',
});
await project.save();
}
Check the ts-morph docs for further information how to load your typescript project.
FAQs
move typescript imports from one package to another
We found that @itlabs/ts-import-move 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.
Product
Socket's Rust support is moving to Beta: all users can scan Cargo projects and generate SBOMs, including Cargo.toml-only crates, with Rust-aware supply chain checks.
Product
Socket Fix 2.0 brings targeted CVE remediation, smarter upgrade planning, and broader ecosystem support to help developers get to zero alerts.
Security News
Socket CEO Feross Aboukhadijeh joins Risky Business Weekly to unpack recent npm phishing attacks, their limited impact, and the risks if attackers get smarter.