Skip to content
This repository has been archived by the owner on Jun 26, 2020. It is now read-only.

Commit

Permalink
Fixed standalone+DOM integration (#1271)
Browse files Browse the repository at this point in the history
  • Loading branch information
bvaughn committed Jan 7, 2019
1 parent bcf6b1a commit 9005cbc
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
11 changes: 7 additions & 4 deletions packages/react-devtools-core/src/standalone.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@

var ws = require('ws');
var fs = require('fs');
var path = require('path');

var installGlobalHook = require('../../../backend/installGlobalHook');
installGlobalHook(window);
Expand Down Expand Up @@ -147,10 +146,14 @@ function startServer(port = 8097) {
});

httpServer.on('request', (req, res) => {
// NPM installs should read from node_modules,
// But local dev mode needs to use a relative path.
const basePath = fs.existsSync('./node_modules/react-devtools-core')
? 'node_modules/react-devtools-core'
: '../react-devtools-core';

// Serve a file that immediately sets up the connection.
var backendFile = fs.readFileSync(
path.join(__dirname, '../build/backend.js')
);
var backendFile = fs.readFileSync(`${basePath}/build/backend.js`);
res.end(backendFile + '\n;ReactDevToolsBackend.connectToDevTools();');
});

Expand Down
4 changes: 3 additions & 1 deletion packages/react-devtools-core/webpack.backend.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@ module.exports = {
output: {
path: __dirname + '/build',
filename: '[name].js',
library: '[name]',

// This name is important; standalone references it in order to connect.
library: 'ReactDevToolsBackend',
libraryTarget: 'umd',
},
plugins: __DEV__ ? [] : [
Expand Down

0 comments on commit 9005cbc

Please sign in to comment.