Skip to content

Commit

Permalink
feat(expo): Add getDefaultConfig option to getSentryExpoConfig
Browse files Browse the repository at this point in the history
  • Loading branch information
krystofwoldrich committed Mar 19, 2024
1 parent 4e6d3cb commit 805eb34
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Changelog

## Unreleased

### Features

- Add `getDefaultConfig` option to `getSentryExpoConfig` ([#3688](https://github.com/getsentry/sentry-react-native/pull/3688))

## 5.20.0

### Features
Expand Down
2 changes: 2 additions & 0 deletions samples/expo/metro.config.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// Learn more https://docs.expo.io/guides/customizing-metro
const { getDefaultConfig } = require('@expo/metro-config');
const path = require('path');

const { getSentryExpoConfig } = require('../../metro');
Expand All @@ -7,6 +8,7 @@ const { getSentryExpoConfig } = require('../../metro');
const config = getSentryExpoConfig(__dirname, {
// [Web-only]: Enables CSS support in Metro.
isCSSEnabled: true,
getDefaultConfig,
});

config.watchFolders.push(path.resolve(__dirname, '../../node_modules/@sentry'));
Expand Down
7 changes: 5 additions & 2 deletions src/js/tools/metroconfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,11 @@ export function withSentryConfig(config: MetroConfig): MetroConfig {
/**
* This function returns Default Expo configuration with Sentry plugins.
*/
export function getSentryExpoConfig(projectRoot: string, options: DefaultConfigOptions = {}): MetroConfig {
const { getDefaultConfig } = loadExpoMetroConfigModule();
export function getSentryExpoConfig(
projectRoot: string,
options: DefaultConfigOptions & { getDefaultConfig?: typeof getSentryExpoConfig } = {},
): MetroConfig {
const getDefaultConfig = options.getDefaultConfig || loadExpoMetroConfigModule().getDefaultConfig;
const config = getDefaultConfig(projectRoot, {
...options,
unstable_beforeAssetSerializationPlugins: [
Expand Down

0 comments on commit 805eb34

Please sign in to comment.