Skip to content

fix: avoid emitting JavaScript for CSS-only entries#14879

Draft
intellild wants to merge 1 commit into
mainfrom
agent/fix-css-entry-extra-js
Draft

fix: avoid emitting JavaScript for CSS-only entries#14879
intellild wants to merge 1 commit into
mainfrom
agent/fix-css-entry-extra-js

Conversation

@intellild

Copy link
Copy Markdown
Contributor

Summary

  • stop treating an entry module as JavaScript solely because it is an entry
  • let native CSS entry modules omit their JavaScript facade when they are only referenced by the configured entry dependency
  • avoid emitting standalone runtime chunks when their entrypoint group contains no JavaScript chunk
  • align the existing asset-module entry regression cases with webpack's CSS-only entry behavior

Example

Given a CSS-only entry:

module.exports = {
  entry: {
    styles: "./src/styles.css"
  },
  experiments: {
    css: true
  }
};

Rspack previously emitted both styles.css and an unnecessary styles.js. After this change it emits only styles.css. If JavaScript imports the CSS module and needs its exports, the JavaScript facade is still generated. JavaScript-valued CSS export types such as text, style, and CSSStyleSheet keep their existing behavior.

Root cause

The JavaScript render manifest considered every entry chunk to contain JavaScript, even when its modules exposed no SourceType::JavaScript. Runtime chunks were also retained merely because runtime modules existed, without checking whether the entrypoint group had a JavaScript consumer.

Related links

  • webpack regression fix: web-infra-dev/webpack#20454

Validation

  • pnpm run build:cli:dev
  • pnpm run test -t "only-entry"
  • pnpm run test -t "entry-with-runtimeChunk"
  • cargo clippy -p rspack_plugin_css -p rspack_plugin_javascript --all-targets -- -D warnings
  • cargo fmt --all --check
  • commit hooks: rustfmt, Prettier, JavaScript lint

Checklist

  • Tests updated.
  • Documentation not required.

by OpenAI Codex

@github-actions

Copy link
Copy Markdown
Contributor

📦 Binary Size-limit

Comparing 069d58e to chore: add rspack perf codspeed goal skill (#14550) by harpsealjs

🙈 Size remains the same at 66.64MB

@github-actions

Copy link
Copy Markdown
Contributor

Rsdoctor Bundle Diff Analysis

⚠️ Note: The latest commit (439df0f525) does not have baseline artifacts. Using commit da0c994fee for baseline comparison instead. If this seems incorrect, please wait a few minutes and try rerunning the workflow.

Found 5 projects in monorepo, 0 projects with changes.

📊 Quick Summary
Project Total Size Gzip Size Change Gzip Change
popular-libs 1.7 MB 552.1 KB 0 0
react-10k 5.6 MB 1.3 MB 0 0
react-1k 823.1 KB 217.0 KB 0 0
react-5k 2.7 MB 663.8 KB 0 0
ui-components 4.9 MB 1.4 MB 0 0

Generated by Rsdoctor GitHub Action

@codspeed-hq

codspeed-hq Bot commented Jul 20, 2026

Copy link
Copy Markdown
Contributor

Merging this PR will not alter performance

✅ 43 untouched benchmarks
⏩ 47 skipped benchmarks1


Comparing agent/fix-css-entry-extra-js (069d58e) with main (da0c994)

Open in CodSpeed

Footnotes

  1. 47 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.

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