File tree 2 files changed +14
-2
lines changed
packages/jest-leak-detector
2 files changed +14
-2
lines changed Original file line number Diff line number Diff line change 8
8
"license" : " MIT" ,
9
9
"main" : " build/index.js" ,
10
10
"dependencies" : {
11
- "pretty-format" : " ^21.2.1" ,
11
+ "pretty-format" : " ^21.2.1"
12
+ },
13
+ "optionalDependencies" : {
12
14
"weak" : " ^1.0.1"
13
15
}
14
16
}
Original file line number Diff line number Diff line change 12
12
import prettyFormat from 'pretty-format' ;
13
13
import v8 from 'v8' ;
14
14
import vm from 'vm' ;
15
- import weak from 'weak' ;
16
15
17
16
const PRIMITIVE_TYPES = new Set ( [
18
17
'undefined' ,
@@ -35,6 +34,17 @@ export default class {
35
34
) ;
36
35
}
37
36
37
+ let weak ;
38
+
39
+ try {
40
+ weak = require ( 'weak' ) ;
41
+ } catch ( err ) {
42
+ throw new Error (
43
+ 'The leaking detection mechanism requires the "weak" package to work. ' +
44
+ 'Please make sure that you can install the native dependency on your platform.' ,
45
+ ) ;
46
+ }
47
+
38
48
weak ( value , ( ) => ( this . _isReferenceBeingHeld = false ) ) ;
39
49
this . _isReferenceBeingHeld = true ;
40
50
You can’t perform that action at this time.
0 commit comments