-
Notifications
You must be signed in to change notification settings - Fork 1
/
metro.config.js
51 lines (38 loc) · 2.12 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
50
51
// Learn more https://docs.expo.io/guides/customizing-metro
const { getSentryExpoConfig } = require('@sentry/react-native/metro');
const path = require('path');
const config = getSentryExpoConfig(__dirname);
// Needed to resolve pure ESM packages that are within Tonomy-ID-SDK
config.resolver.unstable_enablePackageExports = true;
// Turn on symlinks for local development
config.resolver.unstable_enableSymlinks = true;
if (process.env.EXPO_NODE_ENV === 'local') {
console.log('Setting up local development environment. Using local Tonomy-ID-SDK.');
// see https://medium.com/@alielmajdaoui/linking-local-packages-in-react-native-the-right-way-2ac6587dcfa2
const sdkPath = path.resolve(__dirname, '../Tonomy-ID-SDK');
config.resolver.nodeModulesPaths.push(sdkPath);
config.watchFolders.push(sdkPath);
// Need to resolve these babel-plugin-rewrite-require locally as Tonomy-ID-SDK tries to import them from it's directory
config.resolver.extraNodeModules['crypto-browserify'] = path.resolve(__dirname);
config.resolver.extraNodeModules['stream-browserify'] = path.resolve(__dirname);
}
const debugModulePath = path.resolve(__dirname, 'src/utils/debug.ts');
// For all app code, and imported libraries
// if they import the "debug" package
// this should be instead use the ./src/utils/debugAndLog.ts
// so that we can send the logs to Sentry
config.resolver.resolveRequest = (context, moduleName, platform) => {
// if the module is debug and not importing from the src/utils/debug.ts file
if (moduleName === 'debug') {
console.log(`Resolving debug module from ${context.originModulePath}`);
if (context.originModulePath !== debugModulePath) {
return context.resolveRequest(context, debugModulePath, platform);
} else {
console.log(`>> Skipping debug module resolution from ${context.originModulePath}`);
}
}
return context.resolveRequest(context, moduleName, platform);
};
// config.resolver.extraNodeModules.debug = path.resolve(__dirname, 'src/utils/debugAndLog.ts');
console.log('Metro config resolver', config.resolver);
module.exports = config;