@@ -109,62 +109,62 @@ test('build w/ multi page', async () => {
109
109
110
110
const assertSharedAssets = file => {
111
111
// should split and preload vendor chunk
112
- expect ( file ) . toMatch ( / < l i n k [ ^ > ] * j s \/ c h u n k - v e n d o r s [ ^ > ] * \. j s r e l = p r e l o a d a s = s c r i p t > / )
113
- expect ( file ) . toMatch ( / < s c r i p t [ ^ > ] * s r c = \/ j s \/ c h u n k - v e n d o r s \. \w + \. j s > / )
112
+ expect ( file ) . toMatch ( / < l i n k [ ^ > ] * j s \/ c h u n k - v e n d o r s [ ^ > ] * \. j s " r e l = " p r e l o a d " a s = " s c r i p t " > / )
113
+ expect ( file ) . toMatch ( / < s c r i p t [ ^ > ] * s r c = " \/ j s \/ c h u n k - v e n d o r s \. \w + \. j s " > / )
114
114
}
115
115
116
116
const index = await project . read ( 'dist/index.html' )
117
117
assertSharedAssets ( index )
118
118
// should split and preload common js and css
119
- expect ( index ) . toMatch ( / < l i n k [ ^ > ] * j s \/ c h u n k - c o m m o n [ ^ > ] * \. j s r e l = p r e l o a d a s = s c r i p t > / )
120
- expect ( index ) . toMatch ( / < s c r i p t [ ^ > ] * s r c = \/ j s \/ c h u n k - c o m m o n \. \w + \. j s > / )
121
- expect ( index ) . toMatch ( / < l i n k h r e f = \/ c s s \/ c h u n k - c o m m o n \. \w + \. c s s r e l = s t y l e s h e e t > / )
122
- expect ( index ) . toMatch ( / < l i n k [ ^ > ] * c h u n k - c o m m o n [ ^ > ] * \. c s s r e l = p r e l o a d a s = s t y l e > / )
119
+ expect ( index ) . toMatch ( / < l i n k [ ^ > ] * j s \/ c h u n k - c o m m o n [ ^ > ] * \. j s " r e l = " p r e l o a d " a s = " s c r i p t " > / )
120
+ expect ( index ) . toMatch ( / < s c r i p t [ ^ > ] * s r c = " \/ j s \/ c h u n k - c o m m o n \. \w + \. j s " > / )
121
+ expect ( index ) . toMatch ( / < l i n k h r e f = " \/ c s s \/ c h u n k - c o m m o n \. \w + \. c s s " r e l = " s t y l e s h e e t " > / )
122
+ expect ( index ) . toMatch ( / < l i n k [ ^ > ] * c h u n k - c o m m o n [ ^ > ] * \. c s s " r e l = " p r e l o a d " a s = " s t y l e " > / )
123
123
// should preload correct page file
124
- expect ( index ) . toMatch ( / < l i n k [ ^ > ] * j s \/ i n d e x [ ^ > ] * \. j s r e l = p r e l o a d a s = s c r i p t > / )
125
- expect ( index ) . not . toMatch ( / < l i n k [ ^ > ] * j s \/ f o o [ ^ > ] * \. j s r e l = p r e l o a d a s = s c r i p t > / )
126
- expect ( index ) . not . toMatch ( / < l i n k [ ^ > ] * j s \/ b a r [ ^ > ] * \. j s r e l = p r e l o a d a s = s c r i p t > / )
124
+ expect ( index ) . toMatch ( / < l i n k [ ^ > ] * j s \/ i n d e x [ ^ > ] * \. j s " r e l = " p r e l o a d " a s = " s c r i p t " > / )
125
+ expect ( index ) . not . toMatch ( / < l i n k [ ^ > ] * j s \/ f o o [ ^ > ] * \. j s " r e l = " p r e l o a d " a s = " s c r i p t " > / )
126
+ expect ( index ) . not . toMatch ( / < l i n k [ ^ > ] * j s \/ b a r [ ^ > ] * \. j s " r e l = " p r e l o a d " a s = " s c r i p t " > / )
127
127
// should prefetch async chunk js and css
128
- expect ( index ) . toMatch ( / < l i n k [ ^ > ] * c s s \/ c h u n k - \w + \. \w + \. c s s r e l = p r e f e t c h > / )
129
- expect ( index ) . toMatch ( / < l i n k [ ^ > ] * j s \/ c h u n k - \w + \. \w + \. j s r e l = p r e f e t c h > / )
128
+ expect ( index ) . toMatch ( / < l i n k [ ^ > ] * c s s \/ c h u n k - \w + \. \w + \. c s s " r e l = " p r e f e t c h " > / )
129
+ expect ( index ) . toMatch ( / < l i n k [ ^ > ] * j s \/ c h u n k - \w + \. \w + \. j s " r e l = " p r e f e t c h " > / )
130
130
// should load correct page js
131
- expect ( index ) . toMatch ( / < s c r i p t [ ^ > ] * s r c = \/ j s \/ i n d e x \. \w + \. j s > / )
132
- expect ( index ) . not . toMatch ( / < s c r i p t [ ^ > ] * s r c = \/ j s \/ f o o \. \w + \. j s > / )
133
- expect ( index ) . not . toMatch ( / < s c r i p t [ ^ > ] * s r c = \/ j s \/ b a r \. \w + \. j s > / )
131
+ expect ( index ) . toMatch ( / < s c r i p t [ ^ > ] * s r c = " \/ j s \/ i n d e x \. \w + \. j s " > / )
132
+ expect ( index ) . not . toMatch ( / < s c r i p t [ ^ > ] * s r c = " \/ j s \/ f o o \. \w + \. j s " > / )
133
+ expect ( index ) . not . toMatch ( / < s c r i p t [ ^ > ] * s r c = " \/ j s \/ b a r \. \w + \. j s " > / )
134
134
135
135
const foo = await project . read ( 'dist/foo.html' )
136
136
assertSharedAssets ( foo )
137
137
// should preload correct page file
138
- expect ( foo ) . not . toMatch ( / < l i n k [ ^ > ] * j s \/ i n d e x [ ^ > ] * \. j s r e l = p r e l o a d a s = s c r i p t > / )
139
- expect ( foo ) . toMatch ( / < l i n k [ ^ > ] * j s \/ f o o [ ^ > ] * \. j s r e l = p r e l o a d a s = s c r i p t > / )
140
- expect ( foo ) . not . toMatch ( / < l i n k [ ^ > ] * j s \/ b a r [ ^ > ] * \. j s r e l = p r e l o a d a s = s c r i p t > / )
138
+ expect ( foo ) . not . toMatch ( / < l i n k [ ^ > ] * j s \/ i n d e x [ ^ > ] * \. j s " r e l = " p r e l o a d " a s = " s c r i p t " > / )
139
+ expect ( foo ) . toMatch ( / < l i n k [ ^ > ] * j s \/ f o o [ ^ > ] * \. j s " r e l = " p r e l o a d " a s = " s c r i p t " > / )
140
+ expect ( foo ) . not . toMatch ( / < l i n k [ ^ > ] * j s \/ b a r [ ^ > ] * \. j s " r e l = " p r e l o a d " a s = " s c r i p t " > / )
141
141
// should not prefetch async chunk js and css because it's not used by
142
142
// this entry
143
- expect ( foo ) . not . toMatch ( / < l i n k [ ^ > ] * c s s \/ c h u n k - \w + \. \w + \. c s s r e l = p r e f e t c h > / )
144
- expect ( foo ) . not . toMatch ( / < l i n k [ ^ > ] * j s \/ c h u n k - \w + \. \w + \. j s r e l = p r e f e t c h > / )
143
+ expect ( foo ) . not . toMatch ( / < l i n k [ ^ > ] * c s s \/ c h u n k - \w + \. \w + \. c s s " r e l = " p r e f e t c h " > / )
144
+ expect ( foo ) . not . toMatch ( / < l i n k [ ^ > ] * j s \/ c h u n k - \w + \. \w + \. j s " r e l = " p r e f e t c h " > / )
145
145
// should load correct page js
146
- expect ( foo ) . not . toMatch ( / < s c r i p t [ ^ > ] * s r c = \/ j s \/ i n d e x \. \w + \. j s > / )
147
- expect ( foo ) . toMatch ( / < s c r i p t [ ^ > ] * s r c = \/ j s \/ f o o \. \w + \. j s > / )
148
- expect ( foo ) . not . toMatch ( / < s c r i p t [ ^ > ] * s r c = \/ j s \/ b a r \. \w + \. j s > / )
146
+ expect ( foo ) . not . toMatch ( / < s c r i p t [ ^ > ] * s r c = " \/ j s \/ i n d e x \. \w + \. j s " > / )
147
+ expect ( foo ) . toMatch ( / < s c r i p t [ ^ > ] * s r c = " \/ j s \/ f o o \. \w + \. j s " > / )
148
+ expect ( foo ) . not . toMatch ( / < s c r i p t [ ^ > ] * s r c = " \/ j s \/ b a r \. \w + \. j s " > / )
149
149
150
150
const bar = await project . read ( 'dist/bar.html' )
151
151
assertSharedAssets ( bar )
152
152
// bar & index have a shared common chunk (App.vue)
153
- expect ( bar ) . toMatch ( / < l i n k [ ^ > ] * j s \/ c h u n k - c o m m o n [ ^ > ] * \. j s r e l = p r e l o a d a s = s c r i p t > / )
154
- expect ( bar ) . toMatch ( / < s c r i p t [ ^ > ] * s r c = \/ j s \/ c h u n k - c o m m o n \. \w + \. j s > / )
155
- expect ( bar ) . toMatch ( / < l i n k h r e f = \/ c s s \/ c h u n k - c o m m o n \. \w + \. c s s r e l = s t y l e s h e e t > / )
156
- expect ( bar ) . toMatch ( / < l i n k [ ^ > ] * c h u n k - c o m m o n [ ^ > ] * \. c s s r e l = p r e l o a d a s = s t y l e > / )
153
+ expect ( bar ) . toMatch ( / < l i n k [ ^ > ] * j s \/ c h u n k - c o m m o n [ ^ > ] * \. j s " r e l = " p r e l o a d " a s = " s c r i p t " > / )
154
+ expect ( bar ) . toMatch ( / < s c r i p t [ ^ > ] * s r c = " \/ j s \/ c h u n k - c o m m o n \. \w + \. j s " > / )
155
+ expect ( bar ) . toMatch ( / < l i n k h r e f = " \/ c s s \/ c h u n k - c o m m o n \. \w + \. c s s " r e l = " s t y l e s h e e t " > / )
156
+ expect ( bar ) . toMatch ( / < l i n k [ ^ > ] * c h u n k - c o m m o n [ ^ > ] * \. c s s " r e l = " p r e l o a d " a s = " s t y l e " > / )
157
157
// should preload correct page file
158
- expect ( bar ) . not . toMatch ( / < l i n k [ ^ > ] * j s \/ i n d e x [ ^ > ] * \. j s r e l = p r e l o a d a s = s c r i p t > / )
159
- expect ( bar ) . not . toMatch ( / < l i n k [ ^ > ] * j s \/ f o o [ ^ > ] * \. j s r e l = p r e l o a d a s = s c r i p t > / )
160
- expect ( bar ) . toMatch ( / < l i n k [ ^ > ] * j s \/ b a r [ ^ > ] * \. j s r e l = p r e l o a d a s = s c r i p t > / )
158
+ expect ( bar ) . not . toMatch ( / < l i n k [ ^ > ] * j s \/ i n d e x [ ^ > ] * \. j s " r e l = " p r e l o a d " a s = " s c r i p t " > / )
159
+ expect ( bar ) . not . toMatch ( / < l i n k [ ^ > ] * j s \/ f o o [ ^ > ] * \. j s " r e l = " p r e l o a d " a s = " s c r i p t " > / )
160
+ expect ( bar ) . toMatch ( / < l i n k [ ^ > ] * j s \/ b a r [ ^ > ] * \. j s " r e l = " p r e l o a d " a s = " s c r i p t " > / )
161
161
// should prefetch async chunk js and css
162
- expect ( bar ) . toMatch ( / < l i n k [ ^ > ] * c s s \/ c h u n k - \w + \. \w + \. c s s r e l = p r e f e t c h > / )
163
- expect ( bar ) . toMatch ( / < l i n k [ ^ > ] * j s \/ c h u n k - \w + \. \w + \. j s r e l = p r e f e t c h > / )
162
+ expect ( bar ) . toMatch ( / < l i n k [ ^ > ] * c s s \/ c h u n k - \w + \. \w + \. c s s " r e l = " p r e f e t c h " > / )
163
+ expect ( bar ) . toMatch ( / < l i n k [ ^ > ] * j s \/ c h u n k - \w + \. \w + \. j s " r e l = " p r e f e t c h " > / )
164
164
// should load correct page js
165
- expect ( bar ) . not . toMatch ( / < s c r i p t [ ^ > ] * s r c = \/ j s \/ i n d e x \. \w + \. j s > / )
166
- expect ( bar ) . not . toMatch ( / < s c r i p t [ ^ > ] * s r c = \/ j s \/ f o o \. \w + \. j s > / )
167
- expect ( bar ) . toMatch ( / < s c r i p t [ ^ > ] * s r c = \/ j s \/ b a r \. \w + \. j s > / )
165
+ expect ( bar ) . not . toMatch ( / < s c r i p t [ ^ > ] * s r c = " \/ j s \/ i n d e x \. \w + \. j s " > / )
166
+ expect ( bar ) . not . toMatch ( / < s c r i p t [ ^ > ] * s r c = " \/ j s \/ f o o \. \w + \. j s " > / )
167
+ expect ( bar ) . toMatch ( / < s c r i p t [ ^ > ] * s r c = " \/ j s \/ b a r \. \w + \. j s " > / )
168
168
169
169
// assert pages work
170
170
const port = await portfinder . getPortPromise ( )
0 commit comments