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

Update and improve rollup bundles of BSON

    • Type: Icon: Task Task
    • Resolution: Fixed
    • Priority: Icon: Unknown Unknown
    • bson-5.0.0
    • Affects Version/s: None
    • Component/s: None
    • 5
    • Not Needed
    • Not Needed

      Use Case

      With the removal of the dependence on buffer we can remove the bundles that include buffer as a dependency (they will be equal to the ones that do not). We should take this opportunity to modernize the distribution to work with tools and bundlers.

      User Impact

      • Migration should not require changes, it depends on which bundle user may have been targeting with their build scripts. If changes are required it would likely be changing a path name.

      Acceptance Criteria

      Implementation Requirements

      • Update rollup
      • change the script to output 3 bundles:
        • dist/bson.cjs - commonjs module, one shared file for all of bson used by node
        • dist/bson.mjs - esm module, one shared file for all of bson used by bundlers for web (Rename: dist/bson.esm.js)
        • dist/bson.bundle.js - Legacy style script that puts exports on the global object (CDN style)
      • Ensure all bundles have corresponding source maps that do not inline the source
      • Ensure the lib directory is no longer shipped in the npm package
      • Set the "exports" field in the package.json:
        • "import": "./dist/bson.mjs"
        • "require": "./dist/bson.cjs"
      • set "main": "./dist/bson.cjs"

      Testing Requirements

      • Unit tests that make sure the exports are equal could be applicable
      • Test a default webpack setup to see if bundling still works

            Assignee:
            neal.beeken@mongodb.com Neal Beeken
            Reporter:
            neal.beeken@mongodb.com Neal Beeken
            Durran Jordan
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: