Issue 1:
I'm submitting a ... (check one with "x")

[x] bug report => search github for a similar issue or PR before submitting

Current behavior

If you have a lot of form controls in template and compile with AOT, webpack build will hang for a long time or seemingly never complete.

In the below demo of the bug, I have 20 form controls on a template, it will take about 2 minutes to build after compile. If you delete 5 of them, it only take 12 seconds to compile.

If you have 30 controls in total, it will hang for an extremely long time or never complete.

Expected behavior

It should be able to compile in a reasonable amount of time regardless of how many form controls used.

Reproduction of the problem

As this is something that can't be reproduced on plunker, I've created a minimal repo that demonstrates the bug:

https://github.com/qdouble/aot-form-controls-build-bug

To demo the bug, just clone the github repo and run npm i to install.

To compile and build files, run npm run compile.

To create a normal build without ngc, just use npm run build.

To start server, use npm run prodserver.

Please tell us about your environment:

Angular version: 2.0.0-angular-builds

Language: [TypeScript X.X]

Node (for AoT issues): node --version = 6.5.0

Issue 2:
I'm submitting a ... (check one with "x")

[X ] bug report => search github for a similar issue or PR before submitting
[ ] feature request
[ ] support request => Please do not submit support request here, instead see https://github.com/angular/angular/blob/master/CONTRIBUTING.md#question

Current behavior

AOT compilation fails with "Error at .../src/apps/appv1/aot/main.ts:3:36: Cannot find module '../../../ngfactory/src/apps/appv1/app.module.ngfactory'". ie codegen fails foor my code but not node_modules.

Specifically an exception is being thrown in tsc-wrapped/src/main.js at the line:

tsc_1.tsc.typeCheck(host_1, programWithCodegen);

The exception is "_nativeError"

Expected behavior

That the AOT compiler will codegen code for my modules as well as for items in node_modules

Minimal reproduction of the problem with instructions

Run AOT with this tsconfig:

{

"compilerOptions": {

"allowSyntheticDefaultImports": true,

"target": "es5",

"module": "es2015",

"moduleResolution": "node",

"sourceMap": true,

"emitDecoratorMetadata": true,

"experimentalDecorators": true,

"noImplicitAny": false,

"removeComments": true,

"skipLibCheck": true,

"strictNullChecks": true,

"diagnostics": true,

"noUnusedLocals": false,

"noUnusedParameters": false,

"allowUnreachableCode": false,

"outDir": "build",

"typeRoots": [

"node_modules/@types"

],

"types": [

"core-js"

]

},

"exclude": [

"node_modules",

"3P",

"config",

"./src/apps/appv1/jit",

"./src/apps/appv2/"

],

"angularCompilerOptions": {

"genDir": "./src/ngfactory",

"skipMetadataEmit": true,

"debug": true

}

}

What is the motivation / use case for changing the behavior?

AOT Compilation was working before upgrading to 2.3.0/0.4.2

Please tell us about your environment:

W10 NPM3.10.8 Node: 7.0.0

Angular version: 2.0.X

2.3.0

Browser: [all | Chrome XX | Firefox XX | IE XX | Safari XX | Mobile Chrome XX | Android X.X Web

ALL

Language: [all | TypeScript X.X | ES6/7 | ES5]

Typescript 2.1.4

Node (for AoT issues): node --version =

compiler-cli: 2.3.0

tsc-wrapped: 0.4.2