The electors can either decide to vote as the state voters did or follow the compact.
However, you do point out an interesting 'wrinkle', in that electors could/can have always voted for the winner of the national popular vote. In fact, technically, electors could/can have ultimately voted for whomever they preferred. That being said, the ultimate fail safe is simple good faith on behalf of electors. And if that fails, individual state legislators of course have practically unlimited power to enforce decisions.
There's something unique about this case that I haven't fully investigated. The judge is clearly not ruling that state legislative bodies cannot control electors - that of course is entirely false. States are sovereign entities free to act as they please within broad federal constitutional guidelines. (If anyone doubts that, check out sanctuary states.) Rather, the opinion apparently is focused on a specific mechanism that in the judge's opinion fails some type of constitutional test.