Open ExoMemphiz opened 5 years ago
Alright, I got slightly further with a different repo that I found that used this library.
I needed to add these lines of code to the getMetroTransformer.js file:
const metroVersion = semver(require('metro/package.json').version).minor;
if (metroVersion >= 51) {
return require('metro-react-native-babel-transformer/src/index');
}
And of course have the metro-react-native-babel-transformer installed, as well as having this .babelrc file:
{
"presets": ["module:metro-react-native-babel-preset"]
}
It seems to work (Tried react-native v0.59.10 and v0.61.1 currently), but minification happens on the bundle, after obfuscating, which I think is the reason that the output is basically the same, if I obfuscate or not.
Btw. these are the dependencies:
"dependencies": {
"react": "16.8.3",
"react-native": "0.61.1"
},
"devDependencies": {
"babel-core": "6.26.0",
"metro-react-native-babel-preset": "0.56.0",
"react-native-obfuscating-transformer": "^1.0.0-rc.0"
}
I get this in the log when I run the ./gradlew assembleRelease
> Task :app:bundleReleaseJsAndAssets
warning: the transform cache was reset.
Loading dependency graph, done.
transform[stdout]: src/App.js
transform[stdout]: Obfuscating src/App.js
info Writing bundle output to:, .../index.android.bundle
info Done writing bundle output
Which should mean it actually obfuscates the code, unfortunately it is not shown in the output bundle itself. Also the selfDefending option breaks the app, I assume because of the above reason - minifying the output changes the code, and thus breaks the selfDefending code.
Any way to keep the obfuscated code, while bundling it?
I have the same issue, did you managed to solve it?
same here
Can every one give me the solution?
I find the solution when using with react-native 0.61 This is my metro.config.js My problem disappear when I change babelTransformerPath: require.resolve("./transformer") to getTransformModulePath: () => { return require.resolve('./transformer'); },
module.exports = {
transformer: {
getTransformOptions: async () => ({
transform: {
experimentalImportSupport: false,
inlineRequires: false,
},
}),
getTransformModulePath: () => {
return require.resolve('./transformer');
},
},
};
I find the solution when using with react-native 0.61 This is my metro.config.js My problem disappear when I change babelTransformerPath: require.resolve("./transformer") to getTransformModulePath: () => { return require.resolve('./transformer'); },
module.exports = { transformer: { getTransformOptions: async () => ({ transform: { experimentalImportSupport: false, inlineRequires: false, }, }), getTransformModulePath: () => { return require.resolve('./transformer'); }, }, };
yes this issue has been resolved from this Solution. thanks a lot man.
npm i babylon --save-dev
Versions:
"react-native": "0.59.10", "react-native-obfuscating-transformer": "^1.0.0",
Files:
metro.config.js:
transformer.js:
Error I am getting:
Repo
Simplest repo I could make that reproduces this error:
https://github.com/ExoMemphiz/ObfuscationTest/