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

Fixed standalone+DOM integration #1271

Merged
merged 1 commit into from Jan 7, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
11 changes: 7 additions & 4 deletions packages/react-devtools-core/src/standalone.js
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
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