You can change to v1.6.0 and it will work as expected.
Example code
```typescript
import { isBrowser } from "@builder.io/qwik/build";
import { asyncContext as asyncContextClient } from "~/async-context/async-context.client";
import { asyncContext as asyncContextServer } from "~/async-context/async-context.server";
export const AsyncContext = isBrowser ? asyncContextClient : asyncContextServer;
```
Weirdly enough, if we use ESNext await import syntax, it still works. However, we will need to target ES2022 in the vite.config.ts file.
Working with ESNext syntax
```typescript
import { isBrowser } from "@builder.io/qwik/build";
export const AsyncContext = isBrowser
? (await import("./async-context.client")).asyncContext
: (await import("./async-context.server")).asyncContext;
```
Main error on client
```
Module "node:async_hooks" has been externalized for browser compatibility. Cannot access "node:async_hooks.AsyncLocalStorage" in client code. See https://vitejs.dev/guide/troubleshooting.html#module-externalized-for-browser-compatibility for more details.
```
Stack Trace
```bash
Error: Module "node:async_hooks" has been externalized for browser compatibility. Cannot access "node:async_hooks.AsyncLocalStorage" in client code. See https://vitejs.dev/guide/troubleshooting.html#module-externalized-for-browser-compatibility for more details.
at Object.get (http://localhost:5173/@id/__vite-browser-external:node:async_hooks:3:11)
at http://localhost:5173/src/async-context/async-context.server.ts:1:159
```
Which component is affected?
Qwik Runtime
Describe the bug
Server specific code should be excluded from the client. It was somewhat powerful up until v1.6.0 but stop being powerful at v.1.7.0.
Reproduction
https://github.com/nelsonprsousa/qwik-1.7.0-regression/commits/main/
Steps to reproduce
Run
yarn
following byyarn start
.You can change to v1.6.0 and it will work as expected.
Example code
```typescript import { isBrowser } from "@builder.io/qwik/build"; import { asyncContext as asyncContextClient } from "~/async-context/async-context.client"; import { asyncContext as asyncContextServer } from "~/async-context/async-context.server"; export const AsyncContext = isBrowser ? asyncContextClient : asyncContextServer; ```Weirdly enough, if we use ESNext await import syntax, it still works. However, we will need to target ES2022 in the
vite.config.ts
file.Working with ESNext syntax
```typescript import { isBrowser } from "@builder.io/qwik/build"; export const AsyncContext = isBrowser ? (await import("./async-context.client")).asyncContext : (await import("./async-context.server")).asyncContext; ```Main error on client
``` Module "node:async_hooks" has been externalized for browser compatibility. Cannot access "node:async_hooks.AsyncLocalStorage" in client code. See https://vitejs.dev/guide/troubleshooting.html#module-externalized-for-browser-compatibility for more details. ```Stack Trace
```bash Error: Module "node:async_hooks" has been externalized for browser compatibility. Cannot access "node:async_hooks.AsyncLocalStorage" in client code. See https://vitejs.dev/guide/troubleshooting.html#module-externalized-for-browser-compatibility for more details. at Object.get (http://localhost:5173/@id/__vite-browser-external:node:async_hooks:3:11) at http://localhost:5173/src/async-context/async-context.server.ts:1:159 ```System Info
Additional Information
No response