Repository: next.js
Issue: (Next.js v13.4.10) NEXT_RSC_ERR_SERVER_IMPORT: react-dom/server
Labels: bug,Testing

### Verify canary release

- [X] I verified that the issue exists in the latest Next.js canary release
   - Related: #43810

### Provide environment information

```bash
Operating System:
      Platform: darwin
      Arch: x64
      Version: Darwin Kernel Version 22.5.0: Mon Apr 24 20:51:50 PDT 2023; root:xnu-8796.121.2~5/RELEASE_X86_64
    Binaries:
      Node: 18.15.0
      npm: 9.5.0
      Yarn: 3.5.0
      pnpm: N/A
    Relevant Packages:
      next: 13.4.10
      eslint-config-next: 13.4.10
      react: 18.2.0
      react-dom: 18.2.0
      typescript: 5.1.6
    Next.js Config:
      output: N/A
````


### Which area(s) of Next.js are affected? (leave empty if unsure)

Jest (next/jest)

### To Reproduce

1. Install Next.js `v13.4.10`
2. Follow the standard jest setup: [Setting up Jest (with the Rust Compiler)](https://nextjs.org/docs/pages/building-your-application/optimizing/testing#setting-up-jest-with-the-rust-compiler)
3. Add backend code in `lib/` that uses `react-dom/server`.
4. Add corresponding jest test.
5. Run `jest` and observe error `NEXT_RSC_ERR_SERVER_IMPORT: react-dom/server`

### Describe the Bug

It seems `next/jest` from Next.js `13.4.10` mistakenly treats backend code in `lib/` as server component and then uses a jest next/swc transform [that forbids import from `react-dom`](https://github.com/vercel/next.js/blob/canary/packages/next-swc/crates/core/src/react_server_components.rs#L564). But the fact is that the backend code in `lib/` has nothing to do with server component (or client component).

`jest` gives the following error:

```
  x NEXT_RSC_ERR_SERVER_IMPORT: react-dom/server
     1 | import { renderToStaticMarkup } from "react-dom/server";
       : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      ...
      at Object.transformSync (node_modules/next/src/build/swc/index.ts:865:25)
      at transformSync (node_modules/next/src/build/swc/index.ts:1046:19)
      at Object.process (node_modules/next/src/build/swc/jest-transformer.ts:117:25)
      at ScriptTransformer.transformSource (node_modules/@jest/transform/build/ScriptTransformer.js:542:31)
      at ScriptTransformer._transformAndBuildScript (node_modules/@jest/transform/build/ScriptTransformer.js:671:40)
      at ScriptTransformer.transform (node_modules/@jest/transform/build/ScriptTransformer.js:723:19)
      ...
```

No `app/` dir feature is being used.

---

Note that the error only happens on `v13.4.10` and reverting back to `v13.4.9` dismisses it. Thus it might be caused by one of the following PRs based on the release note of `v13.4.10`:
- fix(next/jest): jest can not load server-only code: https://github.com/vercel/next.js/pull/52393
- feat([next-swc](https://linear.app/vercel/issue/NEXT-swc)): report native bindings load err code: https://github.com/vercel/next.js/pull/52570
- feat(turbopack): support swc transform plugins : https://github.com/vercel/next.js/pull/50401

### Expected Behavior

There shouldn't be any error. `next/jest` shouldn't treat any backend code as server component.

### Which browser are you using? (if relevant)

_No response_

### How are you deploying your application? (if relevant)

_No response_