metro: Minification can break code (but cannot be disabled?)
In metro@0.24.7 (react-native@0.53.3), src/JSTransformer/worker/minify.js, and presumably in the latest version in metro-minify-uglify, the setting mangle:{toplevel:true} is passed to uglify-es. Unfortunately, this can break code—we have some stuff that breaks if certain React component names are mangled. Our web version uses a blacklist via mangle:{reserved}; with metro, we have to patch the transformer to stop breaking our app.
It would be great if uglify options could be configured for the transformer.
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Reactions: 12
- Comments: 15 (1 by maintainers)
@chiaraperino you can’t turn off mangle. don’t even try. try to do this:
yarn add -dev metro-minify-terserworked for me. The problem was in metro-minify-uglify. it works over uglify-es when the latter works over terser.
using typeorm with react-native-sqlite-storage to build offline app. As i see it minifier.js brakes my code. I have error in release but no in dev mode. When i retured _ref from minify func i didn’t have error either.
This forum link solved it for me thankfully, with expo and typeorm.
https://forums.expo.io/t/change-minifierconfig-for-minify-uglify/36460/2
Hi! We recently added the
minifierConfigconfig param in the transformer, which allows you to exactly do that 😄Workaround
We get it worked with additional NPM package “patch-package”. On each install it applies the following patch:
nope. check if you use same version of metro packages: 0.53.1