alvesalexsander / whatsappButton

A javascript plugin that makes you a customizable Whatsapp button for your web applications
https://alvesalexsander.github.io/whatsappButton/
9 stars 4 forks source link

How to use with 'import' ES6 modules ? #1

Open AlonsoK28 opened 2 years ago

AlonsoK28 commented 2 years ago

I´ve tried to import the library using webpack 4 like this:

import { WhatsappButton } from 'whatsapp-button.js';

new WhatsappButton('5522123456789', 'Could we help you?', 'We are at your service! Want help at choosing a wine? Any other thing we could help?', 'netWinez, can we help?', '1', '#6f2045', '#000000', '', 'https://fonts.googleapis.com/css?family=Satisfy&display=swap')

But causes this error into browser console

Uncaught (in promise) TypeError WhatsappButton is not a constructor

import reference https://developer.mozilla.org/es/docs/Web/JavaScript/Referencia/Sentencias/import

AlonsoK28 commented 2 years ago

I think issue can be related to this https://stackoverflow.com/a/67757374/7724301

AlonsoK28 commented 2 years ago

I have tried import with these sentences but get the same error

import { WhatsappButton } from 'whatsapp-button.js/dist/wpp_js/whatsappButton';

const WhatsappButton = require('whatsapp-button.js/dist/wpp_js/whatsappButton').default;

const {WhatsappButton} = require('whatsapp-button.js');

import WhatsappButton from 'whatsapp-button.js/dist/wpp_js/whatsappButtonES6';

import WhatsappButton from 'whatsapp-button.js';