cordova-lib icon indicating copy to clipboard operation
cordova-lib copied to clipboard

Better support for local plugin development

Open csabbey opened this issue 6 years ago • 3 comments

Our app has a few local plugins, and I'm the app-backend developer for our team. I haven't found a great way for our team to keep our plugins up-to-date.

I've used hooks to remove and add these plugins automatically, but the plugin spec tends to get corrupted with this approach. For example, this call: cordova plugin add --force file:local_plugins/com.rsginc.mobilesurvey sets the plugin spec to <plugin name="com.rsginc.mobilesurvey" spec="~1.0.0" /> which isn't a local file spec...

My current approach is to have everyone on my team use the --link option to add these plugins, which works for some changes, but breaks when new source files are added - they don't get copied over.

My thought was that adding versioning to the local file spec could fix this - new versions could be picked up when the source code is updated (and the version is updated in the plugin's package.json) without the need for workarounds like re-adding the plugins or linking them. Admittedly, I'm just a cordova user without a good view into everything that's available, so this might be a naive approach.

... and if there's already a way to handle what I'm trying to do, please let me know.

csabbey avatar Nov 01 '18 14:11 csabbey

We're in a transition phase of moving dependency specs from config.xml over to package.json.

I believe what you're trying to do will work if you specify your dependency in package.json:

"com.rsginc.mobilesurvey": "file://local_plugins/com.rsginc.mobilesurvey"

Unfortunately, during this transition phase, Cordova will try to mirror dependencies in both package.json and config.xml, so you might find that it keeps adding it back to config.xml with the wrong spec.

dpogue avatar Nov 01 '18 19:11 dpogue

Thanks for this. Any advice on keeping local plugins up to date?

We're getting white screens on app startup, and that seems to be caused by out-of-sync plugins, so I'm running a lot of extra build steps... could all that be caused by linking the local plugins?

I'm starting to think that local plugins just shouldn't be used until at least the next major version of Cordova. Do you know if local plugins will include versioning then?

csabbey avatar Nov 02 '18 19:11 csabbey

I would say that using local plugins is not supported functionality at this point.

I do think that we should drop using dependencies from config.xml in a new major release and we should improve the consistency with how npm works with dependencies. I forget if we are tracking this somewhere or not.

brody4hire avatar Jan 01 '20 18:01 brody4hire