-
Notifications
You must be signed in to change notification settings - Fork 23
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
feat: add 'browser' field #188
Conversation
I'm not sure what the use case for this is. It's general practice to stub out packages in the build system rather than relying on the package to do it |
Additionally why you would bundle this for browsers? SHould you not use the official navigator.bluetooth there instead of this library which is basically node.js? |
That's the whole point. The specific use case I have in mind is Node-PoweredUp. It has this whole complex abstract adapter class and Noble and WebBluetooth implementations. With this, I will be able to refactor it to just use WebBluetooth directly and still work equally well on Node and browsers. |
What build/packaging system do you use for node-poweredup? |
node-poweredup doesn't have a build system besides tsc, but build systems shouldn't matter. Bundling is done at the application-level, not library level. The bundler (esbuild, rollup, webpack, etc) decides which file to use based on package.json. If the |
Just to be clear: there will be no changes for Node.js users. However, bundlers (webpack, vite, parcel, etc) and CDNs (esm.sh, unpkg, etc) will use the navigator.bluetooth wrapper when targeting browsers. |
The only other feedback I have is that adding this suggests the whole of this library will work in a browser environment (e.g. the As feedback is relatively minor, I'm happy to merge this now. |
I'm excited about this one. This adds a
browser
entry to package.json so that when bundling for browsers, it will automatically usenavigator.bluetooth
when importing this package.