Skip to content

Commit 45dff31

Browse files
author
Brian Vaughn
committed
Patched up react-devtools-core Webpack configs
1 parent 58b39c6 commit 45dff31

File tree

4 files changed

+55
-29
lines changed

4 files changed

+55
-29
lines changed

packages/react-devtools-core/src/backend.js

Lines changed: 32 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -189,34 +189,38 @@ export function connectToDevTools(options: ?ConnectOptions) {
189189
}
190190
};
191191

192-
Object.defineProperty(
193-
hook,
194-
'resolveRNStyle',
195-
({
196-
enumerable: false,
197-
get() {
198-
return lazyResolveRNStyle;
199-
},
200-
set(value) {
201-
lazyResolveRNStyle = value;
202-
initAfterTick();
203-
},
204-
}: Object),
205-
);
206-
Object.defineProperty(
207-
hook,
208-
'nativeStyleEditorValidAttributes',
209-
({
210-
enumerable: false,
211-
get() {
212-
return lazyNativeStyleEditorValidAttributes;
213-
},
214-
set(value) {
215-
lazyNativeStyleEditorValidAttributes = value;
216-
initAfterTick();
217-
},
218-
}: Object),
219-
);
192+
if (!hook.hasOwnProperty('resolveRNStyle')) {
193+
Object.defineProperty(
194+
hook,
195+
'resolveRNStyle',
196+
({
197+
enumerable: false,
198+
get() {
199+
return lazyResolveRNStyle;
200+
},
201+
set(value) {
202+
lazyResolveRNStyle = value;
203+
initAfterTick();
204+
},
205+
}: Object),
206+
);
207+
}
208+
if (!hook.hasOwnProperty('nativeStyleEditorValidAttributes')) {
209+
Object.defineProperty(
210+
hook,
211+
'nativeStyleEditorValidAttributes',
212+
({
213+
enumerable: false,
214+
get() {
215+
return lazyNativeStyleEditorValidAttributes;
216+
},
217+
set(value) {
218+
lazyNativeStyleEditorValidAttributes = value;
219+
initAfterTick();
220+
},
221+
}: Object),
222+
);
223+
}
220224
}
221225
};
222226

packages/react-devtools-core/webpack.backend.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ if (!NODE_ENV) {
1111
process.exit(1);
1212
}
1313

14+
const builtModulesDir = resolve(__dirname, '..', '..', 'build', 'node_modules');
15+
1416
const __DEV__ = NODE_ENV === 'development';
1517

1618
const GITHUB_URL = getGitHubURL();
@@ -30,6 +32,15 @@ module.exports = {
3032
library: 'ReactDevToolsBackend',
3133
libraryTarget: 'umd',
3234
},
35+
resolve: {
36+
alias: {
37+
react: resolve(builtModulesDir, 'react'),
38+
'react-dom': resolve(builtModulesDir, 'react-dom'),
39+
'react-debug-tools': resolve(builtModulesDir, 'react-debug-tools'),
40+
'react-is': resolve(builtModulesDir, 'react-is'),
41+
scheduler: resolve(builtModulesDir, 'scheduler'),
42+
},
43+
},
3344
plugins: [
3445
new DefinePlugin({
3546
__DEV__: true,

packages/react-devtools-core/webpack.standalone.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ if (!NODE_ENV) {
1111
process.exit(1);
1212
}
1313

14+
const builtModulesDir = resolve(__dirname, '..', '..', 'build', 'node_modules');
15+
1416
const __DEV__ = NODE_ENV === 'development';
1517

1618
const GITHUB_URL = getGitHubURL();
@@ -29,6 +31,15 @@ module.exports = {
2931
library: '[name]',
3032
libraryTarget: 'commonjs2',
3133
},
34+
resolve: {
35+
alias: {
36+
react: resolve(builtModulesDir, 'react'),
37+
'react-dom': resolve(builtModulesDir, 'react-dom'),
38+
'react-debug-tools': resolve(builtModulesDir, 'react-debug-tools'),
39+
'react-is': resolve(builtModulesDir, 'react-is'),
40+
scheduler: resolve(builtModulesDir, 'scheduler'),
41+
},
42+
},
3243
plugins: [
3344
new DefinePlugin({
3445
__DEV__: false,

packages/react-devtools/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ By default DevTools listen to port `8097` on `localhost`. If you need to customi
9292

9393
## Developing
9494

95-
* Run `yarn run backend:watch` and `yarn run standalone:watch` in `../react-devtools-core`
95+
* Run `yarn start:backend` and `yarn start:standalone` in `../react-devtools-core`
9696
* Run `yarn start` in this folder
9797
* Refresh the app after it has recompiled a change
9898
* For React Native, copy `react-devtools-core` to its `node_modules` to test your changes.

0 commit comments

Comments
 (0)