mailgun / mailgun.js

Javascript SDK for Mailgun
https://www.npmjs.com/package/mailgun.js
Apache License 2.0
519 stars 109 forks source link

SyntaxError: Export 'default' is not provided by 'mailgun.js' when importing in a Vite + React project #415

Open Fedevs opened 2 months ago

Fedevs commented 2 months ago

Description

I'm encountering a SyntaxError when trying to import mailgun.js in a project created using Vite and React. The error message is as follows:

Uncaught SyntaxError: The requested module '/node_modules/.vite/deps/mailgun__js.js?v=68b1499c' does not provide an export named 'default'

This occurs when trying to import mailgun.js using the default import syntax:

Environment

Vite version: 5.2.0 React version: 18.2.0 Mailgun.js version: 10.2.1 Browser: Chrome 126.0.6478.127 Operating System: Windows 11

Expected Behavior

mailgun.js should be successfully imported without any syntax errors.

Actual Behavior

A SyntaxError is thrown indicating that the default export is not provided by mailgun.js.


import Mailgun from 'mailgun.js';
MananSharma12 commented 1 month ago

I'm getting the same issue in my SolidJS + Tauri project

Environment

Vite version: 5.0.0 SolidJS version: 1.7.8 Mailgun.js version: 10.2.3 Browser: Chrome 127.0.6533.73 Operating System: Windows 10

But using a dynamic import is a workaround for now:

let Mailgun: any;
import('mailgun.js').then(module => {
  Mailgun = module.default;
  initializeMailgun();
});

let mg: any;

function initializeMailgun() {
  const mailgun = new Mailgun(formData);
  mg = mailgun.client({
    username: "api",
    key: import.meta.env.VITE_MAILGUN_API_KEY,
  });
}
JulianKingman commented 1 month ago

Same issue using with typescript in a Turborepo package

kii-dot commented 1 month ago

Having the same issue with remix and turborepo

bramski commented 1 month ago

Same. Anybody gonna fix this at Mailgun? What a pain.

bramski commented 1 month ago
Screenshot 2024-08-16 at 7 53 30 AM

nah that's broken.

sime-time commented 3 weeks ago

Same issue with my QwikCity project

joejordan commented 1 week ago

I am having this same issue building a Bun project that uses mailgun.js.