fix(#38106): use swc client config to pre-compile shared lib (#38137)
fix(#38106): use swc client config to pre-compile shared lib (#38137)



## Bug

- [x] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [ ] Errors have helpful link attached, see `contributing.md`

Fixes #38106.

Currently, the `shared/lib` directory (**which will also be shipped to legacy browsers**) is precompiled under `swcServerOptions`, which targets Node.js 12 and is way too modern:

- The public class field syntax is only supported since Chrome 72, Firefox 69, Edge 79, and Safari 14.1.
- Webpack currently doesn't support the public class field syntax as well (which causes the issue #38106)
- `async/await` syntax is also supported in Node.js 12 but not in the legacy browsers.

The PR fixes the issue by pre-compiling the `shared/lib` directory using `swcClientOptions` (which targets the ES5).

Note:

- The only way to validate the fix is to run an integration test case on a legacy browser.
- The output size is increased by a little. But the size impact can be minimized by enabling `@swc/helpers` (which I will bring up in the next PR)
JeromeFitz/next.js,JeromeFitz/next.js,JeromeFitz/next.js,JeromeFitz/next.js