Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make sure LogBox is not included in production bundles #28984

Closed
wants to merge 1 commit into from
Closed
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
4 changes: 2 additions & 2 deletions Libraries/Core/ExceptionsManager.js
Expand Up @@ -11,7 +11,6 @@
'use strict';

import type {ExtendedError} from './Devtools/parseErrorStack';
import * as LogBoxData from '../LogBox/Data/LogBoxData';
import type {ExceptionData} from './NativeExceptionsManager';

class SyntheticError extends Error {
Expand Down Expand Up @@ -104,7 +103,8 @@ function reportException(
console.error(data.message);
}

if (isHandledByLogBox) {
if (__DEV__ && isHandledByLogBox) {
const LogBoxData = require('../LogBox/Data/LogBoxData');
LogBoxData.addException({
...data,
isComponentError: !!e.isComponentError,
Expand Down
5 changes: 3 additions & 2 deletions Libraries/LogBox/LogBox.js
Expand Up @@ -12,8 +12,6 @@

import Platform from '../Utilities/Platform';
import RCTLog from '../Utilities/RCTLog';
import * as LogBoxData from './Data/LogBoxData';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be handled by the inline requires feature. We don't like manually inlining requires if we can avoid it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sadly this is not enabled by default in OSS so I think doing it manually in this case is fine since it is not only for perf improvements.

import {parseLogBoxLog, parseInterpolation} from './Data/parseLogBoxLog';

import type {IgnorePattern} from './Data/LogBoxData';

Expand All @@ -23,6 +21,9 @@ let LogBox;
* LogBox displays logs in the app.
*/
if (__DEV__) {
const LogBoxData = require('./Data/LogBoxData');
const {parseLogBoxLog, parseInterpolation} = require('./Data/parseLogBoxLog');

// LogBox needs to insert itself early,
// in order to access the component stacks appended by React DevTools.
const {error, warn} = console;
Expand Down