css-modules / icss-utils

Search & replace tokens during the linking stage of ICSS loading
ISC License
23 stars 15 forks source link

feat: support at rule versions of import/export #76

Closed jquense closed 3 years ago

jquense commented 3 years ago

Follow up to: https://github.com/webpack-contrib/css-loader/issues/1217#issuecomment-720677917 searches for both by default. This should allow for more flexibility with ICSS being used as an actual interchange format when sandwiched between tooling. E.g. Svelte automatically mangles :import and :export rules during it's style scoping pass (not configurable). At rules should be safer, as tools generally have to leave unknown at-rules alone

jquense commented 3 years ago

cc @evilebottnawi

jquense commented 3 years ago

sorry for the formatting noise, editor applied my prettier config

jquense commented 3 years ago

i ran it explicitly b/c the lint script is also doing it. It seems like there is a mismatch between which config is used locally though. Is there a standard config ya'll use I can add to the package.json here?

alexander-akait commented 3 years ago

no configuration, we use prettier without options

jquense commented 3 years ago

I think the problem is it's picking up my home directory config. this passes lint for me, but obviously not in CI. might need to have an explicit config. will check

jquense commented 3 years ago

both ideally. I'm going to use this for my stuff, but without css-loader support it requires a custom css-loader to work nicely in webpack. Basically css-module support in Svelte is very hard otherwise.

jquense commented 3 years ago

I understand if that is challenging tho, My guess would be that this is pretty low risk and doesn't expand the complexity in css-loader (i hope)

alexander-akait commented 3 years ago

I understand if that is challenging tho, My guess would be that this is pretty low risk and doesn't expand the complexity in css-loader (i hope)

Yep, I'm only worried about performance here

jquense commented 3 years ago

Yep, I'm only worried about performance here

it should be the same amount of work as before. extracting is only doing a shallow loop through root nodes (which is was doing anyway), so no additional passes, and no more extracting than you'd do otherwise.

alexander-akait commented 3 years ago

@jquense Thanks for the PR, can you ping me tomorrow and we will do merge and release

jquense commented 3 years ago

ping!

jquense commented 3 years ago

gtg?

jquense commented 3 years ago

ok should be good now i think

jquense commented 3 years ago

friendly ping!

alexander-akait commented 3 years ago

I will do release tomorrow

alexander-akait commented 3 years ago

https://github.com/css-modules/icss-utils/releases/tag/v5.1.0 released, I changed atrule to at-rule because it is right from CSS spec