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

100
Views
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 answers
Answer question

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 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!