Skip to content

Commit

Permalink
Merge pull request #1713 from ably/react-native-v2-fixes
Browse files Browse the repository at this point in the history
fix: react-native TextEncoder/TextDecoder polyfill + restore package.json react-native field
  • Loading branch information
owenpearson authored Mar 25, 2024
2 parents 2564c7d + a52972a commit 674b86a
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 0 deletions.
11 changes: 11 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"url": "https://github.com/ably/ably-js/issues",
"email": "[email protected]"
},
"react-native": "./build/ably-reactnative.js",
"exports": {
".": {
"types": "./ably.d.ts",
Expand Down Expand Up @@ -34,6 +35,7 @@
],
"dependencies": {
"@ably/msgpack-js": "^0.4.0",
"fastestsmallesttextencoderdecoder": "^1.0.22",
"got": "^11.8.5",
"ws": "^8.14.2"
},
Expand Down
3 changes: 3 additions & 0 deletions src/platform/react-native/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ import PlatformDefaults from '../web/lib/util/defaults';
import msgpack from '../web/lib/util/msgpack';
import { defaultBundledRequestImplementations } from '../web/lib/http/request';

// lightweight polyfill for TextEncoder/TextDecoder
import 'fastestsmallesttextencoderdecoder';

const Config = configFactory(BufferUtils);

const Crypto = createCryptoClass(Config, BufferUtils);
Expand Down
1 change: 1 addition & 0 deletions webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ const reactNativeConfig = {
request: false,
ws: false,
'react-native': true,
fastestsmallesttextencoderdecoder: 'fastestsmallesttextencoderdecoder',
},
optimization: {
minimize: false,
Expand Down

0 comments on commit 674b86a

Please sign in to comment.