I have several apps in my Angular monorepo project. Also there are about 5 libraries I've written to use across the apps.
What I want to know is how to better build/architect these libraries.
The ins are follows:
- Libraries are for internal usage only (meaning no publishing or using in other apps but those in
projects
folder) - Libraries have different dependencies like
lodash
andRxJs
- One library can import another inside itself
What I've done so far:
- Specified the
umdModuleIds
in each library'sng-package.json
. - Specified
peerDependencies
on external libraries likelodash
andRxJs
- Set up my app build which has
prebuild
with about 5 commandsng build lib-name
combined via "&&" - I import Lodash in next way
import { cloneDeep } from 'lodash'
Now I see that my main.js
chunk is much bigger than it was before extracting some services/components/functions into external libraries. Now main.js
's size on prod build is 2.1 Mb which in my opinion is too big.
Also, I'm not sure whether it's worth making 3 different builds of each library (UMD, FESM2015, FESM5).
I import libraries from dist folder as it recommended in docs following next form import { LibService } from 'lib'
.