philikon / ReactNativify

How to use node.js libraries in React Native
242 stars 23 forks source link

Debug screen was locked about 3minutes #7

Open taipa-ibl opened 7 years ago

taipa-ibl commented 7 years ago

Hi,

I set to run Crypto on React-Native 0.45.1. It is able to run, but have a trouble. That is when debug app, it is always freeze the chrome debug tab for about 3 minutes, after that, it run as normal.

Did you get a problem like this ?

brandonfancher commented 7 years ago

This seems to be happening to me too.

brandonfancher commented 7 years ago

@taipa-ibl, I think I found the culprit.

In my babel-transformer.js file, I had:

const babelRC = {
    presets: ['react-native'],
    sourceMaps: true,
    plugins: [
...

Once I commented out the sourceMaps: true, line, Chrome Debugger stopped locking up on load and refresh.

Let me know if that fixes it for you.

brandonfancher commented 7 years ago

@taipa-ibl: After more investigation, I got source maps working with fast Chrome Debugging and better rebuild times. The solution? Move all of my transform code to .babelrc. I deleted my other transform files entirely. (I'm also depending on a different babel transform plugin, but I believe that's unrelated.) Here's what I have in my .babelrc:

{
  "presets": ["react-native"],
  "sourceMaps": true,
  "plugins": [
    ["module-resolver", {
      "alias": {
        "crypto": "react-native-crypto",
        "stream": "stream-browserify",
        "vm": "vm-browserify",
      },
    }],
  ],
  "env": {
    "development": {
      "plugins": ["transform-react-jsx-source"]
    }
  }
}

I'm fairly new to this babel transform stuff, so if you see anything in there that's incorrect or could be improved, I'm all ears. Hopefully this helps, though!

Of course, you may need more aliases in there. Depends on what all you're using.

taipa-ibl commented 7 years ago

@brandonfancher

Thank you very much. It's work !!! You save my life.

agrcrobles commented 6 years ago

@brandonfancher thanks! it really helped me too! I ended up implementing it your way along with a tiny implementation of randombytes to be compatible with JavascriptCore and I could use crypto-browserify instead.

https://github.com/agrcrobles/babel-preset-react-native-web3/blob/master/src/index.js

I only needed crypto though, it brokes debugging and doesn't hot reload on expo.