Skip to content

Add an experimental tools-typescript package for better react-native builds with typescript#3503

Merged
JasonVMo merged 37 commits intomicrosoft:mainfrom
JasonVMo:tools-typescript
Feb 5, 2025
Merged

Add an experimental tools-typescript package for better react-native builds with typescript#3503
JasonVMo merged 37 commits intomicrosoft:mainfrom
JasonVMo:tools-typescript

Conversation

@JasonVMo
Copy link
Collaborator

@JasonVMo JasonVMo commented Feb 1, 2025

Description

A package that helps with building typescript, particularly for react-native. It
leverages the @rnx-kit/typescript-service package to build using the language
service rather than using the compiler directly. This allows for custom
resolution strategies (among other things). The compilation and type-checking
are still done by typescript but this drives some convenient custom
configurations.

In particular the buildTypescript command can do things like:

  • multiplex a build in a directory, to build for multiple react-native platforms
    at the same time. The files will be split such that the minimal build can be
    performed.
  • detect which react-native platforms should be built based on rnx-kit bundle
    configs or react-native.config.js settings.
  • successfully build with the module suffixes without throwing up a ton of bogus
    unresolved reference errors.
  • share caches where possible to speed up compilations within the same node
    process.

Motivation

The current story for building typescript for react-native is sub-par, and
typescript itself is particularly restrictive with module resolution. This
addresses the ability to build react-native better right now, but also creates a
framework for experimenting with different resolvers.

Test plan

  • There are some unit tests already but more will be added in the future.
  • Tested via repo linking in the FURN repo since it has complex build needs
  • Planning to add a test repo for another change and will run builds in there and compare results with tsc as part of validation.

Copy link
Member

@tido64 tido64 left a comment

Choose a reason for hiding this comment

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

Sorry, didn't mean to approve this already.

@JasonVMo
Copy link
Collaborator Author

JasonVMo commented Feb 3, 2025

Sorry, didn't mean to approve this already.

No worries, wouldn't submit without hearing back anyways. I just submitted changes in response to your comments. Two still warrant a bit of discussion.

@JasonVMo JasonVMo merged commit 87e909b into microsoft:main Feb 5, 2025
10 checks passed
@JasonVMo JasonVMo deleted the tools-typescript branch February 5, 2025 16:26
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.

2 participants