-
Notifications
You must be signed in to change notification settings - Fork 2
fix: resolve Metro bundler error for optional FlashList dependency #121
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
Conversation
- Separate optional library imports into dedicated file - Fix "Requiring unknown module" error when FlashList is not installed
🦋 Changeset detectedLatest commit: 4b2a4a8 The changes in this PR will be included in the next version bump. 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 |
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the WalkthroughThe PR refactors optional FlashList dependency handling by extracting dynamic imports into a dedicated utility file. This centralizes safe loading of the @shopify/flash-list package, enables dynamic feature detection, and prevents Metro bundler static analysis errors when FlashList is unavailable. Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes The changes are predominantly formatting adjustments across configuration and documentation files. Core logic modifications are straightforward—extracting optional dependency handling into a dedicated utility and refactoring the detection mechanism to use that utility. No complex interdependencies or intricate logic patterns present. Possibly related PRs
Poem
Pre-merge checks and finishing touches✅ Passed checks (3 passed)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Deploying react-native-gesture-image-viewer with
|
| Latest commit: |
94b17a5
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://70d15422.react-native-gesture-image-viewer.pages.dev |
| Branch Preview URL: | https://fix-optional-flashlist-depen.react-native-gesture-image-viewer.pages.dev |
|
@coderabbitai review |
✅ Actions performedReview triggered.
|
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.
Actionable comments posted: 0
🧹 Nitpick comments (1)
src/utils/FlashList.ts (1)
1-7: LGTM!This dynamic import pattern correctly prevents Metro's static analysis from requiring @shopify/flash-list when it's not installed. The approach is sound:
- Using
letallows reassignment in the catch block- The
anytype is an acceptable trade-off for optional dependencies- Silent error handling is appropriate for gracefully handling missing optional dependencies
- Module-level synchronous require is the correct pattern to bypass Metro's static import analysis
Optional: Consider adding a clarifying comment.
While the code is correct, a brief comment explaining why this pattern is used could help future maintainers:
+// Dynamic require to prevent Metro bundler static analysis errors when FlashList is not installed export let FlashList: any = null;
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (7)
.changeset/purple-trains-poke.md(1 hunks)docs/docs/en/guide/getting-started/_meta.json(1 hunks)docs/docs/ko/guide/getting-started/_meta.json(1 hunks)docs/tsconfig.json(1 hunks)src/utils/FlashList.ts(1 hunks)src/utils/index.ts(2 hunks)tsconfig.json(1 hunks)
🧰 Additional context used
🪛 LanguageTool
.changeset/purple-trains-poke.md
[grammar] ~7-~7: There might be a mistake here.
Context: ...cy - Separate optional library imports into dedicated file - Fix "Requiring unknown...
(QB_NEW_EN)
🔇 Additional comments (7)
tsconfig.json (1)
29-29: LGTM!Formatting change to compact the exclude array. No semantic changes.
docs/docs/ko/guide/getting-started/_meta.json (1)
1-1: LGTM!Formatting change to compact the array. No semantic changes.
docs/tsconfig.json (1)
16-22: LGTM!Formatting improvement to expand the include array for better readability. No semantic changes.
docs/docs/en/guide/getting-started/_meta.json (1)
1-1: LGTM!Formatting change to compact the array. No semantic changes.
.changeset/purple-trains-poke.md (1)
1-11: LGTM!The changeset accurately documents the fix and references the related issue. The static analysis grammar hint appears to be a false positive; "dedicated file" is correct usage.
src/utils/index.ts (2)
3-4: LGTM!The import updates correctly reflect the new module structure: importing types from the parent directory and FlashList from the new utility file.
18-24: LGTM!The updated detection logic correctly checks the imported FlashList symbol first (with null-safety), then falls back to name-based checks. This prevents Metro bundler errors while maintaining backward compatibility.
Related issue
Summary by CodeRabbit