diff --git a/packages/react-devtools-core/src/standalone.js b/packages/react-devtools-core/src/standalone.js index a5371154efa86..8a20d75aa0164 100644 --- a/packages/react-devtools-core/src/standalone.js +++ b/packages/react-devtools-core/src/standalone.js @@ -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'; @@ -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. diff --git a/packages/react-devtools-core/webpack.standalone.js b/packages/react-devtools-core/webpack.standalone.js index 034d281a5775a..03019861a2301 100644 --- a/packages/react-devtools-core/webpack.standalone.js +++ b/packages/react-devtools-core/webpack.standalone.js @@ -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,