Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
12 changes: 11 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,17 @@ try {

## React Native

BSON vendors the required polyfills for `TextEncoder`, `TextDecoder`, `atob`, `btoa` imported from React Native and therefore doesn't expect users to polyfill these. One additional polyfill, `crypto.getRandomValues` is recommended and can be installed with the following command:
js-bson requires the `atob`, `btoa` and `TextEncoder` globals. Older versions of React Native did not support these global objects, and so
[js-bson v5.4.0](https://github.com/mongodb/js-bson/releases/tag/v5.4.0) added support for bundled polyfills for these globals. Newer versions
of Hermes includes these globals, and so the polyfills for are no longer needed in the js-bson package.

If you find yourself on a version of React Native that does not have these globals, either:

1. polyfill them yourself
2. upgrade to a later version of hermes
3. use a version of js-bson `>=5.4.0` and `<7.0.0`

One additional polyfill, `crypto.getRandomValues` is recommended and can be installed with the following command:

```sh
npm install --save react-native-get-random-values
Expand Down
40 changes: 0 additions & 40 deletions etc/rollup/rollup-plugin-require-vendor/require_vendor.mjs

This file was deleted.

3 changes: 1 addition & 2 deletions rollup.config.mjs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { nodeResolve } from '@rollup/plugin-node-resolve';
import typescript from '@rollup/plugin-typescript';
import { RequireVendor } from './etc/rollup/rollup-plugin-require-vendor/require_vendor.mjs';

/** @type {typescript.RollupTypescriptOptions} */
const tsConfig = {
Expand Down Expand Up @@ -75,7 +74,7 @@ const config = [
},
{
input,
plugins: [typescript(tsConfig), new RequireVendor(), nodeResolve({ resolveOnly: [] })],
plugins: [typescript(tsConfig), nodeResolve({ resolveOnly: [] })],
output: {
file: 'lib/bson.rn.cjs',
format: 'commonjs',
Expand Down
12 changes: 1 addition & 11 deletions test/node/release.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,17 +53,7 @@ const REQUIRED_FILES = [
'src/utils/string_utils.ts',
'src/utils/web_byte_utils.ts',
'src/utils/latin.ts',
'src/parse_utf8.ts',
'vendor/base64/base64.js',
'vendor/base64/package.json',
'vendor/base64/LICENSE-MIT.txt',
'vendor/base64/README.md',
'vendor/text-encoding/lib/encoding-indexes.js',
'vendor/text-encoding/lib/encoding.js',
'vendor/text-encoding/index.js',
'vendor/text-encoding/package.json',
'vendor/text-encoding/LICENSE.md',
'vendor/text-encoding/README.md'
'src/parse_utf8.ts'
].map(f => `package/${f}`);

describe(`Release ${packFile}`, function () {
Expand Down
20 changes: 0 additions & 20 deletions vendor/base64/LICENSE-MIT.txt

This file was deleted.

112 changes: 0 additions & 112 deletions vendor/base64/README.md

This file was deleted.

157 changes: 0 additions & 157 deletions vendor/base64/base64.js

This file was deleted.

Loading