CommonJS aware loader option?

Post your help queries and engine programming questions here

CommonJS aware loader option?

Postby laurie » Mon Aug 11, 2014 11:07 pm

Since the ige code and all code written to work with it is CommonJS module aware, wouldn't it make sense to make the client-side loader CommonJS compliant too? That would provide consistency across client and server, and get rid of the massive pollution of the global namespace on the client side.

Maybe there's already an option I can use to put the loader into CommonJS mode and let me use require() throughout, as I'm used to doing in Node?

Thanks for any insights,

Laurie
laurie
 
Posts: 2
Joined: Tue Jul 22, 2014 6:05 pm

Re: CommonJS aware loader option?

Postby robaldred » Fri Aug 15, 2014 6:30 pm

Im not sure i follow.
CommonJS is just the default way you use node, using modules and exports.

Are you suggesting dependency injection? It would be a fairly big job to AMDify the entire framework.

If you're interested in taking this on. Please fork and discuss on GitHub. IgeLoader would need to be completely rewritten.
I don't work for Irrelon. All comments are my own.
I would strongly encourage anyone building production projects with Isogenic to buy a premium licence, it costs very little and will help towards continued development of the engine. Irrelon have spent thousands of hours developing this wonderful platform with many features found in AAA game engine.
User avatar
robaldred
 
Posts: 243
Joined: Wed Oct 23, 2013 8:09 pm
Location: Manchester, England

Re: CommonJS aware loader option?

Postby laurie » Mon Aug 18, 2014 5:44 am

No, I'm not suggesting AMD; that would be a huge effort for sure. But every file I've looked at already has a guarded CommonJS export (by guarded, I mean that it checks the module.exports variable is defined before setting it). So server side, all you need to do is use require() everywhere (unless there's any third party code being loaded that isn't wrapped as a CommonJS module).

Client-side, it's a little harder but there are existing solutions.

I read the loader code and realized that there's nothing like I was hoping for; it's a simple <script> tag injection system. For what I want (mainly, keeping the global scope clean and avoiding naming conflicts on larger projects) I can probably just take advantage of the built-in CommonJS awareness to leverage something like Browserify.

I just wanted to check before going down that path if there was anything already in the engine, or on the roadmap, to solve the problem without building my own solution.

Thanks,

Laurie
laurie
 
Posts: 2
Joined: Tue Jul 22, 2014 6:05 pm

Re: CommonJS aware loader option?

Postby robaldred » Mon Aug 18, 2014 9:09 am

It seems like you know what you're doing. Go for it. The current loader isn't the best and could certainly be improved. There are no current plans as far as im aware to do anything with the loader.

Please do let us know how you get on.
I don't work for Irrelon. All comments are my own.
I would strongly encourage anyone building production projects with Isogenic to buy a premium licence, it costs very little and will help towards continued development of the engine. Irrelon have spent thousands of hours developing this wonderful platform with many features found in AAA game engine.
User avatar
robaldred
 
Posts: 243
Joined: Wed Oct 23, 2013 8:09 pm
Location: Manchester, England


Return to Help & Questions

Who is online

Users browsing this forum: No registered users and 1 guest
cron