Skip to content

Support a custom TS transformer for final DTS output #73

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

Merged
merged 5 commits into from
Feb 27, 2020

Conversation

joeljeske
Copy link
Contributor

I am a new user of this plugin and I think it is awesome!

Pardon my assumptions in posting a PR before we've discussed it. I wouldn't be offended if you rejected the idea, however, I think it is a nice feature that has merit and could prevent excess feature requests from this plugin in the future.

The idea here is to provide a custom transformation function to allow users to transform the generated DTS before it is handed back to TSServer. This allows the dev to add additional info to the generated DTS, or generate a new set altogether.

This is useful to me as I generate my own set of JS for runtime that does not quite match the standard CSS Module output that is generated from this plugin.

Please let me know if you think this addition has merit and/or if there are changes you would like.

Many thanks for an awesome plugin that solves a real pain point!

@mrmckeb
Copy link
Owner

mrmckeb commented Feb 11, 2020

Hi @joeljeske, thanks for the PR. This is quite interesting - and sorry for the late reply, I was on a business trip.

And thanks for the kind words :)

Basically, this is a post-render hook that allows you to redefine the DTS output. This means that people can add enums, etc.

I'm not opposed to this, although I'd like to think about naming a little more. @lianapache what do you think?

My only concern is that I'm not sure it would have wide usage - but it's also fairly simple, so I don't think supporting it will be a problem.

@joeljeske Do you think it makes more sense to just provide the classnames, rather than the proposed DTS, and let the user completely define the template?

@joeljeske
Copy link
Contributor Author

I think there are a variety of different things people could add, enum is just one of them, and not actually the one I would be using.

My particular use case is generating real react components from the CSS Module JSON. This would be importing react components into a TSX file and use them directly as opposed to using classes.className.

Of course, this is very different from the standard css modules transform, but runs into the same sub-standard coding experience that this plugin solves.

I think that as the CSS in JS landscape is churning right now, that we may continue to see newer solutions arise, and making them Type safe seems like it will always be a challenge. My thought was this would be a non-invasive way to support others crazy ideas without needing to make any big changes.

What do you think?

@mrmckeb
Copy link
Owner

mrmckeb commented Feb 19, 2020

Sorry @joeljeske, I've just pinged @lianapache again for her opinion.

I agree with you that this could be useful for some people - as we'd basically be allowing them to use their own templates.

@lianapache
Copy link
Collaborator

@joeljeske @mrmckeb Sorry for the long response.
I think this feature could be useful 🙂 @mrmckeb Maybe we could release a beta to try it out?

@mrmckeb
Copy link
Owner

mrmckeb commented Feb 26, 2020

OK, great! I'll look at this today or tomorrow, will make a few changes, and release. Thanks @joeljeske and @lianapache

mrmckeb
mrmckeb previously approved these changes Feb 27, 2020
@mrmckeb mrmckeb merged commit eb99666 into mrmckeb:develop Feb 27, 2020
@mrmckeb
Copy link
Owner

mrmckeb commented Feb 28, 2020

Thanks @joeljeske, this is now released at v2.2.0 - sorry it took a while to turn it around.

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

Successfully merging this pull request may close these issues.

3 participants