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

Improve build-time support for UserControl #33

Open
asklar opened this issue Mar 6, 2021 · 1 comment
Open

Improve build-time support for UserControl #33

asklar opened this issue Mar 6, 2021 · 1 comment
Labels
enhancement New feature or request

Comments

@asklar
Copy link
Member

asklar commented Mar 6, 2021

When producing UserControl projections, the ReactNativeXaml project carries metadata for both XAML and the custom WinMDs. This means we end up with modified files inside node_modules. Ideally the codegen files for the custom winmds would be separate from the XAML ones.
The work here is:

  • Produce separate creator/properties/event tables for different assemblies. The ones for XAML go in the ReactNativeXaml project, whereas the projections for the custom WinMDs should go in the App project
  • The ReactNativeXaml project should have build logic to discover the custom WinMD projections so it links all of them together
  • Ideally do this in an automatic way: app project references a winmd, and there is a script that will re-run codegen
@asklar
Copy link
Member Author

asklar commented Mar 8, 2021

Design A: split built logic

  • Produce separate files for XAML and the custom WinMDs. The custom WinMD codegen would need to be part of the app
  • This poses a problem since the custom codegen still needs to get linked into ReactNativeXaml, so we end up reaching into the app's project via msbuild props
  • But also, RNX needs to have a winmd reference to the custom winmd so that cppwinrt can process it, so this would effectively still require modifying RNX under node_modules. An alternative would be to reuse the app's cppwinrt generated headers but this is very fragile (e.g. different versions of cppwinrt between the app and RNX would cause build breaks).
  • moreover this complicates the codegen'd TS since type needs to be a set of known strings (known at codegen time). An alternative is to have a synthetic property on UserControl like userControlType that is just a string (as opposed to type which is a string union); we lose intellisense/type safety with this so not ideal either.
  • I played with this but I'm not sure this is a good way forward. Branch here: https://github.com/asklar/react-native-xaml/tree/buildLogic

Design B: view manager generator

  • Codegen the whole view manager, not just the metadata. Then the app project just gets everything in one package
  • Apps that only need XAML can use the view manager from the package, apps that need custom stuff will use the generated one
  • It would make sense to split codegen into its own npm package, and have the XAML VM be wholly generated by it
  • This could make it trickier to iterate on the VM (since the experience isn't great for T4 files, no intellisense, etc., it's just text)
  • This is closer to what is possible today; you can run codegen and it will update the code in node_modules, and then you can copy the resulting RNX project into your project and get rid of the RNX npm package dependency

@asklar asklar added the enhancement New feature or request label Aug 19, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant