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

Support browser usage in strict mode #190

Closed

Conversation

mpcowan
Copy link

@mpcowan mpcowan commented Feb 13, 2019

Currently, when passing this inside the scope setup function in a
browser leads to a Cannot set property Paho of undefined error.

To address this we wrap up the initialization logic in another scoped
IIFE that sets up a commonjsGlobal variable with appropriate fallback.

We can then use this variable instead of the undefined this when we
attempt to export the Paho library.

Signed-off-by: Matt Cowan mcowan@atlassian.com

Currently, when passing `this` inside the scope setup function in a
browser leads to a `Cannot set property Paho of undefined` error.

To address this we wrap up the initialization logic in another scoped
IIFE that sets up a commonjsGlobal variable with appropriate fallback.

We can then use this variable instead of the undefined `this` when we
attempt to export the Paho library.

Signed-off-by: Matt Cowan <mcowan@atlassian.com>
@mpcowan
Copy link
Author

mpcowan commented Feb 13, 2019

It is easiest to view the diff with whitespace changes hidden, since a lot of indenting happened: https://github.com/eclipse/paho.mqtt.javascript/pull/190/files?utf8=%E2%9C%93&diff=unified&w=1

I'm struggling to understand the test failures, so I can certainly use a hand there.

icraggs pushed a commit that referenced this pull request Jun 4, 2019
@icraggs
Copy link
Collaborator

icraggs commented Jun 4, 2019

The build failure was general, due to package dependencies needing updating. I've merged these changes into the develop branch, and the build & tests worked:

https://travis-ci.org/eclipse/paho.mqtt.javascript/builds/541371747

The auto-merging didn't work, but I think I got the manual resolution correct. Let me know if there's any issue. Thanks!

@icraggs icraggs closed this Jun 4, 2019
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 this pull request may close these issues.

2 participants