-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmetro.config.js
More file actions
40 lines (33 loc) · 1.41 KB
/
Copy pathmetro.config.js
File metadata and controls
40 lines (33 loc) · 1.41 KB
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
const { getDefaultConfig } = require("expo/metro-config");
const path = require("path");
const config = getDefaultConfig(__dirname);
const workspaceRoot = path.resolve(__dirname, "..");
// 1. Watch the workspace root so we can resolve packages there
config.watchFolders = [...(config.watchFolders || []), workspaceRoot];
// 2. Resolve node_modules from the project first, then the workspace
config.resolver.nodeModulesPaths = [
path.resolve(__dirname, "node_modules"),
path.resolve(workspaceRoot, "node_modules"),
];
// 3. Force invalid duplicates to be excluded
// To avoid needing 'metro-config' exports which can be tricky to import, we manually merge the blacklist
const defaultBlacklist = config.resolver.blacklistRE || /(?!)/;
const newExclusions = [
/\/packages\/react-native-calendar-ui\/node_modules\/react\/.*/,
/\/packages\/react-native-calendar-ui\/node_modules\/react-native\/.*/,
];
config.resolver.blacklistRE = new RegExp(
"(" +
defaultBlacklist.source +
")|(" +
newExclusions.map((r) => r.source).join("|") +
")"
);
// 4. Force resolution of critical dependencies to the example app's node_modules
config.resolver.extraNodeModules = {
...config.resolver.extraNodeModules,
react: path.resolve(__dirname, "node_modules/react"),
"react-dom": path.resolve(__dirname, "node_modules/react-dom"),
"react-native": path.resolve(__dirname, "node_modules/react-native"),
};
module.exports = config;