CommonJS auto-require Handlebars
nicovalencia opened this issue · 2 comments
nicovalencia commented
Is there a reason for not having an auto-require option for Handlebars when using the CommonJS compiled version?
For example:
options: {
namespace: false,
commonjs: true,
require: 'handlebars'
}
This would add a var Handlebars = require('handlebars');
to the compiled template module, so the user doesn't have to require and passthrough the Handlebars library in every module that needs templates.
Current usage:
var Handlebars = require('handlebars');
var Templates = require('./templates')(Handlebars);
Proposed change would allow:
var Templates = require('./templates');
Am I missing something, or would this have a decent use case? I'd be happy to contribute, just wanted to make sure I'm not missing something that already exists.
dwick commented
+1
This should be a default behavior for commonjs. I'd argue that an option is unnecessary (namespace should probably also default to false
for commonjs too).