Repository navigation
Conversation
| ".": { | ||
| "browser": "./dist/browser.js", | ||
| "default": "./dist/node.js" | ||
| "node": "./dist/node.js", |
There was a problem hiding this comment.
Could you please test on other runtimes, like Bun, Deno, workerd, and check if they work well.
There was a problem hiding this comment.
I've added test scripts for deno and bun to package.json and ran these locally - they all pass. I didn't know how far you wanted me to take this: do you want github workflows that run the smoke tests on bun and deno as well? Do you want to run the entire test suite on the different runtimes? Am I okay to add dependencies like cloudflare workers pool for vitest?
In this fork, we took it all the way (since we use obug inside of @sanity/client, which needs to run on all these different runtimes) - but again; not sure how much infrastructure/changes you're willing to deal with?
Co-authored-by: Espen Hovlandsdal <[email protected]> closes #1, closes #6
|
Thanks for your contribution! I added you to 0e828cd commit |
AI usage
Description
React Native/Expo projects with the metro bundler module resolution resolves
obugto it's default export field, which it has pointed to thenodetarget, which is using node-specific imports (node:tty) and crashes.I'd argue the more logical stance is to default to a "runtime agnostic" build - currently the closest to that is the browser build, although you could argue a third build that doesn't use CSS/hex colors etc might be a more logical fallback. This PR swaps the default to be the browser build for now. Deno and Bun also uses it, so they resolve to same build as before.
Additionally, react native/expo doesn't support the
%cformatting so it would print things like%cobug:app %chello %c+0msunless a chrome debugger is attached. Not quite sure what the best solution is here - currently I feature-checked ondocument, but that might also exclude workers, so open to other suggestions - but was worried about adding too many bytes to the bundle here.Linked Issues
None
Additional context
The colors check is up for debate - very open to changing or dropping that commit, the most important thing is preventing this from crashing when used in react native.