forked from mattermost/mattermost-mobile
-
Notifications
You must be signed in to change notification settings - Fork 0
/
metro.config.js
49 lines (42 loc) · 1.51 KB
/
metro.config.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
/* eslint-disable no-console */
const resolve = require('path').resolve;
const fs = require('fs');
const modulesRegex = /\/(node_modules)/;
// This script will let the react native packager what modules to include
// in the main bundle and what modules to blacklist from the inline requires
// this modules are taken from the modulePaths.js file
const config = {
transformer: {
getTransformOptions: (entryFile, {platform}) => {
console.log('BUILDING MODULES FOR', platform);
const moduleMap = {};
let modulePaths = [];
if (platform === 'android') {
modulePaths = require('./packager/modules.android');
} else {
modulePaths = require('./packager/modules.ios');
}
modulePaths.forEach((path) => {
let fsFile = path;
if (path.match(modulesRegex).length > 1) {
fsFile = path.replace(modulesRegex, '');
}
if (fs.existsSync(fsFile)) {
moduleMap[resolve(path)] = true;
}
});
return {
preloadedModules: moduleMap,
transform: {
inlineRequires: {
blacklist: moduleMap,
},
},
};
},
},
maxWorkers: 4,
};
module.exports = config;