Reputation: 13693
I have a testing angular project (lets call it project1) where I'm writing my components. I have to use routing in this project in order to navigate from component to component (organizational and esthetic's purpose).
I have another angular project (lets call it project2) which HAS in its node_ modules the component project-project1 (made available by referencing it through package.json) in project2.
Problem
When I have to fetch the components from project1 to project2 (simple angular forRoot routing in project2), a problem appears with forRoot conflict which is now in my project1 and project2.
The problem disappears once I remove the routing from project1 in the node_modules from project2 but thats time consuming.
Is there a way to solve this problem, other than mannualy deleting the routes in my dependency (project1) or commenting code just to make project2 work?
Upvotes: 0
Views: 90
Reputation: 2352
Solution 1
Add a conditional statement for the forRoot() method inside the project1. So everytime you're building it as a standalone app it will do forRoot() and when built as a npm dependency- forChild().
// this is how you're getting the environment
import { environment } from './environment';
Solution 2
Add lazy-loading inside project1 so the cli won't bundle all of the modules as one, but as separate. After that import OR lazy-load project1 modules(not the root, it still has the forRoot()) inside project2, referencing it from the node_modules.
Beware of this issue if doing lazy-loading from node_modules.
If you need more help, please add some code.
Upvotes: 1