requirejs / almond

A minimal AMD API implementation for use after optimized builds
Other
2.42k stars 168 forks source link

add support to Ember resolver dependency on requirejs._eak_seen #97

Closed mattma closed 9 years ago

mattma commented 9 years ago

Hi @jrburke,

requirejs._eak_seen option is used ONLY for Ember-CLI fashion application. In the current Ember-CLI, it uses custom AMD module loader loader.js. It essentially does the same thing that Almond is doing. Lightweight AMD module loader.

The only difference that Loader.js is used inside Ember-Resolver so that It requires a custom option property called _eak_seen. Used ONLY inside Ember application to determine that module is loaded, ready to be DI.

Could we add the support for this property, _eak_seen. I have been used custom version for a while in my project ember-rocks and have to manually update myself each time when you release the new version. I want to take advantage of bower.json if possible so that I do not need to include a plain almond.js file.

Hopefully that you could add this property to support Ember.js Application. Much appreciated.

jrburke commented 9 years ago

Thank you for the well-explained pull request. However, I would prefer to not include this in the base almond.js as I would not want other almond consumers to depend on this. The "seen" is also concerning on a basic AMD module level. Not sure that should be needed, and feels outside the contract promised by AMD loaders.

You could provide your own copy/fork though, and it could be an automated concatenation, to save you some manual work. This sort of file could be appended to the base almond.js to get the same effect:

(function() {
  var oldDefine = define,
    seen = requirejs._eak_seen = {};
  define = function(name, deps, callback) {
    seen[name] = true;
    return oldDefine(name, deps, callback);
  };
  define.amd = oldDefine.amd;
}());
mattma commented 9 years ago

Thank you for the code snippet. I will do just as you said. Thanks again. @jrburke

mattma commented 9 years ago

It works great. Thank you!