Merge pull request #3106 from hon2a/hon2a/ie-error-stack

`babel-template` no longer crashes in IE attempting to access unpopulated error stack
This commit is contained in:
James Kyle 2015-11-25 13:01:54 -08:00
commit afd68f47dd

View File

@ -10,7 +10,13 @@ let TEMPLATE_SKIP = Symbol();
export default function (code: string): Function {
// since we lazy parse the template, we get the current stack so we have the
// original stack to append if it errors when parsing
let stack = new Error().stack.split("\n").slice(1).join("\n");
let stack;
try {
// error stack gets populated in IE only on throw (https://msdn.microsoft.com/en-us/library/hh699850(v=vs.94).aspx)
throw new Error();
} catch (error) {
stack = error.stack.split("\n").slice(1).join("\n")
}
let getAst = function () {
let ast;