Ionic 2 plugins, any good doc out there? I'm confused about how it works and how to update them

I have a lot of trouble understanding how plugins are installed, removed, updated.

I have a list of plugins with versions in plugins/fetch.json
A list of plugins in config.xml
A list of plugins in package.json

I assumed that the best way to install and remove plugins was withionic add plugin_name and ionic rm plugin_name .
But when you remove them, config.xml is not updated and it will reinstall whatever is in there automatically.

Also, I have no idea how my plugins got into the config.xml file in the first place. Also, why they are version locked and does that file even matters because it’s never updated automatically.

Example of confusion. I update my android version
cordova platform remove android cordova platform add android@6.X.X
It says it is installing plugins, but none of these files change.
Is it because those commands only affect the platform folder directly?

I am also confused about the CLI’s ionic state save and ionic state restore… I thought that ionic state save would update my package.json from the platform info and ionic state restore would do the opposite. But then why doensn’t the config.xml update… is the config.xml even important? I figured out that running --save would update the config.xml, but I don’t get why and when we should do that.

This issue says that we should now use cordova plugin add plugin_name but all the docs say to use ionic plugin add plugin_name.

I am very confused about how to approach plugins and how to update them properly and I can’t find any documentation to clearly guide me through, so any help is very welcome.

2 Likes

I am also confused those above:confused:

Is this still the case today?

config.xml is the source of truth for Cordova - so it should be kept correct.

Exactly.

Most people ignore ionic state. It doesn’t play well with the Cordova commands. Also the newer Cordova versions do all that ionic state did back in the day.

Yes. Always use --save if you want the changes to persist.

Earlier with older Cordova versions this was a difference, now they mainly do the same thing.

I think the next Ionic CLI version will clean up here a bit and get rid of some bits and make it more explicit where it “only” proxies the Cordova commands.

1 Like