-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmetro.config.js
More file actions
55 lines (47 loc) · 2.13 KB
/
metro.config.js
File metadata and controls
55 lines (47 loc) · 2.13 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
const { getDefaultConfig } = require('expo/metro-config')
const path = require('path')
const projectRoot = __dirname
const monorepoRoot = path.resolve(projectRoot, '../..')
const config = getDefaultConfig(projectRoot)
// Extend defaults rather than replacing them
config.watchFolders = [...(config.watchFolders || []), monorepoRoot]
config.resolver.nodeModulesPaths = [
path.resolve(projectRoot, 'node_modules'),
path.resolve(monorepoRoot, 'node_modules')
]
// Add react-native to web condition set so Metro resolves packages like
// Zustand to their CJS entries (which use process.env.NODE_ENV) instead
// of ESM entries (which use import.meta.env.MODE — invalid in classic scripts).
config.resolver.unstable_conditionsByPlatform = {
...config.resolver.unstable_conditionsByPlatform,
web: ['browser', 'react-native']
}
// Resolve workspace packages to TypeScript source instead of dist/.
// Metro handles TS natively — this avoids needing a build step on EAS.
config.resolver.resolveRequest = (context, moduleName, platform) => {
const workspacePackages = {
'@randsum/roller': path.resolve(monorepoRoot, 'packages/roller/src/index.ts'),
'@randsum/roller/roll': path.resolve(monorepoRoot, 'packages/roller/src/roll/index.ts'),
'@randsum/roller/docs': path.resolve(monorepoRoot, 'packages/roller/src/docs/index.ts'),
'@randsum/roller/trace': path.resolve(monorepoRoot, 'packages/roller/src/trace/index.ts'),
'@randsum/roller/tokenize': path.resolve(
monorepoRoot,
'packages/roller/src/notation/tokenize.ts'
),
'@randsum/roller/validate': path.resolve(monorepoRoot, 'packages/roller/src/validate.ts'),
'@randsum/roller/errors': path.resolve(monorepoRoot, 'packages/roller/src/errors.ts'),
'@randsum/dice-ui': path.resolve(
monorepoRoot,
platform === 'web' ? 'packages/dice-ui/src/index.ts' : 'packages/dice-ui/src/index.native.ts'
)
}
if (workspacePackages[moduleName]) {
return {
filePath: workspacePackages[moduleName],
type: 'sourceFile'
}
}
// Fall back to default resolution
return context.resolveRequest(context, moduleName, platform)
}
module.exports = config