css-modules-typescript-loader icon indicating copy to clipboard operation
css-modules-typescript-loader copied to clipboard

Doesn't export fields with css-loader ^4.0.0

Open bjephson opened this issue 5 years ago • 7 comments

We are using css-modules-typescript-loader to generate our types with CSS modules, css-loader and sass.

I'm seeing an issue in the generated typescript files from css-modules-typescript-loader. When we update to css-loader version 4, the exports have no fields in CssExports.

This works fine with css-loader version 3.6.0 but issue appears when updating to css-loader version 4.

bjephson avatar Jul 28 '20 15:07 bjephson

It's maybe due to new export feature in css-loader - es6 export (esModule: true)

budarin avatar Aug 24 '20 14:08 budarin

Hey @mattcompiles, do you think you could help us with this? :)

astorije avatar Sep 03 '20 19:09 astorije

Same issue here, played around with the options of the css-loader, but did not get any export

LeopoldLerch avatar Sep 08 '20 11:09 LeopoldLerch

Same here. I tried all different css-loader options and set esModule: false but type files are always generated empty. When I set mode to 'verify' it says the content has changed compared to the saved version and the diff shows it would remove all css entries from the new type file.

tuhlmann avatar Sep 08 '20 13:09 tuhlmann

FYI: I ended up switching to

@teamsupercell/typings-for-css-modules-loader

as this repo seems no longer maintained. Worked with that loader.

LeopoldLerch avatar Sep 08 '20 13:09 LeopoldLerch

For css-loader version 4 has different local export name from version 3. In the index.js file line 83, we can add function to make it work for both versions. See the pull request below for the fix.

mydatahack avatar Sep 21 '20 07:09 mydatahack

Thanks @mydatahack for this PR! You rock! 🤘💀🤘

matthewhartman avatar Sep 22 '20 08:09 matthewhartman