I got this error and found this:
https://fluin.io/blog/critical-dependency-cannot-be-statically-extracted, where the author shows he was getting the same warning. However, I wasn’t using Angular Elements, but I got the idea it might be related to the same problem, so I went ahead and checked whether I was using @angular/compiler/src/core
in any of my imports.
And I was indeed doing so.
The fix was as simple as removing the import line, which in my case was:
import { ViewEncapsulation } from '@angular/compiler/src/core';
And then the editor autoimported it as follows:
import { Component, OnInit, ViewEncapsulation } from '@angular/core';