Skip to content

Commit e8f2b34

Browse files
authored
Import devtools only when DEV=true (#385)
1 parent 13da4ec commit e8f2b34

File tree

2 files changed

+11
-9
lines changed

2 files changed

+11
-9
lines changed

src/devtools.ts

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
// Ignoring missing types error to avoid adding another dependency for this hack to work
22
// @ts-ignore
33
import ws from 'ws';
4+
// @ts-ignore
5+
import {connectToDevTools} from 'react-devtools-core';
46

57
const customGlobal = global as any;
68

@@ -69,10 +71,4 @@ customGlobal.window.__REACT_DEVTOOLS_COMPONENT_FILTERS__ = [
6971
}
7072
];
7173

72-
// Ignoring missing types error to avoid adding another dependency for this hack to work
73-
// @ts-ignore
74-
import {connectToDevTools} from 'react-devtools-core';
75-
76-
if (process.env.DEV === 'true') {
77-
connectToDevTools();
78-
}
74+
connectToDevTools();

src/reconciler.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,14 @@ import type {
2323
} from './dom';
2424
import type {Styles} from './styles';
2525
import type {OutputTransformer} from './render-node-to-output';
26-
// eslint-disable-next-line import/no-unassigned-import
27-
import './devtools';
26+
27+
// We need to conditionally perform devtools connection to avoid
28+
// accidentally breaking other third-party code.
29+
// See https://github.com/vadimdemedes/ink/issues/384
30+
if (process.env.DEV === 'true') {
31+
// eslint-disable-next-line import/no-unassigned-import
32+
require('./devtools');
33+
}
2834

2935
const cleanupYogaNode = (node?: Yoga.YogaNode): void => {
3036
node?.unsetMeasureFunc();

0 commit comments

Comments
 (0)