-
Notifications
You must be signed in to change notification settings - Fork 24.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Remove old JSC workarounds in HMRClient
Reviewed By: fkgozali Differential Revision: D19297717 fbshipit-source-id: e85abe1c0d1b96cf21ae3a223ee65d92e6f88824
- Loading branch information
1 parent
11ea095
commit 02633fe
Showing
1 changed file
with
8 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
cpojer
Author
Contributor
|
||
|
||
import NativeRedBox from '../NativeModules/specs/NativeRedBox'; | ||
import * as LogBoxData from '../LogBox/Data/LogBoxData'; | ||
|
@@ -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. | ||
|
Shouldn't pretty-format be a devDependency? @cpojer