I have two angular library NPM packages:
- A has basic components
- A-BC has components that build upon the components in A, with added features to integrate with BC library
Some components in A-BC
import from A
like import { MyThing } from 'A';
A-BC
's package.json is:
"peerDependencies": {
"A": 1.0.0,
"BC": 4.0.0
},
"devDependencies": {
"A": 1.0.0,
"BC": 4.0.0
}
My attempted development steps were to:
npm link --only=production
in (the built version of)A
npm link --only=production
in (the built version of)A-BC
- In
my-app
, runnpm link A
- In
my-app
, runnpm link A-BC
- Run
my-app
Compilation of my-app
fails when A-BC
can't find A
installed anywhere. They are both listed correctly in node_modules
right next to each other, as symlinked folders. I have tried this with preserveSymlinks
enabled in tsconfig.json
and angular.json
, but that did not help.
A
could be a direct dependency of A-BC
, but:
- Both
A
andA-BC
have aforRoot()
called that is required for the package to function properly for the app it is installed in. I don't know of a way to pass theforRoot()
parameters dynamically from theA-BC
forRoot()
to theA
forRoot()
my-app
needs to use components fromA
AND components fromA-BC
.- If
A
was a direct dependency, I don't know how I would be able to developA-BC
locally--which can involve changing bothA-BC
and occasionallyA
.
Currently my band-aid solution is to:
- Publish
A
as a beta version - Install the beta version in
A-BC
andmy-app
- Link
A-BC
tomy-app
vianpm link
- Publish a new beta version of
A
if changes need to be made, then install that inmy-app
andA-BC
again
There may be an alternative workflow around installing A
via NPM's support for local files, but I'm not sure.