File tree Expand file tree Collapse file tree 3 files changed +12
-19
lines changed
packages/jest-leak-detector Expand file tree Collapse file tree 3 files changed +12
-19
lines changed Original file line number Diff line number Diff line change 1111 "types" : " build/index.d.ts" ,
1212 "dependencies" : {
1313 "jest-get-type" : " ^24.8.0" ,
14- "pretty-format" : " ^24.8.0"
14+ "pretty-format" : " ^24.8.0" ,
15+ "weak-napi" : " ^1.0.3"
1516 },
1617 "devDependencies" : {
17- "weak-napi" : " ^1.0.3 "
18+ "@types/ weak-napi" : " ^1.0.0 "
1819 },
1920 "engines" : {
2021 "node" : " >= 6"
Original file line number Diff line number Diff line change 77
88import v8 from 'v8' ;
99import vm from 'vm' ;
10+ import weak from 'weak-napi' ;
1011import prettyFormat from 'pretty-format' ;
1112import { isPrimitive } from 'jest-get-type' ;
1213
@@ -23,23 +24,7 @@ export default class {
2324 ) ;
2425 }
2526
26- let weak ;
27-
28- try {
29- // eslint-disable-next-line import/no-extraneous-dependencies
30- weak = require ( 'weak-napi' ) ;
31- } catch ( err ) {
32- if ( ! err || err . code !== 'MODULE_NOT_FOUND' ) {
33- throw err ;
34- }
35-
36- throw new Error (
37- 'The leaking detection mechanism requires the "weak-api" package to be installed and work. ' +
38- 'Please install it as a dependency on your main project' ,
39- ) ;
40- }
41-
42- weak ( value , ( ) => ( this . _isReferenceBeingHeld = false ) ) ;
27+ weak ( value as object , ( ) => ( this . _isReferenceBeingHeld = false ) ) ;
4328 this . _isReferenceBeingHeld = true ;
4429
4530 // Ensure value is not leaked by the closure created by the "weak" callback.
Original file line number Diff line number Diff line change 19611961 resolved "https://registry.yarnpkg.com/@types/tough-cookie/-/tough-cookie-2.3.5.tgz#9da44ed75571999b65c37b60c9b2b88db54c585d"
19621962 integrity sha512-SCcK7mvGi3+ZNz833RRjFIxrn4gI1PPR3NtuIS+6vMkvmsGjosqTJwRt5bAEFLRz+wtJMWv8+uOnZf2hi2QXTg==
19631963
1964+ "@types/weak-napi@^1.0.0":
1965+ version "1.0.0"
1966+ resolved "https://registry.yarnpkg.com/@types/weak-napi/-/weak-napi-1.0.0.tgz#b0977c0737cb62d028c4eda76f4e295bb3ae3c49"
1967+ integrity sha512-viW/kPA1gpeoNdUge025WqmThQ2lnnHzZWZJM5KlH8w9E5YehOh3GnDjW5w/sAEC91VOlePEiFSQmbnX7VVyLw==
1968+ dependencies:
1969+ "@types/node" "*"
1970+
19641971"@types/write-file-atomic@^2.1.1":
19651972 version "2.1.1"
19661973 resolved "https://registry.yarnpkg.com/@types/write-file-atomic/-/write-file-atomic-2.1.1.tgz#7f9fcd6c5c8d194dba03472e3fa6cb29a839764c"
You can’t perform that action at this time.
0 commit comments