File tree Expand file tree Collapse file tree 2 files changed +19
-1
lines changed
packages/plugin-rsc/examples/basic Expand file tree Collapse file tree 2 files changed +19
-1
lines changed Original file line number Diff line number Diff line change @@ -8,7 +8,7 @@ const BrowserDep = (
88
99export function TestBrowserOnly ( ) {
1010 return (
11- < div >
11+ < div data-testid = "test-browser-only" >
1212 test-browser-only:{ ' ' }
1313 < BrowserOnly fallback = { < > loading...</ > } >
1414 < BrowserDep />
Original file line number Diff line number Diff line change @@ -4,6 +4,7 @@ import tailwindcss from '@tailwindcss/vite'
44import react from '@vitejs/plugin-react'
55import { type Plugin , defineConfig , parseAstAsync } from 'vite'
66import inspect from 'vite-plugin-inspect'
7+ import path from 'node:path'
78
89// log unhandled rejection to debug e2e failures
910if ( ! ( globalThis as any ) . __debugHandlerRegisterd ) {
@@ -97,6 +98,23 @@ export default defineConfig({
9798 }
9899 } ,
99100 } ,
101+ {
102+ name : 'test-browser-only' ,
103+ writeBundle ( _options , bundle ) {
104+ const moduleIds = Object . values ( bundle ) . flatMap ( ( c ) =>
105+ c . type === 'chunk' ? [ ...c . moduleIds ] : [ ] ,
106+ )
107+ const browserId = path . resolve (
108+ 'src/routes/browser-only/browser-dep.tsx' ,
109+ )
110+ if ( this . environment . name === 'client' ) {
111+ assert ( moduleIds . includes ( browserId ) )
112+ }
113+ if ( this . environment . name === 'ssr' ) {
114+ assert ( ! moduleIds . includes ( browserId ) )
115+ }
116+ } ,
117+ } ,
100118 {
101119 name : 'cf-build' ,
102120 enforce : 'post' ,
You can’t perform that action at this time.
0 commit comments