Skip to content

Conversation

anupriya13
Copy link
Contributor

@anupriya13 anupriya13 commented Sep 6, 2025

Description

Type of Change

  • New feature (non-breaking change which adds functionality)

Why

React Native Windows developers need an automated way to set up Windows support for community modules. The current manual process involves multiple steps (running init-windows, codegen-windows, creating stub files) and is error-prone. This automation reduces setup time from hours to minutes and prevents common configuration mistakes.

Resolves #15078

What

This PR introduces the setup-module-windows command that automates the entire Windows module setup process:

Automated Setup Pipeline:

  • Validates environment and finds TurboModule spec files
  • Updates package.json with codegen configuration
  • Runs init-windows with proper template selection
  • Executes codegen-windows to generate native specs
  • Creates comprehensive C++ stub files based on actual method signatures

Smart TurboModule Integration:

  • Parses codegen-generated nativemodulespec.g.h files
  • Extracts real method signatures including complex callback types
  • Generates accurate REACT_METHOD declarations
  • Creates implementation stubs with TODO comments and usage examples
  • Includes a generic "Hello World" method for immediate testing

Key Features:

  • Template support for both cpp-lib (default) and cpp-app via --template flag
  • Robust directory detection across multiple codegen locations
  • Accurate path reporting using actual Windows project names
  • Seamless spinner integration preventing UI conflicts
  • Comprehensive error handling and validation

Screenshots

cli_new_recording.mp4

Testing

  • Added complete test suite covering validation, configuration updates, directory detection, and stub generation
  • Tested with real-world modules like react-native-webview
  • Verified spinner behavior and logging consistency
  • All existing tests pass without issues

Changelog

Should this change be included in the release notes: yes

Add a brief summary of your change
New setup-module-windows CLI command for automated Windows module scaffolding with comprehensive TurboModule stub generation

Microsoft Reviewers: Open in CodeFlow
Microsoft Reviewers: Open in CodeFlow

…ding with comprehensive TurboModule stub generation (#15118)
@anupriya13 anupriya13 marked this pull request as ready for review September 8, 2025 02:17
@anupriya13 anupriya13 requested a review from a team as a code owner September 8, 2025 02:17
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR introduces the setup-module-windows command that automates Windows module scaffolding for React Native community modules. It streamlines the previously manual multi-step process into a single command that validates environments, sets up Windows project structure, and generates comprehensive TurboModule stubs.

Key changes:

  • Automated Windows module setup pipeline with TurboModule spec validation
  • Smart C++ stub generation based on actual method signatures from codegen
  • Template support for both cpp-lib (default) and cpp-app project types

Reviewed Changes

Copilot reviewed 17 out of 17 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
packages/@react-native-windows/telemetry/src/utils/errorUtils.ts Added NoTurboModuleSpec error code for setup-module-windows command
packages/@react-native-windows/cli/src/index.ts Exported new setupModuleWindowsCommand and setupModuleWindowsInternal
packages/@react-native-windows/cli/src/commands/setupModuleWindows/utils/validationUtils.ts Environment validation and TurboModule spec detection utilities
packages/@react-native-windows/cli/src/commands/setupModuleWindows/utils/templateGenerationUtils.ts Comprehensive C++ stub generation with method signature parsing
packages/@react-native-windows/cli/src/commands/setupModuleWindows/utils/projectSetupUtils.ts Windows project setup coordination including init-windows and codegen-windows
packages/@react-native-windows/cli/src/commands/setupModuleWindows/utils/moduleNameUtils.ts Module name conversion and package.json codegen configuration
packages/@react-native-windows/cli/src/commands/setupModuleWindows/setupModuleWindowsOptions.ts Command-line options and interface definitions
packages/@react-native-windows/cli/src/commands/setupModuleWindows/setupModuleWindows.ts Main command implementation with telemetry and error handling
packages/@react-native-windows/cli/src/commands/setupModuleWindows/index.ts Module exports for setup-module-windows functionality
packages/@react-native-windows/cli/src/commands/setupModuleWindows/tests/setupModuleWindows.test.ts Test suite covering validation, naming, and stub generation
packages/@react-native-windows/cli/src/commands/setupModuleWindows/TESTING.md Comprehensive testing guide with scenarios and validation steps
packages/@react-native-windows/cli/src/commands/setupModuleWindows/README.md Documentation covering usage, options, and generated file structure
packages/@react-native-windows/cli/src/commands/setupModuleWindows/EXAMPLE.md Complete example using react-native-webview with both templates
packages/@react-native-windows/cli/src/commands/initWindows/initWindows.ts Added spinner parameter to support external spinner management
packages/@react-native-windows/cli/src/commands/codegenWindows/codegenWindows.ts Added spinner parameter to support external spinner management
change/@react-native-windows-telemetry-1c4bdce6-3813-4f87-83c2-a9886bab1b05.json Changelog entry for telemetry package
change/@react-native-windows-cli-add-setup-module-windows-command.json Changelog entry for CLI package

@anupriya13 anupriya13 closed this Sep 22, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Streamline RNW Community Modules Integration & Creation Process
2 participants