Precompile all templates

- Benchpress compilation is 33x faster now
- Native module with JS fallback and pre-built binaries
- Dev template build is <1sec now
- Minified template build is ~5sec (uglify accounts for almost all)
This commit is contained in:
Peter Jaszkowiak
2018-07-15 00:12:37 -06:00
parent 9d005fa203
commit 04d31fe1d4
7 changed files with 65 additions and 82 deletions

View File

@@ -289,22 +289,26 @@ Emailer.sendViaFallback = function (data, callback) {
function buildCustomTemplates(config) {
async.waterfall([
function (next) {
Emailer.getTemplates(config, next);
async.parallel({
templates: function (cb) {
Emailer.getTemplates(config, cb);
},
paths: function (cb) {
file.walk(viewsDir, cb);
},
}, next);
},
function (templates, next) {
templates = templates.filter(function (template) {
function (result, next) {
var templates = result.templates.filter(function (template) {
return template.isCustom && template.text !== prevConfig['email:custom:' + path];
});
var paths = _.fromPairs(result.paths.map(function (p) {
var relative = path.relative(viewsDir, p).replace(/\\/g, '/');
return [relative, p];
}));
async.each(templates, function (template, next) {
async.waterfall([
function (next) {
file.walk(viewsDir, next);
},
function (paths, next) {
paths = _.fromPairs(paths.map(function (p) {
var relative = path.relative(viewsDir, p).replace(/\\/g, '/');
return [relative, p];
}));
meta.templates.processImports(paths, template.path, template.text, next);
},
function (source, next) {