Skip to content

Commit d2456c7

Browse files
author
Brian Vaughn
committed
Fixed standalone target not properly serving backend over localhost:8097
1 parent 14c2eab commit d2456c7

File tree

2 files changed

+8
-9
lines changed

2 files changed

+8
-9
lines changed

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

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import Store from 'src/devtools/store';
1212
import { getSavedComponentFilters, getAppendComponentStack } from 'src/utils';
1313
import { Server } from 'ws';
1414
import { join } from 'path';
15-
import { existsSync, readFileSync } from 'fs';
15+
import { readFileSync } from 'fs';
1616
import { installHook } from 'src/hook';
1717
import DevTools from 'src/devtools/views/DevTools';
1818
import { doesFilePathExist, launchEditor } from './editor';
@@ -257,15 +257,8 @@ function startServer(port?: number = 8097) {
257257
});
258258

259259
httpServer.on('request', (request, response) => {
260-
// NPM installs should read from node_modules,
261-
// But local dev mode needs to use a relative path.
262-
let basePath = join(__dirname, 'node_modules/react-devtools-core');
263-
if (!existsSync(basePath)) {
264-
basePath = '../react-devtools-core';
265-
}
266-
267260
// Serve a file that immediately sets up the connection.
268-
const backendFile = readFileSync(`${basePath}/dist/backend.js`);
261+
const backendFile = readFileSync(join(__dirname, 'backend.js'));
269262

270263
// The renderer interface doesn't read saved component filters directly,
271264
// because they are generally stored in localStorage within the context of the extension.

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,12 @@ module.exports = {
3131
src: resolve(__dirname, '../../src'),
3232
},
3333
},
34+
node: {
35+
// Don't replace __dirname!
36+
// This would break the standalone DevTools ability to load the backend.
37+
// see https://github.com/facebook/react-devtools/issues/1269
38+
__dirname: false,
39+
},
3440
plugins: [
3541
new DefinePlugin({
3642
__DEV__: false,

0 commit comments

Comments
 (0)