@@ -48,36 +48,48 @@ test.describe('build-default', () => {
4848 const f = useFixture ( { root : 'examples/basic' , mode : 'build' } )
4949 defineTest ( f )
5050
51- test ( 'custom client chunk ' , async ( ) => {
51+ test ( 'server-chunk-based client chunks ' , async ( ) => {
5252 const { chunks } : { chunks : Rollup . OutputChunk [ ] } = JSON . parse (
5353 f . createEditor ( 'dist/client/.vite/test.json' ) . read ( ) ,
5454 )
55- const chunk = chunks . find ( ( c ) => c . name === 'custom-chunk' )
56- const expected = [ 1 , 2 , 3 ] . map ( ( i ) =>
57- normalizePath ( path . join ( f . root , `src/routes/chunk/client${ i } .tsx` ) ) ,
58- )
59- expect ( chunk ?. moduleIds ) . toEqual ( expect . arrayContaining ( expected ) )
55+ const expectedGroups = {
56+ 'facade:src/routes/chunk2/client1.tsx' : [ 'src/routes/chunk2/client1.tsx' ] ,
57+ 'facade:src/routes/chunk2/server2.tsx' : [
58+ 'src/routes/chunk2/client2.tsx' ,
59+ 'src/routes/chunk2/client2b.tsx' ,
60+ ] ,
61+ 'shared:src/routes/chunk2/client3.tsx' : [ 'src/routes/chunk2/client3.tsx' ] ,
62+ }
63+ const actualGroups : Record < string , string [ ] > = { }
64+ for ( const key in expectedGroups ) {
65+ const groupId = `\0virtual:vite-rsc/client-references/group/${ key } `
66+ const groupChunk = chunks . find ( ( c ) => c . facadeModuleId === groupId )
67+ if ( groupChunk ) {
68+ actualGroups [ key ] = groupChunk . moduleIds
69+ . filter ( ( id ) => id !== groupId )
70+ . map ( ( id ) => normalizePath ( path . relative ( f . root , id ) ) )
71+ }
72+ }
73+ expect ( actualGroups ) . toEqual ( expectedGroups )
6074 } )
6175} )
6276
63- test . describe ( 'build-server -client-chunks' , ( ) => {
77+ test . describe ( 'custom -client-chunks' , ( ) => {
6478 const f = useFixture ( {
6579 root : 'examples/basic' ,
6680 mode : 'build' ,
6781 cliOptions : {
6882 env : {
69- TEST_SERVER_CLIENT_CHUNKS : 'true' ,
83+ TEST_CUSTOM_CLIENT_CHUNKS : 'true' ,
7084 } ,
7185 } ,
7286 } )
7387
74- defineTest ( f )
75-
76- test ( 'custom client chunk' , async ( ) => {
88+ test ( 'basic' , async ( ) => {
7789 const { chunks } : { chunks : Rollup . OutputChunk [ ] } = JSON . parse (
7890 f . createEditor ( 'dist/client/.vite/test.json' ) . read ( ) ,
7991 )
80- const chunk = chunks . find ( ( c ) => c . name === 'root ' )
92+ const chunk = chunks . find ( ( c ) => c . name === 'custom-chunk ' )
8193 const expected = [ 1 , 2 , 3 ] . map ( ( i ) =>
8294 normalizePath ( path . join ( f . root , `src/routes/chunk/client${ i } .tsx` ) ) ,
8395 )
@@ -181,7 +193,7 @@ test.describe('build-stable-chunks', () => {
181193 . sort ( )
182194 expect ( newChunks ) . toEqual ( [
183195 'src/framework/entry.browser.tsx' ,
184- 'virtual:vite-rsc/client-references/group/src/routes/client .tsx' ,
196+ 'virtual:vite-rsc/client-references/group/facade: src/routes/root .tsx' ,
185197 ] )
186198 expect ( oldChunks ) . toEqual ( newChunks )
187199 } )
@@ -1434,4 +1446,12 @@ function defineTest(f: Fixture) {
14341446 await testBackgroundImage ( '.test-assets-server-css' )
14351447 await testBackgroundImage ( '.test-assets-client-css' )
14361448 } )
1449+
1450+ test ( 'lazy' , async ( { page } ) => {
1451+ await page . goto ( f . url ( ) )
1452+ await waitForHydration ( page )
1453+ await expect ( page . getByTestId ( 'test-chunk2' ) ) . toHaveText (
1454+ 'test-chunk1|test-chunk2|test-chunk2b|test-chunk3|test-chunk3' ,
1455+ )
1456+ } )
14371457}
0 commit comments