From 93acfb0d5bb0dca21999d407b29c413a5807e3e0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miguel=20Jim=C3=A9nez=20Es=C3=BAn?= Date: Tue, 9 Jan 2018 13:58:57 +0000 Subject: [PATCH] Fully remove weak and check only in runtime (#5252) --- CHANGELOG.md | 2 ++ packages/jest-leak-detector/package.json | 2 +- packages/jest-leak-detector/src/index.js | 5 +++-- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index fcb07c0a7467..0835e006aa8d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,8 @@ ### Fixes +* `[jest-leak-detector]` Removed the reference to `weak`. Now, parent projects + must install it by hand for the module to work. * `[expect]` Fail test when the types of `stringContaining` and `stringMatching` matchers do not match. ([#5069](https://github.com/facebook/jest/pull/5069)) * `[jest-cli]` Treat dumb terminals as noninteractive diff --git a/packages/jest-leak-detector/package.json b/packages/jest-leak-detector/package.json index d1d03cf1c687..0f28c5276e86 100644 --- a/packages/jest-leak-detector/package.json +++ b/packages/jest-leak-detector/package.json @@ -10,7 +10,7 @@ "dependencies": { "pretty-format": "^22.0.3" }, - "optionalDependencies": { + "devDependencies": { "weak": "^1.0.1" } } diff --git a/packages/jest-leak-detector/src/index.js b/packages/jest-leak-detector/src/index.js index 318b6153c4d0..2fca36551e57 100644 --- a/packages/jest-leak-detector/src/index.js +++ b/packages/jest-leak-detector/src/index.js @@ -37,6 +37,7 @@ export default class { let weak; try { + // eslint-disable-next-line import/no-extraneous-dependencies weak = require('weak'); } catch (err) { if (!err || err.code !== 'MODULE_NOT_FOUND') { @@ -44,8 +45,8 @@ export default class { } throw new Error( - 'The leaking detection mechanism requires the "weak" package to work. ' + - 'Please make sure that you can install the native dependency on your platform.', + 'The leaking detection mechanism requires the "weak" package to be installed and work. ' + + 'Please install it as a dependency on your main project', ); }