astroturfcss / astroturf

Better Styling through Compiling: CSS-in-JS for those that want it all.
https://astroturfcss.github.io/astroturf/
MIT License
2.28k stars 60 forks source link

useAltLoader doesn't work with MiniCssExtractPlugin's experimentalUseImportModule #727

Open dreyks opened 2 years ago

dreyks commented 2 years ago

experimentalUseImportModule is a new option for MiniCssExtractPlugin to use importModule instead of a child compilation.

when calling importModule mini-css-extract-plugin prepends the request with the resource which as far as I understand adds the matchResource to the module.

this leads to astroturf not attaching its own matchResource here

this, in turn, leads to CSS not being processed as CSS modules and then astroturf can't find any CSS Module imports since there are none

my understanding of how things work (especially in the context of matchResource) is limited and mostly comes from the discussion in your PR to css-loader so I might be mistaken here :)

also, If I comment the conditional in astroturf and just reassign this._module.matchResource = style.absoluteFilePath unconditionally - everything seems to be working for me. I don't, however, fully understand the consequences of this action.