happy-css-modules icon indicating copy to clipboard operation
happy-css-modules copied to clipboard

Support for `@value` definitions

Open samhh opened this issue 1 year ago • 5 comments

Hey! Off the back of https://github.com/mizdra/happy-css-modules/issues/200#issuecomment-1539878340 I wondered if you may consider support for @value variables:

@value foo: anything;
import styles from './file.css'

styles.foo // string

This would match the behaviour of Webpack and typed-css-modules.

Cheers!

samhh avatar Aug 04 '23 09:08 samhh

Thanks for the proposal!

I misunderstood the behavior with @value. I see that values defined with @value are also exported (I created a demo project to confirm this behavior).

  • https://github.com/mizdra/playground-css-loader/tree/e9ca040a7169b838e4b0d99ef6f49e11b5d21721

Surely it would be desirable to support this behavior in happy-css-modules as well. I will consider implementing it.

mizdra avatar Aug 05 '23 08:08 mizdra

I was too busy to work on it. However, I will resume this work when I have time. Please wait for further updates!

mizdra avatar Oct 18 '23 01:10 mizdra

the same with :export from icss

Grawl avatar Nov 01 '23 10:11 Grawl

@Grawl Thanks for your comment!

I thought ICSS was a syntax that bundler outputs internally, not for people to write. So happy-css-modules is not designed to work with ICSS. happy-css-modules does not have a test case for ICSS, so it is not guaranteed to work with ICSS.

If you want ICSS to work with happy-css-modules, could you please create a new issue? We need to discuss how much work is needed there.

mizdra avatar Nov 01 '23 11:11 mizdra

Just didn't knew there is @value syntax

Grawl avatar Nov 02 '23 00:11 Grawl

This feature is shipped in v3.1.0. Thanks to @samhh for contributing to this feature!

https://github.com/mizdra/happy-css-modules/releases/tag/v3.1.0

mizdra avatar Jun 16 '24 11:06 mizdra