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

fix: react-native TextEncoder/TextDecoder polyfill + restore package.json react-native field #1713

Merged
merged 2 commits into from
Mar 25, 2024

Conversation

owenpearson
Copy link
Member

@owenpearson owenpearson commented Mar 25, 2024

Resolves #1712, #1711 (Jira https://ably.atlassian.net/browse/ECO-4710)

Contains two fixes for react-native support in v2:

  • React Native does not currently support "exports" field in package.json by default when consuming npm packages (source) - which we started using in v2. It is still an experimental feature and not enabled by default in new React Native apps. We restore root "react-native" field in package.json to fix this issue.
  • React Native does not have support for TextEncoder/TextDecoder API, so we provide polyfills for them.

@github-actions github-actions bot temporarily deployed to staging/pull/1713/features March 25, 2024 09:33 Inactive
@github-actions github-actions bot temporarily deployed to staging/pull/1713/bundle-report March 25, 2024 09:34 Inactive
@github-actions github-actions bot temporarily deployed to staging/pull/1713/typedoc March 25, 2024 09:34 Inactive
credit to @VeskeR

Keeping the exports field for react-native too since this is
experimentally supported.
Copy link
Contributor

@VeskeR VeskeR left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

Resolves #1712, #1711

And just a heads-up, see Lawrence's comment about writing "Resolves #[issue number]" for multiple issues:

Also, just a heads-up that writing "Resolves #1538 , #1332" in your PR description doesn't do what you think it does — you need to write "Resolves #1538, resolves #1332".

@owenpearson owenpearson merged commit 674b86a into main Mar 25, 2024
12 checks passed
@owenpearson owenpearson deleted the react-native-v2-fixes branch March 25, 2024 15:20
VeskeR added a commit that referenced this pull request Jun 3, 2024
Those fields were removed in de5ddfa
and replaced with `exports` field we currently use. However, removal of
root level entry fields from `package.json` have caused issues with
importing `ably` in some setups:
- React Native wasn't able to resolve `ably` at all, due to `exports`
  field resolution is not enabled by default yet [1] (we fixed this by
  re-adding root level `react-native` field in #1713)
- older bundler versions do not support `exports` field, for example,
  webpack has added support for `exports` only in v5.
- TypeScript added support for resolving `exports` field only in its 4.7
  release [2]

This commit re-adds root level entry fields so those setups will still
be able to resolve `ably` package.

Resolves #1751

[1] https://reactnative.dev/blog/2023/06/21/package-exports-support
[2] https://www.typescriptlang.org/docs/handbook/release-notes/typescript-4-7.html#packagejson-exports-imports-and-self-referencing
VeskeR added a commit that referenced this pull request Jun 3, 2024
Those fields were removed in de5ddfa
and replaced with `exports` field we currently use. However, removal of
root level entry fields from `package.json` have caused issues with
importing `ably` in some setups:
- React Native wasn't able to resolve `ably` at all, due to `exports`
  field resolution is not enabled by default yet [1] (we fixed this by
  re-adding root level `react-native` field in #1713)
- older bundler versions do not support `exports` field, for example,
  webpack has added support for `exports` only in v5.
- TypeScript added support for resolving `exports` field only in its 4.7
  release [2]

This commit re-adds root level entry fields so those setups will still
be able to resolve `ably` package.

Resolves #1751

[1] https://reactnative.dev/blog/2023/06/21/package-exports-support
[2] https://www.typescriptlang.org/docs/handbook/release-notes/typescript-4-7.html#packagejson-exports-imports-and-self-referencing
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

Fix React Native bundle does not have access to browsers APIs defined in platform config on v2
2 participants