stub out react-native-svg fetchData on web to drop buffer polyfill
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
@@ -1,3 +1,5 @@
|
|||||||
|
const path = require('path')
|
||||||
|
|
||||||
const createExpoWebpackConfigAsync = require('@expo/webpack-config')
|
const createExpoWebpackConfigAsync = require('@expo/webpack-config')
|
||||||
const {withAlias} = require('@expo/webpack-config/addons')
|
const {withAlias} = require('@expo/webpack-config/addons')
|
||||||
const ReactRefreshWebpackPlugin = require('@pmmmwh/react-refresh-webpack-plugin')
|
const ReactRefreshWebpackPlugin = require('@pmmmwh/react-refresh-webpack-plugin')
|
||||||
@@ -46,11 +48,34 @@ module.exports = async function (env, argv) {
|
|||||||
dangerouslyAddModulePathsToTranspile: ['@bsky.app/expo', '@atproto/api'],
|
dangerouslyAddModulePathsToTranspile: ['@bsky.app/expo', '@atproto/api'],
|
||||||
}
|
}
|
||||||
let config = await createExpoWebpackConfigAsync(env, argv)
|
let config = await createExpoWebpackConfigAsync(env, argv)
|
||||||
|
/*
|
||||||
|
* Expo only registers its own internal config as a cache build dependency,
|
||||||
|
* so changes to this file (e.g. aliases) don't invalidate the persistent
|
||||||
|
* filesystem cache and stale module resolutions get reused. Register this
|
||||||
|
* file so edits here always bust the cache.
|
||||||
|
*/
|
||||||
|
if (config.cache?.buildDependencies) {
|
||||||
|
config.cache.buildDependencies.config = [
|
||||||
|
...(config.cache.buildDependencies.config || []),
|
||||||
|
__filename,
|
||||||
|
]
|
||||||
|
}
|
||||||
config = withAlias(config, {
|
config = withAlias(config, {
|
||||||
'react-native$': 'react-native-web',
|
'react-native$': 'react-native-web',
|
||||||
'react-native-webview': 'react-native-web-webview',
|
'react-native-webview': 'react-native-web-webview',
|
||||||
'react-native-gesture-handler': false, // RNGH should not be used on web, so let's cause a build error if it sneaks in
|
'react-native-gesture-handler': false, // RNGH should not be used on web, so let's cause a build error if it sneaks in
|
||||||
'@sentry-internal/replay': false, // not used, ~300kb of dead weight
|
'@sentry-internal/replay': false, // not used, ~300kb of dead weight
|
||||||
|
/*
|
||||||
|
* react-native-svg's fetchData util imports the ~55KB `buffer` polyfill,
|
||||||
|
* but is only needed by SvgUri/SvgXml remote loading, which we don't use.
|
||||||
|
* Stubbing it out makes fetchText undefined, so it throws if ever called.
|
||||||
|
* The alias key must be an absolute path because the package imports it
|
||||||
|
* via a relative path internally.
|
||||||
|
*/
|
||||||
|
[path.join(
|
||||||
|
__dirname,
|
||||||
|
'node_modules/react-native-svg/lib/module/utils/fetchData',
|
||||||
|
)]: false,
|
||||||
})
|
})
|
||||||
|
|
||||||
// react-native-uuid ships sourceMappingURL comments but no .map files.
|
// react-native-uuid ships sourceMappingURL comments but no .map files.
|
||||||
|
|||||||
Reference in New Issue
Block a user