feat(next-swc): Implement CJS optimizer (#49972)
### What?
Implement a CJS optimizer for next-swc
### Why?
x-ref: https://vercel.slack.com/archives/C02HY34AKME/p1684341093462309
Assuming most CJS files are transpiled from ESM, we can mimic
tree-shaking using an AST transform.
### How?
Closes WEB-1072
Fixes #48469
fix NEXT-1156
---------
Co-authored-by: Shu Ding <g@shud.in>