Fixed standalone target not properly serving backend over localhost:8097
Brian Vaughn committed
Aug 19, 2019 at 07:36 UTC
d2456c75720463eccbf714380adfd050cf804241
2 files changed
+8
-9
packages/react-devtools-core/src/standalone.js
+2
-9
@@ -12,7 +12,7 @@ import Store from 'src/devtools/store';
12
import { getSavedComponentFilters, getAppendComponentStack } from 'src/utils';
13
import { Server } from 'ws';
14
import { join } from 'path';
15
-import { existsSync, readFileSync } from 'fs';
15
+import { readFileSync } from 'fs';
16
import { installHook } from 'src/hook';
17
import DevTools from 'src/devtools/views/DevTools';
18
import { doesFilePathExist, launchEditor } from './editor';
@@ -257,15 +257,8 @@ function startServer(port?: number = 8097) {
257
});
258
259
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
-
260
// 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'));
262
263
// The renderer interface doesn't read saved component filters directly,
264
// because they are generally stored in localStorage within the context of the extension.
packages/react-devtools-core/webpack.standalone.js
+6
@@ -31,6 +31,12 @@ module.exports = {
31
src: resolve(__dirname, '../../src'),
32
},
33
},
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
+ },
40
plugins: [
41
new DefinePlugin({
42
__DEV__: false,