Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

407
Views
Nx & Angular: resolve dependency in module

My plan was to use the NgRx related modules (store, effects, devtools, etc.) in a library module, not in the app-module.

The NgRx related modules are imported into the libs/.../shell-module, which in turn is imported into the app-module.

The problem

I would like to provide the environment.production variable in my libs, but I have no idea how to get it in the shell-module without using a relative/absolute import path.

libs/.../shell.module.ts:

import { environment } from '../../../../../../../apps/test-app/src/environments/environment';

imports:[
...
!environment.production ? StoreDevtoolsModule.instrument() : []
...
]

Questions

  1. Is it not possible to resolve the environment.production variable in an Angular module?
    I know how to inject stuff into components, but how do you inject it into modules?
    The .forRoot() config trick didn't work, because the imports array in the module decorator is out of scope of the module class.

  2. is there another way to do this without tight coupling the environment.ts file and my libs modules?

  3. Defining an '@' path for environment.ts in tsconfig.json, and then importing it into the module still counts as tight coupling ... right?

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

for this I'd generally recommend moving the environment configuration down into a library as well.

For example, you may have libs/shared/env/environment.*.ts, or libs/domain/env/environment.*.ts. You'll need to update the build steps for your app to ensure that fileReplacements is setup to handle these. Then in your app you can use import {environment} from '@company/shared/eng'.

This would look a little different if using buildable libs, since you'd want to handle the fileReplacements in the libraries build definition.

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!