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

102
Visualizações
Ignore and skip requirejs dependency

In my webapplication I have ReactJS bundled together with the my code and included as into html page. We also have set of modules that we load using requireJs. And one of those modules is built using WebPack as umd target.

Whenever the client tries to load that module using requireJS, requirejs also tries to load React and ReactDOM because of that line in the module:

define(["React", "ReactDOM"], factory);

But I don't want require to donwload React and ReactDOM since it already loaded. How to I let requireJS know that this module is already loaded and there is no need to load it again?

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

0

You can define a set of named dummy modules, prior to loading your module.

define('React', function() {
    // return the React global (if there is one)
    return React; 
});

define('ReactDOM', function() { 
    // return the ReactDOM global (if there is one)
    return ReactDOM; 
});

That will "trick" Require into thinking they are already loaded... which they are.

Note: I'm not familiar with React so you may need to return something different. It is going to depend on how you've included React and ReactDOM in you webpage prior to this.

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