Custom class annotations don't work in production build after update to NG9

Viewed 279

Custom annotations are not called at all in production build after updating to Angular 9.
When testing it with ng serve it works as usual.
No errors in the console.

My custom annotation:

@CustomSmartForm('calculatorForm')
@Component({
selector: 'calculator-form',
...
})
export class CalculatorFormComponent implements OnInit {...}

The function which should be called every time an annotation is set on a component:

import * as _ from 'lodash';

export function CustomSmartForm(formId: string) {
    return (target: any) => {
        const glb: any = window;
        glb.__smart_form_definitions = glb.__smart_form_definitions || {};
        const scope = glb.__smart_form_definitions;
        _.set(scope, formId, target);
    };
}

But it is not called for all components and I don't know why.
This only happens in production build.
Using lodash, this function sets the class definition on the object scope on the path formId.
From this object I try to retrieve the class definitions by formId later in the function below:

function getCustomFormDefinition(formId: string): any {
    const scope = (<any> window).__smart_form_definitions;
    return scope && scope[formId];
}

Dependencies and dev-dependencies:

"dependencies": {
    "@angular/animations": "^9.0.6",
    "@angular/cdk": "^9.1.2",
    "@angular/common": "^9.0.6",
    "@angular/compiler": "^9.0.6",
    "@angular/core": "^9.0.6",
    "@angular/forms": "^9.0.6",
    "@angular/localize": "^9.0.6",
    "@angular/platform-browser": "^9.0.6",
    "@angular/platform-browser-dynamic": "^9.0.6",
    "@angular/router": "^9.0.6",
    "@consultingwerk/smartcomponent-library": "^1.12.0",
    "@consultingwerk/smartcomponents-jsdo-core": "^6.0.8",
    "@fullcalendar/core": "^4.4.0",
    "@progress/kendo-angular-buttons": "^5.2.3",
    "@progress/kendo-angular-charts": "^4.1.3",
    "@progress/kendo-angular-common": "^1.2.2",
    "@progress/kendo-angular-dateinputs": "^4.2.2",
    "@progress/kendo-angular-dialog": "^4.1.3",
    "@progress/kendo-angular-dropdowns": "^4.2.5",
    "@progress/kendo-angular-excel-export": "^3.1.3",
    "@progress/kendo-angular-grid": "^4.6.4",
    "@progress/kendo-angular-inputs": "^6.5.0",
    "@progress/kendo-angular-intl": "^2.0.1",
    "@progress/kendo-angular-l10n": "^2.0.1",
    "@progress/kendo-angular-layout": "^4.2.3",
    "@progress/kendo-angular-menu": "^2.0.2",
    "@progress/kendo-angular-pdf-export": "^2.0.3",
    "@progress/kendo-angular-popup": "^3.0.5",
    "@progress/kendo-angular-ripple": "^2.0.1",
    "@progress/kendo-data-query": "^1.5.2",
    "@progress/kendo-drawing": "^1.6.0",
    "@progress/kendo-theme-bootstrap": "^4.11.0",
    "@progress/kendo-theme-default": "^4.13.0",
    "angular2-text-mask": "^9.0.0",
    "angular2-uuid": "^1.1.1",
    "bootstrap": "^3.3.7",
    "chart.js": "^3.0.0-alpha",
    "core-js": "^2.6.0",
    "font-awesome": "^4.7.0",
    "hammerjs": "^2.0.8",
    "jquery": "^3.3.1",
    "moment": "^2.24.0",
    "ng2-ace-editor": "^0.3.9",
    "ngx-file-drop": "^8.0.8",
    "primeicons": "^1.0.0",
    "primeng": "^9.0.0",
    "quill": "^1.3.7",
    "rxjs": "^6.5.4",
    "rxjs-compat": "^6.3.3",
    "ts-metadata-helper": "0.0.4",
    "tslib": "^1.10.0",
    "zone.js": "~0.10.2"
  },
  "devDependencies": {
    "@angular-devkit/build-angular": "~0.900.6",
    "@angular/cli": "~9.0.6",
    "@angular/compiler-cli": "^9.0.6",
    "@angular/language-service": "^9.0.6",
    "@types/jasmine": "~3.3.1",
    "@types/jasminewd2": "~2.0.6",
    "@types/node": "^12.11.1",
    "codelyzer": "^5.1.2",
    "jasmine-core": "~3.3.0",
    "jasmine-spec-reporter": "~4.2.1",
    "karma": "~3.1.3",
    "karma-chrome-launcher": "~2.2.0",
    "karma-coverage-istanbul-reporter": "~2.0.0",
    "karma-jasmine": "~2.0.1",
    "karma-jasmine-html-reporter": "^1.4.0",
    "protractor": "~5.4.0",
    "ts-node": "~7.0.1",
    "tslint": "~5.11.0",
    "typescript": "^3.7.5"
  }

Any help would be appreciated.

1 Answers
Related