From e92940fc1f216acc435c3652879846df544e3177 Mon Sep 17 00:00:00 2001 From: simeng-li Date: Mon, 9 Sep 2024 18:57:15 +0800 Subject: [PATCH 1/2] feat: add react-native package export condition add react-native package export condition --- .changeset/poor-lizards-cheer.md | 17 +++++++++++++++++ packages/client/package.json | 17 +++++------------ 2 files changed, 22 insertions(+), 12 deletions(-) create mode 100644 .changeset/poor-lizards-cheer.md diff --git a/.changeset/poor-lizards-cheer.md b/.changeset/poor-lizards-cheer.md new file mode 100644 index 00000000..07034b8b --- /dev/null +++ b/.changeset/poor-lizards-cheer.md @@ -0,0 +1,17 @@ +--- +"@logto/client": patch +--- + +add react-native package export condition + +[Enabling package export](https://reactnative.dev/blog/2023/06/21/package-exports-support#enabling-package-exports-beta) in react-native is unstable and can cause issues. + +Replace the `exports` in `@logto/client` package.json with the `react-native` [condition](https://reactnative.dev/blog/2023/06/21/package-exports-support#the-new-react-native-condition). + +```json +{ + "react-native": "./lib/shim.js" +} +``` + +So the `shim.js` module can be used in react-native projects, without enabling the unstable package export feature. diff --git a/packages/client/package.json b/packages/client/package.json index 8b5a86b0..93e73cf1 100644 --- a/packages/client/package.json +++ b/packages/client/package.json @@ -5,19 +5,12 @@ "main": "./lib/index.cjs", "module": "./lib/index.js", "types": "./lib/index.d.ts", + "react-native": "./lib/shim.js", "exports": { - ".": { - "types": "./lib/index.d.ts", - "require": "./lib/index.cjs", - "import": "./lib/index.js", - "default": "./lib/index.js" - }, - "./shim": { - "types": "./lib/shim.d.ts", - "require": "./lib/shim.cjs", - "import": "./lib/shim.js", - "default": "./lib/shim.js" - } + "types": "./lib/index.d.ts", + "require": "./lib/index.cjs", + "import": "./lib/index.js", + "default": "./lib/index.js" }, "files": [ "lib" From d6ca88d16be135bef41cb78cfae46c3b70eb4597 Mon Sep 17 00:00:00 2001 From: simeng-li Date: Mon, 9 Sep 2024 19:04:20 +0800 Subject: [PATCH 2/2] fix: fix node client fix node client import error --- packages/node/src/utils/cookie-storage.test.ts | 2 +- packages/node/src/utils/session.test.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/node/src/utils/cookie-storage.test.ts b/packages/node/src/utils/cookie-storage.test.ts index b22c771e..47749dd5 100644 --- a/packages/node/src/utils/cookie-storage.test.ts +++ b/packages/node/src/utils/cookie-storage.test.ts @@ -1,4 +1,4 @@ -import { PersistKey } from '@logto/client/shim'; +import { PersistKey } from '@logto/client'; import { type CookieConfig, CookieStorage } from './cookie-storage.js'; import { unwrapSession, wrapSession } from './session.js'; diff --git a/packages/node/src/utils/session.test.ts b/packages/node/src/utils/session.test.ts index 7f49fe3b..7dfe5b81 100644 --- a/packages/node/src/utils/session.test.ts +++ b/packages/node/src/utils/session.test.ts @@ -1,4 +1,4 @@ -import { PersistKey } from '@logto/client/shim'; +import { PersistKey } from '@logto/client'; import { unwrapSession, wrapSession } from './session.js';