I've spent all morning on ts-paths to shorten my import paths.
I can confirm that custom paths work IF you setup barreling (an index file exports your modules)
root
├── client
│ ├──tsconfig.json
│ ├── src
│ ├──app
│ ├── shared
│ ├── services
│ ├── some.service.ts
├── common
│ ├── index.ts // exports * from each file
My NG8 tsconfig.ts file:
"compilerOptions": {
"baseUrl": ".",
"paths": {
"@common": ["../common"], // works with barreling
"@services": ["./src/app/shared/services"] // only works with barreling
},
@services does not work... unless I setup barreling
(adding an index.ts file in shared folder with export * from './some.service';)
@common works out of the box because of barreling like above.
Am I missing something or is everything I've read leaving out a requirement to export your modules in this way?
My research:
https://angularfirebase.com/lessons/shorten-typescript-imports-in-an-angular-project/
https://www.typescriptlang.org/docs/handbook/module-resolution.html#path-mapping
How to use paths in tsconfig.json?
many more...
./Just"src/app/shared/services". Though I think there should be atsconfig.jsonin the root - C_Ogoosrc/app/shared/servicesbreaks it... Unless the index with exports exist in which case it still works. - Ben Racicot.../services/some-file.ts- C_Ogoo