Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

411
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda