From 59d40eff1f39eb0d98a1b2c991db2e7ae50f654e Mon Sep 17 00:00:00 2001 From: Adrian Hartanto Date: Tue, 27 Oct 2026 10:23:31 +0700 Subject: [PATCH] expose sourcemap-output on sign commands --- .changeset/brave-maps-sign.md | 7 +++ .../src/lib/commands/signAndroid/command.ts | 7 +++ .../lib/commands/signAndroid/signAndroid.ts | 14 +++-- .../src/lib/commands/sign/modifyApp.ts | 8 +++ .../src/lib/commands/sign/modifyIpa.ts | 8 +++ .../platform-ios/src/lib/commands/signIos.ts | 8 +++ website/src/docs/cli/introduction.md | 57 ++++++++++--------- 7 files changed, 77 insertions(+), 32 deletions(-) create mode 100644 .changeset/brave-maps-sign.md diff --git a/.changeset/brave-maps-sign.md b/.changeset/brave-maps-sign.md new file mode 100644 index 000000000..59dc477ba --- /dev/null +++ b/.changeset/brave-maps-sign.md @@ -0,0 +1,7 @@ +--- +'@rock-js/platform-ios': patch +'@rock-js/platform-apple-helpers': patch +'@rock-js/platform-android': patch +--- + +Add `--sourcemap-output` to `sign:ios` and `sign:android` to write the source map of the JS bundle built with `--build-jsbundle`. diff --git a/packages/platform-android/src/lib/commands/signAndroid/command.ts b/packages/platform-android/src/lib/commands/signAndroid/command.ts index ff1aa4501..d16547037 100644 --- a/packages/platform-android/src/lib/commands/signAndroid/command.ts +++ b/packages/platform-android/src/lib/commands/signAndroid/command.ts @@ -10,6 +10,7 @@ export type SignFlags = { keyAlias?: string; keyPassword?: string; buildJsbundle?: boolean; + sourcemapOutput?: string; jsbundle?: string; noHermes?: boolean; }; @@ -50,6 +51,11 @@ const OPTIONS = [ name: '--build-jsbundle', description: 'Build the JS bundle before signing.', }, + { + name: '--sourcemap-output ', + description: + 'Path to write the source map of the built JS bundle. Requires "--build-jsbundle".', + }, { name: '--jsbundle ', description: 'Path to the JS bundle to apply before signing.', @@ -75,6 +81,7 @@ export const registerSignCommand = (api: PluginApi) => { keyPassword: flags.keyPassword, outputPath: flags.output, buildJsBundle: flags.buildJsbundle, + sourcemapOutputPath: flags.sourcemapOutput, jsBundlePath: flags.jsbundle, useHermes: !flags.noHermes, }); diff --git a/packages/platform-android/src/lib/commands/signAndroid/signAndroid.ts b/packages/platform-android/src/lib/commands/signAndroid/signAndroid.ts index 3e7fb74e6..20639ce21 100644 --- a/packages/platform-android/src/lib/commands/signAndroid/signAndroid.ts +++ b/packages/platform-android/src/lib/commands/signAndroid/signAndroid.ts @@ -22,6 +22,7 @@ export type SignAndroidOptions = { keyPassword?: string; outputPath?: string; buildJsBundle?: boolean; + sourcemapOutputPath?: string; jsBundlePath?: string; useHermes?: boolean; }; @@ -48,10 +49,9 @@ export async function signAndroid(options: SignAndroidOptions) { await buildJsBundle({ bundleOutputPath, assetsDestPath: path.join(tempPath, 'res'), - sourcemapOutputPath: path.join( - tempPath, - 'index.android.bundle.packager.map', - ), + sourcemapOutputPath: + options.sourcemapOutputPath ?? + path.join(tempPath, 'index.android.bundle.packager.map'), useHermes: options.useHermes ?? true, }); loader.stop( @@ -126,6 +126,12 @@ function validateOptions(options: SignAndroidOptions) { ); } + if (options.sourcemapOutputPath && !options.buildJsBundle) { + throw new RockError( + 'The "--sourcemap-output" flag requires "--build-jsbundle".', + ); + } + if (options.jsBundlePath && !fs.existsSync(options.jsBundlePath)) { throw new RockError(`JS bundle file not found "${options.jsBundlePath}"`); } diff --git a/packages/platform-apple-helpers/src/lib/commands/sign/modifyApp.ts b/packages/platform-apple-helpers/src/lib/commands/sign/modifyApp.ts index 75881d0e0..3cf1f7b2f 100644 --- a/packages/platform-apple-helpers/src/lib/commands/sign/modifyApp.ts +++ b/packages/platform-apple-helpers/src/lib/commands/sign/modifyApp.ts @@ -15,6 +15,7 @@ export type ModifyAppOptions = { appPath: string; outputPath?: string; buildJsBundle?: boolean; + sourcemapOutputPath?: string; jsBundlePath?: string; useHermes?: boolean; useAppEntitlements?: boolean; @@ -48,6 +49,7 @@ export const modifyApp = async (options: ModifyAppOptions) => { await buildJsBundle({ bundleOutputPath: appPaths.jsBundle, assetsDestPath: appPaths.assetsDest, + sourcemapOutputPath: options.sourcemapOutputPath, useHermes: options.useHermes ?? true, }); loader.stop( @@ -85,6 +87,12 @@ function validateOptions(options: ModifyAppOptions) { ); } + if (options.sourcemapOutputPath && !options.buildJsBundle) { + throw new RockError( + 'The "--sourcemap-output" flag requires "--build-jsbundle".', + ); + } + if (options.jsBundlePath && !fs.existsSync(options.jsBundlePath)) { throw new RockError( `JS bundle file not found at "${options.jsBundlePath}". Please provide a correct path.`, diff --git a/packages/platform-apple-helpers/src/lib/commands/sign/modifyIpa.ts b/packages/platform-apple-helpers/src/lib/commands/sign/modifyIpa.ts index 5e41867b2..53dec879f 100644 --- a/packages/platform-apple-helpers/src/lib/commands/sign/modifyIpa.ts +++ b/packages/platform-apple-helpers/src/lib/commands/sign/modifyIpa.ts @@ -27,6 +27,7 @@ export type ModifyIpaOptions = { identity?: string; outputPath?: string; buildJsBundle?: boolean; + sourcemapOutputPath?: string; jsBundlePath?: string; useHermes?: boolean; useAppEntitlements?: boolean; @@ -51,6 +52,7 @@ export const modifyIpa = async (options: ModifyIpaOptions) => { await buildJsBundle({ bundleOutputPath: appPaths.jsBundle, assetsDestPath: appPaths.assetsDest, + sourcemapOutputPath: options.sourcemapOutputPath, useHermes: options.useHermes ?? true, }); loader.stop( @@ -140,6 +142,12 @@ function validateOptions(options: ModifyIpaOptions) { ); } + if (options.sourcemapOutputPath && !options.buildJsBundle) { + throw new RockError( + 'The "--sourcemap-output" flag requires "--build-jsbundle".', + ); + } + if (options.jsBundlePath && !fs.existsSync(options.jsBundlePath)) { throw new RockError( `JS bundle file not found at "${options.jsBundlePath}". Please provide a correct path.`, diff --git a/packages/platform-ios/src/lib/commands/signIos.ts b/packages/platform-ios/src/lib/commands/signIos.ts index efd5719e2..ca90f7a9e 100644 --- a/packages/platform-ios/src/lib/commands/signIos.ts +++ b/packages/platform-ios/src/lib/commands/signIos.ts @@ -7,6 +7,7 @@ export type SignFlags = { output?: string; identity?: string; buildJsbundle?: boolean; + sourcemapOutput?: string; jsbundle?: string; noHermes?: boolean; useAppEntitlements?: boolean; @@ -38,6 +39,11 @@ const OPTIONS = [ name: '--build-jsbundle', description: 'Build the JS bundle before signing.', }, + { + name: '--sourcemap-output ', + description: + 'Path to write the source map of the built JS bundle. Requires "--build-jsbundle".', + }, { name: '--jsbundle ', description: 'Path to the JS bundle to apply before signing.', @@ -65,6 +71,7 @@ export const registerSignCommand = (api: PluginApi) => { appPath: binaryPath, outputPath: flags.output, buildJsBundle: flags.buildJsbundle, + sourcemapOutputPath: flags.sourcemapOutput, jsBundlePath: flags.jsbundle, useHermes: !flags.noHermes, useAppEntitlements: flags.useAppEntitlements, @@ -76,6 +83,7 @@ export const registerSignCommand = (api: PluginApi) => { identity: flags.identity, outputPath: flags.output, buildJsBundle: flags.buildJsbundle, + sourcemapOutputPath: flags.sourcemapOutput, jsBundlePath: flags.jsbundle, useHermes: !flags.noHermes, useAppEntitlements: flags.useAppEntitlements, diff --git a/website/src/docs/cli/introduction.md b/website/src/docs/cli/introduction.md index a5fe9578d..e76180044 100644 --- a/website/src/docs/cli/introduction.md +++ b/website/src/docs/cli/introduction.md @@ -113,12 +113,12 @@ Platform plugins are configured through the [`platform`](/docs/configuration/ind - `@rock-js/platform-android` – Android platform plugin with the following commands: - | Command | Description | - | :------------------------- | :-------------------------------------------------------------- | - | `run:android` | Runs Android app on emulator or device | - | `build:android` | Builds Android app for generic emulator, device or distribution | - | `sign:android` | Signs Android app with keystore | - | `validate-elf-alignment` | Validates ELF alignment of shared libraries in an APK | + | Command | Description | + | :----------------------- | :-------------------------------------------------------------- | + | `run:android` | Runs Android app on emulator or device | + | `build:android` | Builds Android app for generic emulator, device or distribution | + | `sign:android` | Signs Android app with keystore | + | `validate-elf-alignment` | Validates ELF alignment of shared libraries in an APK | - `@rock-js/platform-ios` – iOS platform plugin with the following commands: @@ -203,15 +203,16 @@ The `sign:ios` command either signs your iOS app with certificates and provision | :----------- | :-------------------------- | | `binaryPath` | Path to the IPA or APP file | -| Option | Description | -| :----------------------- | :------------------------------------------------------------------------------------------------------ | -| `--app` | Modify APP file (directory) instead of IPA file. No signing is done | -| `--identity ` | Certificate Identity name for code signing | -| `--output ` | Path to output IPA file | -| `--build-jsbundle` | Build JS bundle before signing | -| `--jsbundle ` | Path to JS bundle to apply before signing | -| `--no-hermes` | Don't use Hermes for JS bundle | -| `--use-app-entitlements` | Extract app bundle codesigning entitlements and combine with entitlements from new provisioning profile | +| Option | Description | +| :---------------------------- | :------------------------------------------------------------------------------------------------------ | +| `--app` | Modify APP file (directory) instead of IPA file. No signing is done | +| `--identity ` | Certificate Identity name for code signing | +| `--output ` | Path to output IPA file | +| `--build-jsbundle` | Build JS bundle before signing | +| `--sourcemap-output ` | Path to write the source map of the built JS bundle (requires `--build-jsbundle`) | +| `--jsbundle ` | Path to JS bundle to apply before signing | +| `--no-hermes` | Don't use Hermes for JS bundle | +| `--use-app-entitlements` | Extract app bundle codesigning entitlements and combine with entitlements from new provisioning profile | ## Platform Android @@ -256,15 +257,15 @@ The `sign:android ` command signs your Android app with a keystore, | :----------- | :-------------------------- | | `binaryPath` | Path to the APK or AAB file | -| Option | Description | -| :----------------------------- | :---------------------------------------- | -| `--keystore ` | Path to keystore file | -| `--keystore-password ` | Password for keystore file | -| `--output ` | Path to output APK or AAB file | -| `--build-jsbundle` | Build JS bundle before signing | -| `--jsbundle ` | Path to JS bundle to apply before signing | -| `--no-hermes` | Don't use Hermes for JS bundle | - +| Option | Description | +| :----------------------------- | :-------------------------------------------------------------------------------- | +| `--keystore ` | Path to keystore file | +| `--keystore-password ` | Password for keystore file | +| `--output ` | Path to output APK or AAB file | +| `--build-jsbundle` | Build JS bundle before signing | +| `--sourcemap-output ` | Path to write the source map of the built JS bundle (requires `--build-jsbundle`) | +| `--jsbundle ` | Path to JS bundle to apply before signing | +| `--no-hermes` | Don't use Hermes for JS bundle | ### `rock validate-elf-alignment` Options @@ -407,11 +408,11 @@ The `config` command outputs the autolinking configuration from Community CLI, w The `clean` command helps you free up disk space by removing various caches and temporary files from your React Native project. It can clean Android (Gradle), iOS (CocoaPods), Metro, Watchman, Rock's own project caches, package manager caches, and CCache compiler cache. -| Option | Description | -| :------------------- | :------------------------------------------------------------------------------------------------------------------------------------------------------ | +| Option | Description | +| :------------------- | :---------------------------------------------------------------------------------------------------------------------------------------------------------------- | | `--include ` | Comma-separated list of caches to clean. Available options: `android`, `gradle`, `cocoapods`, `metro`, `watchman`, `npm`, `yarn`, `bun`, `pnpm`, `rock`, `ccache` | -| `--verify-cache` | Whether to verify the cache (currently only applies to npm cache) | -| `--all` | Clean all available caches without interactive prompt | +| `--verify-cache` | Whether to verify the cache (currently only applies to npm cache) | +| `--all` | Clean all available caches without interactive prompt | ## Plugin Remote Cache