Home > database >  Replacing resource import from old library by import from new library
Replacing resource import from old library by import from new library

Time:02-18

I had run into a problem in my javascript project. I was using a resource from a library in my project, and I need to replace all instances of it by a resource of the same name, but from another library. The problem is that I'm importing this resource in more than a hundred files alongisde other resources.

What I need is to replace all instances of something that looks like this:

import {someResource, changedResource, anotherResource} from 'old-library'

By this:

import {someResource, anotherResource} from 'old-library'
import {changedResource} from 'new-library'

I need to keep the old imports that includes this resource that I want to get from the new library as well as importing the changed resource from the new library. Is that a way I can do that in Visual Code or I'll need to use some script in order to do that?

CodePudding user response:

right click project root folder ---> find in folder ---> expand the filter

for every "import {someResource, anotherResource} from 'old-library'" you should replace with "import {someResource, anotherResource} from 'old-library' import {changedResource} from 'new-library'"

example

enter image description here

becomes

enter image description here

  • Related