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

[Feature]: There are some missing APIs for frameworks support React Server Component #8469

Open
yimingjfe opened this issue Nov 19, 2024 · 7 comments
Assignees
Labels
feat New feature or request

Comments

@yimingjfe
Copy link
Member

yimingjfe commented Nov 19, 2024

What problem does this feature solve?

In Modern.js, we want to support RSC building base on Rspack. When using webpack, the solution can work normally, but with Rspack, there are some APIs that are not exported now, so it's difficult to support RSC in the Modern.js repository.

The following APIs are currently used for support RSC, but are not seen exported in Rspack:

Server-side building:

  1. Add modules to the compilation
  • compilation.addInclude
  • Avoiding tree-shaking of the modules
    • webpack.util.runtime.getEntryRuntime
    • compilation.moduleGraph.getExportsInfo
    • exportsInfo.setUsedInUnknownWay
  • compilation.hooks.needAdditionalPass
  1. Add custom dependencies
  • compilation.dependencyFactories
  • compilation.dependencyTemplates
  • module.addDependency
  • NullDependency
  1. Get ModuleId
  • compilation.hooks.afterOptimizeModuleIds
  • chunkGraph.getModuleId

Client-side building:

  1. Add client reference chunks
  • AsyncDependenciesBlock
    • block.addDependency
  • Module
    • module.blocks
    • module.addBlock
  1. Get moduleInfo
  • module.nameForCondition
  • chunkGraph.getModuleId
  • chunkGraph.getModuleChunksIterable
  • moduleGraph.getOutgoingConnections

Here there are some APIs that may have alternatives , and some are difficult to have real alternatives.

I want to discuss what the recommended solution is from the perspective of Rspack, such as the addDependency API, in the webpack ecosystem, there are many webpack plugins that depend on it.

What does the proposed API of configuration look like?

It is best to be consistent with webpack.

@yimingjfe yimingjfe added feat New feature or request pending triage The issue/PR is currently untouched. labels Nov 19, 2024
@GiveMe-A-Name GiveMe-A-Name self-assigned this Nov 19, 2024
@GiveMe-A-Name GiveMe-A-Name removed the pending triage The issue/PR is currently untouched. label Nov 19, 2024
@GiveMe-A-Name
Copy link
Member

GiveMe-A-Name commented Nov 19, 2024

The compilation.entries.entries is exists. You can use it directly.
Then webpack.util.runtime.getEntryRuntime is not exported in webpack also, maybe you need implement by yourself.
And other api or attributes will be implemented in the future.

@GiveMe-A-Name
Copy link
Member

GiveMe-A-Name commented Nov 19, 2024

Tasks

@SyMind
Copy link
Member

SyMind commented Nov 19, 2024

I am supporting module graph api here: #8470

@yimingjfe
Copy link
Member Author

The compilation.entries.entries is exists. You can use it directly. Then webpack.util.runtime.getEntryRuntime is not exported in webpack also, maybe you need implement by youself. And other api or attributes we will add in the future.

Yeah, you are right, compilation.entries.entries already exists, I'll update the description.

For getEntryRuntime, in webpack, it is possible to get it by compiler.webpack.util.runtime.getEntryRuntime.

@inottn
Copy link
Collaborator

inottn commented Nov 20, 2024

I would like to know where the hooks listed above are used in the RSC build. Do we have corresponding links to check?

@GiveMe-A-Name
Copy link
Member

I would like to know where the hooks listed above are used in the RSC build. Do we have corresponding links to check?

@yimingjfe Can you give us a RSC webpack plugin example to explain it

@yimingjfe
Copy link
Member Author

I would like to know where the hooks listed above are used in the RSC build. Do we have corresponding links to check?

Sure, you can check it at the link modern.js/packages/cli/uni-builder/src/shared/rsc at feat-next-wym · web-infra-dev/modern.js · GitHub, it is still in development.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feat New feature or request
Projects
None yet
Development

No branches or pull requests

4 participants