I'm creating an Angular library and within tsconfig.lib.json
I've added the following paths
configuration:
"compilerOptions": {
"outDir": "../../out-tsc/lib",
"target": "es2015",
"declaration": true,
"inlineSources": true,
"types": [],
"lib": [
"dom",
"es2018"
],
"paths": {
"@fs/*": ["src/lib/*"]
}
}
However attempting to import things like:
import { Test } from '@fs/Test'
Does not work. Anyone know if Angular libraries support hte paths
configuration option within tsconfig.lib.json
?
Generally I use typescript-transform-paths
to perform path transformation on the compiled result, and I was hoping Angular had baked something like this in for libraries?
Try using the following pattern in your tsconfig.json file :
"paths": {
"@services/*": ["app/path/to/services/*"],
"@components/*": ["app/path/to/some/deeply/nested/component/*"],
"@environments/*": ["environments/*"]
},
Then when importing:
import { yourServiceClass } from "@services/yourServiceClass";
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.