Skip to content

[Bug]: rebuildModule not work when using with importModule(i.e.: with CssExtract) #9778

@colinaaa

Description

@colinaaa

System Info

System:
OS: macOS 14.6.1
CPU: (12) arm64 Apple M2 Max
Memory: 15.10 GB / 96.00 GB
Shell: 4.0.0 - /opt/homebrew/bin/fish
Binaries:
Node: 22.14.0 - ~/.local/state/fnm_multishells/59684_1742807915544/bin/node
npm: 10.9.2 - ~/.local/state/fnm_multishells/59684_1742807915544/bin/npm
pnpm: 9.15.2 - ~/.local/state/fnm_multishells/59684_1742807915544/bin/pnpm
bun: 1.2.5 - ~/.bun/bin/bun
Browsers:
Chrome: 134.0.6998.119
Safari: 17.6
npmPackages:
@rspack/cli: ^1.3.0-beta.0 => 1.3.0-beta.0
@rspack/core: ^1.3.0-beta.0 => 1.3.0-beta.0

Details

I'm trying to implement the Tailwind CSS plugin for Rspack, and it does not work with CssExtractRspackPlugin.

I'm using the compilation.rebuildModule API in hooks.finishModules. And it seems like the module is not rebuilding.

Remove the CssExtractRspackPlugin.loader would work as expected.

I add some log to the CssExtractRspackPlugin.loader

Image

It seems like the loader is not running when importModule is called. And it directly returns the last result.

Reproduce link

https://github.com/colinaaa-reproductions/rspack-repro-css-rebuild-module#

Reproduce Steps

  1. pnpm install
  2. pnpm run build

Expect to have color: red in rspack-dist/src_render_js.css, but got color: green.

Webpack also generates color: green, but it might be an issue of mini-css-extract-plugin. The loader has run twice. Switching to style-loader would work just fine.

Also note that webpack got the same result if the experimentalUseImportModule: false is removed.

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