electrode-io / electrode-native

A platform to ease integration&delivery of React Native apps in existing mobile applications

Home Page:https://native.electrode.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Cannot create plugin for modules written in Kotlin

ryanliljestrom opened this issue · comments

commented

Whenever I attempt to create a plugin for a third-party package that contains Kotlin (e.g., https://github.com/stashenergy/react-native-msal) it always fails in

public async findReactPackageImplementationFile(): Promise<string> {
.

Looks like it needs some tweaks to look for *Package.kt files as well, plus some additional parsing of the Kotlin files as well.

Hi @ryanliljestrom - Thanks for opening this issue!
At this point there is no support for Kotlin in React Native native modules used with Electrode Native.

More details about the current and potential future support for Kotlin in React Native/Electrode Native:

Electrode Native is a platform that builds on top of React Native. React Native itself currently does not have any Kotlin dependencies or code (neither in the core native modules, nor in the default template used to create a new RN app). While it is possible to use Kotlin in an application project (one that uses React Native, as well as Electrode Native), the situation for native modules is slightly different. This is mainly due to the unconventional way in which React Native libraries (specifically, the Android native modules) are distributed and consumed by application projects. Instead of the "regular" way of distributing precompiled (binary) artifacts for native code, RN dependencies with their native modules are distributed as zip files and extracted into node_modules. They are then taken in source form from there and compiled on the fly - Because all these dependencies are standalone projects, not directly aware of each other, the probability for conflicts increases with every additional dependency.
Electrode Native has to support hundreds of possible plugins/React Native dependencies, and ideally any arbitrary combination of them. To minimize the risk of conflicts, we require it to be as closely aligned with core React Native as possible. That said, we continue to monitor the situation, and should there be a major change in core React Native, you can expect a similar update for Electrode Native soon thereafter.

@ryanliljestrom - I've opened a PR in react-native-msal converting the native module code to plain Java and removing the dependency on kotlin-stdlib. If everything goes well it should get merged this weekend. Once a new release is out, the dependency should be ready to use with a plugin config.

stashenergy/react-native-msal#61

commented

Wow, that’s fantastic! I appreciate the PR and am glad that the react-native-msal devs are so responsive. Hypothetically if they weren’t, could the applyPatch plugin configuration be used to do the same thing without a PR?

Hypothetically if they weren’t, could the applyPatch plugin configuration be used to do the same thing without a PR?

That's a very interesting idea. I haven't given that potential path much thought, but good to keep in mind. 👍

Just released v3.0.4 of react-native-msal without kotlin. Hopefully that solves your problem for now Ryan. Let me know if there's anything more we can do to help.

Awesome, thank you so much @josmithua 💯 👍

Primary platform support was added in #1807, and #1824 will add additional support to the plugin config generator.