Skip to content

Fix bundling to use typescript files rather than js files - #3934

Merged
Jason Morse (JasonVMo) merged 2 commits into
mainfrom
user/jasonvmo/fix-bundling
Jul 14, 2025
Merged

Fix bundling to use typescript files rather than js files#3934
Jason Morse (JasonVMo) merged 2 commits into
mainfrom
user/jasonvmo/fix-bundling

Conversation

@JasonVMo

Copy link
Copy Markdown
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
Jason Morse (JasonVMo) requested a review from a team as a code owner July 14, 2025 06:12

@Saadnajmi Saad Najmi (Saadnajmi) left a comment

Copy link
Copy Markdown
Collaborator

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
Copy Markdown
Contributor Author

Should we have some linter or CI check enforce this?

Created issue #3936 to keep track of this.

@JasonVMo
Jason Morse (JasonVMo) merged commit 6b4d592 into main Jul 14, 2025
11 checks passed
@JasonVMo
Jason Morse (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.

2 participants