Build for prod with angular 7 results in Super expression must either be null or a function

Viewed 328

I have a older angular application where I have implemented okta auth.

It uses angular 7.2, and okta versions

   "@okta/okta-angular": "^5.1.0",
    "@okta/okta-auth-js": "^5.9.0",
    "@okta/okta-signin-widget": "^5.16.1",
    "@oktadev/schematics": "^5.2.0",

I'm using "target": "es2015", When I'm compiling the app without the prod flag, everything works. But as soon as I compile with the --prod=true flag it crashes with the following error.

Uncaught TypeError: Super expression must either be null or a function.

If I go into the angular.json file and turn off optimizations, it works:

"optimization": false,

But the application goes from 2mb to 9mb size.

What can I do to get optimizations to work?

1 Answers

Turns out upgrading to angular 8 was the solution.

npm config set legacy-peer-deps true
cmd /C "set "NG_DISABLE_VERSION_CHECK=1" && npx @angular/cli@8 update @angular/cli@8 @angular/core@8"
Related