-
-
Notifications
You must be signed in to change notification settings - Fork 29
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
feat: codegen based on platform #395
feat: codegen based on platform #395
Conversation
…ng}>` specified in when creating a hybrid object Currently, nitrogen generates code for all platforms (code/hybrid objects) regardless of the platform specified in `<{platform:lang}>` generic tags. This PR modifies the code generation to respect these platform tags and only generate the necessary code for the specified platforms. For example: - `<{ios:'swift'|'c++'}>` will only generate iOS-specific code - `<{android:'kotlin'|'c++'}>` will only generate Android-specific code This change improves efficiency by preventing unnecessary code generation for unused platforms.
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
Hmm, not sure if we want to increase complexity here. The autolinking setup code is empty anyways if you dont have any Hybrids - not sure if we want to fully remove that code then? |
I see your point about empty configs, but I think generating only platform-specific code would be beneficial:
The implementation complexity would be a one-time cost, but could save confusion down the line. What are your thoughts? |
packages/nitrogen/src/nitrogen.ts
Outdated
@@ -101,7 +103,8 @@ export async function runNitrogen({ | |||
continue | |||
} | |||
|
|||
const platforms = Object.keys(platformSpec) as Platform[] | |||
platforms = Object.keys(platformSpec) as Platform[] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This overwrites platforms
each time instead of appending to it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of lifting out platforms
here, let's create a new value in line 82 called usedPlatforms
and we additionally append to it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
addressed the comment above
Hey @mrousavy, anything else you'd like me to check or tweak on this PR? |
Hey - I'm still thinking about this. The main reason why I don't want to merge this is because it is not tested in the example here. There is no module that's iOS or Android only. |
Alright thanks for the feedback. i will add some tests for this over the weekend. |
dont worry, lets just use it as is. |
Currently, nitrogen generates code for all platforms (code/hybrid objects) regardless of the platform specified in
<{platform:lang}>
generic tags. This PR modifies the code generation to respect these platform tags and only generate the necessary code for the specified platforms.For example:
<{ios:'swift'|'c++'}>
will only generate iOS-specific and shared code<{android:'kotlin'|'c++'}>
will only generate Android-specific and shared code<{ios:'swift'|'c++', android:'kotlin'|'c++'}>
will generate Android, iOS and shared codeThis change improves efficiency by preventing unnecessary code generation for unused platforms.