-
Notifications
You must be signed in to change notification settings - Fork 12k
Custom typescript transformer source file changes are not applied #16250
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Hi @JulianH, The That being said it is important to highlight that you are using a private API ( |
Hi @alan-agius4, thank you for the response. Yes i kow, using the private API is not the best option here. But as angular also strongly relies on typescript transformers, i am sure that such an API will be present always :-) Do you need a repo with the custom transformer for the reproduction of this problem? Does the NGC compiler also not see the angular internal transformations and works on the unmodified typescript files? |
Hi @alan-agius4, here is the repo to reproduce the problem: https://github.com/JulianH/angular-provider-transformer. What i've also identified is, that only AOT is affected, with JIT the metadata are still present and used by the compiler to create the correct provider instance: var AppComponent = /** @class */ (function () {
function AppComponent(service) {
this.service = service;
this.title = 'angular-transformer';
}
AppComponent.ctorParameters = function () { return [
{ type: _service1__WEBPACK_IMPORTED_MODULE_3__["Service1"] }
]; };
AppComponent = tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
Object(_angular_core__WEBPACK_IMPORTED_MODULE_2__["Component"])({
selector: 'app-root',
template: tslib__WEBPACK_IMPORTED_MODULE_0__["__importDefault"](__webpack_require__(/*! raw-loader!./app.component.html */ "./node_modules/raw-loader/dist/cjs.js!./src/app/app.component.html")).default,
providers: [{
provide: _service1__WEBPACK_IMPORTED_MODULE_3__["Service1"],
useClass: _service2__WEBPACK_IMPORTED_MODULE_1__["Service2"]
}]
})
], AppComponent);
return AppComponent;
}()); The AOT result looks like this: function View_AppComponent_Host_0(_l) {
return _angular_core__WEBPACK_IMPORTED_MODULE_0__["ɵvid"](0, [
(_l()(),_angular_core__WEBPACK_IMPORTED_MODULE_0__["ɵeld"](0, 0, null, null, 2, "app-root", [], null, null, null, View_AppComponent_0, RenderType_AppComponent)),
_angular_core__WEBPACK_IMPORTED_MODULE_0__["ɵprd"](512, null, _service1__WEBPACK_IMPORTED_MODULE_1__["Service1"], _service1__WEBPACK_IMPORTED_MODULE_1__["Service1"], []),
_angular_core__WEBPACK_IMPORTED_MODULE_0__["ɵdid"](2, 49152, null, 0, _app_component__WEBPACK_IMPORTED_MODULE_2__["AppComponent"], [_service1__WEBPACK_IMPORTED_MODULE_1__["Service1"]], null, null)
], null, null);
} It seems, that there is no support for typescript transformers when using the AOT compiler as he is working with Or can you suggest any alternative to us, to replace provider tokens based on an configuration/environment without introducing a lot of cicrular dependencies? Thank you in advance! |
Hello @alan-agius4, yesterday i spend time to identify how the ivy compilation process is working and identified, that it will be basically impossible for us, to use typescript transformers in the future, which are updating the component decorator metadata. Therefore we will follow a different approach, to use the already existing environements to export there the provider tokens for the custom services we want to use. |
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
🐞 Bug report
Command (mark with an
x
)Is this a regression?
Yes, the custom transformer worked in angular 7
Description
We are using a custom typescript transformer which is replacing provider tokens in component decorators to enable custom implementations of services depending on the build configuration.
Example:
which will be transformed to the following:
This custom transformer we add to the beginning of
_transformers
array of theAngularCompilerPlugin
.Until the upgrade from Angular 7 to Angular 8, this worked like a charm but now on runtime, the custom implementation is not present, when doing the build with AOT enabled, the JIT build does use the transformed version.
If i dump the modified
ts.SourceFile
, i can see the applied change as well as another already applied change, theimportFactory
transformer addsexport { ɵ0 };
to the sourceFile, even if i add the custom transformer to the beginning of the_transformers
list?🌍 Your Environment
The text was updated successfully, but these errors were encountered: