Angular import custom lib from dist like it's installed

Viewed 207

In an older project I have this structure:

_ dist
_ e2e
_ node_modules
_ projects
| _ lib1
| _ lib2
| _ lib3
| _ demo
_ all configuration file (like angular.json, tsconfig.json ecc)

Assume that lib3 is a main lib that inlcude all other lib. When I import something from lib1 or lib2 in lib3 i use simply import { x } from "lib1" and if lib1 is installed, lib3 search the module in node_modules instead if lib1 isn't installed lib3 search the module in dist folder! So if i build lib1 I can import it like it was installed.

Now I create a new project with the same structure but I don't know why, when lib1 isn't installed lib3 not serach it in dist folder so if I would to import lib without installing it i must use the "runtime" import going up with the path import { x } from "../../lib1".

There is an option that let me to have in second project the same behavior of the first project?

1 Answers

You cannot import it directly, as lib1, lib2, and lib3 are completely different projects placed inside the same workspace. So to use anything from library 1, you need to build it first and then you need to add it inside lib3 like we import libraries.

Related