Skip to content

refactor: use @react-native/assets-registry/registry#1135

Closed
jbroma wants to merge 6 commits intomainfrom
refactor/use-asset-registry-package
Closed

refactor: use @react-native/assets-registry/registry#1135
jbroma wants to merge 6 commits intomainfrom
refactor/use-asset-registry-package

Conversation

@jbroma
Copy link
Copy Markdown
Contributor

@jbroma jbroma commented Apr 28, 2025

Summary

based on the suggestion from @huntie, instead of using deep import from RN core, we can import @react-native/assets-registry/registry directly.

Test plan

  • - testers work

@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented Apr 28, 2025

🦋 Changeset detected

Latest commit: 4bea110

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 6 packages
Name Type
@callstack/repack Patch
@callstack/repack-plugin-expo-modules Patch
@callstack/repack-plugin-nativewind Patch
@callstack/repack-plugin-reanimated Patch
@callstack/repack-dev-server Patch
@callstack/repack-init Patch

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

@vercel
Copy link
Copy Markdown

vercel Bot commented Apr 28, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
repack-website ✅ Ready (Inspect) Visit Preview 💬 Add feedback Apr 28, 2025 3:33pm

@jbroma
Copy link
Copy Markdown
Contributor Author

jbroma commented Apr 28, 2025

upon further tests turns out it's not that simple - when we use deep import of AssetRegistry from core it results in a singleton registry module (since all imports of @react-native/assets-registry/registry are from within react-native)

if we however request the module from the context of project it will result in duplicate inclusion of assets registry, causing the module to be included twice in the build and not pointing to the same registry

@huntie
Copy link
Copy Markdown

huntie commented Apr 28, 2025

@jbroma We probably want some abstraction then similar to rn-get-polyfills.js. I say "similar" in concept, not in exact design (this root file is somewhat horrible 😅). But it's an API design problem we'll have to take on over the coming months.

Making a note to discuss this at the Core Contributors Summit.

@jbroma
Copy link
Copy Markdown
Contributor Author

jbroma commented Apr 30, 2025

@jbroma We probably want some abstraction then similar to rn-get-polyfills.js. I say "similar" in concept, not in exact design (this root file is somewhat horrible 😅). But it's an API design problem we'll have to take on over the coming months.

Making a note to discuss this at the Core Contributors Summit.

also not a big fan of root level entrypoints 😅

I've managed to almost get around this by rerouting all imports in the bundle to a virtual module from Re.Pack (kinda like a rn-get-polyfills.js) but then in the tests this fails because @react-native/assets-registry is not a peer dependency of Re.Pack 🙃 - it's a rather hacky solution to the problem.

I'll close this PR for now and we will tackle this in the future 👍

@jbroma jbroma closed this Apr 30, 2025
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.

2 participants