fix(expo): add subpath directory fallbacks for bundlers without exports support#8172
fix(expo): add subpath directory fallbacks for bundlers without exports support#8172jacekradko merged 2 commits intomainfrom
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
🦋 Changeset detectedLatest commit: a147a04 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
@clerk/agent-toolkit
@clerk/astro
@clerk/backend
@clerk/chrome-extension
@clerk/clerk-js
@clerk/dev-cli
@clerk/expo
@clerk/expo-passkeys
@clerk/express
@clerk/fastify
@clerk/hono
@clerk/localizations
@clerk/nextjs
@clerk/nuxt
@clerk/react
@clerk/react-router
@clerk/shared
@clerk/tanstack-react-start
@clerk/testing
@clerk/ui
@clerk/upgrade
@clerk/vue
commit: |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository YAML (base), Organization UI (inherited) Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughThis pull request adds multiple 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@packages/expo/package.json`:
- Around line 95-96: Add a regression test that simulates Metro package
resolution with unstable_enablePackageExports disabled and asserts that
`@clerk/expo/token-cache` still resolves correctly: create a unit/integration test
in the expo package test suite that sets unstable_enablePackageExports = false
(or toggles the equivalent config), invokes the resolver logic used by the
package (the same code path affected by the "experimental"/"legacy" package.json
export entries), and verifies the module resolution and import behave as
expected; ensure the test fails before the fix and passes after, and include it
in CI so this regression is prevented.
In `@packages/expo/token-cache/package.json`:
- Around line 1-4: Add an integration/regression test that verifies Metro can
resolve `@clerk/expo/token-cache` (and a representative subpath) when
unstable_enablePackageExports is false; specifically, create a test that starts
Metro with unstable_enablePackageExports disabled, attempts to require/import
the package (resolving the "main" and a subpath) and asserts the module loads
successfully (using the package.json "main" ../dist/token-cache/index.js and a
chosen subpath under ../dist/token-cache). Ensure the test lives with other
Metro integration tests and fails if fallback resolution from package exports is
not performed so this regression is covered before merge.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository YAML (base), Organization UI (inherited)
Review profile: ASSERTIVE
Plan: Pro
Run ID: 48eca6d3-b488-4501-8f40-ea5a917172fc
📒 Files selected for processing (11)
packages/expo/apple/package.jsonpackages/expo/experimental/package.jsonpackages/expo/google/package.jsonpackages/expo/legacy/package.jsonpackages/expo/local-credentials/package.jsonpackages/expo/package.jsonpackages/expo/passkeys/package.jsonpackages/expo/resource-cache/package.jsonpackages/expo/secure-store/package.jsonpackages/expo/token-cache/package.jsonpackages/expo/web/package.json
|
Reviewing / testing. |
|
@jacekradko this is tested, and working on both ios and android, native builds, and js only quickstart. |
chriscanin
left a comment
There was a problem hiding this comment.
This is looking good! Tested on ios and android, native quickstart and js only quickstart.
Summary
package.jsonfallback stubs for all@clerk/exposubpath exports (token-cache,web,passkeys,local-credentials,secure-store,resource-cache,google,apple,experimental,legacy)@clerk/expo/token-cacheresolve correctly when Metro'sunstable_enablePackageExportsis disabled@clerk/expo/nativeContext
Closes #8164
Metro's support for the
exportsfield inpackage.jsonis gated behindunstable_enablePackageExports, which is experimental and commonly disabled when it causes issues with other packages. When disabled, Metro falls back to traditional Node.js resolution — looking for a physical directory with apackage.jsoncontaining amainfield.The
./nativesubpath already had this fallback, but the other 10 subpath exports did not, causing resolution failures for users withunstable_enablePackageExportsdisabled.Test plan
pnpm buildpasses for@clerk/expo@clerk/expo/token-cacheresolves in an Expo app withunstable_enablePackageExportsdisabledSummary by CodeRabbit