excludeHbsParser does not seem to have any effect
I followed the example.build.js found in the demo directory, but setting all of the pragmas still leaves me with the full Handlebars compiler built into my source.
Grepping 1.0.0 for excludeHbsParser gives no results other than the build config, so I don't think it's actually being used anywhere.
That's the (I think) objective thing I found, now if I may make a couple suggestions:
- The readme could be amended to provide something like the build config to show people how to optimize their build. I suspect most users have the entire Handlebars compiler built into their project
- Could we just adopt the same config as the requirejs text plugin, and use
stubModulesfor the optimized plugin? To do that you'd need to (a) not requirehbsin compiled templates and (b) get it to loadhandlebars.runtime.jswhich the compiled templates need, maybe by having users adjust theirpaths.config
I was able to achieve the right build without having to fork the code:
stubModules: ['hbs', 'hbs/underscore', 'hbs/json2'],
onBuildWrite: function (moduleName, path, contents) {
if (moduleName === 'hbs/handlebars') {
return grunt.file.read('vendor/require-handlebars-plugin/hbs/handlebars.runtime.js')
.replace('define(factory);', 'define(\'hbs/handlebars\', factory);');
} else {
return contents;
}
}
I still think the pragmas could be dropped and the documentation updated, I'm willing to help. Seems like it's been agreed that's the best way to do plugins according to @jrburke here https://github.com/jrburke/r.js/issues/116
Happy to take a PR for it.
On Thu, Oct 22, 2015 at 3:13 PM Caleb Hearon [email protected] wrote:
I was able to achieve the right build without having to fork the code:
stubModules: ['hbs', 'hbs/underscore', 'hbs/json2'], onBuildWrite: function (moduleName, path, contents) { if (moduleName === 'hbs/handlebars') { return grunt.file.read('vendor/require-handlebars-plugin/hbs/handlebars.runtime.js') .replace('define(factory);', 'define('hbs/handlebars', factory);'); } else { return contents; } }
I still think the pragmas could be dropped and the documentation updated, I'm willing to help. Seems like it's been agreed that's the best way to do plugins according to @jrburke https://github.com/jrburke here jrburke/r.js#116 https://github.com/jrburke/r.js/issues/116
— Reply to this email directly or view it on GitHub https://github.com/SlexAxton/require-handlebars-plugin/issues/244#issuecomment-150343416 .
See what you think of my branch for this issue: https://github.com/chearon/require-handlebars-plugin/tree/issue-244
I didn't have to change hbs.js except to remove the pragmas. So I've just updated config/readme to show the stubModules way of optimizing out the plugin. The demo-build/main.js is now like 4,000 lines shorter because it stubs out the whole module this time
Yea. Might need a couple more words in the readme (or a link) on how to get the optimized output, but the code looks great. PR me?
cool! Just added some stuff to the readme and opened a PR