Hi
I'm using requirejs for a project and I have 2 modules:
app.js looks like this:
//source code for app.js require(['a.js', 'b.js'], function( a, b ) { a.x = 2;//this will fail because 'a' is not defined });
Now the question is: what is the simplest way to require() both modules in app.js? I can't do it like:
//source code for app.js require(['b.js', 'a.js'], function( b ) { a.x = 2;//it works because module 'a' defines a global variable named 'a' b.x = 2;//this will fail because module 'b' is loaded before 'a' so it doesn't work });
This is standard fare for AMD loaders. Most of the time, a shim will not be needed. Your source for app.js is correct but you didn't show your source for b.js. Since you have control over b.js, it should be written as an AMD module with a dependency on a.js
// source code for b.js // You have to use define, not require, and the dependency on a.js must be here rather than via a nested or internal require define(['a.js'], function(a){ // your code for b.js });
This will ensure that a.js is loaded before b.js when app.js is ready to execute.
Should this thread be moved to AMD Forums Developer?
Can you clarify what exactly you are talking about?
Does this have to do with something like OpenCL or OpenGl ?
What exactly do you mean by "AMD Modules"? Is this related to AMD hardware or software or something else?
Maybe you can help this other User that just opened a RequireJS thread at AMD Forums: https://community.amd.com/t5/general-discussions/compile-requirejs-to-remove-amd-dependency/m-p/5237...