Repository: next.js
Issue: Importing wasm module no longer works with App Router 
Labels: bug

### Verify canary release

- [X] I verified that the issue exists in the latest Next.js canary release

### Provide environment information

```bash
Operating System:
      Platform: darwin
      Arch: arm64
      Version: Darwin Kernel Version 22.5.0: Thu Jun  8 22:22:20 PDT 2023; root:xnu-8796.121.3~7/RELEASE_ARM64_T6000
    Binaries:
      Node: 18.10.0
      npm: 9.1.2
      Yarn: 1.22.19
      pnpm: 7.13.4
    Relevant Packages:
      next: 13.4.13-canary.0
      eslint-config-next: N/A
      react: 18.2.0
      react-dom: 18.2.0
      typescript: N/A
    Next.js Config:
      output: N/A
```


### Which area(s) of Next.js are affected? (leave empty if unsure)

App Router

### Link to the code that reproduces this issue or a replay of the bug

https://github.com/rossng/nextjs-app-router-wasm

### To Reproduce

* Install Cargo with Rustup if you do not have it: https://rustup.rs/
* Install wasm-pack: https://rustwasm.github.io/wasm-pack/installer/
* Install npm packages with `yarn`
* Run `cargo build`. This should install required Rust crates.
* Run `yarn serve`. This should build the wasm library and start a server at http://localhost:8080
* Navigate to http://localhost:8080 and observe that the alert (implemented in wasm library) triggers correctly
* Kill the server
* Run `yarn dev`. This starts the Next.js server on http://localhost:3000/
* Navigate to http://localhost:3000/old and observe that the alert is triggered correctly. This page is served from the old router.
* Navigate to http://localhost:3000/. This page is served from the app router. The first attempt will hang, so try again.

### Describe the Bug

You will see the following error printed in your terminal, and the page will fail to load with an Internal Server Error.

```
Error: 'entryOptions.layer' is only allowed when 'experiments.layers' is enabled
    at EntryOptionPlugin.entryDescriptionToOptions (/Users/ross/Projects/nextjs-wasm/node_modules/next/dist/compiled/webpack/bundle5.js:28:206883)
    at /Users/ross/Projects/nextjs-wasm/node_modules/next/dist/compiled/webpack/bundle5.js:28:205862
- error Error: 'entryOptions.layer' is only allowed when 'experiments.layers' is enabled
    at EntryOptionPlugin.entryDescriptionToOptions (/Users/ross/Projects/nextjs-wasm/node_modules/next/dist/compiled/webpack/bundle5.js:28:206883)
    at /Users/ross/Projects/nextjs-wasm/node_modules/next/dist/compiled/webpack/bundle5.js:28:205862 {
  digest: undefined
}
Error: 'entryOptions.layer' is only allowed when 'experiments.layers' is enabled
    at EntryOptionPlugin.entryDescriptionToOptions (/Users/ross/Projects/nextjs-wasm/node_modules/next/dist/compiled/webpack/bundle5.js:28:206883)
    at /Users/ross/Projects/nextjs-wasm/node_modules/next/dist/compiled/webpack/bundle5.js:28:205862
Error: 'entryOptions.layer' is only allowed when 'experiments.layers' is enabled
    at EntryOptionPlugin.entryDescriptionToOptions (/Users/ross/Projects/nextjs-wasm/node_modules/next/dist/compiled/webpack/bundle5.js:28:206883)
    at /Users/ross/Projects/nextjs-wasm/node_modules/next/dist/compiled/webpack/bundle5.js:28:205862 {
  digest: undefined
}
```

If you enable the `layers` experiment in `next.config.js`, you will see the following error in your browser instead:

```
Error: Element type is invalid. Received a promise that resolves to: [object Promise]. Lazy element type must resolve to a class or function.
```

![image](https://github.com/vercel/next.js/assets/565371/89539118-2491-4e37-a631-ebc892f8d4c8)


### Expected Behavior

The page should load and the wasm library should execute correctly.

### Which browser are you using? (if relevant)

_No response_

### How are you deploying your application? (if relevant)

_No response_