<p dir="auto"><strong>I'm submitting a ...</strong>  (check one with "x")</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="[x] bug report =&gt; search github for a similar issue or PR before submitting"><pre class="notranslate"><code class="notranslate">[x] bug report =&gt; search github for a similar issue or PR before submitting
</code></pre></div>
<p dir="auto"><strong>Current behavior</strong></p>
<p dir="auto">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.</p>
<p dir="auto">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.<br>
If you have 30 controls in total, it will hang for an extremely long time or never complete.</p>
<p dir="auto"><strong>Expected behavior</strong></p>
<p dir="auto">It should be able to compile in a reasonable amount of time regardless of how many form controls used.</p>
<p dir="auto"><strong>Reproduction of the problem</strong></p>
<p dir="auto">As this is something that can't be reproduced on plunker, I've created a minimal repo that demonstrates the bug:</p>
<p dir="auto"><a href="https://github.com/qdouble/aot-form-controls-build-bug">https://github.com/qdouble/aot-form-controls-build-bug</a></p>
<p dir="auto">To demo the bug, just clone the github repo and run <code class="notranslate">npm i</code> to install.<br>
To compile and build files, run <code class="notranslate">npm run compile</code>.<br>
To create a normal build without ngc, just use <code class="notranslate">npm run build</code>.<br>
To start server, use <code class="notranslate">npm run prodserver</code>.</p>
<p dir="auto"><strong>Please tell us about your environment:</strong></p>
<ul dir="auto">
<li><strong>Angular version:</strong> 2.0.0-angular-builds</li>
<li><strong>Language:</strong> [TypeScript X.X]</li>
<li><strong>Node (for AoT issues):</strong> <code class="notranslate">node --version</code> =   6.5.0</li>
</ul>
<p dir="auto"><strong>I'm submitting a ...</strong>  (check one with "x")</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="[X ] bug report =&gt; search github for a similar issue or PR before submitting
[ ] feature request
[ ] support request =&gt; Please do not submit support request here, instead see https://github.com/angular/angular/blob/master/CONTRIBUTING.md#question"><pre class="notranslate"><code class="notranslate">[X ] bug report =&gt; search github for a similar issue or PR before submitting
[ ] feature request
[ ] support request =&gt; Please do not submit support request here, instead see https://github.com/angular/angular/blob/master/CONTRIBUTING.md#question
</code></pre></div>
<p dir="auto"><strong>Current behavior</strong><br>
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.</p>
<p dir="auto"><strong>Specifically an exception is being thrown in tsc-wrapped/src/main.js at the line:<br>
tsc_1.tsc.typeCheck(host_1, programWithCodegen);<br>
The exception is "_nativeError"</strong></p>
<p dir="auto"><strong>Expected behavior</strong><br>
That the AOT compiler will codegen code for my modules as well as for items in node_modules</p>
<p dir="auto"><strong>Minimal reproduction of the problem with instructions</strong><br>
Run AOT with this tsconfig:<br>
{<br>
"compilerOptions": {<br>
"allowSyntheticDefaultImports": true,<br>
"target": "es5",<br>
"module": "es2015",<br>
"moduleResolution": "node",<br>
"sourceMap": true,<br>
"emitDecoratorMetadata": true,<br>
"experimentalDecorators": true,<br>
"noImplicitAny": false,<br>
"removeComments": true,<br>
"skipLibCheck": true,<br>
"strictNullChecks": true,<br>
"diagnostics": true,<br>
"noUnusedLocals": false,<br>
"noUnusedParameters": false,<br>
"allowUnreachableCode": false,<br>
"outDir": "build",<br>
"typeRoots": [<br>
"node_modules/<a class="user-mention notranslate" data-hovercard-type="organization" data-hovercard-url="/orgs/types/hovercard" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="https://github.com/types">@types</a>"<br>
],<br>
"types": [<br>
"core-js"<br>
]<br>
},<br>
"exclude": [<br>
"node_modules",<br>
"3P",<br>
"config",<br>
"./src/apps/appv1/jit",<br>
"./src/apps/appv2/"<br>
],<br>
"angularCompilerOptions": {<br>
"genDir": "./src/ngfactory",<br>
"skipMetadataEmit": true,<br>
"debug": true<br>
}<br>
}</p>
<p dir="auto"><strong>What is the motivation / use case for changing the behavior?</strong><br>
AOT Compilation was working before upgrading to 2.3.0/0.4.2</p>
<p dir="auto"><strong>Please tell us about your environment:</strong><br>
W10 NPM3.10.8 Node: 7.0.0</p>
<ul dir="auto">
<li>
<p dir="auto"><strong>Angular version:</strong> 2.0.X<br>
2.3.0</p>
</li>
<li>
<p dir="auto"><strong>Browser:</strong> [all | Chrome XX | Firefox XX | IE XX | Safari XX | Mobile Chrome XX | Android X.X Web<br>
ALL</p>
</li>
<li>
<p dir="auto"><strong>Language:</strong> [all | TypeScript X.X | ES6/7 | ES5]<br>
Typescript 2.1.4</p>
</li>
<li>
<p dir="auto"><strong>Node (for AoT issues):</strong> <code class="notranslate">node --version</code> =<br>
compiler-cli: 2.3.0<br>
tsc-wrapped: 0.4.2</p>
</li>
</ul>