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 21032103 resolved "https://registry.yarnpkg.com/@types/tough-cookie/-/tough-cookie-2.3.5.tgz#9da44ed75571999b65c37b60c9b2b88db54c585d"
21042104 integrity sha512-SCcK7mvGi3+ZNz833RRjFIxrn4gI1PPR3NtuIS+6vMkvmsGjosqTJwRt5bAEFLRz+wtJMWv8+uOnZf2hi2QXTg==
21052105
2106+ "@types/weak-napi@^1.0.0":
2107+ version "1.0.0"
2108+ resolved "https://registry.yarnpkg.com/@types/weak-napi/-/weak-napi-1.0.0.tgz#b0977c0737cb62d028c4eda76f4e295bb3ae3c49"
2109+ integrity sha512-viW/kPA1gpeoNdUge025WqmThQ2lnnHzZWZJM5KlH8w9E5YehOh3GnDjW5w/sAEC91VOlePEiFSQmbnX7VVyLw==
2110+ dependencies:
2111+ "@types/node" "*"
2112+
21062113"@types/write-file-atomic@^2.1.1":
21072114 version "2.1.2"
21082115 resolved "https://registry.yarnpkg.com/@types/write-file-atomic/-/write-file-atomic-2.1.2.tgz#1657761692b70cf9ad2593e4eb4ac498adb9463f"
You can’t perform that action at this time.
0 commit comments