profile
viewpoint

Ask questionsMinification 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.

facebook/metro

Answer questions chiaraperino

@skurgansky-sugarcrm thank you for your answer but I have another problem :(

I install metro-minify-terser ("metro-minify-terser": "^0.53.1") but, when I build the bundle, I have the error:

node_modules/expo/AppEntry.js: minify.withSourceMap is not a function. (/node_modules/metro/src/JSTransformer/worker.js)

Have you encontered the same problem?

//metro.config.js
module.exports = {
  transformer: {
    minifierPath: 'metro-minify-terser',
    minifierConfig: {
      ecma: 8,
      keep_classnames: true,
      keep_fnames: true,
      module: true,
      mangle: {
        module: true,
        keep_classnames: true,
        keep_fnames: true,
      },
    },
  },
};
useful!

Related questions

ReferenceError: SHA-1 for file [(...).png] is not computed hot 3
i have local javascript library How do i config metro.config.js hot 2
`SHA-1 for file ... is not computed` when using `resolver.resolveRequest` hot 1
metro-config sharedBlacklist regexp without scape "\" hot 1
Follow symlinks? hot 1
`SHA-1 for file ... is not computed` when using `resolver.resolveRequest` hot 1
metro-config sharedBlacklist regexp without scape "\" hot 1
bundleReleaseJsAndAssets slow for react-native 0.60 / node v12 combo hot 1
Error: Cannot find module 'metro/src/DeltaBundler/Worker' hot 1
concurrent builds fail due to shared use of /tmp/metro-cache/ hot 1
metro-config sharedBlacklist regexp without scape "\" hot 1
Error: Cannot find module 'metro/src/DeltaBundler/Worker' hot 1
RN - Error: jest-haste-map: @providesModule naming collision hot 1
Couldn't find preset "module:metro-react-native-babel-preset" when running jest hot 1
metro-config sharedBlacklist regexp without scape "\" hot 1
source:https://uonfu.com/
Github User Rank List