Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

408
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda