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

refactor: clean-up build situation and make cali/mcp-server ESM modules #47

Merged
merged 6 commits into from
Dec 2, 2024

Conversation

grabbou
Copy link
Collaborator

@grabbou grabbou commented Dec 1, 2024

Changelog:
Do not use Bun to run.
Use Node (with import --tsx) instead to make sure same behavior across dev/prod
Update TypeScript config to get early warnings about incorrect ESM/CJS imports
Use customCondition to point TypeScript to "source" so it gives correct type information without having to rebuild
Use RSLib to generate bundle for each package (generally most reliable after testing tsup and pkg roll)
Do not bundle anything into Cali but AI package that we had to temporarily patch

TL;DR

React Native CLI is an ESModule converted to CJS. It uses default exports and is transpiled with Babel. When this gets loaded into Bun, Bun follows Babel interop and will make import default resolve properly. However, in production, Node uses different approach. Importing default will import entire module, and to get actual "default" we must call "default.default". More can be read on this matter here https://esbuild.github.io/content-types/#default-interop

@grabbou grabbou requested a review from okwasniewski December 1, 2024 17:29
@grabbou
Copy link
Collaborator Author

grabbou commented Dec 1, 2024

TBH, now that we have rslib and it supports watch mode, we should consider dropping Bun to make sure that we run into those issues earlier than after releasing.

packages/cali/rslib.config.ts Show resolved Hide resolved
@grabbou grabbou merged commit 0d33139 into main Dec 2, 2024
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