Issue title: Consider adding `transformMixedEsModules: true` to rollup commonjs plugin for optimizer.
 Issue body: **Is your feature request related to a problem? Please describe.**

I added `monaco-yaml` library to my dependencies and the optimized output contained stray require statements. I reported the issue to rollup.

https://github.com/rollup/plugins/issues/518


**Describe the solution you'd like**
Seems the solution is to use `transformMixedEsModules: true` as suggested by @lukastaegert on the commonjs plugin config. Does it make sense to use that given, some libraries might mix ES/Require statements. Atleast we should expose an option in the optimizer config to have this flag as `true`.

**Describe alternatives you've considered**
I manually removed the stray requires from the optimized output, to find the app worked after that.

**Additional context**
Currently my app fails to load with this error:

`require is undefined`
 Comments: 
 Comment 0: I had to revert the commit because it causes issues with actual ESM dependencies that has env detection.

Technically, dependencies with mixed CommonJS usage inside ESM is **incorrect distribution format** and should be considered bugs to be fixed in that dependency.
 Comment 1: @yyx990803 Would you consider having this as optional for anyone getting blocked ?
{'source': 'GithubIssues', 'repo_name_with_owner': 'vitejs/vite', 'issue_id': 668386589, 'repo_stars': 43291.0}