简体   繁体   中英

Angular 11.0.5 production build - Class extends value undefined is not a constructor or null

In production build (ie ng b --prod ) of Angular 11.0.5, the web page output has the following error:

在此处输入图像描述

If I were to disable optimization during production build (ie via ng b --prod --optimization=false ), the problem disappears.

My suspicion is the circular reference was accidentally created during one of the Webpack processes.

Thanks.

[Edit1]: After including the source map, the error is as below:

详细错误

edit-form.service.ts:11 is referring to: export class EditFormService extends BehaviorSubject<Opportunity[]>

Top snippet from edit-form.service.ts:

import { Injectable } from '@angular/core';
import { Observable } from 'rxjs/Observable';
import { Opportunity } from 'src/app/shared/models/opportunity.model';
import { BehaviorSubject } from 'rxjs/BehaviorSubject';
import { APIService } from '../../api/API.service';
import { SharepointRequest } from 'src/app/shared/models/sharepoint.model';

@Injectable({
    providedIn: 'root',
})
export class EditFormService extends BehaviorSubject<Opportunity[]> {
    constructor(private APIService: APIService) {
        super(Array<Opportunity>());
    }

Notice that I have indeed initialised the constructor (ie via super(Array<Opportunity>()); . At lost as to where to from here.

I am looking for advice to take the troubleshooting further.

As it turns out, there is a circular dependency going on.

Using madge ( https://www.npmjs.com/package/madge ) and by running the command npx madge --circular --extensions ts./ , I was able to locate a circular dependency in opportunity.model.ts and resolved it.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM