Search code examples
react-nativesqliteexpotypeorm

TypeOrm + Sqlite works only in development [React Native + Expo]


On development the app database works very well but when I generated APK it just not work, I can't use the database.


Solution

  • I found this answare of jbenzshawel:

    1º: yarn add metro-minify-terser

    2º: Update the metro config to keep class names and file names. Add the following to the metro.config.js transformer:

    minifierConfig: {
        ecma: 8,
        keep_classnames: true,
        keep_fnames: true,
        module: true,
        mangle: {
            module: true,
            keep_classnames: true,
            keep_fnames: true,
        },
     },
    

    So if you need to create metro.config.js add the following:

    const { getDefaultConfig } = require('expo/metro-config');
    
    const config = getDefaultConfig(__dirname);
    
    config.transformer.minifierPath = 'metro-minify-terser';
    config.transformer.minifierConfig = {
        ecma: 8,
        keep_classnames: true,
        keep_fnames: true,
        module: true,
        mangle: {
            module: true,
            keep_classnames: true,
            keep_fnames: true,
        },
    };
    
    module.exports = config;