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

Refactor build context for better plugin state sharing #46706

Merged
merged 5 commits into from Mar 2, 2023
Merged

Conversation

shuding
Copy link
Member

@shuding shuding commented Mar 2, 2023

Love the change made in #46666! This PR tries to refactor it by adding an abstraction pluginState object. For the build process, it's just a serializable field that we can attach to the result and resume it as the state at the process beginning. For Webpack plugins, it's an object with all the needed states and their initial values.

The proxy is for lazily initializing these states so they're still global variables, but always initialized after the worker resumes the plugin state.

This way we no longer need to import these plugins from the build worker, and mutate each module export field: Object.assign((flightPluginModule as any)[field], (serializedFlightMaps as any)[field]).

Closes NEXT-758.

Bug

  • Related issues linked using fixes #number
  • Integration tests added
  • Errors have a helpful link attached, see contributing.md

Feature

  • Implements an existing feature request or RFC. Make sure the feature request has been accepted for implementation before opening a PR.
  • Related issues linked using fixes #number
  • e2e tests added
  • Documentation added
  • Telemetry added. In case of a feature if it's used or not.
  • Errors have a helpful link attached, see contributing.md

Documentation / Examples

  • Make sure the linting passes by running pnpm build && pnpm lint
  • The "examples guidelines" are followed from our contributing doc

@ijjk ijjk merged commit ad6961d into canary Mar 2, 2023
@ijjk ijjk deleted the shu/5a47 branch March 2, 2023 22:03
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 2, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants