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

Avoid duplicate work being done in RSC server plugin #45

Merged
merged 1 commit into from
Mar 5, 2024

Conversation

unstubbable
Copy link
Owner

@unstubbable unstubbable commented Mar 5, 2024

The RSC server loader already collects all the server references. So we don't need to do the same work again in the plugin. Instead, we can just read them from the provided map. (With a slight disadvantage being that the module IDs can only be added afterwards in the plugin, while also creating the server manifest.) To still support client-side imported server actions, the SSR loader now also needs to collect server references.

This should simplify adding support for inline 'use server' references to the plugin.

BREAKING CHANGE: The serverReferencesMap is now a required option of createWebpackRscServerLoader. In addition, it also needs to be passed to createWebpackRscSsrLoader (required for server actions that are imported from client components).

The RSC server loader already collects all the server references. So we
don't need to do the same work again in the plugin. Instead, we can just
read them from the provided map.

This should simplify adding support for inline `'use server'` references
to the plugin.

BREAKING CHANGE: The `serverReferencesMap` is now a required option of
`createWebpackRscServerLoader`. In addition, it also needs to be passed
to `createWebpackRscSsrLoader` (required for server actions that are
imported from client components).
Copy link

vercel bot commented Mar 5, 2024

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

Name Status Preview Updated (UTC)
mfng ✅ Ready (Inspect) Visit Preview Mar 5, 2024 8:52pm

@unstubbable unstubbable merged commit 596fba1 into main Mar 5, 2024
6 checks passed
@unstubbable unstubbable deleted the refactor-reference-map-usages branch March 5, 2024 20:55
unstubbable added a commit that referenced this pull request Mar 5, 2024
Turns out, with #45 we've already implemented that modules containing
functions with inline `'use server'` directives, are added to the bundle
as non-concatenated modules in production mode, which ensures that they
can be required by their module ID.

With this PR, we are adding unit tests to verify the behaviour, and
prevent regressions.
unstubbable added a commit that referenced this pull request Mar 5, 2024
Turns out, with #45 we've already implemented that modules containing
functions with inline `'use server'` directives, are added to the bundle
as non-concatenated modules in production mode, which ensures that they
can be required by their module ID.

With this PR, we are adding unit tests to verify the behaviour, and
prevent regressions.
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