Skip to content

Conversation

@saseungmin
Copy link
Owner

@saseungmin saseungmin commented Oct 17, 2025

  • Separate optional library imports into dedicated file
  • Fix "Requiring unknown module" error when FlashList is not installed

Related issue

Summary by CodeRabbit

  • Bug Fixes
    • Resolved Metro bundler errors when optional FlashList dependency is not installed, including "Requiring unknown module" scenarios
    • Improved optional dependency handling to support FlashList as a truly optional feature, preventing crashes when the package is unavailable
    • Enhanced dynamic feature detection for improved build stability and compatibility

- Separate optional library imports into dedicated file
- Fix "Requiring unknown module" error when FlashList is not installed
@changeset-bot
Copy link

changeset-bot bot commented Oct 17, 2025

🦋 Changeset detected

Latest 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

@coderabbitai
Copy link

coderabbitai bot commented Oct 17, 2025

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Walkthrough

The 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

Cohort / File(s) Summary
Changeset
.changeset/purple-trains-poke.md
Documents a patch-level update addressing optional FlashList dependency handling and Metro bundler errors.
Documentation Configuration
docs/docs/en/guide/getting-started/_meta.json, docs/docs/ko/guide/getting-started/_meta.json
Reformatted JSON metadata arrays from multi-line to single-line format; no semantic changes.
TypeScript Configuration
docs/tsconfig.json, tsconfig.json
Updated configuration formatting: docs/tsconfig.json converts include paths to multi-line indentation; root tsconfig.json reformats exclude array to single-line. No functional changes.
FlashList Optional Import Handling
src/utils/FlashList.ts
New utility file that safely loads @shopify/flash-list via try/catch dynamic require, exporting FlashList variable (null if package unavailable).
FlashList Detection Refactoring
src/utils/index.ts
Updated isFlashListLike logic to use imported FlashList utility instead of inline dynamic require; replaced try/catch runtime detection with direct equality check.

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

🐰 A hop, a skip, through bundler's domain,
We tuck FlashList safe, in a try/catch refrain,
No "unknown module" cries in the night—
Dependencies optional, detection feels right!
Metro's at peace, the build runs so bright! ✨

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title Check ✅ Passed The pull request title "fix: resolve Metro bundler error for optional FlashList dependency" directly and clearly addresses the main objective of the changeset. The raw summary confirms that the core change is implementing optional FlashList dependency handling in a dedicated utility file (src/utils/FlashList.ts) and updating the detection logic in src/utils/index.ts to resolve "Requiring unknown module" Metro bundler errors. The title is specific and concise, avoiding vague terms, and a teammate reviewing the history would immediately understand that this PR fixes a Metro bundler issue related to optional FlashList handling. The supporting formatting changes to configuration files are secondary and do not detract from the clarity of the primary objective.
Docstring Coverage ✅ Passed No functions found in the changes. Docstring coverage check skipped.

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@saseungmin saseungmin linked an issue Oct 17, 2025 that may be closed by this pull request
3 tasks
@cloudflare-workers-and-pages
Copy link

Deploying react-native-gesture-image-viewer with  Cloudflare Pages  Cloudflare Pages

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

View logs

@saseungmin saseungmin removed a link to an issue Oct 17, 2025
3 tasks
@saseungmin
Copy link
Owner Author

@coderabbitai review

@coderabbitai
Copy link

coderabbitai bot commented Oct 17, 2025

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

Copy link

@coderabbitai coderabbitai bot left a 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 let allows reassignment in the catch block
  • The any type 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

📥 Commits

Reviewing files that changed from the base of the PR and between edafaf0 and d15f652.

📒 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.

@saseungmin saseungmin merged commit 9774327 into v1.x Oct 17, 2025
5 checks passed
@saseungmin saseungmin deleted the fix/optional-flashlist-dependency branch October 17, 2025 04:39
@saseungmin saseungmin linked an issue Oct 17, 2025 that may be closed by this pull request
3 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Requiring unknown module "undefined"

2 participants