Skip to content

Commit

Permalink
Remove old JSC workarounds in HMRClient
Browse files Browse the repository at this point in the history
Reviewed By: fkgozali

Differential Revision: D19297717

fbshipit-source-id: e85abe1c0d1b96cf21ae3a223ee65d92e6f88824
  • Loading branch information
cpojer authored and facebook-github-bot committed Jan 8, 2020
1 parent 11ea095 commit 02633fe
Showing 1 changed file with 8 additions and 21 deletions.
29 changes: 8 additions & 21 deletions Libraries/Utilities/HMRClient.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@
'use strict';

const DevSettings = require('./DevSettings');
const Platform = require('./Platform');
const invariant = require('invariant');

const MetroHMRClient = require('metro/src/lib/bundle-modules/HMRClient');
const Platform = require('./Platform');
const prettyFormat = require('pretty-format');

This comment has been minimized.

Copy link
@heroic

heroic Jan 10, 2020

Shouldn't pretty-format be a devDependency? @cpojer

This comment has been minimized.

Copy link
@cpojer

cpojer Jan 10, 2020

Author Contributor

This module is not included in production. If it is, that's a separate bug.


import NativeRedBox from '../NativeModules/specs/NativeRedBox';
import * as LogBoxData from '../LogBox/Data/LogBoxData';
Expand Down Expand Up @@ -114,36 +114,23 @@ const HMRClient: HMRClientNativeInterface = {
return;
}
try {
let message;
if (global.Symbol) {
message = JSON.stringify({
hmrClient.send(
JSON.stringify({
type: 'log',
level,
data: data.map(item =>
typeof item === 'string'
? item
: require('pretty-format')(item, {
: prettyFormat(item, {
escapeString: true,
highlight: true,
maxDepth: 3,
min: true,
plugins: [require('pretty-format').plugins.ReactElement],
plugins: [prettyFormat.plugins.ReactElement],
}),
),
});
} else {
try {
message = JSON.stringify({type: 'log', level, data});
} catch (error) {
message = JSON.stringify({
type: 'log',
level,
data: [error.message],
});
}
}

hmrClient.send(message);
}),
);
} catch (error) {
// If sending logs causes any failures we want to silently ignore them
// to ensure we do not cause infinite-logging loops.
Expand Down

0 comments on commit 02633fe

Please sign in to comment.