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

[Bug]: Import does not work properly with webpack > 5, ember-auto-import 2.X, browser and SSR (fastboot) #1934

Open
hoIIer opened this issue Sep 1, 2024 · 0 comments
Labels

Comments

@hoIIer
Copy link
Contributor

hoIIer commented Sep 1, 2024

MQTTjs Version

5.4.0

Broker

aws

Environment

NodeJS

Description

I'm in the process of upgrading an app that was previously using 5.0.3 and worked normally.

When using the latest mqtt 5.4.0, with webpack 5.94.0, ember 5.0.0, ember-auto-import 2.7.1, I see these issues:

Normal import no longer works (node/browser):

Previously worked:

import { connectAsync } from 'mqtt';

Now that results in connectAsync is not defined

Using strategy described here, I can get import to work in browser mode, but it fails in node as described below. (also this)

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

 function() {
    ...
     connection = await mqtt.default.connectAsync(...)
}

Fastboot (node/ssr):

  1. TypeError: Cannot set properties of undefined (setting 'AbortSignal')

TypeError: Cannot set properties of undefined (setting 'AbortSignal')
at eval (webpack://ember_auto_import/./node_modules/mqtt/dist/mqtt.esm.js?:6:1347)
at eval (webpack://ember_auto_import/./node_modules/mqtt/dist/mqtt.esm.js?:5:1354)
at eval (webpack://ember_auto_import/./node_modules/mqtt/dist/mqtt.esm.js?:6:102193)
at eval (webpack://ember_auto_import/./node_modules/mqtt/dist/mqtt.esm.js?:5:1354)
at eval (webpack://ember_auto_import/./node_modules/mqtt/dist/mqtt.esm.js?:6:107827)
at eval (webpack://ember_auto_import/./node_modules/mqtt/dist/mqtt.esm.js?:5:1354)
at eval (webpack://ember_auto_import/./node_modules/mqtt/dist/mqtt.esm.js?:6:109301)
at eval (webpack://ember_auto_import/./node_modules/mqtt/dist/mqtt.esm.js?:5:1354)
at eval (webpack://ember_auto_import/./node_modules/mqtt/dist/mqtt.esm.js?:6:115088)
at eval (webpack://ember_auto_import/./node_modules/mqtt/dist/mqtt.esm.js?:5:1354)
at eval (webpack://ember_auto_import/./node_modules/mqtt/dist/mqtt.esm.js?:6:127946)
at eval (webpack://ember_auto_import/./node_modules/mqtt/dist/mqtt.esm.js?:5:1354)
at eval (webpack://ember_auto_import/./node_modules/mqtt/dist/mqtt.esm.js?:6:156523)
at eval (webpack://ember_auto_import/./node_modules/mqtt/dist/mqtt.esm.js?:5:1354)
at eval (webpack://ember_auto_import/./node_modules/mqtt/dist/mqtt.esm.js?:6:241329)
at eval (webpack://ember_auto_import/./node_modules/mqtt/dist/mqtt.esm.js?:5:1354)
at eval (webpack://ember_auto_import/./node_modules/mqtt/dist/mqtt.esm.js?:9:20193)
at eval (webpack://ember_auto_import/./node_modules/mqtt/dist/mqtt.esm.js?:5:1354)
at eval (webpack://ember_auto_import/./node_modules/mqtt/dist/mqtt.esm.js?:9:21547)
at eval (webpack://ember_auto_import/./node_modules/mqtt/dist/mqtt.esm.js?:5:1354)
at eval (webpack://ember_auto_import/./node_modules/mqtt/dist/mqtt.esm.js?:9:21647)
at Module../node_modules/mqtt/dist/mqtt.esm.js (/var/folders/9r/gp7xyl_j0l3flcwp78j7mjcr0000gn/T/broccoli-77912wElEFjGOhfM7/out-464-broccoli_merge_trees/assets/chunk.vendors-node_modules_ember_test-helpers_dist_index_js-node_modules_faker-js_faker_dist_cjs_in-f33e59.7ed5976d6f429d809e98.js:33940:1)
at webpack_require (/var/folders/9r/gp7xyl_j0l3flcwp78j7mjcr0000gn/T/broccoli-77912wElEFjGOhfM7/out-464-broccoli_merge_trees/assets/chunk.app.38b6e5e110dec6f113ad.js:360:42)

  1. ReferenceError: Cannot access '__WEBPACK_DEFAULT_EXPORT__' before initialization

ReferenceError: Cannot access 'WEBPACK_DEFAULT_EXPORT' before initialization
at Module.default (webpack://ember_auto_import/./node_modules/mqtt/dist/mqtt.esm.js?:3:42)
at Module.makeDefaultExport (/var/folders/9r/gp7xyl_j0l3flcwp78j7mjcr0000gn/T/broccoli-77912wElEFjGOhfM7/out-464-broccoli_merge_trees/assets/vendor/loader/loader.js:87:1)

This is not ideal and I'd like to be able to do the regular import that previously worked with import { connectAsync } from 'mqtt'.

Any suggestions?

Thanks!

Minimal Reproduction

n/a

Debug logs

n/a

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

No branches or pull requests

1 participant