Backport $compiler fixes from 1.3 to v1.2.x

This doesn't include 2cde927e58c8d1588569d94a797e43cdfbcedaf9 which contained breaking changes,
but includes all of the transclusion fixes.