Closed reinseth closed 11 years ago
This looks like a good approach. Unfortunately (for my setup) it looks like the process of extracting the config strips the init function that can be configured to run once a library has been shimmed.
My config is as follows:
require.config({
// ... paths etc.
shim: {
'cocktail': {
deps: ['backbone', 'backbone.layoutmanager'],
exports: 'Cocktail',
// This function is removed from the resulting config
init: function () {
Cocktail.patch(Backbone);
}
}
}
});
Any ideas?
That is not good. Maybe it's a bug in r.js. I'll look into it.
The problem is not with r.js, but is caused by doing JSON.stringify() on the config object (which in effect removes any function declarations). I'll figure out a different way to do this.
Thanks for spotting this, though.
I met same issue and fixed in my fork, check it out. https://github.com/jsoverson/grunt-template-jasmine-requirejs/pull/9
On Thu, Apr 11, 2013 at 4:41 PM, reinseth notifications@github.com wrote:
The problem is not with r.js, but is caused by doing JSON.stringify() on the config object (which in effect removes any function declarations). I'll figure out a different way to do this.
Thanks for spotting this, though.
— Reply to this email directly or view it on GitHubhttps://github.com/jsoverson/grunt-template-jasmine-requirejs/pull/13#issuecomment-16222836 .
@cloudchen Didn't see your comment before I had it fixed myself. I used a slightly different solution though: I used the "replacer" argument to JSON.stringify to hook into the serialization.
+1 I'm using this fork, and it's a great new option. Greatly reduces redundancy in the grunt config.
+1, I think it is a missing key feature
Is this included in the last production version? I tried to use the last version (0.1.1) and it wasn't working
This builds on the idea of #10 to let the user include a require configuration from an external file.
This pull request includes tools from r.js (the tools are copied from r.js instead of included as dependencies - see last comments on https://github.com/jrburke/r.js/issues/385). These tools are used to extract the config from
options.mainRequireConfigFile
and merge it withoptions.requireConfig
(note that the latter overrides the former).