Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Circular Dep error when calling environment.ts from within a library #2851

Closed
Abdallah-khalil opened this issue Apr 12, 2020 · 3 comments
Closed
Labels

Comments

@Abdallah-khalil
Copy link

Abdallah-khalil commented Apr 12, 2020

I'm currently having a situation where i'm using the environment.ts file from my app into more than one library and those libraries are used in this app . which was going fine with angular 8 , but now it's showing a circular dep error . Is there a way to get a round that ?

in my tsconfig.json file i have this code added to paths
"@global-env/*": ["apps/web/src/environments/*"],

i have a library called core-data-access where i call the environment
import { environment } from '@global-env/environment';

then i import some services from the core-data-access library in my web app

@Abdallah-khalil Abdallah-khalil changed the title Circular Dep error when calling environment.ts from with a library Circular Dep error when calling environment.ts from within a library Apr 12, 2020
@jaysoo
Copy link
Member

jaysoo commented Apr 15, 2020

I would extract the shared environments to a separate util library. You shouldn't be mapping subdirectories of the web app as another library.

Nx will resolve your mapping in your tsconfig.json back to the web app, so you essentially end up with web -> core-data-access -> web dependency chain.

Let us know if you need any more help!

@jaysoo jaysoo closed this as completed Apr 15, 2020
@VanTigranyan
Copy link

@jaysoo Hi. Could you suggest how one can do that? Angular takes care of replacing environment.ts with environment.prod or dev.ts depending on build type and I cannot understand how we would do that when building a library

@github-actions
Copy link

This issue has been closed for more than 30 days. If this issue is still occuring, please open a new issue with more recent context.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 21, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

3 participants