Skip to content

Conversation

@JasonVMo
Copy link
Contributor

Platforms Impacted

  • all

Description of changes

We used to have the package.json main field pointing at src/index.ts, then we would change it to point to lib-commonjs/index.js on publish. This served to ensure that metro bundling used the typescript files directly when bundling. This avoids the need to build, while also ensuring fast-refresh worked correctly when changes were made. This was changed as part of modernizing the way modules were defined and referenced in the repo (which was previously hiding bugs) but had the downside of breaking fast-refresh in the repo.

Instead of the old system (with the custom publishing hook) instead I added "react-native": "src/index.ts" references to the packages. This will cause the metro bundler to use the typescript entry-point and causes fast-refresh to work again. This will also cause downstream consumers to use the typescript entry points in their builds as well which is good for type-checking, good for avoiding intermediate helpers being added as part of JS build targeting, and eventually good for allowing static hermes to better optimize the code.

Verification

Normal build & pipeline checks, also checked that bundling runs without building the repo first.

@JasonVMo JasonVMo requested a review from a team as a code owner July 14, 2025 06:12
Copy link
Collaborator

@Saadnajmi Saadnajmi left a comment

Choose a reason for hiding this comment

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

Should we have some linter or CI check enforce this?

@JasonVMo
Copy link
Contributor Author

Should we have some linter or CI check enforce this?

Created issue #3936 to keep track of this.

@JasonVMo JasonVMo merged commit 6b4d592 into main Jul 14, 2025
11 checks passed
@JasonVMo JasonVMo deleted the user/jasonvmo/fix-bundling branch July 14, 2025 19:58
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.

3 participants