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', () => {
57
57
buildProject ( 'red' ) ,
58
58
buildProject ( 'blue' ) ,
59
59
] )
60
+ expect ( getOutputHashChanges ( result [ 0 ] , result [ 1 ] ) ) . toMatchInlineSnapshot ( `
61
+ {
62
+ "changed": [
63
+ "index",
64
+ "_subentry.css",
65
+ ],
66
+ "unchanged": [
67
+ "undefined",
68
+ ],
69
+ }
70
+ ` )
60
71
assertOutputHashContentChange ( result [ 0 ] , result [ 1 ] )
61
72
} )
62
73
@@ -105,6 +116,21 @@ describe('build', () => {
105
116
buildProject ( 'yellow' ) ,
106
117
buildProject ( 'blue' ) ,
107
118
] )
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
+ ` )
108
134
assertOutputHashContentChange ( result [ 0 ] , result [ 1 ] )
109
135
} )
110
136
@@ -750,3 +776,17 @@ function assertOutputHashContentChange(
750
776
}
751
777
}
752
778
}
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