File tree Expand file tree Collapse file tree 2 files changed +12
-9
lines changed
packages/@vue/cli-service Expand file tree Collapse file tree 2 files changed +12
-9
lines changed Original file line number Diff line number Diff line change @@ -25,13 +25,13 @@ test('modern mode', async () => {
25
25
// assert correct asset links
26
26
const index = await project . read ( 'dist/index.html' )
27
27
28
- // should use <script type="module"> for modern bundle
29
- expect ( index ) . toMatch ( / < s c r i p t t y p e = m o d u l e s r c = \/ j s \/ c h u n k - v e n d o r s \. \w { 8 } \. j s > / )
30
- expect ( index ) . toMatch ( / < s c r i p t t y p e = m o d u l e s r c = \/ j s \/ a p p \. \w { 8 } \. j s > / )
28
+ // should use <script type="module" crossorigin=use-credentials > for modern bundle
29
+ expect ( index ) . toMatch ( / < s c r i p t t y p e = m o d u l e s r c = \/ j s \/ c h u n k - v e n d o r s \. \w { 8 } \. j s c r o s s o r i g i n = u s e - c r e d e n t i a l s > / )
30
+ expect ( index ) . toMatch ( / < s c r i p t t y p e = m o d u l e s r c = \/ j s \/ a p p \. \w { 8 } \. j s c r o s s o r i g i n = u s e - c r e d e n t i a l s > / )
31
31
32
- // should use <link rel="modulepreload"> for modern bundle
33
- expect ( index ) . toMatch ( / < l i n k [ ^ > ] * j s \/ c h u n k - v e n d o r s \. \w { 8 } \. j s r e l = m o d u l e p r e l o a d > / )
34
- expect ( index ) . toMatch ( / < l i n k [ ^ > ] * j s \/ a p p \. \w { 8 } \. j s r e l = m o d u l e p r e l o a d > / )
32
+ // should use <link rel="modulepreload" crossorigin=use-credentials > for modern bundle
33
+ expect ( index ) . toMatch ( / < l i n k [ ^ > ] * j s \/ c h u n k - v e n d o r s \. \w { 8 } \. j s r e l = m o d u l e p r e l o a d c r o s s o r i g i n = u s e - c r e d e n t i a l s > / )
34
+ expect ( index ) . toMatch ( / < l i n k [ ^ > ] * j s \/ a p p \. \w { 8 } \. j s r e l = m o d u l e p r e l o a d c r o s s o r i g i n = u s e - c r e d e n t i a l s > / )
35
35
36
36
// should use <script nomodule> for legacy bundle
37
37
expect ( index ) . toMatch ( / < s c r i p t s r c = \/ j s \/ c h u n k - v e n d o r s - l e g a c y \. \w { 8 } \. j s n o m o d u l e > / )
Original file line number Diff line number Diff line change @@ -38,9 +38,12 @@ class ModernModePlugin {
38
38
compilation . hooks . htmlWebpackPluginAlterAssetTags . tapAsync ( ID , async ( data , cb ) => {
39
39
// use <script type="module"> for modern assets
40
40
const modernAssets = data . body . filter ( a => a . tagName === 'script' )
41
- modernAssets . forEach ( a => { a . attributes . type = 'module' } )
41
+ modernAssets . forEach ( a => {
42
+ a . attributes . type = 'module'
43
+ a . attributes . crossorigin = 'use-credentials'
44
+ } )
42
45
43
- // inject Safari 10 nomdoule fix
46
+ // inject Safari 10 nomodule fix
44
47
data . body . push ( {
45
48
tagName : 'script' ,
46
49
closeTag : true ,
@@ -62,7 +65,7 @@ class ModernModePlugin {
62
65
data . html = data . html
63
66
// use <link rel="modulepreload"> instead of <link rel="preload">
64
67
// for modern assets
65
- . replace ( / ( < l i n k a s = s c r i p t .* ?) r e l = p r e l o a d > / g, '$1rel=modulepreload>' )
68
+ . replace ( / ( < l i n k a s = s c r i p t .* ?) r e l = p r e l o a d > / g, '$1rel=modulepreload crossorigin=use-credentials >' )
66
69
. replace ( / \s n o m o d u l e = " " > / g, ' nomodule>' )
67
70
} )
68
71
} )
You can’t perform that action at this time.
0 commit comments