0

I know it's possible to require other modules, but how can you tell aura to process a module as an extension?

Background:

For a large project I'm working on, I'm using aura extensions to modify a jQuery instance I'm keeping in the app's sandbox. A typical extension would look something like this, where plug1 and plug2 are jQuery plugins.

define({
    require : {
        paths : {
            'jquery.plug1' : 'lib/plug1',
            'jquery.plug2' : 'lib/plug2'
        },
        shim : {
            'jquery.plug1' : {
                exports : 'jQuery'
            },
            'jquery.plug2' : {
                deps : ['jquery.plug1'],
                exports : 'jQuery'
            }
        }
    },
    initialize : function(app) {
        var $ = app.sandbox.$;
        $ = require('jquery.plug1');
        app.sandbox.$ = require('jquery.plug2');
    }
});

For tightly coupled plugins I can specify dependencies as shown here, but I'd rather avoid this for more loosely coupled components.

jmac
  • 7,078
  • 2
  • 29
  • 57
turtlemonvh
  • 9,149
  • 6
  • 47
  • 53
  • I don't understand. Do you have a module and want to use it as an extension? What does jQuery has to do with it? – fiatjaf Jan 02 '14 at 12:09
  • The code above would be the code for the extension. The extension simply defines a version of jQuery (available at `app.sandbox.$`) that has plugin 1 and plugin 2 loaded. This is useful because the application may need multiple versions of jquery with incompatible plugins, and this pattern allows me to separate those versions. The problem I was running in to is that some extensions need other extensions loaded first before they can work (just as some components need to be loaded after other components). I couldn't see how to define those dependencies between extensions. – turtlemonvh Jan 03 '14 at 15:00
  • This seems more like an AMD question than an Aura question. I think I would, in case of an extension that requires another _module_ (and this module requires another, for example), define them all as plain AMD modules and load the immediately required by the extension directly into it. – fiatjaf Jan 06 '14 at 13:47
  • (I know this doesn't answer your question, but as Aura is structured on AMD loaders, it doesn't bothers to "aurify" every aspect and issue of AMD, so we are left into using pure AMD solutions, and it is not so bad)(but I am not a great connoisseur of neither Aura or AMD, so don't take me serious). – fiatjaf Jan 06 '14 at 13:50

0 Answers0