Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 37 commits into from
Feb 5, 2025

Conversation

JasonVMo
Copy link
Contributor

@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.

incubator/tools-typescript/README.md Outdated Show resolved Hide resolved
.changeset/hot-bobcats-play.md Outdated Show resolved Hide resolved
incubator/tools-typescript/src/build.ts Outdated Show resolved Hide resolved
incubator/tools-typescript/src/build.ts Outdated Show resolved Hide resolved
incubator/tools-typescript/src/build.ts Outdated Show resolved Hide resolved
incubator/tools-typescript/src/resolver.ts Outdated Show resolved Hide resolved
incubator/tools-typescript/src/resolver.ts Outdated Show resolved Hide resolved
incubator/tools-typescript/src/task.ts Outdated Show resolved Hide resolved
incubator/tools-typescript/src/task.ts Outdated Show resolved Hide resolved
incubator/tools-typescript/src/task.ts Outdated Show resolved Hide resolved
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
Contributor 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