forked from Axionvera/pocketpay-mobile
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmetro.config.js
More file actions
45 lines (38 loc) · 1.51 KB
/
Copy pathmetro.config.js
File metadata and controls
45 lines (38 loc) · 1.51 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
const { getDefaultConfig } = require("expo/metro-config");
const path = require("path");
const config = getDefaultConfig(__dirname);
config.resolver.extraNodeModules = {
...config.resolver.extraNodeModules,
events: require.resolve("events"),
process: require.resolve("process/browser"),
buffer: require.resolve("buffer"),
};
config.resolver.resolveRequest = (context, moduleName, platform) => {
// Shim Node-only modules for React Native compatibility
if (moduleName === "eventsource") {
return {
filePath: path.resolve(__dirname, "src/shims/eventsource.js"),
type: "sourceFile",
};
}
// The SDK loads dotenv for Node consumers. Expo injects EXPO_PUBLIC_* variables
// itself, so resolve dotenv to a no-op instead of bundling Node-only modules.
if (moduleName === 'dotenv') {
return {
filePath: path.resolve(__dirname, 'src/shims/dotenv.js'),
type: 'sourceFile',
};
}
// @stellar/stellar-sdk's package.json "browser" field points resolverMainFields
// (['react-native', 'browser', 'main']) at dist/stellar-sdk.min.js, a Webpack/Terser
// bundle that uses native `#privateField` syntax Hermes can't parse. Force the
// Babel-compiled Node build instead, which is already down-leveled.
if (moduleName === '@stellar/stellar-sdk') {
return {
filePath: path.resolve(__dirname, 'node_modules/@stellar/stellar-sdk/lib/cjs/index.js'),
type: 'sourceFile',
};
}
return context.resolveRequest(context, moduleName, platform);
};
module.exports = config;