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

219
Views
Load a module in requirejs and inject it with a specific dependency

I need moduleA and moduleB to have a different context. moduleA and moduleB are exisisting javascript libraries which both request a 'context' module.

Is it possible when we require moduleA or moduleB to pass in a different version of context Or another way to differentiate

// EXISTING libraries, can not alter:

// moduleA uses 'context'
define(["context"], function (context) {}); 

// moduleB also uses 'context'
define(["context"], function (context) {}); 


// MY code:

// ❌. Can define a 'global' context here, but it will be the same for both.
define("context", () => {});

// ✅ Possible to let moduleA require a different context then module B ??
// On requiring module A, or a different way 

requirejs(["moduleA"],()=>{ 
    // console.log('run when moduleA and thus context are loaded
});  

requirejs(["moduleB"],()=>{    
    // console.log('run when moduleB and thus context are loaded
});  
about 4 years ago · Juan Pablo Isaza
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!