Skip to content

Conversation

hi-ogawa
Copy link
Contributor

@hi-ogawa hi-ogawa commented Aug 21, 2025

Description

Currently all plugin states are managed in module scope (as a reminiscence of my original prototype). These states should be isolated per plugin instance. This also helps splitting up more plugins from single file plugin.ts. Also helps fixing an issues like #575.

For now, let's do something mechanical by moving the state to RscPluginManager and just passing around manager. As a follow up, we could move some helpers to manager class such as assetURL method.

TODO

  • test
    • build two different rsc apps programatically?

@hi-ogawa hi-ogawa changed the title fix(rsc): isolate plugin state per plugin fix(rsc): isolate plugin state per plugin instance Aug 21, 2025
@hi-ogawa hi-ogawa marked this pull request as ready for review August 21, 2025 06:26
@hi-ogawa hi-ogawa requested a review from Copilot August 21, 2025 06:26
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

Refactors RSC plugin state management from module-level global variables to an isolated RscPluginManager class instance per plugin instance, enabling proper state isolation between multiple plugin instances.

Key changes:

  • Introduces RscPluginManager class to encapsulate all plugin state
  • Updates all plugin functions to accept and use the manager instance
  • Adds test to verify independent plugin state isolation during multiple builds

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

File Description
packages/plugin-rsc/src/plugin.ts Removes global state variables, adds RscPluginManager class, and refactors all plugin functions to use manager instance
packages/plugin-rsc/e2e/starter.test.ts Adds test case to verify plugin state isolation between multiple builds

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@hi-ogawa hi-ogawa merged commit 596c76b into main Aug 21, 2025
20 checks passed
@hi-ogawa hi-ogawa deleted the 08-21-fix_rsc_isolate_plugin_state_per_plugin branch August 21, 2025 06:37
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.

1 participant