2022-08-09 03:29:14 +00:00
|
|
|
const { makeMetroConfig, resolveUniqueModule, exclusionList } = require('@rnx-kit/metro-config');
|
|
|
|
|
2022-10-17 13:27:14 +00:00
|
|
|
const path = require('path');
|
|
|
|
|
2022-08-09 03:29:14 +00:00
|
|
|
// Needed for transforming svgs from @sd/assets
|
|
|
|
const [reactSVGPath, reactSVGExclude] = resolveUniqueModule('react-native-svg');
|
|
|
|
|
2023-05-04 06:21:42 +00:00
|
|
|
const [rspcClientPath, rspcClientExclude] = resolveUniqueModule('@rspc/client');
|
|
|
|
const [rspcReactPath, rspcReactExclude] = resolveUniqueModule('@rspc/react');
|
|
|
|
|
2022-08-09 03:29:14 +00:00
|
|
|
const { getDefaultConfig } = require('expo/metro-config');
|
|
|
|
const expoDefaultConfig = getDefaultConfig(__dirname);
|
|
|
|
|
2022-10-17 13:27:14 +00:00
|
|
|
const projectRoot = __dirname;
|
|
|
|
const workspaceRoot = path.resolve(projectRoot, '../..');
|
|
|
|
|
2022-08-09 03:29:14 +00:00
|
|
|
const metroConfig = makeMetroConfig({
|
2023-03-17 02:00:02 +00:00
|
|
|
...expoDefaultConfig,
|
2022-10-17 13:27:14 +00:00
|
|
|
projectRoot,
|
|
|
|
watchFolders: [workspaceRoot],
|
2022-08-09 03:29:14 +00:00
|
|
|
resolver: {
|
|
|
|
...expoDefaultConfig.resolver,
|
|
|
|
extraNodeModules: {
|
|
|
|
'react-native-svg': reactSVGPath
|
|
|
|
},
|
2023-05-04 06:21:42 +00:00
|
|
|
blockList: exclusionList([reactSVGExclude, rspcClientExclude, rspcReactExclude]),
|
2022-08-09 03:29:14 +00:00
|
|
|
sourceExts: [...expoDefaultConfig.resolver.sourceExts, 'svg'],
|
2022-10-17 13:27:14 +00:00
|
|
|
assetExts: expoDefaultConfig.resolver.assetExts.filter((ext) => ext !== 'svg'),
|
2023-05-29 08:34:47 +00:00
|
|
|
disableHierarchicalLookup: false,
|
2022-10-17 13:27:14 +00:00
|
|
|
nodeModulesPaths: [
|
|
|
|
path.resolve(projectRoot, 'node_modules'),
|
|
|
|
path.resolve(workspaceRoot, 'node_modules')
|
2023-05-04 06:21:42 +00:00
|
|
|
],
|
|
|
|
resolveRequest: (context, moduleName, platform) => {
|
|
|
|
if (moduleName.startsWith('@rspc/client/v2')) {
|
|
|
|
return {
|
2023-05-04 13:56:24 +00:00
|
|
|
filePath: path.resolve(rspcClientPath, 'dist', 'v2.js'),
|
2023-05-04 06:21:42 +00:00
|
|
|
type: 'sourceFile'
|
|
|
|
};
|
|
|
|
}
|
|
|
|
if (moduleName.startsWith('@rspc/react/v2')) {
|
|
|
|
return {
|
2023-05-04 13:56:24 +00:00
|
|
|
filePath: path.resolve(rspcReactPath, 'dist', 'v2.js'),
|
2023-05-04 06:21:42 +00:00
|
|
|
type: 'sourceFile'
|
|
|
|
};
|
|
|
|
}
|
|
|
|
// Optionally, chain to the standard Metro resolver.
|
|
|
|
return context.resolveRequest(context, moduleName, platform);
|
|
|
|
},
|
|
|
|
platforms: ['ios', 'android']
|
2022-08-09 03:29:14 +00:00
|
|
|
},
|
|
|
|
transformer: {
|
2023-03-17 02:00:02 +00:00
|
|
|
...expoDefaultConfig.transformer,
|
2022-08-09 03:29:14 +00:00
|
|
|
getTransformOptions: async () => ({
|
|
|
|
transform: {
|
2023-05-04 08:10:31 +00:00
|
|
|
// What does this do?
|
2022-08-09 03:29:14 +00:00
|
|
|
experimentalImportSupport: false,
|
|
|
|
inlineRequires: true
|
|
|
|
}
|
|
|
|
}),
|
|
|
|
babelTransformerPath: require.resolve('react-native-svg-transformer')
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
module.exports = metroConfig;
|