File tree Expand file tree Collapse file tree 2 files changed +31
-0
lines changed
Expand file tree Collapse file tree 2 files changed +31
-0
lines changed Original file line number Diff line number Diff line change 99 waitForHydration ,
1010} from './helper'
1111import { x } from 'tinyexec'
12+ import { normalizePath , type Rollup } from 'vite'
13+ import path from 'node:path'
1214
1315test . describe ( 'dev-default' , ( ) => {
1416 const f = useFixture ( { root : 'examples/basic' , mode : 'dev' } )
@@ -45,6 +47,17 @@ test.describe('dev-initial', () => {
4547test . describe ( 'build-default' , ( ) => {
4648 const f = useFixture ( { root : 'examples/basic' , mode : 'build' } )
4749 defineTest ( f )
50+
51+ test ( 'custom client chunk' , async ( ) => {
52+ const { chunks } : { chunks : Rollup . OutputChunk [ ] } = JSON . parse (
53+ f . createEditor ( 'dist/client/.vite/test.json' ) . read ( ) ,
54+ )
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 ) )
60+ } )
4861} )
4962
5063test . describe ( 'dev-non-optimized-cjs' , ( ) => {
Original file line number Diff line number Diff line change @@ -11,6 +11,7 @@ import {
1111} from 'vite'
1212// import inspect from 'vite-plugin-inspect'
1313import path from 'node:path'
14+ import fs from 'node:fs'
1415import { fileURLToPath } from 'node:url'
1516
1617export default defineConfig ( {
@@ -48,6 +49,23 @@ export default defineConfig({
4849 }
4950 } ,
5051 } ,
52+ {
53+ // dump entire bundle to analyze build output for e2e
54+ name : 'test-metadata' ,
55+ enforce : 'post' ,
56+ writeBundle ( options , bundle ) {
57+ const chunks : Rollup . OutputChunk [ ] = [ ]
58+ for ( const chunk of Object . values ( bundle ) ) {
59+ if ( chunk . type === 'chunk' ) {
60+ chunks . push ( chunk )
61+ }
62+ }
63+ fs . writeFileSync (
64+ path . join ( options . dir ! , '.vite/test.json' ) ,
65+ JSON . stringify ( { chunks } , null , 2 ) ,
66+ )
67+ } ,
68+ } ,
5169 {
5270 name : 'test-server-assets-security' ,
5371 buildStart ( ) {
You can’t perform that action at this time.
0 commit comments