feat: support import.meta.rspackRsc#13840
Conversation
📦 Binary Size-limit
❌ Size increased by 32.13KB from 61.92MB to 61.95MB (⬆️0.05%) |
Merging this PR will not alter performance
Comparing Footnotes
|
Rsdoctor Bundle Diff AnalysisFound 6 projects in monorepo, 6 projects with changes. 📊 Quick Summary
📋 Detailed Reports (Click to expand)📁 popular-libsPath:
📁 react-10kPath:
📁 react-1kPath:
📁 react-5kPath:
📁 romePath:
📁 ui-componentsPath:
Generated by Rsdoctor GitHub Action |
Deploying rspack with
|
| Latest commit: |
e598048
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://66a422a9.rspack-v2.pages.dev |
| Branch Preview URL: | https://import-meta-rspackrsc-load-c.rspack-v2.pages.dev |
4b55509 to
fb55c92
Compare
eaaabe5 to
b01b8e2
Compare
b01b8e2 to
3f1cbb0
Compare
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 3f1cbb0bdd
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
There was a problem hiding this comment.
Pull request overview
Adds RSC-side support for import.meta.rspackRsc by introducing a dedicated JS dependency/template that generates a per-module helper (loadCss()), and wiring RSC manifest collection to track and inherit server-entry CSS for modules that use this API.
Changes:
- Add
ImportMetaRscDependency+ parser handling soimport.meta.rspackRscis rewritten to a generated helper withloadCss(). - Extend RSC plugin state/collection to track modules using
import.meta.rspackRscand inherit CSS from the nearestuse server-entry. - Add typings and expand config-case tests to validate current-entry and inherited CSS loading.
Reviewed changes
Copilot reviewed 16 out of 17 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/rspack-test/configCases/rsc-plugin/server-entry/src/framework/entry.rsc.js | Adds test assertions for loadCss() and inherited CSS behavior. |
| tests/rspack-test/configCases/rsc-plugin/server-entry/src/Child.js | New test fixture module that uses import.meta.rspackRsc.loadCss(). |
| tests/rspack-test/configCases/rsc-plugin/server-entry/src/App.js | Uses import.meta.rspackRsc and exposes helpers for tests. |
| packages/rspack/module.d.ts | Adds TS typing for ImportMeta.rspackRsc.loadCss(). |
| crates/rspack_plugin_rsc/src/server_plugin.rs | Plumbs import_meta_rsc_importers through server plugin state aggregation. |
| crates/rspack_plugin_rsc/src/plugin_state.rs | Extends ServerEntryState to track import.meta.rspackRsc importers. |
| crates/rspack_plugin_rsc/src/component_info.rs | Collects import.meta.rspackRsc importer modules during server component traversal. |
| crates/rspack_plugin_rsc/src/client_plugin.rs | Propagates server-entry CSS files to tracked import.meta.rspackRsc importers in the manifest. |
| crates/rspack_plugin_javascript/src/visitors/dependency/util.rs | Adds expression name constant for import.meta.rspackRsc. |
| crates/rspack_plugin_javascript/src/plugin/impl_plugin_for_js_plugin.rs | Registers factory/template for new ImportMetaRsc dependency type. |
| crates/rspack_plugin_javascript/src/parser_plugin/import_meta_plugin.rs | Parses import.meta.rspackRsc and emits ImportMetaRscDependency; marks usage in RSC metadata. |
| crates/rspack_plugin_javascript/src/dependency/esm/mod.rs | Exposes new import_meta_rsc_dependency module. |
| crates/rspack_plugin_javascript/src/dependency/esm/import_meta_rsc_dependency.rs | Implements codegen that injects helper + replaces import.meta.rspackRsc. |
| crates/rspack_loader_swc/src/rsc_transforms/server_actions.rs | Initializes new RscMeta.import_meta_rsc field for server action modules. |
| crates/rspack_loader_swc/src/rsc_transforms/react_server_components.rs | Initializes new RscMeta.import_meta_rsc field for server-entry/client modules. |
| crates/rspack_core/src/module.rs | Adds import_meta_rsc: bool to RscMeta. |
| crates/rspack_core/src/dependency/dependency_type.rs | Adds new DependencyType::ImportMetaRsc. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 54dd2826fb
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: cc95d3d1cd
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
9fa011d to
22650b0
Compare
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 22650b007a
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
…y without RSC plugins
22650b0 to
8a4b46c
Compare
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 8a4b46cbea
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
@codex review |
|
Codex Review: Didn't find any major issues. 🚀 ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
Summary
This PR adds support for
import.meta.rspackRscin RSC server modules.ImportMetaRscDependencyand parser handling forimport.meta.rspackRsc.import.meta.rspackRsc.loadCss()returns React<link rel="stylesheet">nodes for CSS files recorded in the RSC manifest.import.meta.rspackRscso they can inherit CSS from the nearest parentuse server-entry.entryCssFilesandcssLinkProps.ImportMeta.rspackRsc.loadCss().Related links
Checklist