Skip to content

Commit 01e214f

Browse files
antonisclaude
andauthored
feat(core): Introduce @sentry/expo-upload-sourcemaps package (#6027)
* feat(core): Introduce @sentry/expo-upload-sourcemaps package Moves the Expo sourcemap upload script into a new scoped workspace package @sentry/expo-upload-sourcemaps and replaces the original scripts/expo-upload-sourcemaps.js in @sentry/react-native with a shim that forwards to it. The existing sentry-expo-upload-sourcemaps bin in @sentry/react-native keeps working unchanged, so projects with the bin referenced in package.json scripts or invoked via npx are not affected. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * docs(core): Add CHANGELOG entry for @sentry/expo-upload-sourcemaps package Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * Update changelog * docs(core): Soften CHANGELOG wording for superseded sentry-expo-upload-sourcemaps bin Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * fix(core): Address Warden review findings in expo-upload-sourcemaps CLI - Drop the callback passed to fs.writeFileSync. writeFileSync is synchronous and silently discards the callback argument; the error branch never fired and the success log never printed. - Preserve a non-zero exit code when sentry-cli is terminated by a signal. spawnSync returns result.status === null in that case, and process.exit(null) coerces to 0, previously reporting success after an aborted upload. Both issues were inherited verbatim from the script's prior location inside @sentry/react-native. Fixed now that the script has moved to its own package. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * fix(core): Use bash script for @sentry/expo-upload-sourcemaps build:tarball Yarn 3's built-in shell errors on unmatched globs, so the inlined "rm -f *.tgz && npm pack" fails in CI where no prior tarball exists. Match packages/core's pattern and run through real bash via a script file. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * fix(core): Include @sentry/expo-upload-sourcemaps in TypeScript 3.8 type check Yalc rewrites the workspace:* dep to 8.8.0 when publishing @sentry/react-native, so ts3.8-test's yarn install tries to fetch @sentry/expo-upload-sourcemaps@8.8.0 from the npm registry before the package is published and fails with 404. Publish and yalc-add the new package alongside @sentry/react-native, and pin the transitive dep to the same local file reference via resolutions so yarn doesn't try to resolve it from the registry. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * fix(core): Include @sentry/expo-upload-sourcemaps in e2e sample app setup The e2e CLI (dev-packages/e2e-tests/cli.mjs) yalc-publishes @sentry/react-native and yalc-adds it into each matrix RN app. Yalc rewrites the workspace:* dep to a concrete 8.8.0, so yarn install in the sample app tries to fetch @sentry/expo-upload-sourcemaps@8.8.0 from the npm registry and 404s. Mirror the fix applied to the TypeScript 3.8 type check: also yalc-publish the new package, yalc-add it in the sample, and pin the transitive dep to the file reference via resolutions so yarn does not touch the registry. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * Correct copyright date * Make rm command stricter --------- Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 0589692 commit 01e214f

14 files changed

Lines changed: 504 additions & 307 deletions

File tree

.craft.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,5 @@ targets:
88
sdks:
99
npm:@sentry/react-native:
1010
includeNames: /^sentry-react-native-\d.*\.tgz$/
11+
npm:@sentry/expo-upload-sourcemaps:
12+
includeNames: /^sentry-expo-upload-sourcemaps-\d.*\.tgz$/

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010

1111
### Features
1212

13+
- Add new `@sentry/expo-upload-sourcemaps` package for uploading JavaScript bundles and source maps from Expo builds to Sentry ([#6027](https://github.com/getsentry/sentry-react-native/pull/6027))
14+
- The existing `sentry-expo-upload-sourcemaps` bin bundled with `@sentry/react-native` is superseded by the new package; it continues to work unchanged for now
1315
- Expose scope-level attributes API (`setAttribute`, `setAttributes`, `removeAttribute`) bridging to native SDKs ([#6009](https://github.com/getsentry/sentry-react-native/pull/6009))
1416
- Expose screenshot masking options (`screenshot.maskAllText`, `screenshot.maskAllImages`, `screenshot.maskedViewClasses`, `screenshot.unmaskedViewClasses`) for error screenshots ([#6007](https://github.com/getsentry/sentry-react-native/pull/6007))
1517
- Warn Expo users at Metro startup when prebuilt native projects are missing Sentry configuration ([#5984](https://github.com/getsentry/sentry-react-native/pull/5984))

dev-packages/e2e-tests/cli.mjs

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ const e2eTestPackageName = JSON.parse(fs.readFileSync(`${e2eDir}/package.json`,
5555
const patchScriptsDir = path.resolve(e2eDir, 'patch-scripts');
5656
const workspaceRootDir = path.resolve(__dirname, '../..');
5757
const corePackageDir = path.resolve(workspaceRootDir, 'packages/core');
58+
const expoUploadSourcemapsPackageDir = path.resolve(workspaceRootDir, 'packages/expo-upload-sourcemaps');
5859
const corePackageJson = JSON.parse(fs.readFileSync(`${corePackageDir}/package.json`, 'utf8'));
5960
const RNVersion = env.RN_VERSION ? env.RN_VERSION : corePackageJson.devDependencies['react-native'];
6061
const RNEngine = env.RN_ENGINE ? env.RN_ENGINE : 'hermes';
@@ -109,6 +110,7 @@ function patchBoostIfNeeded(rnVersion, patchScriptsDir) {
109110
if (actions.includes('create') || (env.CI === undefined && actions.includes('build'))) {
110111
execSync(`yarn build`, { stdio: 'inherit', cwd: workspaceRootDir, env: env });
111112
execSync(`yalc publish --private`, { stdio: 'inherit', cwd: e2eDir, env: env });
113+
execSync(`yalc publish`, { stdio: 'inherit', cwd: expoUploadSourcemapsPackageDir, env: env });
112114
execSync(`yalc publish`, { stdio: 'inherit', cwd: corePackageDir, env: env });
113115
}
114116

@@ -122,7 +124,14 @@ if (actions.includes('create')) {
122124

123125
// Install dependencies
124126
// yalc add doesn't fail if the package is not found - it skips silently.
125-
let yalcAddOutput = execSync(`yalc add @sentry/react-native`, { cwd: appDir, env: env, encoding: 'utf-8' });
127+
let yalcAddOutput = execSync(`yalc add @sentry/expo-upload-sourcemaps`, { cwd: appDir, env: env, encoding: 'utf-8' });
128+
if (!yalcAddOutput.match(/Package .* added ==>/)) {
129+
console.error(yalcAddOutput);
130+
process.exit(1);
131+
} else {
132+
console.log(yalcAddOutput.trim());
133+
}
134+
yalcAddOutput = execSync(`yalc add @sentry/react-native`, { cwd: appDir, env: env, encoding: 'utf-8' });
126135
if (!yalcAddOutput.match(/Package .* added ==>/)) {
127136
console.error(yalcAddOutput);
128137
process.exit(1);
@@ -137,6 +146,19 @@ if (actions.includes('create')) {
137146
console.log(yalcAddOutput.trim());
138147
}
139148

149+
// Force yarn to resolve the transitive @sentry/expo-upload-sourcemaps dep
150+
// to the local yalc copy. Without this, yarn tries to fetch it from the
151+
// npm registry (because yalc rewrites the workspace:* spec in core's
152+
// published package.json to a concrete version) and 404s until the package
153+
// is released.
154+
const appPackageJsonPath = `${appDir}/package.json`;
155+
const appPackageJson = JSON.parse(fs.readFileSync(appPackageJsonPath, 'utf-8'));
156+
appPackageJson.resolutions = {
157+
...appPackageJson.resolutions,
158+
'@sentry/expo-upload-sourcemaps': 'file:.yalc/@sentry/expo-upload-sourcemaps',
159+
};
160+
fs.writeFileSync(appPackageJsonPath, JSON.stringify(appPackageJson, null, 2) + '\n');
161+
140162
// original yarnrc contains the exact yarn version which causes corepack to fail to install yarn v3
141163
fs.writeFileSync(`${appDir}/.yarnrc.yml`, 'nodeLinker: node-modules', { encoding: 'utf-8' });
142164
// yarn v3 won't install dependencies in a sub project without a yarn.lock file present

dev-packages/type-check/run-type-check.sh

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,24 @@ set -ex
44

55
__dirpath=$(dirname $(realpath "$0"))
66

7+
cd "${__dirpath}/../../packages/expo-upload-sourcemaps"
8+
9+
yalc publish
10+
711
cd "${__dirpath}/../../packages/core"
812

913
yalc publish
1014

1115
cd "${__dirpath}/ts3.8-test"
1216

13-
# Add yalc package (creates .yalc/ directory and updates package.json)
17+
# Add yalc packages (creates .yalc/ directory and updates package.json)
18+
yalc add @sentry/expo-upload-sourcemaps
1419
yalc add @sentry/react-native
1520

1621
yarn install
1722

18-
# Re-add yalc package to ensure it's in node_modules (yarn might have removed it)
23+
# Re-add yalc packages to ensure they are in node_modules (yarn might have removed them)
24+
yalc add @sentry/expo-upload-sourcemaps
1925
yalc add @sentry/react-native
2026

2127
echo "Removing duplicate React types..."

dev-packages/type-check/ts3.8-test/package.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,12 @@
1414
"typescript": "3.8.3"
1515
},
1616
"dependencies": {
17+
"@sentry/expo-upload-sourcemaps": "file:.yalc/@sentry/expo-upload-sourcemaps",
1718
"@sentry/react-native": "file:.yalc/@sentry/react-native",
1819
"react": "17.0.2",
1920
"react-native": "0.65.3"
21+
},
22+
"resolutions": {
23+
"@sentry/expo-upload-sourcemaps": "file:.yalc/@sentry/expo-upload-sourcemaps"
2024
}
2125
}

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
},
4343
"workspaces": [
4444
"packages/core",
45+
"packages/expo-upload-sourcemaps",
4546
"dev-packages/e2e-tests",
4647
"dev-packages/type-check",
4748
"dev-packages/utils",

packages/core/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@
7575
"@sentry/browser": "10.49.0",
7676
"@sentry/cli": "3.4.0",
7777
"@sentry/core": "10.49.0",
78+
"@sentry/expo-upload-sourcemaps": "workspace:*",
7879
"@sentry/react": "10.49.0",
7980
"@sentry/types": "10.49.0"
8081
},

0 commit comments

Comments
 (0)