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

[RFC] Support for React Native #222

Closed
lb90 opened this issue Oct 22, 2021 · 3 comments · Fixed by #227
Closed

[RFC] Support for React Native #222

lb90 opened this issue Oct 22, 2021 · 3 comments · Fixed by #227
Assignees
Milestone

Comments

@lb90
Copy link

lb90 commented Oct 22, 2021

Hello, thanks for the good work!

I have been using this library on React Native (together with Axios) and so far it's been working ok!

I only had to remove some debug code using the utils module: lb90@b43b4e9.

Would you be interested in React Native support or do you specifically target just NodeJS? I can provide a PR if such a feature is welcome!

@awaterma awaterma self-assigned this Oct 25, 2021
@awaterma
Copy link
Member

I'll take a look! We are definitely interested in supporting React; thank you for reaching out.

@awaterma awaterma added this to the 4.x Release milestone Oct 25, 2021
@lb90
Copy link
Author

lb90 commented Oct 26, 2021

Great!

I forgot to say that a polyfill for the NodeJS url module is also needed!

First I have tried porting tough-cookie to use the WHATWG url API instead of the legacy url API, that way I could use the great https://www.npmjs.com/package/react-native-url-polyfill. Unfortunately that didn't work out really well because the WHATWG API does not support relative URL's:

So in the end I opted for https://www.npmjs.com/package/url (from the github repo, seeing as the npm package was last updated 6 years ago!). Probably using https://www.npmjs.com/package/native-url + https://www.npmjs.com/package/react-native-url-polyfill is a best match!

colincasey added a commit to colincasey/tough-cookie that referenced this issue Nov 23, 2021
This PR fixes salesforce#222 by:
 - introducing a fallback for the `util.*` code paths used as indicated in [this comment](salesforce#222 (comment))
 - adding a dependency on `url-parse` to act as a polyfill for the usage of `require('url').parse`
colincasey added a commit to colincasey/tough-cookie that referenced this issue Nov 24, 2021
This PR fixes salesforce#222 by:
 - introducing a fallback for the `util.*` code paths used as indicated in [this comment](salesforce#222 (comment))
 - adding a dependency on `url-parse` to act as a polyfill for the usage of `require('url').parse`
 - configuring eslint to error on `no-restricted-modules` which will not be present in native environments
@pe-johndpope
Copy link

pe-johndpope commented Mar 4, 2022

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants