Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

### Fixes

- Support `metro@0.80.10` new `sourceMapString` export ([#4004](https://github.com/getsentry/sentry-react-native/pull/4004))
- `Sentry.captureMessage` stack trace is in `event.exception` (moved from `event.threads`) ([#3635](https://github.com/getsentry/sentry-react-native/pull/3635), [#3988](https://github.com/getsentry/sentry-react-native/pull/3988))
- To revert to the old behavior (causing the stack to be unsymbolicated) use `useThreadsForMessageStack` option

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@
"jest-environment-jsdom": "^29.6.2",
"jest-extended": "^4.0.2",
"madge": "^6.1.0",
"metro": "0.76",
"metro": "0.80.10",
"prettier": "^2.0.5",
"react": "18.2.0",
"react-native": "0.73.9",
Expand Down
24 changes: 23 additions & 1 deletion src/js/tools/vendor/metro/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,11 @@ import * as bundleToString from 'metro/src/lib/bundleToString';

import type { MetroSerializer } from '../../utils';

type NewSourceMapStringExport = {
// Since Metro v0.80.10 https://github.com/facebook/metro/compare/v0.80.9...v0.80.10#diff-1b836d1729e527a725305eef0cec22e44605af2700fa413f4c2489ea1a03aebcL28
sourceMapString: typeof sourceMapString;
};

/**
* This function ensures that modules in source maps are sorted in the same
* order as in a plain JS bundle.
Expand Down Expand Up @@ -75,8 +80,25 @@ export const createDefaultMetroSerializer = (): MetroSerializer => {
return code;
}

let sourceMapStringFunction: typeof sourceMapString | undefined;
if (typeof sourceMapString === 'function') {
sourceMapStringFunction = sourceMapString;
} else if (
typeof sourceMapString === 'object' &&
sourceMapString != null &&
'sourceMapString' in sourceMapString &&
typeof sourceMapString['sourceMapString'] === 'function'
) {
sourceMapStringFunction = (sourceMapString as NewSourceMapStringExport).sourceMapString;
} else {
throw new Error(`
[@sentry/react-native/metro] Cannot find sourceMapString function in 'metro/src/DeltaBundler/Serializers/sourceMapString'.
Please check the version of Metro you are using and report the issue at http://www.github.com/getsentry/sentry-react-native/issues
`);
}

// Always generate source maps, can't use Sentry without source maps
const map = sourceMapString([...preModules, ...getSortedModules(graph, options)], {
const map = sourceMapStringFunction([...preModules, ...getSortedModules(graph, options)], {
processModuleFilter: options.processModuleFilter,
shouldAddToIgnoreList: options.shouldAddToIgnoreList,
});
Expand Down
Loading