Skip to content

fix: enqueue resolvers before ScriptManager init#1156

Merged
jbroma merged 7 commits intomainfrom
fix/register-remote-resolver
May 20, 2025
Merged

fix: enqueue resolvers before ScriptManager init#1156
jbroma merged 7 commits intomainfrom
fix/register-remote-resolver

Conversation

@jbroma
Copy link
Copy Markdown
Contributor

@jbroma jbroma commented May 19, 2025

Summary

registerRemote is a sync hook and previous approach with adding resolvers asynchronously proves very brittle as seen in https://github.com/ZephyrCloudIO/zephyr-repack-example

The hook is triggered very early in the runtime, before initialisation of RN Core & ScriptManager. Since there is no reliable way to wait for ScriptManager to be initialised, in ResolverPlugin we now check whether the ScriptManager instance is present in runtime:

  • if ScriptManager is initialized, we add resolver normally just as before
  • if ScriptManager is not initialised, we add a resolver to queue that will be consumed at the end of ScriptManager initialisation sequence (ctor).

The queue is an internal runtime mechanism and is not exposed to the user.

Ideally, in the future, we could be replace it by generating a virtual module based on the build config for Module Federation - we know that registerRemote will be triggered only by the defined remotes in build config. Runtime calls of registerRemote in the userland should not be of any concern since they will happen after initialisation of ScriptManager

Test plan

  • - tests pass
  • - testers work

@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented May 19, 2025

🦋 Changeset detected

Latest commit: b08977d

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 May 19, 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 May 19, 2025 10:27pm

@jbroma jbroma merged commit 897dc5a into main May 20, 2025
5 checks passed
@jbroma jbroma deleted the fix/register-remote-resolver branch May 20, 2025 10:03
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