fix: bundle sourcemap output#95
Merged
leegeunhyeok merged 1 commit intoJun 1, 2026
Merged
Conversation
🦋 Changeset detectedLatest commit: 759fe3c The changes in this PR will be included in the next version bump. This PR includes changesets to release 7 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
bundleCLI receives--sourcemap-outputsourcemap: trueonly when a sourcemap output path is providedrollipopRoot Cause
React Native Gradle already passes a sourcemap output path to the JavaScript bundler. The missing piece was inside Rollipop: the parsed
--sourcemap-outputvalue was forwarded assourcemapOutfile, but it was not also treated as a request to generate sourcemaps.End-to-end flow
React Native Gradle registers a bundle task for non-debuggable variants.
TaskConfiguration.ktregisterscreateBundle${targetName}JsAndAssetsas aBundleHermesCTask.For a normal Android release variant, that becomes:
BundleHermesCTask.run()computes the JavaScript bundle output and packager sourcemap output.In Hermes builds, the first sourcemap expected from the JS bundler is the packager sourcemap:
BundleHermesCTask.getBundleCommand()builds the React Native CLI command and includes--sourcemap-output.The relevant arguments are assembled like this:
Gradle executes that exact command with
execOperations.exec { exec.commandLine(command) }.So by the time the JS CLI starts, the sourcemap output path is already present in argv. This is not a Gradle configuration issue.
Apps can replace React Native CLI commands via
react-native.config.js.A Rollipop app typically exposes:
That means React Native CLI dispatches the
bundlecommand to Rollipop's React Native CLI command wrapper.Rollipop defines and parses
--sourcemap-output <string>asoptions.sourcemapOutput.Before this change, the Rollipop bundle action passed that value only as:
It did not pass:
Bundler.build()later decides the final Rolldown sourcemap option fromresolvedBuildOptions.sourcemap.Existing code normalizes it to a boolean:
With
--sourcemap-outputalone,resolvedBuildOptions.sourcemapisundefined, so Rollipop sendsoutput.sourcemap = falseto Rolldown.Because Rolldown receives
sourcemap: false, it does not emit a.mapfile and the output chunk has nosourcemapFileName.Rollipop has later code that can move the generated map to
sourcemapOutfile, but that branch requireschunk.sourcemapFileName. Since no map was generated, there is nothing to move.In Hermes builds, React Native Gradle then tries to compose the packager sourcemap with the Hermes compiler sourcemap.
The expected packager file is missing:
Therefore the final composed sourcemap cannot be produced correctly:
Fix
When
options.sourcemapOutputis present, the bundle action now forwardssourcemap: truetorunBuild:This keeps the existing behavior when
--sourcemap-outputis omitted, while matching React Native CLI semantics: providing a sourcemap output path means the bundler should generate a sourcemap at that path.Validation
yarn workspace rollipop vp test --run src/node/commands/bundle/__tests__/action.spec.tsyarn workspace rollipop typecheckyarn fmt