Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

116
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda