realm-js icon indicating copy to clipboard operation
realm-js copied to clipboard

RJS-2765: Upgrade BSON

Open elle-j opened this issue 1 year ago • 2 comments
trafficstars

What, How & Why?

Upgrading packages to use BSON v6. There are several breaking changes (v5, v6) in the BSON package, some of which affect us.

Notes on breaking changes:

  • Since we are reexporting the package, we should likely consider this a breaking change to our own packages as well.

Blocking:

  • The BSON package is currently using top-level await which currently prevents us from bundling if don't enable that feature. @kraenhansen has contributed a PR to BSON to alleviate this for us (see Jira ticket).

This closes #6561

☑️ ToDos

  • [ ] 📝 Changelog entry
  • [ ] 📝 Compatibility label is updated or copied from previous entry
  • [ ] 📝 Update COMPATIBILITY.md
  • [ ] 🚦 Tests
  • [ ] 📦 Updated internal package version in consuming package.jsons (if updating internal packages)
  • [ ] 📱 Check the React Native/other sample apps work if necessary
  • [ ] 💥 Breaking label has been applied or is not necessary

elle-j avatar Apr 04 '24 17:04 elle-j

I've rebased on latest main to get b88a065cbd50cf1b84f381d1ab1a781d72bd4f2e and force-pushed to your branch 🤞

kraenhansen avatar Apr 17 '24 07:04 kraenhansen

Latest React Native specific failure:

ReferenceError: Property 'btoa' doesn't exist
      at webByteUtils.toBase64 (/Users/runner/work/realm-js/realm-js/node_modules/bson/lib/bson.cjs:387:15)
      at Binary#toExtendedJSON (/Users/runner/work/realm-js/realm-js/node_modules/bson/lib/bson.cjs:549:47)
      at serializeDocument (/Users/runner/work/realm-js/realm-js/node_modules/bson/lib/bson.cjs:4088:36)
      at serializeValue (/Users/runner/work/realm-js/realm-js/node_modules/bson/lib/bson.cjs:4021:32)
      at stringify (/Users/runner/work/realm-js/realm-js/node_modules/bson/lib/bson.cjs:4120:30)

Metro seems to pick up "bson/lib/bson.cjs" instead of the RN specific bundle that is included in bson 🤔

kraenhansen avatar Apr 18 '24 12:04 kraenhansen