Skip to content

Commit

Permalink
fix(bazel): construct a manifest file even when warnings are emitted (#…
Browse files Browse the repository at this point in the history
…43582)

Refs #42966.

Previously if _any_ diagnostics were emitted, regardless of their category, the manifest would not be generated. This means that if a target emits only warnings and no errors, it would still fail to build because it does not generate all the required output files (specifically the `.es5.MF` file). Now the manifest file is generated as long as there are no error diagnostics in the result. This makes `ng_module()` support compiler warnings as a user would expect.

Added a test which uses extended template diagnostics to trigger the invalid banana in box diagnostic. This generates a warning and uses Skylib's `build_test()` to verify that it builds successfully. Unfortunately there is no easy way to verify that the warning diagnostic is emitted at all. `expected_diagnostics` should be able to do that, but it doesn't seem to have any effect on `ng_module()` and may not be integrated. Instead, testing that a target with warnings builds correctly is the best we can easily do here without a deeper investigation.

PR Close #43582
  • Loading branch information
dgp1130 authored and alxhub committed Sep 29, 2021
1 parent 62d7005 commit e0a7285
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 1 deletion.
3 changes: 2 additions & 1 deletion packages/bazel/src/ngc-wrapped/index.ts
Expand Up @@ -351,7 +351,8 @@ export function compile({
});
const tsickleEmitResult = emitResult as tsickle.EmitResult;
let externs = '/** @externs */\n';
if (!diagnostics.length) {
const hasError = diagnostics.some((diag) => diag.category === ts.DiagnosticCategory.Error);
if (!hasError) {
if (bazelOpts.tsickleGenerateExterns) {
externs += tsickle.getGeneratedExterns(tsickleEmitResult.externs);
}
Expand Down
16 changes: 16 additions & 0 deletions packages/bazel/test/ngc-wrapped/ivy_enabled/BUILD.bazel
@@ -1,3 +1,4 @@
load("@bazel_skylib//rules:build_test.bzl", "build_test")
load("//tools:defaults.bzl", "jasmine_node_test", "ng_module", "ts_library")

ts_library(
Expand Down Expand Up @@ -44,3 +45,18 @@ jasmine_node_test(
],
tags = ["ivy-only"],
)

ng_module(
name = "test_module_warnings_lib",
srcs = ["test_module_warnings.ts"],
experimental_extended_template_diagnostics = True,
strict_templates = True,
tags = ["ivy-only"],
deps = ["//packages/core"],
)

build_test(
name = "test_module_warnings",
tags = ["ivy-only"],
targets = [":test_module_warnings_lib"],
)
@@ -0,0 +1,19 @@
/**
* @license
* Copyright Google LLC All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/

import {Component} from '@angular/core';

/** Test component which contains an invalid banana in box warning. Should build successfully. */
@Component({
template: `
<div ([foo])="bar"></div>
`,
})
export class TestCmp {
bar: string = 'test';
}

0 comments on commit e0a7285

Please sign in to comment.