Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

113
Views
How to use a capacitor plugin meant to be imported in a vanilla js app

I'm currently pulling hairs trying to figure out how to go about this.

So, I'm working in a vanilla JS environment with no webpack setup served with capacitor and want to use this capacitor-plugin: https://github.com/CodetrixStudio/CapacitorGoogleAuth

However, to use this plugin I have to import the package into my client code.

Here's what I've tried:

  1. Unpkg type="module": however browser support in mobile isn't that great. And this app will be served to a ton of users
  2. Using browserify + esmify to bundle the plugins code into something I could import with a <script> tag into my index.html. Didn't work

My last thought is to setup webpack to bundle everything for me, similar to the browserify approach and import that. However before I go through with all of that I wanted to reach out here to see if you guys had any other ideas.

Is there a way to access this plugin from window maybe?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

so I figured out the way to go about this by following this article: https://medium.com/@SmileFX/a-complete-guide-building-a-capacitorjs-application-using-pure-javascript-and-webpack-37d00f11720d

Basically you have a www/js directory (vanilla js), and a src directory (ES6/import code goes). You then configure webpack to output in your www/js/ directory. Note: Any variable you want accessible to your vanilla js code must be explicitly stored in the window object.

Example

./src/toBeWebpacked.js

import Module from "your-module"

window.doSomething = () => Module.doSomething()

./www/js/vanilla.js

const useModuleCode = () => {
  // use code from webpacked ES6 JavaScript here
  return window.doSomething();
}
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!