Library decomment does exactly what you described:
Everything else should be left as it is, in particular white space is not removed, BUT if a comment takes a whole line, the line is removed too.
And it also supports JSON5, JavaScript ES6, CSS and HTML.