fix and clean up metro config
This commit is contained in:
@@ -1,40 +0,0 @@
|
|||||||
// Learn more https://docs.expo.io/guides/customizing-metro
|
|
||||||
const {getSentryExpoConfig} = require('@sentry/react-native/metro')
|
|
||||||
const cfg = getSentryExpoConfig(__dirname)
|
|
||||||
|
|
||||||
// inject `.e2e.ts` and `.e2e.tsx` into the sourceExts when running tests
|
|
||||||
cfg.resolver.sourceExts = process.env.RN_SRC_EXT
|
|
||||||
? process.env.RN_SRC_EXT.split(',').concat(cfg.resolver.sourceExts)
|
|
||||||
: cfg.resolver.sourceExts
|
|
||||||
|
|
||||||
if (cfg.resolver.resolveRequest) {
|
|
||||||
throw Error('Update this override because it is conflicting now.')
|
|
||||||
}
|
|
||||||
|
|
||||||
if (process.env.BSKY_PROFILE) {
|
|
||||||
cfg.cacheVersion += ':PROFILE'
|
|
||||||
}
|
|
||||||
|
|
||||||
cfg.resolver.assetExts = [...cfg.resolver.assetExts, 'woff2']
|
|
||||||
|
|
||||||
cfg.resolver.resolveRequest = (context, moduleName, platform) => {
|
|
||||||
if (process.env.BSKY_PROFILE) {
|
|
||||||
if (moduleName.endsWith('ReactNativeRenderer-prod')) {
|
|
||||||
return context.resolveRequest(
|
|
||||||
context,
|
|
||||||
moduleName.replace('-prod', '-profiling'),
|
|
||||||
platform,
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return context.resolveRequest(context, moduleName, platform)
|
|
||||||
}
|
|
||||||
|
|
||||||
cfg.transformer.getTransformOptions = async () => ({
|
|
||||||
transform: {
|
|
||||||
experimentalImportSupport: true,
|
|
||||||
inlineRequires: true,
|
|
||||||
},
|
|
||||||
})
|
|
||||||
|
|
||||||
module.exports = cfg
|
|
||||||
@@ -0,0 +1,55 @@
|
|||||||
|
// Learn more https://docs.expo.io/guides/customizing-metro
|
||||||
|
import {type CustomResolver} from '@expo/metro/metro-resolver'
|
||||||
|
import {getDefaultConfig} from '@expo/metro-config'
|
||||||
|
import {getSentryExpoConfig} from '@sentry/react-native/metro.js'
|
||||||
|
|
||||||
|
const config = getSentryExpoConfig(import.meta.dirname, {
|
||||||
|
// TODO: confirm this doesn't break anything when we switch to metro web
|
||||||
|
includeWebReplay: true,
|
||||||
|
|
||||||
|
getDefaultConfig: (projectRoot, options) => {
|
||||||
|
const config = getDefaultConfig(projectRoot, options)
|
||||||
|
|
||||||
|
if (typeof process.env.RN_SRC_EXT === 'string') {
|
||||||
|
// inject `.e2e.ts` and `.e2e.tsx` into the sourceExts when running tests)
|
||||||
|
config.resolver.sourceExts.push(...process.env.RN_SRC_EXT.split(','))
|
||||||
|
}
|
||||||
|
|
||||||
|
config.resolver.assetExts = [...config.resolver.assetExts, 'woff2']
|
||||||
|
|
||||||
|
if (config.resolver.resolveRequest) {
|
||||||
|
throw Error('Update this override because it is conflicting now.')
|
||||||
|
}
|
||||||
|
|
||||||
|
if (process.env.BSKY_PROFILE) {
|
||||||
|
// @ts-expect-error readonly property
|
||||||
|
config.cacheVersion += ':PROFILE'
|
||||||
|
|
||||||
|
const resolver: CustomResolver = (context, moduleName, platform) => {
|
||||||
|
if (moduleName.endsWith('ReactNativeRenderer-prod')) {
|
||||||
|
return context.resolveRequest(
|
||||||
|
context,
|
||||||
|
moduleName.replace('-prod', '-profiling'),
|
||||||
|
platform,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
return context.resolveRequest(context, moduleName, platform)
|
||||||
|
}
|
||||||
|
|
||||||
|
// @ts-expect-error readonly property
|
||||||
|
config.resolver.resolveRequest = resolver
|
||||||
|
}
|
||||||
|
|
||||||
|
config.transformer.getTransformOptions = () =>
|
||||||
|
Promise.resolve({
|
||||||
|
transform: {
|
||||||
|
experimentalImportSupport: true,
|
||||||
|
inlineRequires: true as false, // ??? typescript why?
|
||||||
|
},
|
||||||
|
})
|
||||||
|
|
||||||
|
return config as unknown as Record<string, unknown>
|
||||||
|
},
|
||||||
|
})
|
||||||
|
|
||||||
|
export default config
|
||||||
Reference in New Issue
Block a user