File tree Expand file tree Collapse file tree 1 file changed +40
-0
lines changed
packages/vite/src/node/__tests__ Expand file tree Collapse file tree 1 file changed +40
-0
lines changed Original file line number Diff line number Diff line change @@ -57,6 +57,17 @@ describe('build', () => {
5757 buildProject ( 'red' ) ,
5858 buildProject ( 'blue' ) ,
5959 ] )
60+ expect ( getOutputHashChanges ( result [ 0 ] , result [ 1 ] ) ) . toMatchInlineSnapshot ( `
61+ {
62+ "changed": [
63+ "index",
64+ "_subentry.css",
65+ ],
66+ "unchanged": [
67+ "undefined",
68+ ],
69+ }
70+ ` )
6071 assertOutputHashContentChange ( result [ 0 ] , result [ 1 ] )
6172 } )
6273
@@ -105,6 +116,21 @@ describe('build', () => {
105116 buildProject ( 'yellow' ) ,
106117 buildProject ( 'blue' ) ,
107118 ] )
119+ expect ( getOutputHashChanges ( result [ 0 ] , result [ 1 ] ) ) . toMatchInlineSnapshot ( `
120+ {
121+ "changed": [
122+ "index",
123+ "_foo",
124+ "_bar",
125+ "_baz.css",
126+ ],
127+ "unchanged": [
128+ "_foo.css",
129+ "_bar.css",
130+ "undefined",
131+ ],
132+ }
133+ ` )
108134 assertOutputHashContentChange ( result [ 0 ] , result [ 1 ] )
109135 } )
110136
@@ -750,3 +776,17 @@ function assertOutputHashContentChange(
750776 }
751777 }
752778}
779+
780+ function getOutputHashChanges ( output1 : RollupOutput , output2 : RollupOutput ) {
781+ const map1 = Object . fromEntries (
782+ output1 . output . map ( ( o ) => [ o . name , o . fileName ] ) ,
783+ )
784+ const map2 = Object . fromEntries (
785+ output2 . output . map ( ( o ) => [ o . name , o . fileName ] ) ,
786+ )
787+ const names = Object . keys ( map1 ) . filter ( Boolean )
788+ return {
789+ changed : names . filter ( ( name ) => map1 [ name ] !== map2 [ name ] ) ,
790+ unchanged : names . filter ( ( name ) => map1 [ name ] === map2 [ name ] ) ,
791+ }
792+ }
You can’t perform that action at this time.
0 commit comments