0

I everyone, I have an Angular project structured like following

├── projects
│    ├── lib-1
│    ├── lib-2
│    ├── lib-wrapper
│    .
│    .
│
└── src
     ├── app
     ├── assets
     .
     .

in particular I not only develop library but also the app that incorporate them. So I have to develop library and test them in my app "runtime" without build them for every time, then I import my libraries in my modules app using the ugly import { a } from "../../../../lib-1/public-api.ts" import statements and when I have to build libraries and also app I have to change all import in the "consumer" form import { a } from "lib-1".

Notice that lib-wrapper imports lib-1 and lib-2 and then I import lib-wrapper in my app in the same way (runtime import when develop and compile import when build).

Since I have too much libraries and too much import in my app, did anyone know if there is a method to import in an absolute way my libraries in such a way that when I use ng serve I link directly to my lib and I can test it runtime and when I use ng build the import link to the installed library?

Notice that I cannot use only production configuration fileReplacements (I can use it to change the import in the src/app but not in library since libraries not support this option. So the question is mainly for the libraries.

I found something useful here questions 56949487 but I didn't understand well how to use that informations in my use case.

Edo2610
  • 184
  • 1
  • 9
  • tsconfig.json file: { "compilerOptions": { "baseUrl": "./", "paths": { "lib-1": ["projects/lib-1/src/public-api.ts"], "lib-2": ["projects/lib-2/src/public-api.ts"], "lib-wrapper": ["projects/lib-wrapper/src/public-api.ts"] } } } – onetwo12 Jan 16 '23 at 12:30
  • With this configuration, you can use the following imports in your application and libraries: import { a } from "lib-1"; import { b } from "lib-2"; import { c } from "lib-wrapper"; This is will work in both runtime and build time. – onetwo12 Jan 16 '23 at 12:31
  • In this way my app import the libraries like they are installed and if I develop on library I have to build and reinstall it to see changes. – Edo2610 Jan 16 '23 at 15:43
  • My previous comment is wrong, with these paths the imports link to the project folder correctly but when I run the demo application it needs all libraries installed and the app run the installed libraries despite the import links to the projects file – Edo2610 Jan 17 '23 at 13:20

0 Answers0