-
Notifications
You must be signed in to change notification settings - Fork 2
/
metro.config.cjs
40 lines (38 loc) · 1.01 KB
/
metro.config.cjs
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
/**
* Metro configuration for React Native
* https://github.com/facebook/react-native
*
* @format
*/
const Resolver = require('metro-resolver');
const path = require('path');
module.exports = {
transformer: {
getTransformOptions: async () => ({
transform: {
experimentalImportSupport: false,
inlineRequires: true
}
})
},
resolver: {
sourceExts: ['js', 'jsx'],
// simplistic hack to allow resolving skypack assets
// with node_modules in native
resolveRequest: (context, realModuleName, platform, moduleName) => {
let name = moduleName;
if (moduleName.startsWith('https://')) {
name = moduleName
.replace(/https:\/\/cdn\.skypack\.dev\//, '')
.replace(/@\d+/, '');
console.log(`Replacing ${moduleName} with ${name}`);
}
return Resolver.resolve(
{ ...context, resolveRequest: undefined },
name,
platform
);
},
nodeModulesPaths: [path.resolve('native/node_modules')]
}
};