@@ -18,7 +18,8 @@ const CHUNK_CHECKS = { goodbye: 1, parent: 2 } as const;
18
18
const numMatchesTest = ( file : string , pattern : RegExp , nMatches : number ) =>
19
19
async function ( ) {
20
20
const code = await readFile ( file , "utf-8" ) ;
21
- expect ( code . match ( new RegExp ( pattern , "g" ) ) ?. length ) . to . equal ( nMatches ) ;
21
+ const globalPattern = new RegExp ( pattern , "g" ) ;
22
+ expect ( code . match ( globalPattern ) ?. length ?? 0 ) . to . equal ( nMatches ) ;
22
23
} ;
23
24
24
25
for ( const runtime of [ false , { version : devDependencies [ "@babel/runtime" ] } ] ) {
@@ -74,6 +75,7 @@ for (const runtime of [false, { version: devDependencies["@babel/runtime"] }]) {
74
75
75
76
for ( const [ name , nMatches ] of Object . entries ( CHUNK_CHECKS ) ) {
76
77
const outChunk = join ( outDir , `src_${ name } _js.cjs` ) ;
78
+ let nStrict = 0 ; // only one at top chunk level
77
79
if ( nodeVersion < 7.6 ) {
78
80
it (
79
81
`Transpiles the async function to a generator in the ${ name } chunk` ,
@@ -85,6 +87,7 @@ for (const runtime of [false, { version: devDependencies["@babel/runtime"] }]) {
85
87
nMatches ,
86
88
) ,
87
89
) ;
90
+ if ( runtime ) nStrict = nMatches ; // because helper is included in chunk
88
91
} else {
89
92
it (
90
93
`Contains async arrow function in the ${ name } chunk` ,
@@ -106,7 +109,12 @@ for (const runtime of [false, { version: devDependencies["@babel/runtime"] }]) {
106
109
nMatches ,
107
110
) ,
108
111
) ;
112
+ nStrict = 0 ; // because asyncToGenerator hlper is split to separate chunk
109
113
}
114
+ it (
115
+ `Does not add extra strict mode in the ${ name } chunk` ,
116
+ numMatchesTest ( outChunk , / \n " u s e s t r i c t " ; / , nStrict ) ,
117
+ ) ;
110
118
}
111
119
112
120
for ( const name of ENTRY_NAMES ) {
0 commit comments