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

Remove is-browser.ts detection util in favor of config option #1900

Open
olso-nordsec opened this issue Jul 10, 2024 · 1 comment
Open

Remove is-browser.ts detection util in favor of config option #1900

olso-nordsec opened this issue Jul 10, 2024 · 1 comment

Comments

@olso-nordsec
Copy link
Contributor

olso-nordsec commented Jul 10, 2024

Is your feature request related to a problem? Please describe.

Describe the solution you'd like
Configurable by required option

mqtt.connect(credentials.endpoint, {
  environment: 'browser', // 'react-native' 'electron' 'node'
})

Describe alternatives you've considered
A clear and concise description of any alternative solutions or features you've considered.

Additional context
Add any other context or screenshots about the feature request here.

@robertsLando
Copy link
Member

robertsLando commented Jul 10, 2024

@olso-nordsec problem is that actually we also need that in order to know which modules to load and which not (as some wouldn't work on browser). For the other points in code I think your solution could work but we firstly should define how to fix this. Maybe there could be a way by using esbuild

If you have something in mind feel free to open a PR

Ref:

if (!IS_BROWSER) {
protocols.mqtt = require('./tcp').default
protocols.tcp = require('./tcp').default
protocols.ssl = require('./tls').default
protocols.tls = protocols.ssl
protocols.mqtts = require('./tls').default
} else {
protocols.wx = require('./wx').default
protocols.wxs = require('./wx').default
protocols.ali = require('./ali').default
protocols.alis = require('./ali').default
}

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

No branches or pull requests

2 participants