react-native-obfuscating-transformer
Obfuscate selected source files when building for React Native.
Installation
yarn add react-native-obfuscating-transformer --dev
or
npm install react-native-obfuscating-transformer --save-dev
Usage
/rn-cli.config.js
module.exports = {+ transformer {+ babelTransformerPath: require.resolve("./transformer")+ }, }
/transformer.js
const obfuscatingTransformer = moduleexports =
Configuration
Options are:
upstreamTransformer: MetroTransformer
Defines what the first pass of code transformation is. If you don't use a custom transformer already, you don't need to set this option.
TypeScript example:
const obfuscatingTransformer = require('react-native-obfuscating-transformer')+ const typescriptTransformer = require('react-native-typescript-transformer') module.exports = obfuscatingTransformer({+ upstreamTransformer: typescriptTransformer })
require('metro/src/transformer')
Default value: filter: (filename: string, source: string) => boolean
Returns true for any files that should be obfuscated and false for any files which should not be obfuscated.
By default, it obfuscates all files in src/**/*
obfuscatorOptions: ObfuscatorOptions
Warning — Not all options are guaranteed to produce working code. In particular, stringArray
definitely breaks builds.
See the javascript-obfuscator docs for more info about what each option does.
trace: boolean
Iff true, prints a list of files being obfuscated
false
Default value: emitObfuscatedFiles: boolean
Iff true, emits the obfuscated versions of files alongside their originals, for comparison.
false
Default value: enableInDevelopment: boolean
Iff true, enables obfuscation in development mode.
false
Default value: License
MIT