webpack - React-native taking over 150-200% of computers CPU -
i've been having problem when run react-native
app in xcode starts use 150%
of cpu. insane! i've got no idea why well? i'm using webpack convert babel react.
here modules:
"scripts": { "android-setup-port": "adb reverse tcp:8081 tcp:8080", "start": "env node_env=dev rnws start --hostname localhost", "build": "env node_env=production rnws bundle", "test": "eslint src", "debugger-replace": "remotedev-debugger-replace --hostname localhost --port 5678", "remotedev": "npm run debugger-replace && remotedev --hostname localhost --port 5678" }, "engines": { "node": ">=4", "npm": ">=2 <4" }, "dependencies": { "@exponent/react-native-navigator": "^0.4.1", "file-loader": "^0.8.5", "immutable": "^3.7.5", "react-native": "^0.19.0", "react-native-button": "^1.3.1", "react-native-form": "^1.0.6", "react-native-google-places-autocomplete": "^1.1.6", "react-native-maps": "^0.3.0", "react-redux": "^4.0.6", "redux": "^3.0.4", "redux-thunk": "^1.0.3", "tcomb-form-native": "^0.3.3" }, "devdependencies": { "babel-core": "^6.3.17", "babel-eslint": "^5.0.0-beta6", "babel-loader": "^6.2.0", "babel-preset-es2015": "^6.3.13", "babel-preset-react": "^6.3.13", "babel-preset-stage-0": "^6.3.13", "clean-webpack-plugin": "^0.1.5", "eslint": "^1.10.3", "eslint-loader": "^1.1.1", "eslint-plugin-react": "^3.11.2", "react-native-webpack-server": "^0.8.3", "remote-redux-devtools": "0.0.10", "remote-redux-devtools-on-debugger": "^0.2.0", "webpack": "^1.12.9", "webpack-dev-server": "^1.14.0" }
here webpack config:
var path = require('path'), webpack = require('webpack'), clean = require('clean-webpack-plugin'); // { // test: /\.(jpe?g|png|gif|svg)$/i, // loaders: [ // 'url?limit=8192', // 'img' // ] // }, var dev = process.env.node_env === 'dev' ? true : false, production = process.env.node_env === 'production' ? true : false; module.exports = { // debug: false, // devtool: 'source-map', entry: { 'index.ios': ['./src/index.jsx'], 'index.android': ['./src/index.jsx'], }, output: { path: path.resolve(__dirname, '__build__'), filename: '[name].js' }, module: { loaders: [ { test: /\.jpe?g$|\.gif$|\.png$/i, loader: "file-loader" }, { test: /\.jsx?$|\.js?$/, include: [ path.resolve(__dirname, 'src'), path.resolve(__dirname, './config'), path.resolve(__dirname, 'node_modules/react-native/libraries/react-native'), path.resolve(__dirname, 'node_modules/react-native-navbar'), // path.resolve(__dirname, 'node_modules/react-native-maps'), path.resolve(__dirname, 'node_modules/react-native-google-places-autocomplete'), path.resolve(__dirname, 'node_modules/@exponent'), path.resolve(__dirname, 'node_modules/react-clone-referenced-element') ], loader: 'babel', query: { presets: ['es2015', 'stage-0', 'react'] }, }, ] }, resolve: { extensions: ['', '.js', '.jsx'], modulesdirectories: [ 'node_modules', './config', './src/', './src/components', './src/layouts', './src/scripts/', './src/scripts/actions/', './src/scripts/api/', './src/scripts/containers/', './src/scripts/reducers/' ] }, plugins: [ new webpack.defineplugin({ __prod__ : production, __dev__ : dev }) ].concat(production ? [ new webpack.optimize.uglifyjsplugin(), new clean(['__build__']) ] : []) };
has got idea why happening? i've searched on google find solution can't!
update 1:
i have not solved yet. instead of running simulator
, have connected iphone
act device
. @ least takes stress off cpu
.
update 2:
so developing took blind eye issue didn't want spend long debugging it. think issue requiring un-needed files, using loops on objects instead of having objects in array , mapping them using .map(
, changing var
const
, let
, updating react-code comply es6 standards
.
this helped lot! cpu
usage went down , running normally.
update 3:
update 2 did out lot. i've found reason why cpu
getting throttled. when enabling live reload
cpu
usage jumped straight 150+%
, computer fan starting running real hot.
the weird thing live reload
never worked? anyway hope helps!
so found out why happening. has todo live reload
feature simulator offers.
when activated, instantly computer cpu
jumped 150+%
. i'm not sure why happening? thing should add live reload
never worked, maybe i've not set right or something.
anyway, hope helps! if confirm or replicate issue , me that'd great! reported issue on github: https://github.com/facebook/react-native/issues/6752
just disable live reload
.
Comments
Post a Comment