mirror of
https://gh-proxy.org/https://github.com/tiajinsha/JKVideo
synced 2026-07-09 07:46:05 +08:00
fix(web): 补全缺失的 web shims 并修复渲染崩溃问题
- 新增 sentry-react-native、react-native-video、react-native-static-server、expo-network、expo-intent-launcher、expo-clipboard、expo-file-system 的 web shim - 重写 react-native-pager-view shim,通过 useImperativeHandle 暴露 setPage 方法 - 修复 sentry-react-native shim 缺少 ErrorBoundary 导致的渲染崩溃 - 在 _layout.tsx 中加载 Ionicons 字体,修复 web 端字体 404 - 更新 metro.config.js 中 sentry shim 路径为 .tsx
This commit is contained in:
@@ -1,16 +1,29 @@
|
||||
const path = require('path');
|
||||
const {
|
||||
getSentryExpoConfig
|
||||
} = require("@sentry/react-native/metro");
|
||||
const { getSentryExpoConfig } = require("@sentry/react-native/metro");
|
||||
|
||||
const config = getSentryExpoConfig(__dirname);
|
||||
|
||||
// Ensure shims directory is watched by Metro
|
||||
config.watchFolders = [...(config.watchFolders ?? []), path.resolve(__dirname, 'shims')];
|
||||
|
||||
const originalResolveRequest = config.resolver.resolveRequest;
|
||||
|
||||
const WEB_SHIMS = {
|
||||
'react-native-pager-view': 'shims/react-native-pager-view.web.tsx',
|
||||
'@sentry/react-native': 'shims/sentry-react-native.web.tsx',
|
||||
'@dr.pogodin/react-native-static-server': 'shims/react-native-static-server.web.ts',
|
||||
'expo-network': 'shims/expo-network.web.ts',
|
||||
'expo-intent-launcher': 'shims/expo-intent-launcher.web.ts',
|
||||
'react-native-video': 'shims/react-native-video.web.tsx',
|
||||
'expo-file-system': 'shims/expo-file-system.web.ts',
|
||||
'expo-file-system/legacy': 'shims/expo-file-system.web.ts',
|
||||
'expo-clipboard': 'shims/expo-clipboard.web.ts',
|
||||
};
|
||||
|
||||
config.resolver.resolveRequest = (context, moduleName, platform) => {
|
||||
if (platform === 'web' && moduleName === 'react-native-pager-view') {
|
||||
if (platform === 'web' && WEB_SHIMS[moduleName]) {
|
||||
return {
|
||||
filePath: path.resolve(__dirname, 'shims/react-native-pager-view.web.tsx'),
|
||||
filePath: path.resolve(__dirname, WEB_SHIMS[moduleName]),
|
||||
type: 'sourceFile',
|
||||
};
|
||||
}
|
||||
@@ -20,4 +33,4 @@ config.resolver.resolveRequest = (context, moduleName, platform) => {
|
||||
return context.resolveRequest(context, moduleName, platform);
|
||||
};
|
||||
|
||||
module.exports = config;
|
||||
module.exports = config;
|
||||
|
||||
Reference in New Issue
Block a user