I am working on a project where multiple frontends share a common library.
The module dependencies for these projects are managed using npm.
In the package.json file of each project, I specify:
"dependencies": {
"mylib": "file:../<...path...>/mylib",
...other dependencies...
},
I utilize "mylib" for two main purposes :
- sharing certain classes;
- sharing common dependencies (mostly Angular).
Previously, with npm version 3.3.12, after running npm install
, the Angular dependencies of mylib were directly under the node_modules directory of my top level projects.
For example:
node_modules
@angular
core
common
...
mylib
However, in the current npm version 5.4.2, the structure has changed to:
node_modules
mylib
node_modules
@angular
core
common
This change is causing issues in my build process, requiring additional TypeScript configuration such as:
"baseUrl": "",
"paths": {
"@angular/common": ["node_modules/mylib/node_modules/@angular/common/"],
"@angular/core": ["node_modules/mylib/node_modules/@angular/core/"],
...
}
This becomes cumbersome when configuring for AOT, rollup, etc...
I attempted to simplify this by using npm dedupe. However, due to the numerous dependencies, it takes over 10 minutes for just one project:
npm dedupe
...
...
removed 824 packages and moved 1020 packages in 623.196s
Is there an efficient standard way to achieve the previous flattening of dependencies without the time-consuming process of npm dedupe?