Skip to content

feat: support import.meta.rspackRsc#13840

Merged
SyMind merged 9 commits into
mainfrom
import-meta-rspackrsc-load-css
May 11, 2026
Merged

feat: support import.meta.rspackRsc#13840
SyMind merged 9 commits into
mainfrom
import-meta-rspackrsc-load-css

Conversation

@SyMind

@SyMind SyMind commented Apr 27, 2026

Copy link
Copy Markdown
Member

Summary

This PR adds support for import.meta.rspackRsc in RSC server modules.

  • Introduces a new ImportMetaRscDependency and parser handling for import.meta.rspackRsc.
  • Generates a per-module helper where import.meta.rspackRsc.loadCss() returns React <link rel="stylesheet"> nodes for CSS files recorded in the RSC manifest.
  • Tracks modules that use import.meta.rspackRsc so they can inherit CSS from the nearest parent use server-entry.
  • Wires the helper output to existing RSC manifest entryCssFiles and cssLinkProps.
  • Adds TypeScript typing for ImportMeta.rspackRsc.loadCss().
  • Extends the RSC server-entry config case to verify CSS loading for both the current server entry and inherited server-entry CSS.

Related links

Checklist

  • Tests updated (or not required).
  • Documentation updated (or not required).

@github-actions github-actions Bot added release: feature release: feature related release(mr only) team The issue/pr is created by the member of Rspack. labels Apr 27, 2026
@github-actions

github-actions Bot commented Apr 27, 2026

Copy link
Copy Markdown
Contributor

📦 Binary Size-limit

Comparing e598048 to test: split benchmark case entrypoints (#13971) by hardfist

❌ Size increased by 32.13KB from 61.92MB to 61.95MB (⬆️0.05%)

@codspeed-hq

codspeed-hq Bot commented Apr 27, 2026

Copy link
Copy Markdown
Contributor

Merging this PR will not alter performance

✅ 34 untouched benchmarks
⏩ 25 skipped benchmarks1


Comparing import-meta-rspackrsc-load-css (e598048) with main (81aa0bb)

Open in CodSpeed

Footnotes

  1. 25 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

@github-actions

github-actions Bot commented Apr 27, 2026

Copy link
Copy Markdown
Contributor

Rsdoctor Bundle Diff Analysis

Found 6 projects in monorepo, 6 projects with changes.

📊 Quick Summary
Project Total Size Change
popular-libs 1.7 MB -
react-10k 5.7 MB -
react-1k 826.3 KB -
react-5k 2.7 MB -
rome 1.6 MB -
ui-components 4.8 MB -
📋 Detailed Reports (Click to expand)

📁 popular-libs

Path: ../build-tools-performance/cases/popular-libs/dist/rsdoctor-data.json

⚠️ No baseline data found - Unable to perform comparison analysis

Metric Current Baseline Change
📊 Total Size 1.7 MB - -
📄 JavaScript 1.7 MB - -
🎨 CSS 0 B - -
🌐 HTML 289.0 B - -
📁 Other Assets 0 B - -

📁 react-10k

Path: ../build-tools-performance/cases/react-10k/dist/rsdoctor-data.json

⚠️ No baseline data found - Unable to perform comparison analysis

Metric Current Baseline Change
📊 Total Size 5.7 MB - -
📄 JavaScript 5.7 MB - -
🎨 CSS 21.0 B - -
🌐 HTML 328.0 B - -
📁 Other Assets 0 B - -

📁 react-1k

Path: ../build-tools-performance/cases/react-1k/dist/rsdoctor-data.json

⚠️ No baseline data found - Unable to perform comparison analysis

Metric Current Baseline Change
📊 Total Size 826.3 KB - -
📄 JavaScript 826.0 KB - -
🎨 CSS 0 B - -
🌐 HTML 328.0 B - -
📁 Other Assets 0 B - -

📁 react-5k

Path: ../build-tools-performance/cases/react-5k/dist/rsdoctor-data.json

⚠️ No baseline data found - Unable to perform comparison analysis

Metric Current Baseline Change
📊 Total Size 2.7 MB - -
📄 JavaScript 2.7 MB - -
🎨 CSS 21.0 B - -
🌐 HTML 328.0 B - -
📁 Other Assets 0 B - -

📁 rome

Path: ../build-tools-performance/cases/rome/dist/rsdoctor-data.json

⚠️ No baseline data found - Unable to perform comparison analysis

Metric Current Baseline Change
📊 Total Size 1.6 MB - -
📄 JavaScript 1.6 MB - -
🎨 CSS 0 B - -
🌐 HTML 0 B - -
📁 Other Assets 0 B - -

📁 ui-components

Path: ../build-tools-performance/cases/ui-components/dist/rsdoctor-data.json

⚠️ No baseline data found - Unable to perform comparison analysis

Metric Current Baseline Change
📊 Total Size 4.8 MB - -
📄 JavaScript 4.7 MB - -
🎨 CSS 107.0 KB - -
🌐 HTML 328.0 B - -
📁 Other Assets 0 B - -

Generated by Rsdoctor GitHub Action

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Apr 29, 2026

Copy link
Copy Markdown

Deploying rspack with  Cloudflare Pages  Cloudflare Pages

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

View logs

@SyMind SyMind force-pushed the import-meta-rspackrsc-load-css branch from 4b55509 to fb55c92 Compare April 30, 2026 05:22
@SyMind SyMind force-pushed the import-meta-rspackrsc-load-css branch from eaaabe5 to b01b8e2 Compare May 6, 2026 08:55
@SyMind SyMind force-pushed the import-meta-rspackrsc-load-css branch from b01b8e2 to 3f1cbb0 Compare May 8, 2026 10:34
@SyMind SyMind marked this pull request as ready for review May 9, 2026 02:04
@SyMind SyMind requested a review from hardfist as a code owner May 9, 2026 02:04
Copilot AI review requested due to automatic review settings May 9, 2026 02:04
@SyMind

SyMind commented May 9, 2026

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 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".

Comment thread crates/rspack_plugin_javascript/src/parser_plugin/import_meta_plugin.rs Outdated

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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 so import.meta.rspackRsc is rewritten to a generated helper with loadCss().
  • Extend RSC plugin state/collection to track modules using import.meta.rspackRsc and inherit CSS from the nearest use 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.

Comment thread crates/rspack_loader_swc/src/rsc_transforms/server_actions.rs
@SyMind

SyMind commented May 9, 2026

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 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".

Comment thread crates/rspack_plugin_rsc/src/client_plugin.rs
@SyMind

SyMind commented May 9, 2026

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 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".

Comment thread crates/rspack_plugin_javascript/src/parser_plugin/import_meta_plugin.rs Outdated
Comment thread packages/rspack/module.d.ts Outdated
@SyMind SyMind force-pushed the import-meta-rspackrsc-load-css branch 2 times, most recently from 9fa011d to 22650b0 Compare May 9, 2026 03:50
@SyMind

SyMind commented May 9, 2026

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 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".

Comment thread packages/rspack/module.d.ts Outdated
@SyMind SyMind force-pushed the import-meta-rspackrsc-load-css branch from 22650b0 to 8a4b46c Compare May 9, 2026 06:11
@SyMind

SyMind commented May 9, 2026

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 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".

@SyMind

SyMind commented May 9, 2026

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. 🚀

ℹ️ 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".

@github-actions

github-actions Bot commented May 11, 2026

Copy link
Copy Markdown
Contributor

📝 Rspack Ecosystem CI: Open

suite result
modernjs ❌ failure
rsdoctor ✅ success
rstest ✅ success
rspress ✅ success
rslib ✅ success
rsbuild ❌ failure
examples ✅ success
rsbuild-rsc-plugin ✅ success
plugin ❌ failure
devserver ✅ success
lynx-stack ❌ failure

@web-infra-dev web-infra-dev deleted a comment from github-actions Bot May 11, 2026
@SyMind SyMind merged commit 625d729 into main May 11, 2026
37 checks passed
@SyMind SyMind deleted the import-meta-rspackrsc-load-css branch May 11, 2026 06:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

release: feature release: feature related release(mr only) team The issue/pr is created by the member of Rspack.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants