Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upThe component cache is not reset until you change the component #18707
Comments
|
I can reproduce, but only with the CLI. ngtsc's emit does emit both |
|
I had a look and it and the problem is that the NGTSC compiler adds a reversed dependency class AppComponent {
constructor() {
this.title = 'material-test';
}
}
AppComponent.ɵfac = function AppComponent_Factory(t) { return new (t || AppComponent)(); };
AppComponent.ɵcmp = _angular_core__WEBPACK_IMPORTED_MODULE_0__["ɵɵdefineComponent"]({ type: AppComponent, selectors: [["app-root"]], decls: 2, vars: 0, consts: [["matInput", ""]], template: function AppComponent_Template(rf, ctx) { if (rf & 1) {
_angular_core__WEBPACK_IMPORTED_MODULE_0__["ɵɵelementStart"](0, "mat-form-field");
_angular_core__WEBPACK_IMPORTED_MODULE_0__["ɵɵelement"](1, "input", 0);
_angular_core__WEBPACK_IMPORTED_MODULE_0__["ɵɵelementEnd"]();
} }, directives: [_angular_material_form_field__WEBPACK_IMPORTED_MODULE_1__["MatFormField"], _angular_material_input__WEBPACK_IMPORTED_MODULE_2__["MatInput"]], styles: ["\n/*# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IiIsImZpbGUiOiJzcmMvYXBwL2FwcC5jb21wb25lbnQuY3NzIn0= */"] });
/*@__PURE__*/ (function () { _angular_core__WEBPACK_IMPORTED_MODULE_0__["ɵsetClassMetadata"](AppComponent, [{
type: _angular_core__WEBPACK_IMPORTED_MODULE_0__["Component"],
args: [{
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.css']
}]
}], null, null); })();In It seems to me that the NGTSC compiler should offer an API to retrieve such dependencies. |
|
@clydin talked to @alxhub in the past to introduce something like |
Command
Is this a regression?
Yes, I think it's a regression.
Description
If you first create a component without importing the necessary modules, and then add these necessary modules, the component is not updated until you change the component itself.
Not sure if this bug is Angular CLI, maybe it's more of an Angular Material bug.
Step 1
ng new my-project cd my-project ng add @angular/materialStep 2
In
src/app/app.module.tsimport onlyReactiveFormsModuleandMatFormFieldModule:Step 3
Put this code to
src/app/app.component.html:Step 4
In console the browser see:
Step 5
Import
MatInputModule:In the browser still:
Step 6
Make any change in
src/app/app.component.tsand the error disappear.