Closed samhh closed 1 year ago
@samhh Thanks for the report!
First of all, I think this error message is harmless and can be ignored (more on that later). The error message is occurring during the processing of foo.css, but the generation of the type definition in foo.css is successful.
The reason why the bar.css type definition is not generated is not because an error occurred during the processing of bar.css, but because bar.css was not processed in the first place. Rewrite the command as follows
-hcm --logLevel=debug --webpackResolveAlias='{ \"bar\": \"bar.css\" }' foo.css
+hcm --logLevel=debug --webpackResolveAlias='{ \"bar\": \"bar.css\" }' '*.css'
I think this will solve your problem. Please try it!
In the first place, @value something from "bar";
should not be resolved. With or without this statement, the only selector exported from foo.css
is .foo
. .bar
is not exported from foo.css
, because @value <imported-value-name> from '<specifier>';
is an import statement for @value
. It does not have the ability to import the selector and expand it to the import destination.
I had intended happy-css-modules to also implement @value <imported-value-name> from '<specifier>';
so that it would not resolve. However, it was being resolved by mistake, causing the aforementioned error. I can generate the type definitions without any problem, just an error message.
However, it is noisy and I will fix this error message problem at a later date.
Hey, thank you! Some more observations:
Supplying a bad PostCSS config path offers no feedback, so there's no way to know if it's failing to apply because of a bad path or otherwise. I've pushed this to the above repo.
TCM was happy to type @value foo: val;
as if as Webpack's css-loader gives us foo
were a class nameval
instead of a class name. How could one get that behaviour back in HCM?
A little more information on @value
.
TCM uses postcss-modules-loader-core, which contrary to its README includes postcss-modules-values.
I've tried replicating that same config - and I know it's loading with a console.log
in the PostCSS config - to no avail.
Some progress. The following enables HCM to at least parse @value
non-import statements.
Alternatively one of the PostCSS plugins TCM implicitly uses causes it to be transformed into an :export
block.
Hi there! I'm struggling to get
--webpackResolveAlias
working. I've created a small repro repo here: https://git.sr.ht/~samhh/hcm-reproWhat I've observed:
logLevel=debug
it'd be convenient to know at least if the alias had hit a match.For what it's worth the real repo currently successfully uses typed-css-modules... but we'd really like declaration maps :wink:
Cheers!