diff --git a/test/e2e/app-dir/typeof-window/.gitignore b/test/e2e/app-dir/typeof-window/.gitignore
new file mode 100644
index 0000000000000..cf4bab9ddde9f
--- /dev/null
+++ b/test/e2e/app-dir/typeof-window/.gitignore
@@ -0,0 +1 @@
+!node_modules
diff --git a/test/e2e/app-dir/typeof-window/app/layout.tsx b/test/e2e/app-dir/typeof-window/app/layout.tsx
new file mode 100644
index 0000000000000..888614deda3ba
--- /dev/null
+++ b/test/e2e/app-dir/typeof-window/app/layout.tsx
@@ -0,0 +1,8 @@
+import { ReactNode } from 'react'
+export default function Root({ children }: { children: ReactNode }) {
+ return (
+
+
{children}
+
+ )
+}
diff --git a/test/e2e/app-dir/typeof-window/app/page.tsx b/test/e2e/app-dir/typeof-window/app/page.tsx
new file mode 100644
index 0000000000000..a0c803a25b597
--- /dev/null
+++ b/test/e2e/app-dir/typeof-window/app/page.tsx
@@ -0,0 +1,10 @@
+'use client'
+if (typeof window !== 'undefined') {
+ import('my-differentiated-files/browser').then((mod) => {
+ console.log({ TEST: mod.default })
+ })
+}
+
+export default function Page() {
+ return Page loaded
+}
diff --git a/test/e2e/app-dir/typeof-window/next.config.js b/test/e2e/app-dir/typeof-window/next.config.js
new file mode 100644
index 0000000000000..807126e4cf0bf
--- /dev/null
+++ b/test/e2e/app-dir/typeof-window/next.config.js
@@ -0,0 +1,6 @@
+/**
+ * @type {import('next').NextConfig}
+ */
+const nextConfig = {}
+
+module.exports = nextConfig
diff --git a/test/e2e/app-dir/typeof-window/node_modules/my-differentiated-files/my-file-browser.js b/test/e2e/app-dir/typeof-window/node_modules/my-differentiated-files/my-file-browser.js
new file mode 100644
index 0000000000000..f745a87a31f71
--- /dev/null
+++ b/test/e2e/app-dir/typeof-window/node_modules/my-differentiated-files/my-file-browser.js
@@ -0,0 +1 @@
+export default 'BROWSER'
diff --git a/test/e2e/app-dir/typeof-window/node_modules/my-differentiated-files/my-file-server.js b/test/e2e/app-dir/typeof-window/node_modules/my-differentiated-files/my-file-server.js
new file mode 100644
index 0000000000000..44add8f95a595
--- /dev/null
+++ b/test/e2e/app-dir/typeof-window/node_modules/my-differentiated-files/my-file-server.js
@@ -0,0 +1 @@
+export default 'SERVER'
diff --git a/test/e2e/app-dir/typeof-window/node_modules/my-differentiated-files/package.json b/test/e2e/app-dir/typeof-window/node_modules/my-differentiated-files/package.json
new file mode 100644
index 0000000000000..fcc1800c04883
--- /dev/null
+++ b/test/e2e/app-dir/typeof-window/node_modules/my-differentiated-files/package.json
@@ -0,0 +1,14 @@
+{
+ "name": "my-differentiated-files",
+ "type": "module",
+ "exports": {
+ "./browser": {
+ "browser": "./my-file-browser.js",
+ "node": null
+ },
+ "./server": {
+ "browser": null,
+ "node": "./my-file-server.js"
+ }
+ }
+}
diff --git a/test/e2e/app-dir/typeof-window/typeof-window.test.ts b/test/e2e/app-dir/typeof-window/typeof-window.test.ts
new file mode 100644
index 0000000000000..0a8088882fdc0
--- /dev/null
+++ b/test/e2e/app-dir/typeof-window/typeof-window.test.ts
@@ -0,0 +1,12 @@
+import { nextTestSetup } from 'e2e-utils'
+
+describe('typeof-window', () => {
+ const { next } = nextTestSetup({
+ files: __dirname,
+ })
+
+ it('should work using cheerio', async () => {
+ const $ = await next.render$('/')
+ expect($('h1').text()).toBe('Page loaded')
+ })
+})