How to prevent node from running out of memory when bundling js for React Native

前端 未结 5 2081
误落风尘
误落风尘 2021-01-02 06:01

When bundling js for React Native using ClojureScript I got the following error. It seems that node runs out of memory when bundling the javascript bundle. This is probably

5条回答
  •  耶瑟儿~
    2021-01-02 06:22

    I have found way to generate Signed APK in re-natal project. For this we must edit file in node_modules/react-native/react.gradle

    Change 84-th row in this file. From

    commandLine(*nodeExecutableAndArgs, "node_modules/react-native/local-cli/cli.js", "bundle", "--platform", "android", "--dev", "${devEnabled}",
        "--reset-cache", "--entry-file", entryFile, "--bundle-output", jsBundleFile, "--assets-dest", resourcesDir, *extraPackagerArgs)
    

    To this

    commandLine(*nodeExecutableAndArgs, "--max-old-space-size=4096", "node_modules/react-native/local-cli/cli.js", "bundle", "--platform", "android", "--dev", "${devEnabled}",
        "--reset-cache", "--entry-file", entryFile, "--bundle-output", jsBundleFile, "--assets-dest", resourcesDir, *extraPackagerArgs)
    

    To create production build you must use

    lein prod-build
    

    After compiling of ClojureScript use this commands:

    cd android && ./gradlew assembleRelease
    

    The generated APK can be found under android/app/build/outputs/apk/app-release.apk, and is ready to be distributed.

提交回复
热议问题