Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Vite not working with v5.2.0: Uncaught SyntaxError: ambiguous indirect export: default #1733

Closed
jitbasemartin opened this issue Nov 10, 2023 · 2 comments · Fixed by #1734
Closed

Comments

@jitbasemartin
Copy link

Hi,

I use Vite and MQTT.JS in my project and since I updated to v5.2.0, I got the following error in Firefox console:

# Console
Uncaught SyntaxError: ambiguous indirect export: default   [App.vue:2:8](http://localhost:5173/src/App.vue)

# App.vue
import { createHotContext as __vite__createHotContext } from "/@vite/client";import.meta.hot = __vite__createHotContext("/src/App.vue");import { ref } from "/node_modules/.vite/deps/vue.js?v=29721d56"
import __vite__cjsImport1_mqtt_dist_mqtt_min from "/node_modules/.vite/deps/mqtt_dist_mqtt__min.js?v=b7b5e482"; const connect = __vite__cjsImport1_mqtt_dist_mqtt_min["connect"]


const _sfc_main = {
....

To reproduce, use the example here: https://github.com/mqttjs/MQTT.js/tree/main/examples/vite-example
And update the package.json with:

--- a/package.json
+++ b/package.json
@@ -9,7 +9,7 @@
   },
   "dependencies": {
     "@esbuild-plugins/node-modules-polyfill": "^0.2.2",
-    "mqtt": "^5.0.5",
+    "mqtt": "5.2.0",
     "process": "^0.11.10",
     "vue": "^3.3.4"
   },

then classic

npm install
npm run dev
@robertsLando
Copy link
Member

Try with:

import mqtt from 'mqtt/dist/mqtt.esm'

@robertsLando
Copy link
Member

I also created this pr: #1734

So then you will be able to use import mqtt from 'mqtt'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants