Uploaded image for project: 'Node.js Driver'
  1. Node.js Driver
  2. NODE-3555

Refactor BSON to work with only cross platform JS APIs

    • Type: Icon: Improvement Improvement
    • Resolution: Fixed
    • Priority: Icon: Unknown Unknown
    • bson-5.0.0
    • Affects Version/s: None
    • Component/s: None
    • Labels:
    • 8
    • Not Needed
    • Not Needed

      Using jsvu and eshost we can test our BSON lib directly on v8, spidermonkey, and JavascriptCore (Safari). This could go a long way to ensuring web compatibility and enable perf testing on multiple javascript runtimes.

      To make this possible we have to add some polyfilling to allow our lib to work in environments that have no Buffer present. And we would need a TextEncoder/Decoder polyfill.


      The surface area of our API usage is:

      • Buffer.copy (uses .set internally) – replaced with .set
      • Buffer.alloc – replaced with Uint8Array constructor call (17mb, we might want remove)
      • toString('utf8', start, end) – there's no easy replacement - requires TextDecoder

      Karma has so many errors surrounding the node builtins and polyfils and there are outstanding issues that are years old and people still report issues with 20 days ago. There is very little documentation on this because of how odd it is. It's rare and non-performant to want to ship to the browser code that uses Node.js. https://github.com/rollup/plugins/issues/581#issuecomment-757376570

      We have to implement:

            Assignee:
            neal.beeken@mongodb.com Neal Beeken
            Reporter:
            neal.beeken@mongodb.com Neal Beeken
            Daria Pardue
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: