metro-minify-obfuscator
A metro minifier based on javascript-obfuscator for React Native
Installation
yarn add -D metro-minify-obfuscator
or
npm i --save-dev metro-minify-obfuscator
Usage
- update
metro.config.js
on your project
module.exports = {
transformer: {
...
minifierPath: 'metro-minify-obfuscator',
minifierConfig: {
defaultMinifierPath: require('metro-minify-uglify'),
filter: (filename) => true,
includeNodeModules: true,
trace: false,
obfuscatorOptions: {
}
},
},
};
- you can add additional obfuscation config to the
minifierConfig
properties (⚠️ NOT ALL OPTION IS GUARANTEED WORKING ON REACT-NATIVE, IT MIGHT BREAK YOUR APPS 🙈 ) - run packager with
--reset-cache
argument to clear metro cache
Default Options
{
"stringArray": false,
"compact": true,
"controlFlowFlattening": true,
"controlFlowFlatteningThreshold": 0.75,
"identifierNamesGenerator": "hexadecimal",
"numbersToExpressions": true,
"splitStrings": true,
"splitStringsChunkLength": 3,
"transformObjectKeys": true,
"simplify": true,
"disableConsoleOutput": true,
"log": false,
"selfDefending": true,
"unicodeEscapeSequence": true
}
Comparison with other libraries
Release History
- v1.0.x - Add additional option to filter / exclude node_modules file from obfuscation. ⚠️ upgrading to this version need update to your metro.config.js please be aware
module.exports = {
transformer: {
...
minifierPath: 'metro-minify-obfuscator',
minifierConfig: {
},
},
};
module.exports = {
transformer: {
...
minifierPath: 'metro-minify-obfuscator',
minifierConfig: {
defaultMinifierPath: require('metro-minify-uglify'),
filter: (filename) => true,
includeNodeModules: true,
trace: false,
obfuscatorOptions: {
}
},
},
};
- v0.x.x - Initial fork from
metro-minify-uglify
configured with JSO library