Skip to content

Commit 93acfb0

Browse files
authored
Fully remove weak and check only in runtime (#5252)
1 parent 6931b0f commit 93acfb0

File tree

3 files changed

+6
-3
lines changed

3 files changed

+6
-3
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
### Fixes
44

5+
* `[jest-leak-detector]` Removed the reference to `weak`. Now, parent projects
6+
must install it by hand for the module to work.
57
* `[expect]` Fail test when the types of `stringContaining` and `stringMatching`
68
matchers do not match. ([#5069](https://github.com/facebook/jest/pull/5069))
79
* `[jest-cli]` Treat dumb terminals as noninteractive

packages/jest-leak-detector/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
"dependencies": {
1111
"pretty-format": "^22.0.3"
1212
},
13-
"optionalDependencies": {
13+
"devDependencies": {
1414
"weak": "^1.0.1"
1515
}
1616
}

packages/jest-leak-detector/src/index.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,15 +37,16 @@ export default class {
3737
let weak;
3838

3939
try {
40+
// eslint-disable-next-line import/no-extraneous-dependencies
4041
weak = require('weak');
4142
} catch (err) {
4243
if (!err || err.code !== 'MODULE_NOT_FOUND') {
4344
throw err;
4445
}
4546

4647
throw new Error(
47-
'The leaking detection mechanism requires the "weak" package to work. ' +
48-
'Please make sure that you can install the native dependency on your platform.',
48+
'The leaking detection mechanism requires the "weak" package to be installed and work. ' +
49+
'Please install it as a dependency on your main project',
4950
);
5051
}
5152

0 commit comments

Comments
 (0)