Capacitor Plugins and Vanilla JS


I am hoping to make a simple application using capacitor. Due to its simplicity I do not need, nor want, to use one of the Javascript frameworks.

I have created a project by including Ionic and Capacitor within script tags:

  <script type="module" src="@ionic/ionic.esm.js"></script>
  <script nomodule src="@ionic/ionic.js"></script>
  <script src="capacitor.js"></script>

It all works, when I serve the application I can access the Capacitor object within console.

However, when I install a plugin, for example Geolocation, the capacitor.js file is not updated to include the geolocation plugin. This means I either need to manually add in another include, or merge the two files.

Is there a reason why npx cap copy isn’t merging the Capacitor plugins into one file for me to include in the project?

I tried pika/web, but it hasn’t really solved the problem.

Is my best option to stick with Ionic and Cordova?

When I get to the point of generating an Android or IOS application, will I have similar issues with the plugins not being integrated?

I have had a look in the Android build files and I can’t seem to find the Geolocation plugin javascript. The cordova and cordiva_plugins files are empty and the capacitor.js only contains the core.

Thank you!

Check my answer on How to use plugins like Filesystem in VanillaJS - #3 by jcesarmobile

What are you doing to make the ionic scripts work?