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

rnmbxcodegen #3552

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open

rnmbxcodegen #3552

wants to merge 2 commits into from

Conversation

mfazekas
Copy link
Contributor

Fight RN codegen with more codegen.

See also reactwg/react-native-new-architecture#199

Using swift and RN with new architecture but providing compatibility with old arch requires an insane amount of boilerplate code. See required files.

We attempt to work around this using the schema.json generated by RN codegen and generating as many boilerplate as possible with ejs templates. Ejs templates can have grey-matter metadata in comments in the front.

To run the codegen:
1.) Run combine-js-to-schema-cli to create the schema.json used internally by react native codegen tool

cd example
mkdir -p ../tmp/generated
node ./node_modules/@react-native/codegen/lib/cli/combine/combine-js-to-schema-cli.js --platform android ../tmp/generated/schema.json ../src/specs/

2.) Run rnmbxcodegen

 npx bun ./scripts/rnmbxcodegen/rnmbxcodegen.ts

Pros:

  • we can create new components faster
  • we can refactor boilerplate code a bit easier by changing codeine

Cons:

  • more complexity of codegen

Boilerplate:

On android it's better only 3 files:

Copy link
Contributor

@FrederickEngelhardt FrederickEngelhardt Sep 2, 2024

Choose a reason for hiding this comment

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

Curious why is this file needed vs a kotlin file? Looks painful to support this syntax too.

Is this required for turbo modules to work in a library? Also is this auto-generated? Some of the iOS files say this, but not here 🤷 .

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