cocos2d jsb implemented a require function to connec js files in the project.
require is simply to find and execute the script. But this can be very dangerous for large project with many js files.
- if you require a file twice the script is executed twice. You need to add some flag the prevent the code from executing the second time.
- It’s very easy to override global variables defined in other files.
So my advice is to implement a require function like Node.js did.