Skip to content

[Bug]: Native CSS skips async stylesheet when it is initial in another entry sharing the runtime #15858

Closed

Description

@jkissel

System Info

System: Ubuntu 24.04 LTS
Node: 24.16.0
pnpm: 12.3.4
Rspack: 2.2.3

Details

With native CSS (type: 'css', parser.exportType: 'link'), multiple entries, optimization.runtimeChunk: 'single', and a shared CSS chunk, a dynamic import can resolve without loading its required stylesheet.

The stylesheet is initial for a different entry in the same compilation. That other entry is not loaded on the current page. The generated shared runtime nevertheless initializes the stylesheet's chunk as loaded in cssInstalledChunks.

It's unclear to me whether this is a known missing feature of the builtin CSS support. It came up for me when I tried to refactor the css-loader out which was archived recently.

Expected behavior

The dynamic import requests the shared stylesheet and waits for it to load before resolving.

Actual behavior

The import resolves without requesting the stylesheet. The CssExtractRspackPlugin control with the same shared runtime works correctly.
Native CSS with a separate runtime per entry also.

Reproduce link

No response

Reproduce Steps

See the attached standalone project and README.

npm ci
npm run build
npm run check

The last command intentionally exits 1 while the bug is present. For a browser reproduction, run npm run serve, open http://127.0.0.1:8080/native-single/, and click "Load feature" with the Network panel open.

Configuration shape

  • main dynamically imports feature.js, which imports feature.css.
  • other uses feature.js as its entry.
  • An enforced split-chunk group puts feature.css into shared-css.
  • Only main's initial entry assets are included on the page.

Validation

The standalone automated check executes emitted JavaScript with a simulated DOM; it verifies CSS requests and import-promise timing, not browser rendering. The attached project also includes real browser pages for visual confirmation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions