Skip to content

Browser detection using global __webpack_require__ is misleading #1233

Closed
@ArminEberle

Description

@ArminEberle

Hi there,

we're using your library from a node standalone application.
It works fine when running our .js files as original.

Anyway when we build the node application using webpack, it seems to me that this has an unwanted impact on the browser detection in lib/connect/index.js and lib/connect/ws.js, effectively leading to connection problems.

We want to switch to a webpack build in order reduce our container sizes in kubernetes.

This is where it fails then:

ReferenceError: WebSocket is not defined
    at createBrowserWebSocket (/.build-tmp/webpack-dist/index.js:1993:16)
    at Object.browserStreamBuilder (/.build-tmp/webpack-dist/index.js:2019:16)
    at MqttClient.wrapper [as streamBuilder] (/.build-tmp/webpack-dist/index.js:2633:36)
    at MqttClient._setupStream (/.build-tmp/webpack-dist/index.js:395:22)
    at new MqttClient (/.build-tmp/webpack-dist/index.js:374:8)
    at Object.connect (/.build-tmp/webpack-dist/index.js:2635:16)

The line numbers are not correct of course in this scenario.

I'm just asking if you already know of this issue and could give me a hint, if not I can create a reproducible demo of the problem or bugfix fork if you want me to.

Best Regards,

Armin

AB#9138553

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions