Reputation: 580
I have an Angular CLI 6 project, with contains 2 components:
When I want to use the library in the frontend project, I should use for example:
import { SomeLibModule } from "some-lib";
Instead, with IntelliJ, when I'm using auto-import feature (i.e. I'm typing SomeLibModule
and I'm hitting Alt + Enter), the specified import is:
import {SomeLibModule} from '../../projects/some-lib/src/lib/some-lib.module';
How can I change this behavior to prefer imports using their package name?
Here a simple repository to reproduce this behavior : https://github.com/lbar/ngcli-with-lib (the library import is in app.module.ts
).
Thank you.
Upvotes: 1
Views: 305
Reputation: 93828
You can try adding one more path mapping to your tsconfig.json
:
"paths": {
"some-lib": [
"dist/some-lib",
"projects/some-lib/src/lib/some-lib.module"
],
"some-lib/*": [
"dist/some-lib/*"
]
}
Upvotes: 3