improve commonjs esm interop and node ESM (#4738)
### Description
* generate a default export when import faux modules
* detect specified module type and follow that
* emit errors/warnings when using non-matching syntax
next.js test case: https://github.com/vercel/next.js/pull/48940