Skip to content

Commit

Permalink
Move react-devtools-core to optional peer dependency (#498)
Browse files Browse the repository at this point in the history
  • Loading branch information
SimenB committed Feb 17, 2022
1 parent 763db80 commit 8c2378a
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 4 deletions.
8 changes: 6 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@
"is-ci": "^2.0.0",
"lodash": "^4.17.20",
"patch-console": "^1.0.0",
"react-devtools-core": "^4.19.1",
"react-reconciler": "^0.26.2",
"scheduler": "^0.20.2",
"signal-exit": "^3.0.2",
Expand Down Expand Up @@ -92,6 +91,7 @@
"p-queue": "^6.2.1",
"prettier": "^2.0.4",
"react": "^17.0.2",
"react-devtools-core": "^4.19.1",
"sinon": "^8.1.1",
"strip-ansi": "^6.0.0",
"ts-node": "7.0.0",
Expand All @@ -100,11 +100,15 @@
},
"peerDependencies": {
"@types/react": ">=16.8.0",
"react": ">=16.8.0"
"react": ">=16.8.0",
"react-devtools-core": "^4.19.1"
},
"peerDependenciesMeta": {
"@types/react": {
"optional": true
},
"react-devtools-core": {
"optional": true
}
},
"ava": {
Expand Down
18 changes: 16 additions & 2 deletions src/reconciler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,22 @@ import {OutputTransformer} from './render-node-to-output';
// accidentally breaking other third-party code.
// See https://github.com/vadimdemedes/ink/issues/384
if (process.env.DEV === 'true') {
// eslint-disable-next-line import/no-unassigned-import
require('./devtools');
try {
// eslint-disable-next-line import/no-unassigned-import
require('./devtools');
} catch (error) {
if (error.code === 'MODULE_NOT_FOUND') {
console.warn(
`
Debugging with React Devtools requires \`react-devtools-core\` dependency to be installed.
$ npm install --save-dev react-devtools-core
`.trim()
);
} else {
throw error;
}
}
}

const cleanupYogaNode = (node?: Yoga.YogaNode): void => {
Expand Down

0 comments on commit 8c2378a

Please sign in to comment.