|
1
|
const { getDefaultConfig } = require("expo/metro-config"); |
|
2
|
const path = require("path"); |
|
3
|
|
|
4
|
// The SDK root — one level up from this example app |
|
5
|
const sdkRoot = path.resolve(__dirname, ".."); |
|
6
|
|
|
7
|
const config = getDefaultConfig(__dirname); |
|
8
|
|
|
9
|
// Watch the SDK source so Metro picks up changes without a rebuild |
|
10
|
config.watchFolders = [sdkRoot]; |
|
11
|
|
|
12
|
// Resolve @ondeinference/react-native to the SDK's TypeScript source |
|
13
|
// directly, bypassing the compiled build/ output. |
|
14
|
config.resolver.extraNodeModules = { |
|
15
|
"@ondeinference/react-native": sdkRoot, |
|
16
|
}; |
|
17
|
|
|
18
|
// When Metro processes files from the SDK directory (outside this example app), |
|
19
|
// it needs a fallback path to find transitive dependencies like @babel/runtime. |
|
20
|
// Without this, Babel-transformed async/await in SDK files fails to resolve |
|
21
|
// @babel/runtime/helpers/asyncToGenerator because the SDK's own node_modules |
|
22
|
// is blocked below and the example's node_modules isn't in the resolution path. |
|
23
|
config.resolver.nodeModulesPaths = [path.resolve(__dirname, "node_modules")]; |
|
24
|
|
|
25
|
// Block the SDK's own node_modules from Metro. Without this, Metro picks up |
|
26
|
// react-native@0.85 (installed as a peer dep in sdk/react-native/node_modules/) instead |
|
27
|
// of the example's own react-native@0.76 — causing syntax errors from newer RN |
|
28
|
// internals that use pattern matching syntax not supported by this Babel config. |
|
29
|
config.resolver.blockList = [ |
|
30
|
new RegExp( |
|
31
|
path.resolve(sdkRoot, "node_modules").replace(/\\/g, "\\\\") + "/.*", |
|
32
|
), |
|
33
|
]; |
|
34
|
|
|
35
|
module.exports = config; |