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

732
Visualizações
Angular 12 warning Critical dependency: the request of a dependency is an expression

I'm getting these warnings after ng build (Angular 12):

./node_modules/@angular/core/__ivy_ngcc__/fesm2015/core.js:35289:13-34 - Warning: Critical dependency: the request of a dependency is an expression

./node_modules/@angular/core/__ivy_ngcc__/fesm2015/core.js:35301:13-100 - Warning: Critical dependency: the request of a dependency is an expression

I'm using @angular-builders/custom-webpack to extract the moment.js from the initial bundle.

If I disabled the @angular-builders/custom-webpack, then everything goes well and the warnings disappear.

Also, the warnings disappeared if I add the following within custom-webpack.config.js:

new webpack.ContextReplacementPlugin(
    /\@angular(\\|\/)core(\\|\/)__ivy_ngcc__(\\|\/)fesm2015/,
    path.join(__dirname, './src'),
    {}
),

So kindly, what causing these warnings exactly? and is there any other solution to handle it without adding the plugin to the webpack config like above? Thanks.

over 4 years ago · Santiago Trujillo
2 Respostas
Responde à pergunta

0

I got the following feedback from the Angular dev team:

This comes from code in the deprecated SystemJsNgModuleLoader and is normally suppressed when using the CLI builders, which also uses ContextReplacementPlugin. I don't think there is an alternative to suppress them, other than to not suppress them and ignore the warnings.

https://github.com/angular/angular/issues/43092#issuecomment-895848535

So I ended up using the mentioned CLI builders code as the following within custom-webpack.config.js:

// Always replace the context for the System.import in angular/core to prevent warnings.
new ContextReplacementPlugin(
    /\@angular(\\|\/)core(\\|\/)/,
    path.join(__dirname, '$_lazy_route_resources'),
    {}
),
over 4 years ago · Santiago Trujillo Relatório

0

When using a custom ContextReplacementPlugin in Angular 12, take care about this:

If in your custom configuration you specify a plugin that is already added by Angular CLI then by default the two instances will be merged.

I use the ContextReplacementPlugin to exclude moment.js locales. After upgrading to Angular 12, all locales were removed, because it's config was merged with $_lazy_route_resources. I solved it by setting replaceDuplicatePlugins to true.

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