-
Notifications
You must be signed in to change notification settings - Fork 82
Expand file tree
/
Copy pathmetro.config.js
More file actions
55 lines (45 loc) · 1.64 KB
/
Copy pathmetro.config.js
File metadata and controls
55 lines (45 loc) · 1.64 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
// Learn more https://docs.expo.io/guides/customizing-metro
const { getDefaultConfig } = require("expo/metro-config");
const revenueCatPurchasesUmdPath = require.resolve("@revenuecat/purchases-js");
/** @type {import('expo/metro-config').MetroConfig} */
const config = getDefaultConfig(__dirname);
config.projectRoot = __dirname;
config.watchFolders = [__dirname];
config.server = config.server || {};
config.server.unstable_serverRoot = __dirname;
const originalResolveRequest = config.resolver.resolveRequest;
config.resolver.resolveRequest = (context, moduleName, platform) => {
if (platform === "web" && moduleName === "@revenuecat/purchases-js") {
return {
type: "sourceFile",
filePath: revenueCatPurchasesUmdPath,
};
}
const rewrittenModuleName =
moduleName === "@noble/hashes/crypto.js"
? "@noble/hashes/crypto"
: moduleName;
if (originalResolveRequest) {
return originalResolveRequest(context, rewrittenModuleName, platform);
}
return context.resolveRequest(context, rewrittenModuleName, platform);
};
const expoSerializer = config.serializer?.customSerializer;
if (expoSerializer) {
config.serializer.customSerializer = async (
entryPoint,
preModules,
graph,
options,
) => {
return expoSerializer(entryPoint, preModules, graph, {
...options,
includeAsyncPaths: false,
});
};
}
// TODO: this is a hack to not bundle all of the @expo/vector-icons fonts
config.resolver.assetExts = config.resolver.assetExts.filter(
(ext) => ext !== "ttf",
);
module.exports = config;