-
Notifications
You must be signed in to change notification settings - Fork 220
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
Removed the text-encondig code line #227
base: main
Are you sure you want to change the base?
Conversation
All contributors have signed the CLA ✍️ ✅ |
I have read the CLA Document and I hereby sign the CLA |
Make sure your project has a `metro.config.js` file. If not, create one at the root of your project. | ||
|
||
```js | ||
const { getDefaultConfig } = require("expo/metro-config"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
here there's usage of expo/metro-config
inside next code snippet there's @react-native/metro-config
which can be confusing, let's say explicitly that the first one is for Expo projects and second is for Bare React Native
README.md
Outdated
return config; | ||
})(); | ||
``` | ||
Merge the contents from your project's metro.config.js file with this config (create the file if it does not exist already). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Merge the contents from your project's metro.config.js file with this config (create the file if it does not exist already). | |
Merge the contents from your project's metro.config.js file with this config. |
For Bare React Native it's inside a default template :)
README.md
Outdated
|
||
const { assetExts, sourceExts } = defaultConfig.resolver; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const { assetExts, sourceExts } = defaultConfig.resolver; | |
const { assetExts, sourceExts } = defaultConfig.resolver; | |
useless?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, left few nits comments
textEncodingTransformation.js
Outdated
|
||
// React Native versions below 0.75 do not include a global TextEncoder implementation. | ||
// To ensure compatibility with these older versions, we add a polyfill using the 'text-encoding' library. | ||
if (major === '0' && minor < '75') { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what if React Native will be 1.0? 🙈 maybe we can leverage semver
package here since we're in Node.js runtime
if (major === '0' && minor < '75') { | |
if (semver.lt(version, '0.75.0')) { |
textEncodingTransformation.js
Outdated
|
||
module.exports = { | ||
transform: createTransformer(upstreamTransformer), | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: missing new line
Wouldn't telling the users to install |
@AbdulrhmnGhanem Thanks for the feedback! I agree that installing a library is simpler, and in mine, users need to tweak their Metro config if they're on RN < 0.75, meaning that it requires a bit of knowledge of it, and everything happens at build time. |
Thanks for taking the time to respond! My initial PR is flawed too. I don't think we need an effect if we are going to say it explicitly in the docs: If you are on RN < 0.75 install the text-encoding package and add the following two lines to import the package
|
@gedu I am not sure if I understand the build considerations in our case, we are on 0.75 and we will switch to 0.76. We can note this in the Readme, but we are not sure if we need to worry about it from the App perspective. Am I missing something? |
On Exfy all should be ok |
package.json
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please update lock file as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same for the example app.
Screenshots🔲 iOS / native23.12.2024_23.26.08_REC.mp4🔲 MacOS / Chrome23.12.2024_21.41.46_REC.mp4🔲 Android / native23.12.2024_21.54.39_REC.mp4 |
@gedu There are small requests but the changes looks good to me. |
@parasharrajat I will review the npm version, Probably on a follow-up PR we can increase the RN version on the Example app. |
@gedu Ok, No problem. But we can atleast fix the lock files as they do not match the package.json files. I see changes on |
@parasharrajat I Updated the package-lock.json from root, on the Example app, what should I update? I didn't change dependencies there. |
On Exfy is working fine for 0.75 qrcode-svg-exfy.mp4 |
@gedu Looks like svg version is mismatched on yarn.lock file on Example app. But this is a no blocker for me. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🎀 👀 🎀 C+ reviewed
All yours @mountiny |
Details
Adds a custom transformer to support React Native versions below 0.75, which require the TextEncoder polyfill. The transformer modifies the src/index.js file of the library to include the necessary polyfill.
What this fixes
This PR addresses an issue where the
text-encoding
library was being included unnecessarily in the bundle for React Native versions 0.75 and above. By conditionally adding the polyfill only when needed, this change reduces the bundle size and improves performance.Checklist
Example
AppExample
App on all platforms:Screenshots/Videos