如何为Metro config(react-native)提供RAM模块?

时间:2019-04-11 13:31:28

标签: react-native

按照https://facebook.github.io/react-native/docs/performance上的说明 我创建了一个modulePaths.js文件,其中包含我要首先加载的模块列表。 就我而言,默认设置在应用程序启动时提供631个已加载模块和1324个等待模块。 但是当我提供Metro.config.js文件的模块路径时,加载的是1348,等待的是607。

这是我的metro.config.js文件:

const modulePaths = require('./packager/modulePaths');
const resolve = require('path').resolve;
const fs = require('fs');

// Update the following line if the root folder of your app is somewhere else.
const ROOT_FOLDER = resolve(__dirname, '..');


module.exports = {
    transformer: {
      getTransformOptions: () => {
        const moduleMap = {};
        modulePaths.forEach(path => {
          if (fs.existsSync(path)) {
            moduleMap[resolve(path)] = true;
          }
        });
        return {
          transform: {
            preloadedModules: moduleMap,     
            experimentalImportSupport: true,
            inlineRequires: { blacklist: moduleMap },
          },
        }
      },
      projectRoot: ROOT_FOLDER,
    }
};

我的modulePath文件有470个模块,因此我希望首先加载470个模块,其余的等待加载。但是使用此设置,加载的模块大于默认设置

0 个答案:

没有答案