question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Minification can break code (but cannot be disabled?)

See original GitHub issue

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.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:12
  • Comments:15 (1 by maintainers)

github_iconTop GitHub Comments

7reactions
skurgansky-sugarcrmcommented, Mar 25, 2019

@chiaraperino you can’t turn off mangle. don’t even try. try to do this:

  1. yarn add -dev metro-minify-terser
  2. add to metro.config.js these lines:
minifierPath: 'metro-minify-terser',
  minifierConfig: {
      // https://www.npmjs.com/package/terser#mangle-options
      ecma: 8,
      keep_classnames: true,
      keep_fnames: true,
      module: true,
      mangle: {
        module: true,
        keep_classnames: true,
        keep_fnames: true,
    }
}

worked for me. The problem was in metro-minify-uglify. it works over uglify-es when the latter works over terser.

7reactions
skurgansky-sugarcrmcommented, Mar 19, 2019

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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

angular cli - AngularCli: disable minification - Stack Overflow
C'est genial :-D I was trying to find out, what setting is responsible for file minification in published Angular site, specifically on ...
Read more >
some minify issue - WordPress.org
Hello mate, I am having a small issue with FVM, I have recently installed a plugin named WooCommerce Product Categories Selection, I have...
Read more >
What is Minification and why is it Wreaking Havoc
One popular practice is to minify that code. Minifying your code is usually safe, but if you're not careful it can cause problems....
Read more >
Using code minification and compression | Kentico 12 Service ...
You can enable or disable code minification and compression globally for all sites in Settings -> System -> Performance, through the settings ...
Read more >
Minification - WP-Optimize - FAQs
Pressing the “Reset the minified files” does: ... The previously minified CSS files will remain on the server until they expire, or until...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found