README
Global Metro React Native Obfuscator
This metro obfuscate your React Native bundle using javascript-obfuscator
It only obfuscates your code not the code of node_modules
, you can verify the obfuscated bundle by either extracting the main.jsbundle
from generated apk
or you can find the file at project_root\android\app\build\generated\assets\react\release
after assembleRelease
process.
Installation
// TODO
Usage
Include the plugin in your metro.config.js
:
const jsoMetroPlugin = require("obfuscator-io-metro-plugin")(
{
// for these option look javascript-obfuscator library options from above url
compact: false,
sourceMap: true,
controlFlowFlattening: true,
controlFlowFlatteningThreshold: 1,
numbersToExpressions: true,
simplify: true,
shuffleStringArray: true,
splitStrings: true,
stringArrayThreshold: 1,
},
{
runInDev: false /* optional */,
logObfuscatedFiles: true /* optional generated files will be located at ./.jso */,
sourceMapLocation:
"./main.jsbundle.map" /* optional only works if sourceMap: true in obfuscation option */,
}
);
module.exports = {
transformer: {
getTransformOptions: async () => ({
transform: {
experimentalImportSupport: false,
inlineRequires: false,
},
}),
},
...jsoMetroPlugin,
};
For Android builds, add this line to the build.gradle under app module to make js bundle name same with iOS build:
project.ext.react = [
bundleAssetName: "main.jsbundle",
]
For obfuscation options configuration docs see: https://github.com/javascript-obfuscator/javascript-obfuscator