Skip to content
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

fix: decouple init & module error handling from runtime module #868

Merged
merged 7 commits into from
Jan 15, 2025

Conversation

jbroma
Copy link
Member

@jbroma jbroma commented Jan 14, 2025

Summary

partial solution to #866

In some cases loadScript runtime module might not get injected into the bundle. Since all of the logic for Repack runtime lives there, it might cause undefined behaviour like failing to process EarlyJS errors or failure to initialise Repack global object.

This PR separates the loadScript part into it's own runtime module, and makes init and moduleErrorHandler parts separate runtime modules.

Previously in Rspack there was no way to add runtime modules - we could only edit existing ones and we were forced to concatenate init & load script modules into one. This is no longer the case so we can split them into separate entities.

The types injected into the global scope were also reworked - now most types are hidden behind a RepackRuntimeGlobals namespace to prevent polluting the global typescript scope

Test plan

  • - testers work

Copy link

changeset-bot bot commented Jan 14, 2025

🦋 Changeset detected

Latest commit: cc9dfbc

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

This PR includes changesets to release 4 packages
Name Type
@callstack/repack 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

Copy link

vercel bot commented Jan 14, 2025

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

1 Skipped Deployment
Name Status Preview Comments Updated (UTC)
repack-website ⬜️ Ignored (Inspect) Visit Preview Jan 14, 2025 5:36pm

Copy link
Member

@thymikee thymikee left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like a solid improvement with less hacks. Any ideas how you could test it?

@jbroma
Copy link
Member Author

jbroma commented Jan 14, 2025

Looks like a solid improvement with less hacks. Any ideas how you could test it?

I would just stick to existing integration tests that we have - this is a very internal change. The easiest way to test it in an additional way would be to compile a bundle and verify that the modules get injected properly.

@jbroma
Copy link
Member Author

jbroma commented Jan 14, 2025

I needed to make the runtime module classes dynamic to deal with the compatibility between webpack and rspack, all works good now on both platforms 👍

@jbroma jbroma merged commit 96915f8 into main Jan 15, 2025
5 checks passed
@jbroma jbroma deleted the fix/target-plugin-rework branch January 15, 2025 14:14
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