Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Evaluate typescript-plugin-css-modules #74

Open
amannn opened this issue Nov 3, 2021 · 7 comments
Open

Evaluate typescript-plugin-css-modules #74

amannn opened this issue Nov 3, 2021 · 7 comments

Comments

@amannn
Copy link
Member

amannn commented Nov 3, 2021

https://www.npmjs.com/package/typescript-plugin-css-modules

@amannn
Copy link
Member Author

amannn commented Nov 4, 2021

The editor integration is quite nice:

Screenshot 2021-11-04 at 11 05 49

The big drawback is unfortunately that TypeScript plugins are not run at compilation time. Therefore you only see the errors in the IDE, not for example when linting on CI. See microsoft/TypeScript#16607. I also tried running the type checks with ttsc, but not luck unforunately.

So probably for now the ESLint plugin is still the better option.

@barak007
Copy link

barak007 commented Feb 1, 2022

This plugin provides one of the best experiences of css-modules in a typescript project and the draw back of not having the errors in build time is huge.
One additional drawback of this plugin is that it uses monkey patching on the typescript module.
This plugin patches createLanguageServiceSourceFile and updateLanguageServiceSourceFile and this is another reason why we avoid this approach for our project.
I would like to here feedback about this approach or suggest a cleaner alternative.

@amannn
Copy link
Member Author

amannn commented Feb 1, 2022

Oh hi @barak007, thanks for chiming in! Are you a user of eslint-config-molindo? I'd also be interested in a way to get the errors from this plugin at build time.

@barak007
Copy link

barak007 commented Feb 1, 2022

I'm not aware of eslint-config-molindo. I wanted to achieve the same goals for our library Stylable. We looked at solutions and typescript-plugin-css-modules was doing the closest to what we want. (We are competing in the same domain)

@amannn
Copy link
Member Author

amannn commented Feb 1, 2022

Oh ok, I was just curious since you commented on this repo! I unfortunately don't have a solution here yet. But if you have any link to follow along on your progress I'd be curious.

@barak007
Copy link

barak007 commented Feb 1, 2022

I got here from the typescript issue and honestly thought this issue is in the Typescript repo 😭😯.

@amannn
Copy link
Member Author

amannn commented Dec 13, 2023

Not integrated with TypeScript, but this also improves DX with CSS Modules without introducing complexity: https://marketplace.visualstudio.com/items?itemName=clinyong.vscode-css-modules

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants