activeguild / vite-plugin-sass-dts

This is a plugin that automatically creates a type file when using the CSS module type-safely.
MIT License
116 stars 18 forks source link

Not working when using with "sass" version 1.65.1+ #83

Closed Lexe003 closed 9 months ago

Lexe003 commented 1 year ago

Hello, I've observed a conflict emerging with "sass" version 1.65.1 while updating dependencies.

Unfortunately, I don't have the time right now to provide an example. The problem is that it intermittently includes fields from external sources, as when using the import statement: @use 'Theme/fonts.module';

This behavior didn't occur previously, and it's one of the issues I've encountered. I kindly request you to investigate this matter. Thank you!

activeguild commented 1 year ago

@Lexe003

Thanks for your inquiry. I will check it out.

activeguild commented 1 year ago

@Lexe003

Does this still happen after updating sass to 1.66.1? I could not reproduce the event in my environment.

Lexe003 commented 1 year ago

@activeguild I tested it on the example react files in this repository:

Please do the following:

  1. Make a file colors.module.scss to the root and add the following to it:

$gray100: #f9fafb;

:export { gray100: $gray100; }

  1. In App.module.scss add the following:

@use './colors.module.scss';

.test { color: colors.$gray100; }

Trigger the generator and you'll notice that it adds "readonly gray100: 'gray100'" to the App.module d.ts file - On previous versions of sass it wasn't doing this. It also messes up some other d ts files in another scenario which I can't figur out at the moment.

activeguild commented 1 year ago

@Lexe003 What inconsistencies occur when gray100 is added? This variable is being added to use CSS variables in javascript. A solution may be possible based on the inconsistencies that occur.

Lexe003 commented 1 year ago

@activeguild not only used variables but all exported colors from @use './colors.module.scss'; are added to the generated App.module.scss.d.ts. Maybe prevent this from happening to solve the issue?

activeguild commented 9 months ago

@Lexe003

How about reading in additionalData as follows? https://github.com/activeguild/vite-plugin-sass-dts/blob/e4f183d7f3a38616c269813b97a41386815e6a5d/example/react-sass/vite.config.ts#L13

activeguild commented 9 months ago

Fixed issue.