You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently, each gladius extension includes its own version of almond.js, which means that each extension is using its own AMD loader. As a result, each extension needs to include code from gladius-core that it uses, resulting in possibly-out-of-date code being used and extra code lying around.
This is, IMO, one of the most important things to fix about gladius, as it is very very likely to break behavior between extensions, and makes using gladius for a game awkward.
One solution I can think of is attaching the almond.js functions define and require to the Gladius object and having the extensions pull them in within their wrapper:
(function(root,factory){if(typeofexports==="object"){// Nodemodule.exports=factory(require,define);}elseif(typeofdefine==="function"&&define.amd){// AMD. Register as an anonymous module.define(factory.bind(undefined,require,define));}elseif(root.Gladius){// Browser globalsvaramd=root.Gladius.amd;root.Gladius["gladius-cubicvr"]=factory(amd.require,amd.define);}else{thrownewError("failed to load gladius-cubicvr; depends on Gladius");}}(this,function(require,define){// ...varextension=require("gladius/cubicvr");returnextension;}));
The snippet above is untested, mostly looking for feedback before seeing if it'd actually work. I think it should work.
The gladius/cubicvr thing above should be achievable with some path magic, especially now that lib doesn't need to be included during the build step for extensions.
While we're at it, we should make that wrapper automatically load the extension into Gladius. :D
This way we get a project-wide benefit of using AMD without repeating code, yet still don't depend on the outside world to use an AMD loader.
The text was updated successfully, but these errors were encountered:
Currently, each gladius extension includes its own version of almond.js, which means that each extension is using its own AMD loader. As a result, each extension needs to include code from gladius-core that it uses, resulting in possibly-out-of-date code being used and extra code lying around.
This is, IMO, one of the most important things to fix about gladius, as it is very very likely to break behavior between extensions, and makes using gladius for a game awkward.
One solution I can think of is attaching the almond.js functions
define
andrequire
to the Gladius object and having the extensions pull them in within their wrapper:gladius/cubicvr
thing above should be achievable with some path magic, especially now that lib doesn't need to be included during the build step for extensions.This way we get a project-wide benefit of using AMD without repeating code, yet still don't depend on the outside world to use an AMD loader.
The text was updated successfully, but these errors were encountered: