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 Expo, #468 #515

Merged
merged 1 commit into from
Mar 7, 2025
Merged

Fix Expo, #468 #515

merged 1 commit into from
Mar 7, 2025

Conversation

steida
Copy link
Contributor

@steida steida commented Jan 5, 2025

No description provided.

Verified

This commit was signed with the committer’s verified signature.
j178 Jo
@ai
Copy link
Owner

ai commented Jan 5, 2025

  1. Can you give me some proofs that React Native support global.crypto right now
  2. Do we need to change docs? https://github.com/ai/nanoid?tab=readme-ov-file#react-native

@steida
Copy link
Contributor Author

steida commented Jan 6, 2025

I use only this:

import { install } from "react-native-quick-crypto";
install();

The same fix works for both NanoId versions (3/5).

Here is my package.json:

"type": "module",
  "types": "./dist/src/index.d.ts",
  "exports": {
    ".": {
      "types": "./dist/src/index.d.ts",
      "import": "./dist/src/index.js",
      "browser": "./dist/src/index.js",
      "react-native": "./dist/src/index.js"
    },
    "./evolu": {
      "import": "./dist/src/Evolu/Internal.js"
    }
  },
  "typesVersions": {
    "*": {
      "evolu": [
        "./dist/src/Evolu/Internal.d.ts"
      ]
    }
  },

Btw, I think it should be mentioned that it's recommended to use nanoid 3 in monorepos with hoisting enabled because many packages are still using nanoid 3 (which is not dead; that should also be mentioned). Anyway, thank you for your work.

@ai
Copy link
Owner

ai commented Jan 6, 2025

Honestly, this PR looks like quick fix which will break workflow of many users because the changes was not careful considered and planned.

Can you explain me what happened and how did we find exactly this solution (and not another one). How migration from current Nano ID 5.x will looks like?

import { install } from "react-native-quick-crypto";
install()

Is the code will fail without it?

Why we are not mentioning it in the docs?

Why it is better than previous polyfill?

Btw, I think it should be mentioned that it's recommended to use nanoid 3 in monorepos with hoisting enabled because many packages are still using nanoid 3

We can release the be version of 3.x with the new polyfill

@steida
Copy link
Contributor Author

steida commented Feb 25, 2025

All I know is that it allows me to use NanoId in Expo/RN without hacks. I will provide more details when I release the new https://github.com/evoluhq/evolu

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 this pull request may close these issues.

None yet

2 participants