@@ -7,7 +7,7 @@ const defaultOptions = {
7
7
filename : 'test-entry-file.js'
8
8
}
9
9
10
- const genCoreJSImportRegExp = mod => {
10
+ const getAbsolutePolyfill = mod => {
11
11
// expected to include a `node_modules` in the import path because we use absolute path for core-js
12
12
return new RegExp ( `import "${ [ '.*node_modules' , 'core-js' , 'modules' , mod ] . join ( `[\\${ path . sep } ]+` ) } ` )
13
13
}
@@ -27,9 +27,9 @@ test('polyfill detection', () => {
27
27
filename : 'test-entry-file.js'
28
28
} )
29
29
// default includes
30
- expect ( code ) . not . toMatch ( genCoreJSImportRegExp ( 'es6 .promise') )
30
+ expect ( code ) . not . toMatch ( getAbsolutePolyfill ( 'es .promise') )
31
31
// usage-based detection
32
- expect ( code ) . not . toMatch ( genCoreJSImportRegExp ( 'es6 .map' ) )
32
+ expect ( code ) . not . toMatch ( 'import "core-js/modules/es .map"' )
33
33
34
34
; ( { code } = babel . transformSync ( `
35
35
const a = new Map()
@@ -41,11 +41,11 @@ test('polyfill detection', () => {
41
41
filename : 'test-entry-file.js'
42
42
} ) )
43
43
// default includes
44
- expect ( code ) . toMatch ( genCoreJSImportRegExp ( 'es6 .promise') )
44
+ expect ( code ) . toMatch ( getAbsolutePolyfill ( 'es .promise') )
45
45
// promise polyfill alone doesn't work in IE, needs this as well. fix: #1642
46
- expect ( code ) . toMatch ( genCoreJSImportRegExp ( 'es6 .array.iterator') )
46
+ expect ( code ) . toMatch ( getAbsolutePolyfill ( 'es .array.iterator') )
47
47
// usage-based detection
48
- expect ( code ) . toMatch ( / i m p o r t " c o r e - j s \ /m o d u l e s \/ e s 6 .m a p " / )
48
+ expect ( code ) . toMatch ( ' import "core-js/modules/es .map"' )
49
49
} )
50
50
51
51
test ( 'modern mode always skips polyfills' , ( ) => {
@@ -61,9 +61,9 @@ test('modern mode always skips polyfills', () => {
61
61
filename : 'test-entry-file.js'
62
62
} )
63
63
// default includes
64
- expect ( code ) . not . toMatch ( genCoreJSImportRegExp ( 'es6 .promise') )
64
+ expect ( code ) . not . toMatch ( getAbsolutePolyfill ( 'es .promise') )
65
65
// usage-based detection
66
- expect ( code ) . not . toMatch ( / i m p o r t " c o r e - j s \ /m o d u l e s \/ e s 6 .m a p " / )
66
+ expect ( code ) . not . toMatch ( ' import "core-js/modules/es .map"' )
67
67
68
68
; ( { code } = babel . transformSync ( `
69
69
const a = new Map()
@@ -76,9 +76,9 @@ test('modern mode always skips polyfills', () => {
76
76
filename : 'test-entry-file.js'
77
77
} ) )
78
78
// default includes
79
- expect ( code ) . not . toMatch ( genCoreJSImportRegExp ( 'es6 .promise') )
79
+ expect ( code ) . not . toMatch ( getAbsolutePolyfill ( 'es .promise') )
80
80
// usage-based detection
81
- expect ( code ) . not . toMatch ( / i m p o r t " c o r e - j s \ /m o d u l e s \/ e s 6 .m a p " / )
81
+ expect ( code ) . not . toMatch ( ' import "core-js/modules/es .map"' )
82
82
delete process . env . VUE_CLI_MODERN_BUILD
83
83
} )
84
84
@@ -103,11 +103,11 @@ test('async/await', () => {
103
103
}
104
104
hello()
105
105
` . trim ( ) , defaultOptions )
106
- expect ( code ) . toMatch ( genCoreJSImportRegExp ( 'es6 .promise') )
106
+ expect ( code ) . toMatch ( getAbsolutePolyfill ( 'es .promise') )
107
107
// should use regenerator runtime
108
108
expect ( code ) . toMatch ( `import "regenerator-runtime/runtime"` )
109
109
// should use required helper instead of inline
110
- expect ( code ) . toMatch ( / i m p o r t _ a s y n c T o G e n e r a t o r f r o m " .* r u n t i m e - c o r e j s 2 \/ h e l p e r s \/ e s m \/ a s y n c T o G e n e r a t o r \" / )
110
+ expect ( code ) . toMatch ( / i m p o r t _ a s y n c T o G e n e r a t o r f r o m " .* r u n t i m e - c o r e j s 3 \/ h e l p e r s \/ e s m \/ a s y n c T o G e n e r a t o r \" / )
111
111
} )
112
112
113
113
test ( 'jsx' , ( ) => {
@@ -152,6 +152,6 @@ test('disable absoluteRuntime', () => {
152
152
filename : 'test-entry-file.js'
153
153
} )
154
154
155
- expect ( code ) . toMatch ( 'import _toConsumableArray from "@babel/runtime-corejs2 /helpers/esm/toConsumableArray"' )
156
- expect ( code ) . not . toMatch ( genCoreJSImportRegExp ( 'es6 .promise') )
155
+ expect ( code ) . toMatch ( 'import _toConsumableArray from "@babel/runtime-corejs3 /helpers/esm/toConsumableArray"' )
156
+ expect ( code ) . not . toMatch ( getAbsolutePolyfill ( 'es .promise') )
157
157
} )
0 commit comments