Skip to content

chore(build): enable Rspack runtime for Rslib builds - #1854

Merged
Timeless0911 merged 3 commits into
mainfrom
david/chore-rslib-runtime-mode
Sep 16, 2026
Merged

Timeless0911 merged 3 commits into
mainfrom
david/chore-rslib-runtime-mode

Conversation

@Timeless0911

Copy link
Copy Markdown
Contributor

Motivation

Enable Rspack's runtime output for the packages built with Rslib and verify the updated Rslib toolchain.

Changes

  • Update @rslib/core from 1.0.0 to 1.0.1 across Rslib build workspaces.
  • Configure the shared Rslib Rspack options with experiments.runtimeMode: 'rspack'.
  • Rebuild and validate Node, browser, adapter, coverage, Playwright, and VS Code artifacts.

Rspack documents runtimeMode: 'rspack' as experimental: https://rspack.rs/zh/config/experiments#experimentsruntimemode

Validation: all Rslib builds passed; adapter/core targeted tests, in-source CLI E2E, typecheck, Knip, format/spell, and dependency-version checks passed.

@Timeless0911
Timeless0911 requested a review from 9aoy September 16, 2026 09:00
@github-actions

github-actions Bot commented Sep 16, 2026

Copy link
Copy Markdown

Rsdoctor Bundle Diff Analysis

Found 13 projects in monorepo, 8 projects with changes.

📊 Quick Summary
Project Total Size Change
adapter-rslib 51.1 KB 0
browser 1.1 MB -453.0 B (-0.0%)
adapter-rsbuild 6.1 KB 0
adapter-rspack 12.4 KB +27.0 B (0.2%)
browser-react 6.4 KB 0
coverage-v8 82.2 KB -73.0 B (-0.1%)
coverage-istanbul 20.1 KB -73.0 B (-0.4%)
browser/client 79.6 KB 0
playwright 53.0 KB 0
core/browser 645.2 KB -556.0 B (-0.1%)
core/main 2.0 MB +108.0 B (0.0%)
vscode/extension 1.3 MB -170.0 B (-0.0%)
vscode/worker 18.4 KB +34.0 B (0.2%)
📋 Detailed Reports (Click to expand)

📁 browser

Path: packages/browser/.rsdoctor/rsdoctor-data.json

📌 Baseline Commit: 4f133dd3fe | PR: #1851

Metric Current Baseline Change
📊 Total Size 1.1 MB 1.1 MB -453.0 B (-0.0%)
📄 JavaScript 1.0 MB 1.0 MB -453.0 B (-0.0%)
🎨 CSS 11.6 KB 11.6 KB 0
🌐 HTML 763.0 B 763.0 B 0
📁 Other Assets 62.4 KB 62.4 KB 0

📦 Download Diff Report: browser Bundle Diff

📁 adapter-rspack

Path: packages/adapter-rspack/.rsdoctor/rsdoctor-data.json

📌 Baseline Commit: 4f133dd3fe | PR: #1851

Metric Current Baseline Change
📊 Total Size 12.4 KB 12.4 KB +27.0 B (0.2%)
📄 JavaScript 11.2 KB 11.2 KB +27.0 B (0.2%)
🎨 CSS 0 B 0 B 0
🌐 HTML 0 B 0 B 0
📁 Other Assets 1.2 KB 1.2 KB 0

📦 Download Diff Report: adapter-rspack Bundle Diff

📁 coverage-v8

Path: packages/coverage-v8/.rsdoctor/rsdoctor-data.json

📌 Baseline Commit: 4f133dd3fe | PR: #1851

Metric Current Baseline Change
📊 Total Size 82.2 KB 82.3 KB -73.0 B (-0.1%)
📄 JavaScript 75.9 KB 75.9 KB -73.0 B (-0.1%)
🎨 CSS 0 B 0 B 0
🌐 HTML 0 B 0 B 0
📁 Other Assets 6.3 KB 6.3 KB 0

📦 Download Diff Report: coverage-v8 Bundle Diff

📁 coverage-istanbul

Path: packages/coverage-istanbul/.rsdoctor/rsdoctor-data.json

📌 Baseline Commit: 4f133dd3fe | PR: #1851

Metric Current Baseline Change
📊 Total Size 20.1 KB 20.1 KB -73.0 B (-0.4%)
📄 JavaScript 16.6 KB 16.7 KB -73.0 B (-0.4%)
🎨 CSS 0 B 0 B 0
🌐 HTML 0 B 0 B 0
📁 Other Assets 3.4 KB 3.4 KB 0

📦 Download Diff Report: coverage-istanbul Bundle Diff

📁 core/browser

Path: packages/core/.rsdoctor/browser/rsdoctor-data.json

📌 Baseline Commit: 4f133dd3fe | PR: #1851

Metric Current Baseline Change
📊 Total Size 645.2 KB 645.7 KB -556.0 B (-0.1%)
📄 JavaScript 478.3 KB 478.8 KB -556.0 B (-0.1%)
🎨 CSS 0 B 0 B 0
🌐 HTML 0 B 0 B 0
📁 Other Assets 166.9 KB 166.9 KB 0

📦 Download Diff Report: core/browser Bundle Diff

📁 core/main

Path: packages/core/.rsdoctor/main/rsdoctor-data.json

📌 Baseline Commit: 4f133dd3fe | PR: #1851

Metric Current Baseline Change
📊 Total Size 2.0 MB 2.0 MB +108.0 B (0.0%)
📄 JavaScript 1.6 MB 1.6 MB +108.0 B (0.0%)
🎨 CSS 0 B 0 B 0
🌐 HTML 0 B 0 B 0
📁 Other Assets 440.3 KB 440.3 KB 0

📦 Download Diff Report: core/main Bundle Diff

📁 vscode/extension

Path: packages/vscode/.rsdoctor/extension/rsdoctor-data.json

📌 Baseline Commit: 4f133dd3fe | PR: #1851

Metric Current Baseline Change
📊 Total Size 1.3 MB 1.3 MB -170.0 B (-0.0%)
📄 JavaScript 471.7 KB 471.8 KB -170.0 B (-0.0%)
🎨 CSS 0 B 0 B 0
🌐 HTML 0 B 0 B 0
📁 Other Assets 821.4 KB 821.4 KB 0

📦 Download Diff Report: vscode/extension Bundle Diff

📁 vscode/worker

Path: packages/vscode/.rsdoctor/worker/rsdoctor-data.json

📌 Baseline Commit: 4f133dd3fe | PR: #1851

Metric Current Baseline Change
📊 Total Size 18.4 KB 18.4 KB +34.0 B (0.2%)
📄 JavaScript 18.4 KB 18.4 KB +34.0 B (0.2%)
🎨 CSS 0 B 0 B 0
🌐 HTML 0 B 0 B 0
📁 Other Assets 0 B 0 B 0

📦 Download Diff Report: vscode/worker Bundle Diff

Generated by Rsdoctor GitHub Action

@Timeless0911
Timeless0911 enabled auto-merge (squash) September 16, 2026 09:08
@github-actions

github-actions Bot commented Sep 16, 2026

Copy link
Copy Markdown

📝 Rstest Ecosystem CI: Open

suite result
rsdoctor ✅ success
examples ✅ success
rsbuild ✅ success
rslib ✅ success
rspress ✅ success
modernjs ✅ success
rstack-cli ✅ success

Timeless0911 commented Sep 16, 2026

Copy link
Copy Markdown
Contributor Author

A minimal reproduction is confirmed in Rspack Playground (Rspack v2.2.5).

The reproduction uses the Rslib-style output shape: multiple entries, ESM library output, a named runtime chunk, and concatenateModules: false.

The relevant source is:

export function getCommonJsSyntheticModule(exports) {
  const exportNames = Object.getOwnPropertyNames(exports);
  const namespace =
    exports !== null &&
    (typeof exports === 'object' || typeof exports === 'function')
      ? Object.defineProperties(
          {},
          Object.fromEntries(
            exportNames.map((name) => [
              name,
              {
                enumerable: true,
                get() {
                  return exports[name];
                },
              },
            ]),
          ),
        )
      : { default: exports };
  return namespace;
}

const namespace = getCommonJsSyntheticModule({ hiddenReceiverValue: 42 });
console.log('namespace keys:', Object.keys(namespace));

if (!Object.hasOwn(namespace, 'hiddenReceiverValue')) {
  throw new Error('missing named export: hiddenReceiverValue');
}

The generated /dist/index.mjs renames the parameter to __nested_rspack_exports__, but leaves the typeof exports check unchanged:

function getCommonJsSyntheticModule(__nested_rspack_exports__) {
  const namespace =
    __nested_rspack_exports__ !== null &&
    (typeof exports === 'object' || typeof exports === 'function')
      ? ...
      : { default: __nested_rspack_exports__ };
}

Since the output is ESM, typeof exports is 'undefined', so the function exposes only default and the named export hiddenReceiverValue is lost. Running the generated module prints only ['default'] and throws missing named export: hiddenReceiverValue.

Renaming the source parameter to cjsExports makes the generated output consistent and avoids the Rspack runtime mode issue.

@Timeless0911
Timeless0911 merged commit 7e01d9e into main Sep 16, 2026
10 checks passed
@Timeless0911
Timeless0911 deleted the david/chore-rslib-runtime-mode branch September 16, 2026 10:19
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