Skip to content

Commit

Permalink
Correctly cache <head> tag.
Browse files Browse the repository at this point in the history
Our workaround for meteor/meteor#5913 was
breaking the cache because it made empty head to be cached even for
the client target.
  • Loading branch information
mitar committed Aug 4, 2016
1 parent 5937088 commit de9e4b8
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions patch-compiling.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,10 +86,19 @@ var matches = function (host, program) {
// See: https://github.com/meteor/meteor/issues/5913
var originalAddCompileResult = CachingHtmlCompiler.prototype.addCompileResult;
CachingHtmlCompiler.prototype.addCompileResult = function (inputFile, compileResult) {
var head = compileResult.head;

if (compileResult.head && !matches(inputFile.getArch(), 'web')) {
// Head can only be emitted to web targets.
delete compileResult.head;
compileResult.head = '';
}

originalAddCompileResult.call(this, inputFile, compileResult);
try {
originalAddCompileResult.call(this, inputFile, compileResult);
}
finally {
// Restore whatever was initially stored for head. We have to restore because
// the cache is shared between targets and an empty head is cached otherwise.
compileResult.head = head;
}
};

0 comments on commit de9e4b8

Please sign in to comment.