Everything was working on SDK 50. I upgraded to SDK 51 using Expo's instructions. The app itself works fine. When I try to launch the share extension, I now get this error:
I have tried:
clearing all caches (metro, pods, etc)
deleting all node_modules + yarn.lock and reinstalling everything
new builds
Note that I am in a monorepo but this has never caused issues before. I simply upgraded from SDK 50 to SDK 51, updating package versions and nothing else, and the issue started occurring.
I have tried launching the share extension on both the iOS simulator as well as my physical device, same issue occurs (debug mode and release mode fail).
Here are relevant files:
metro.config.js
// Learn more https://docs.expo.io/guides/customizing-metro
/**
* @type {import('expo/metro-config')}
*/
// Sentry replacement
// const { getDefaultConfig } = require('expo/metro-config');
const { getSentryExpoConfig } = require('@sentry/react-native/metro');
const path = require('path');
const projectRoot = __dirname;
const workspaceRoot = path.resolve(__dirname, '../..');
// Sentry replacement
// const config = getDefaultConfig(projectRoot);
const config = getSentryExpoConfig(projectRoot);
config.watchFolders = [workspaceRoot];
config.resolver.nodeModulesPaths = [
path.resolve(projectRoot, 'node_modules'),
path.resolve(workspaceRoot, 'node_modules'),
];
config.transformer = { ...config.transformer, unstable_allowRequireContext: true };
// ! HAVE TO USE metro-minify-esbuild BC TERSER WAS BREAKING THE BUILD ENTIRELY!
config.transformer.minifierPath = require.resolve('metro-minify-esbuild');
config.transformer.minifierConfig = {
drop: ['console'],
};
/**
* Add support for share.js as a recognized extension to the Metro config.
* This allows creating an index.share.js entry point for our iOS share extension
*/
config.transformer.getTransformOptions = () => ({
resolver: {
sourceExts: [...config.resolver.sourceExts, 'share.js'], // Add 'share.js' as a recognized extension
},
});
module.exports = config;
index.share.js
// could be any component you want to use as the root component of your share extension's bundle
import { ShareExtension } from 'app/shareExtension';
import { AppRegistry } from 'react-native';
// IMPORTANT: the first argument to registerComponent, must be "shareExtension"
AppRegistry.registerComponent('shareExtension', () => ShareExtension);
index.js
// import 'expo-router/entry';
import { registerRootComponent } from 'expo';
import { ExpoRoot } from 'expo-router';
// Must be exported or Fast Refresh won't update the context
export function App() {
const ctx = require.context('./app');
return <ExpoRoot context={ctx} />;
}
registerRootComponent(App);
Everything was working on SDK 50. I upgraded to SDK 51 using Expo's instructions. The app itself works fine. When I try to launch the share extension, I now get this error:
I have tried:
Note that I am in a monorepo but this has never caused issues before. I simply upgraded from SDK 50 to SDK 51, updating package versions and nothing else, and the issue started occurring.
I have tried launching the share extension on both the iOS simulator as well as my physical device, same issue occurs (debug mode and release mode fail).
Here are relevant files:
metro.config.js
index.share.js
index.js
app.json
expo share extension plugin entrypackage.json
for the expo app