-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmetro.config.js
More file actions
54 lines (47 loc) · 1.83 KB
/
metro.config.js
File metadata and controls
54 lines (47 loc) · 1.83 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
const { getDefaultConfig } = require('expo/metro-config');
const { withTamagui } = require('@tamagui/metro-plugin');
const nodePath = require('path');
/** @type {import('expo/metro-config').MetroConfig} */
const config = getDefaultConfig(__dirname, {
isCSSEnabled: true,
});
// Ensure mjs is resolved
config.resolver.sourceExts.push('mjs');
// Allow bundling .tflite model files as assets
config.resolver.assetExts.push('tflite');
// Prioritize react-native condition exports (e.g. onecrawl native entry)
config.resolver.unstable_conditionNames = [
'react-native',
'import',
'require',
'default',
];
// Shim Node.js built-ins that onecrawl's non-native adapters reference
const NODE_SHIMS = {
'fs/promises': nodePath.resolve(__dirname, 'shims/fs-promises.js'),
'fs': nodePath.resolve(__dirname, 'shims/fs.js'),
'path': nodePath.resolve(__dirname, 'shims/path.js'),
'os': nodePath.resolve(__dirname, 'shims/os.js'),
'net': nodePath.resolve(__dirname, 'shims/net.js'),
'tls': nodePath.resolve(__dirname, 'shims/tls.js'),
'http': nodePath.resolve(__dirname, 'shims/http.js'),
'https': nodePath.resolve(__dirname, 'shims/https.js'),
'http2': nodePath.resolve(__dirname, 'shims/http2.js'),
'punycode': require.resolve('punycode/'),
'crypto': nodePath.resolve(__dirname, 'shims/crypto.js'),
};
const originalResolveRequest = config.resolver.resolveRequest;
config.resolver.resolveRequest = (context, moduleName, platform) => {
if (NODE_SHIMS[moduleName]) {
return { filePath: NODE_SHIMS[moduleName], type: 'sourceFile' };
}
if (originalResolveRequest) {
return originalResolveRequest(context, moduleName, platform);
}
return context.resolveRequest(context, moduleName, platform);
};
module.exports = withTamagui(config, {
components: ['tamagui'],
config: './tamagui.config.ts',
outputCSS: './tamagui-web.css',
});