perf: Don’t subclass Error; resulting in smaller binary (#14160)

Subclassing errors is problematic since Error returns a
new instance. All of the patching which we do than prevent
proper application of source maps.

PR Close #14160
This commit is contained in:
Miško Hevery
2017-01-27 13:19:00 -08:00
committed by Miško Hevery
parent 3c2842be96
commit c33fda2607
51 changed files with 407 additions and 500 deletions

View File

@ -13,8 +13,8 @@ import 'reflect-metadata';
import * as ts from 'typescript';
import * as tsc from '@angular/tsc-wrapped';
import {isSyntaxError} from '@angular/compiler';
import {SyntaxError} from '@angular/compiler';
import {CodeGenerator} from './codegen';
function codegen(
@ -29,7 +29,7 @@ export function main(
const cliOptions = new tsc.NgcCliOptions(args);
return tsc.main(project, cliOptions, codegen).then(() => 0).catch(e => {
if (e instanceof tsc.UserError || e instanceof SyntaxError) {
if (e instanceof tsc.UserError || isSyntaxError(e)) {
consoleError(e.message);
return Promise.resolve(1);
} else {