-
Type: Task
-
Resolution: Fixed
-
Priority: Unknown
-
Affects Version/s: None
-
Component/s: None
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"
- Check the documentation here: https://nodejs.org/api/packages.html#dual-commonjses-module-packages while implementing
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