Skip to content

Comments

fix: preserve CSS entry names in manifest by using Map instead of Set#6662

Closed
Copilot wants to merge 3 commits intomainfrom
copilot/port-vite-css-plugin-code
Closed

fix: preserve CSS entry names in manifest by using Map instead of Set#6662
Copilot wants to merge 3 commits intomainfrom
copilot/port-vite-css-plugin-code

Conversation

Copy link
Contributor

Copilot AI commented Oct 22, 2025

Description

This PR ports the fix from vitejs/vite#20585 to rolldown's builtin vite-css plugin. The issue was that CSS entry point names were being incorrectly transformed in the manifest output (e.g., foo.scssfoo.css), making it impossible to locate CSS entries by their original names.

Problem

When CSS files are used as entry points with custom names (e.g., styles/tailwind.scss or bar.custom), the manifest was:

  1. Transforming the entry names to .css extension regardless of the original name
  2. Only storing whether an asset was an entry (boolean), not preserving the actual entry name

This broke use cases where:

  • Entry names had non-CSS extensions (.scss, .less, etc.)
  • Custom entry names without extensions were used (e.g., bar.custom)
  • The entry name needed to match the original input configuration

Solution

Changed the CSS entries tracking mechanism from a Set to a Map to preserve the original chunk names:

Key Changes

  1. CSS Entries Storage: Changed from Set<referenceId> to Map<chunkName, referenceId>

    // Before
    pub struct CSSEntriesCache {
      pub inner: FxDashSet<ArcStr>,
    }
    
    // After
    pub struct CSSEntriesCache {
      pub inner: FxDashMap<String, ArcStr>,
    }
  2. Entry Tracking: Store chunk name along with reference ID

    // Before
    css_entries_cache.inner.insert(reference_id);
    
    // After
    css_entries_cache.inner.insert(chunk.name.to_string(), reference_id);
  3. Manifest Output: Added name field with the unmangled entry name

    pub struct ManifestChunk {
      // ... other fields
      pub name: Option<String>,         // NEW: preserves original entry name
      pub names: Option<Vec<String>>,   // Kept for backward compatibility
    }

Example

With an entry point named styles/tailwind.scss, the manifest will now include:

{
  "styles/tailwind.scss": {
    "file": "assets/tailwind-abc123.css",
    "src": "styles/tailwind.scss",
    "isEntry": true,
    "name": "styles/tailwind.scss",
    "names": ["styles/tailwind.css"]
  }
}

The name field preserves the original styles/tailwind.scss entry name, while names is kept for backward compatibility.

Backward Compatibility

  • The names field is preserved in the manifest output for backward compatibility
  • The new name field is added as an optional field
  • Existing consumers will continue to work without changes

Testing

  • ✅ All Rust clippy checks pass
  • ✅ All Rust formatting checks pass
  • ✅ TypeScript linting and type checking pass
  • ✅ Build completes successfully

Related

Original prompt

Read vitejs/vite#20585 and port the code into rolldown's builtin vite css plugin


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

@graphite-app
Copy link
Contributor

graphite-app bot commented Oct 22, 2025

How to use the Graphite Merge Queue

Add the label graphite: merge to this PR to add it to the merge queue.

You must have a Graphite account in order to use the merge queue. Sign up using this link.

An organization admin has enabled the Graphite Merge Queue in this repository.

Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue.

@netlify
Copy link

netlify bot commented Oct 22, 2025

Deploy Preview for rolldown-rs canceled.

Name Link
🔨 Latest commit 73ac18d
🔍 Latest deploy log https://app.netlify.com/projects/rolldown-rs/deploys/68f8a2d930d2dc00089e82b9

Copilot AI and others added 2 commits October 22, 2025 09:20
- Updated CSSEntriesCache to use FxDashMap<String, ArcStr> instead of FxDashSet<ArcStr>
- Modified vite_css_post_plugin to store chunk name → reference_id mapping
- Updated manifest plugin to extract name from CSS entries map
- Modified ManifestChunk to include optional name field
- Updated TypeScript bindings to use Map<string, string> for cssEntries
- Fixed test fixture to use Map instead of Set

Co-authored-by: shulaoda <[email protected]>
Copilot AI changed the title [WIP] Port code from Vite CSS plugin to Rolldown fix: preserve CSS entry names in manifest by using Map instead of Set Oct 22, 2025
Copilot AI requested a review from shulaoda October 22, 2025 09:33
@github-actions
Copy link
Contributor

github-actions bot commented Oct 24, 2025

Benchmarks Rust

  • target: main(5a2636b)
  • pr: copilot/port-vite-css-plugin-code(73ac18d)
group                                                        pr                                     target
-----                                                        --                                     ------
bundle/bundle@multi-duplicated-top-level-symbol              1.00     65.6±2.08ms        ? ?/sec    1.05     69.0±2.80ms        ? ?/sec
bundle/bundle@multi-duplicated-top-level-symbol-sourcemap    1.00     74.3±1.69ms        ? ?/sec    1.02     75.7±3.85ms        ? ?/sec
bundle/bundle@rome_ts                                        1.00    107.2±2.46ms        ? ?/sec    1.05    113.0±1.95ms        ? ?/sec
bundle/bundle@rome_ts-sourcemap                              1.00   122.1±12.03ms        ? ?/sec    1.02    125.1±2.57ms        ? ?/sec
bundle/bundle@threejs                                        1.00     39.1±2.40ms        ? ?/sec    1.06     41.5±2.76ms        ? ?/sec
bundle/bundle@threejs-sourcemap                              1.00     43.4±0.77ms        ? ?/sec    1.00     43.5±0.91ms        ? ?/sec
bundle/bundle@threejs10x                                     1.01    399.5±8.46ms        ? ?/sec    1.00    397.0±7.46ms        ? ?/sec
bundle/bundle@threejs10x-sourcemap                           1.00    454.7±5.21ms        ? ?/sec    1.02    462.1±8.02ms        ? ?/sec
scan/scan@rome_ts                                            1.00     86.7±1.69ms        ? ?/sec    1.01     87.8±1.88ms        ? ?/sec
scan/scan@threejs                                            1.02     29.2±0.41ms        ? ?/sec    1.00     28.7±0.62ms        ? ?/sec
scan/scan@threejs10x                                         1.02    307.5±5.57ms        ? ?/sec    1.00    300.5±6.22ms        ? ?/sec

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.

2 participants