From 047a0ddf8dd84d5e2603fe544f6acd46a3a5aa9f Mon Sep 17 00:00:00 2001 From: Diego Mello Date: Tue, 13 Aug 2019 10:03:46 -0300 Subject: [PATCH] [FIX] Remove console on production builds (#1124) * [FIX] Remove console on production builds * Add react-native-markdown-renderer patch * Update react-native-notifications * Increase maxHeapSize --- .babelrc | 8 ------- android/gradle.properties | 1 + app/lib/createStore.js | 3 +-- babel.config.js | 8 +++++++ index.js | 6 +++-- package.json | 2 +- ...react-native-markdown-renderer+3.2.8.patch | 23 +++++++++++++++++++ yarn.lock | 8 +++---- 8 files changed, 42 insertions(+), 17 deletions(-) delete mode 100644 .babelrc create mode 100644 babel.config.js create mode 100644 patches/react-native-markdown-renderer+3.2.8.patch diff --git a/.babelrc b/.babelrc deleted file mode 100644 index 12560f94..00000000 --- a/.babelrc +++ /dev/null @@ -1,8 +0,0 @@ -{ - "presets": ["module:metro-react-native-babel-preset"], - "env": { - "production": { - "plugins": ["transform-remove-console"] - } - } -} diff --git a/android/gradle.properties b/android/gradle.properties index bf40c6de..5f50bc36 100644 --- a/android/gradle.properties +++ b/android/gradle.properties @@ -18,6 +18,7 @@ # android.enableAapt2=false # commenting this makes notifications to stop working # android.useDeprecatedNdk=true +org.gradle.jvmargs=-Xmx2048M -XX\:MaxHeapSize\=32g android.useAndroidX=true android.enableJetifier=true VERSIONCODE=999999999 diff --git a/app/lib/createStore.js b/app/lib/createStore.js index a163875c..b4e1113a 100644 --- a/app/lib/createStore.js +++ b/app/lib/createStore.js @@ -1,5 +1,4 @@ import { createStore, applyMiddleware, compose } from 'redux'; -import Reactotron from 'reactotron-react-native'; import createSagaMiddleware from 'redux-saga'; import applyAppStateListener from 'redux-enhancer-react-native-appstate'; @@ -10,8 +9,8 @@ let sagaMiddleware; let enhancers; if (__DEV__) { - /* eslint-disable global-require */ const reduxImmutableStateInvariant = require('redux-immutable-state-invariant').default(); + const Reactotron = require('reactotron-react-native').default; sagaMiddleware = createSagaMiddleware({ sagaMonitor: Reactotron.createSagaMonitor() }); diff --git a/babel.config.js b/babel.config.js new file mode 100644 index 00000000..215ba473 --- /dev/null +++ b/babel.config.js @@ -0,0 +1,8 @@ +module.exports = { + presets: ['module:metro-react-native-babel-preset'], + env: { + production: { + plugins: ['transform-remove-console'] + } + } +}; diff --git a/index.js b/index.js index e84346a3..06af35ed 100644 --- a/index.js +++ b/index.js @@ -1,9 +1,11 @@ import 'react-native-console-time-polyfill'; - -import './app/ReactotronConfig'; import { AppRegistry } from 'react-native'; import { name as appName, share as shareName } from './app.json'; +if (__DEV__) { + require('./app/ReactotronConfig'); +} + AppRegistry.registerComponent(appName, () => require('./app/index').default); AppRegistry.registerComponent(shareName, () => require('./app/share').default); diff --git a/package.json b/package.json index 806bf49c..fe43fbd5 100644 --- a/package.json +++ b/package.json @@ -55,7 +55,7 @@ "react-native-markdown-renderer": "^3.2.8", "react-native-mime-types": "^2.2.1", "react-native-modal": "^11.3.0", - "react-native-notifications": "2.0.3", + "react-native-notifications": "^2.0.6", "react-native-optimized-flatlist": "^1.0.4", "react-native-orientation-locker": "^1.1.6", "react-native-picker-select": "6.3.0", diff --git a/patches/react-native-markdown-renderer+3.2.8.patch b/patches/react-native-markdown-renderer+3.2.8.patch new file mode 100644 index 00000000..02379a17 --- /dev/null +++ b/patches/react-native-markdown-renderer+3.2.8.patch @@ -0,0 +1,23 @@ +diff --git a/node_modules/react-native-markdown-renderer/src/index.js b/node_modules/react-native-markdown-renderer/src/index.js +index 653bba2..e5cb521 100644 +--- a/node_modules/react-native-markdown-renderer/src/index.js ++++ b/node_modules/react-native-markdown-renderer/src/index.js +@@ -88,9 +88,15 @@ export default class Markdown extends Component { + }), + }; + +- copy = ''; +- renderer = null; +- markdownParser = null; ++ constructor(props) { ++ super(props); ++ this.copy = ''; ++ this.renderer = null; ++ this.markdownParser = null; ++ } ++ // copy = ''; ++ // renderer = null; ++ // markdownParser = null; + + /** + * Only when the copy changes will the markdown render again. diff --git a/yarn.lock b/yarn.lock index 3c1660f7..1edd3a37 100644 --- a/yarn.lock +++ b/yarn.lock @@ -9672,10 +9672,10 @@ react-native-modal@^9.0.0: prop-types "^15.6.2" react-native-animatable "^1.2.4" -react-native-notifications@2.0.3: - version "2.0.3" - resolved "https://registry.yarnpkg.com/react-native-notifications/-/react-native-notifications-2.0.3.tgz#139f693c79e4e37b3e4aa78e7373f5abca53f8e4" - integrity sha512-kMrfhnwFaogErVsJORnUD3L3XFhzG3UkQpI8xPFG+cOo80u03U27J4hPXiEqOAp03ReiuxMgP4EvMXB8NRsLAg== +react-native-notifications@^2.0.6: + version "2.0.6" + resolved "https://registry.yarnpkg.com/react-native-notifications/-/react-native-notifications-2.0.6.tgz#5355fad1ea53327fb00fd5e8a6570279fe32f2a9" + integrity sha512-NFx5ADlqfQYTFkKWvd/GxM8rxKf1lSWJZJY0jbydAOZAuhnKFR/CsH7Mpx6T+9pY5Z3rvu7UzBtVn9LTBx0jYg== dependencies: core-js "^1.0.0" uuid "^2.0.3"