Skip to content

Commit

Permalink
fix(@ngtools/webpack): only diagnose each resource once (#4374)
Browse files Browse the repository at this point in the history
  • Loading branch information
clydin authored and hansl committed Feb 3, 2017
1 parent 6650b75 commit b0c1551
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions packages/@ngtools/webpack/src/loader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -307,12 +307,14 @@ function _checkDiagnostics(refactor: TypeScriptFileRefactor) {
* Recursively calls diagnose on the plugins for all the reverse dependencies.
* @private
*/
function _diagnoseDeps(reasons: ModuleReason[], plugin: AotPlugin) {
function _diagnoseDeps(reasons: ModuleReason[], plugin: AotPlugin, checked: Set<string>) {
reasons
.filter(reason => reason && reason.module && reason.module instanceof NormalModule)
.filter(reason => !checked.has(reason.module.resource))
.forEach(reason => {
checked.add(reason.module.resource);
plugin.diagnose(reason.module.resource);
_diagnoseDeps(reason.module.reasons, plugin);
_diagnoseDeps(reason.module.reasons, plugin, checked);
});
}

Expand Down Expand Up @@ -344,7 +346,7 @@ export function ngcLoader(this: LoaderContext & { _compilation: any }) {
if (plugin.typeCheck) {
// Check all diagnostics from this and reverse dependencies also.
if (!plugin.firstRun) {
_diagnoseDeps(this._module.reasons, plugin);
_diagnoseDeps(this._module.reasons, plugin, new Set<string>());
}
// We do this here because it will throw on error, resulting in rebuilding this file
// the next time around if it changes.
Expand Down

0 comments on commit b0c1551

Please sign in to comment.