Skip to content

Commit 883f238

Browse files
feat(NODE-7019): remove react native vendor polyfills (#827)
1 parent 7ba8917 commit 883f238

File tree

14 files changed

+13
-4128
lines changed

14 files changed

+13
-4128
lines changed

README.md

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,17 @@ try {
230230

231231
## React Native
232232

233-
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:
233+
js-bson requires the `atob`, `btoa` and `TextEncoder` globals. Older versions of React Native did not support these global objects, and so
234+
[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
235+
of Hermes includes these globals, and so the polyfills for are no longer needed in the js-bson package.
236+
237+
If you find yourself on a version of React Native that does not have these globals, either:
238+
239+
1. polyfill them yourself
240+
2. upgrade to a later version of hermes
241+
3. use a version of js-bson `>=5.4.0` and `<7.0.0`
242+
243+
One additional polyfill, `crypto.getRandomValues` is recommended and can be installed with the following command:
234244

235245
```sh
236246
npm install --save react-native-get-random-values

etc/rollup/rollup-plugin-require-vendor/require_vendor.mjs

Lines changed: 0 additions & 40 deletions
This file was deleted.

rollup.config.mjs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import { nodeResolve } from '@rollup/plugin-node-resolve';
22
import typescript from '@rollup/plugin-typescript';
3-
import { RequireVendor } from './etc/rollup/rollup-plugin-require-vendor/require_vendor.mjs';
43

54
/** @type {typescript.RollupTypescriptOptions} */
65
const tsConfig = {
@@ -75,7 +74,7 @@ const config = [
7574
},
7675
{
7776
input,
78-
plugins: [typescript(tsConfig), new RequireVendor(), nodeResolve({ resolveOnly: [] })],
77+
plugins: [typescript(tsConfig), nodeResolve({ resolveOnly: [] })],
7978
output: {
8079
file: 'lib/bson.rn.cjs',
8180
format: 'commonjs',

test/node/release.test.ts

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -53,17 +53,7 @@ const REQUIRED_FILES = [
5353
'src/utils/string_utils.ts',
5454
'src/utils/web_byte_utils.ts',
5555
'src/utils/latin.ts',
56-
'src/parse_utf8.ts',
57-
'vendor/base64/base64.js',
58-
'vendor/base64/package.json',
59-
'vendor/base64/LICENSE-MIT.txt',
60-
'vendor/base64/README.md',
61-
'vendor/text-encoding/lib/encoding-indexes.js',
62-
'vendor/text-encoding/lib/encoding.js',
63-
'vendor/text-encoding/index.js',
64-
'vendor/text-encoding/package.json',
65-
'vendor/text-encoding/LICENSE.md',
66-
'vendor/text-encoding/README.md'
56+
'src/parse_utf8.ts'
6757
].map(f => `package/${f}`);
6858

6959
describe(`Release ${packFile}`, function () {

vendor/base64/LICENSE-MIT.txt

Lines changed: 0 additions & 20 deletions
This file was deleted.

vendor/base64/README.md

Lines changed: 0 additions & 112 deletions
This file was deleted.

vendor/base64/base64.js

Lines changed: 0 additions & 157 deletions
This file was deleted.

0 commit comments

Comments
 (0)