File tree 1 file changed +23
-7
lines changed
packages/react-scripts/config/jest
1 file changed +23
-7
lines changed Original file line number Diff line number Diff line change 3
3
'use strict' ;
4
4
5
5
const fs = require ( 'fs' ) ;
6
+ const crypto = require ( 'crypto' ) ;
6
7
const tsc = require ( 'typescript' ) ;
7
8
const tsconfigPath = require ( 'app-root-path' ) . resolve ( '/tsconfig.json' ) ;
9
+ const THIS_FILE = fs . readFileSync ( __filename ) ;
8
10
9
11
let compilerConfig = {
10
12
module : tsc . ModuleKind . CommonJS ,
11
13
jsx : tsc . JsxEmit . React ,
12
- }
14
+ } ;
13
15
14
16
if ( fs . existsSync ( tsconfigPath ) ) {
15
17
try {
@@ -18,18 +20,32 @@ if (fs.existsSync(tsconfigPath)) {
18
20
if ( tsconfig && tsconfig . compilerOptions ) {
19
21
compilerConfig = tsconfig . compilerOptions ;
20
22
}
21
- } catch ( e ) { /* Do nothing - default is set */ }
23
+ } catch ( e ) {
24
+ /* Do nothing - default is set */
25
+ }
22
26
}
23
27
24
28
module . exports = {
25
29
process ( src , path ) {
26
30
if ( path . endsWith ( '.ts' ) || path . endsWith ( '.tsx' ) ) {
27
- return tsc . transpile (
28
- src ,
29
- compilerConfig ,
30
- path , [ ]
31
- ) ;
31
+ return tsc . transpile ( src , compilerConfig , path , [ ] ) ;
32
32
}
33
33
return src ;
34
34
} ,
35
+ getCacheKey ( fileData , filePath , configStr , options ) {
36
+ return crypto
37
+ . createHash ( 'md5' )
38
+ . update ( THIS_FILE )
39
+ . update ( '\0' , 'utf8' )
40
+ . update ( fileData )
41
+ . update ( '\0' , 'utf8' )
42
+ . update ( filePath )
43
+ . update ( '\0' , 'utf8' )
44
+ . update ( configStr )
45
+ . update ( '\0' , 'utf8' )
46
+ . update ( JSON . stringify ( compilerConfig ) )
47
+ . update ( '\0' , 'utf8' )
48
+ . update ( options . instrument ? 'instrument' : '' )
49
+ . digest ( 'hex' ) ;
50
+ } ,
35
51
} ;
You can’t perform that action at this time.
0 commit comments