Welcome to FreeCodeCamp forums, I’m by no means an expert on this topic, but hopefully someone here is, or at least knows enough to point you to the right answers. I’ll provide what I know on the topic, but by no means am I an expert on this
To build a compiler in the browser, you first need to know how to build a compiler, or know how to port a existing compiler into the browser. Porting an existing compiler is easier so I assume that’;s the route you want to go.
I think something like webassembly could be able to “run” a C++ compiler in the browser. If its powerful enough to run windows 95 in a browser, then I don’t see why it could already exists (or already exist!)
Now if you wanted to build your own C++ compiler I’d say good luck! I recommend reading about how compilers work. Its a fascinating topic, but I do think the “building a compiler” seems like re-inventing the wheel and not the core goal.