Skip to content

Commit

Permalink
Fixed standalone target not properly serving backend over localhost:8097
Browse files Browse the repository at this point in the history
  • Loading branch information
Brian Vaughn committed Aug 19, 2019
1 parent 14c2eab commit d2456c7
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 9 deletions.
11 changes: 2 additions & 9 deletions packages/react-devtools-core/src/standalone.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import Store from 'src/devtools/store';
import { getSavedComponentFilters, getAppendComponentStack } from 'src/utils';
import { Server } from 'ws';
import { join } from 'path';
import { existsSync, readFileSync } from 'fs';
import { readFileSync } from 'fs';
import { installHook } from 'src/hook';
import DevTools from 'src/devtools/views/DevTools';
import { doesFilePathExist, launchEditor } from './editor';
Expand Down Expand Up @@ -257,15 +257,8 @@ function startServer(port?: number = 8097) {
});

httpServer.on('request', (request, response) => {
// NPM installs should read from node_modules,
// But local dev mode needs to use a relative path.
let basePath = join(__dirname, 'node_modules/react-devtools-core');
if (!existsSync(basePath)) {
basePath = '../react-devtools-core';
}

// Serve a file that immediately sets up the connection.
const backendFile = readFileSync(`${basePath}/dist/backend.js`);
const backendFile = readFileSync(join(__dirname, 'backend.js'));

// The renderer interface doesn't read saved component filters directly,
// because they are generally stored in localStorage within the context of the extension.
Expand Down
6 changes: 6 additions & 0 deletions packages/react-devtools-core/webpack.standalone.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,12 @@ module.exports = {
src: resolve(__dirname, '../../src'),
},
},
node: {
// Don't replace __dirname!
// This would break the standalone DevTools ability to load the backend.
// see https://github.com/facebook/react-devtools/issues/1269
__dirname: false,
},
plugins: [
new DefinePlugin({
__DEV__: false,
Expand Down

0 comments on commit d2456c7

Please sign in to comment.