Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: update migration guide TLA #728

Merged
merged 2 commits into from
Nov 13, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions docs/upgrade-to-v5.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,17 @@ bin.value(true).toString('utf16le');
new TextDecoder('utf-16le').decode(bin.value(true));
```

### Bundling Top-Level Await in BSON

The `"export"` conditions in [package.json](../package.json) make it possible for the `bson` package to provide module resolutions for ES Module and CommonJS.
When using a bundler and targeting the browser the export condition `"browser"` will likely point your bundler at the bson.mjs file, an ES Module.
This ES Module form of `BSON` works in both Node.js and browser environments, however, one sticking point is often bundlers do not by default enable support of top-level await usage.
nbbeeken marked this conversation as resolved.
Show resolved Hide resolved

For example, you may need to:
nbbeeken marked this conversation as resolved.
Show resolved Hide resolved
- enable Webpack's [`topLevelAwait`](https://webpack.js.org/configuration/experiments/#experimentstoplevelawait) setting to bypass the issue.
- override the [resolution](https://webpack.js.org/configuration/resolve/#resolve) of `bson` to use the CommonJS module, "bson.cjs".
- `require('bson')` instead of using `import`.

## Other Changes

### TS "target" set to es2020
Expand Down