-
Notifications
You must be signed in to change notification settings - Fork 131
Expand file tree
/
Copy pathmetro.config.js
More file actions
60 lines (55 loc) · 2.06 KB
/
metro.config.js
File metadata and controls
60 lines (55 loc) · 2.06 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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
const path = require('path')
const { getDefaultConfig } = require('expo/metro-config')
/**
* Metro config scoped to this example so the parent app's metro.config.js
* (packages/mobile) is not used.
*/
const projectRoot = __dirname
const monorepoRoot = path.resolve(projectRoot, '../../../../')
const sdkPath = path.resolve(monorepoRoot, 'packages/sdk')
const sdkSourcePath = path.resolve(sdkPath, 'src/index.native.ts')
const packagesPath = path.resolve(monorepoRoot, 'packages')
const config = getDefaultConfig(projectRoot)
config.watchFolders = [
projectRoot,
sdkPath,
packagesPath,
path.resolve(monorepoRoot, 'node_modules')
]
config.resolver.nodeModulesPaths = [
path.resolve(projectRoot, 'node_modules'),
path.resolve(monorepoRoot, 'node_modules')
]
config.resolver.extraNodeModules = {
...config.resolver.extraNodeModules,
'@audius/sdk': sdkSourcePath,
'@audius/fixed-decimal': path.resolve(packagesPath, 'fixed-decimal'),
'@audius/eth': path.resolve(packagesPath, 'eth'),
'@audius/spl': path.resolve(packagesPath, 'spl'),
// Force SDK source imports to use the example's installed version of
// expo-web-browser rather than the SDK's devDependency copy, so the JS
// bundle matches the native module that is actually linked in the build.
'expo-web-browser': path.resolve(
projectRoot,
'node_modules',
'expo-web-browser'
),
crypto: require.resolve('expo-crypto'),
fs: path.resolve(projectRoot, 'polyfills/fs.js'),
stream: require.resolve('stream-browserify'),
util: require.resolve('util'),
buffer: require.resolve('buffer'),
process: require.resolve('process/browser'),
path: require.resolve('path-browserify'),
os: require.resolve('os-browserify/browser'),
events: require.resolve('events'),
url: require.resolve('url'),
querystring: require.resolve('querystring-es3')
}
config.resolver.resolveRequest = (context, moduleName, platform) => {
if (moduleName === '@audius/sdk') {
return { filePath: sdkSourcePath, type: 'sourceFile' }
}
return context.resolveRequest(context, moduleName, platform)
}
module.exports = config