Change minifierConfig for minify/uglify

Please provide the following:

  1. SDK Version: 37
  2. Platforms(Android/iOS/web/all): Android

I’m using Expo and Typeorm for the Android app, in dev mode it’s working, but when in the production publication there are errors that I found to be related to the minify / uglify changing the class and function names

the workaround im using is disable it in
node_modules\metro-config\src\defaults\index.js

minifierConfig: {
      keep_classnames: true,  // enable to fix typeorm
      keep_fnames: true,  // enable to fix typeorm
      mangle: {
        // toplevel: false,
        keep_classnames: true, // enable to fix typeorm
        keep_fnames: true, // enable to fix typeorm
      },
      output: {
        ascii_only: true,
        quote_style: 3,
        wrap_iife: true
      },
      sourceMap: {
        includeSources: false
      },
      toplevel: false,
      compress: {
        // reduce_funcs inlines single-use functions, which cause perf regressions.
        reduce_funcs: false
      }
    },

is there anyway to configure it in expo? i tried metro.config.js without success

found a way to replace minify configs:

Add in app.json

"packagerOpts": {
  "config": "metro.config.js"
},

create metro.config.js in root project directory:

module.exports = {
     transformer: {
      minifierConfig: {
        keep_classnames: true, // FIX typeorm
        keep_fnames: true, // FIX typeorm
        mangle: {
          // toplevel: false,
          keep_classnames: true, // FIX typeorm
          keep_fnames: true, // FIX typeorm
        },
        output: {
          ascii_only: true,
          quote_style: 3,
          wrap_iife: true,
        },
        sourceMap: {
          includeSources: false,
        },
        toplevel: false,
        compress: {
          // reduce_funcs inlines single-use functions, which cause perf regressions.
          reduce_funcs: false,
        },
      },
    },
};

i still need to check if theres a way to change this config only for the typeorm package

4 Likes

This topic was automatically closed 20 days after the last reply. New replies are no longer allowed.