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

Add Yew output compatibility #44

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

SafariMonkey
Copy link

This PR implements Yew as an OutputType, meaning typed-html can be used to build yew-based applications. (Specifically, Yew<T> where T is a yew model.) This may enable yewstack/yew#438.

No examples or documentation yet, as I have been testing on my own prototype (proprietary) yew application, but it seems to work. Would porting a couple of yew examples and covering differences in syntax be sufficient?

I also noticed that typed-html doesn't include pointer events, while yew does. I've commented them out for now, but it seems like they could be added fairly easily.

Feedback would be welcome.

@bodil
Copy link
Owner

bodil commented May 28, 2019

That's very cool - making this work with Yew was actually my original motivation for building typed-html, before I got sidetracked.

The absent event types are probably just due to my not immediately finding the corresponding stdweb types for them, there's no good technical reason they're excluded. If Yew supports them, it's entirely safe to put them back in.

It needs an example of some kind, though, just a hello world so we can verify that the output compiles at a minimum.

@SafariMonkey
Copy link
Author

Thanks for getting to this!

I've been using it since, and I like how it works when everything compiles. Unfortunately, I seem to sometimes be hitting the recursion limit on errors instead of getting nice error messages. I can try to get an example of that behaviour, if you'd like to look into it. I'm honestly a little stumped.

I can also get a hello world example for you, by the weekend or so.

@jstarry
Copy link

jstarry commented Jul 24, 2019

Hey @SafariMonkey it would be great to move this forward! Are you still stuck? Happy to help if I can!

@SafariMonkey
Copy link
Author

Oh shoot, I keep meaning to do this. Work's been busy. Sorry!

I'll put something together ASAP to demo what it's like both when it works and when it doesn't. I wanted to resolve the issues before pushing something out, but I haven't managed that, hence this getting stuck in the pipeline.

Because the error is a compiler recursion limit error, I've found it difficult to diagnose.

I appreciate the reminder, @jstarry. If you do figure out the compiler issues I'll be very grateful.

@bodil
Copy link
Owner

bodil commented Jul 26, 2019

If the issues you're having are just about running into the recursion limit, imo it's perfectly acceptable to increase it, as the compiler should suggest you do when you hit it. It's pretty normal for generated code at typed-html's complexity to hit it a lot - it's not really a problem until you have to increase it to astronomical levels and type checking starts to take minutes to complete.

@SafariMonkey
Copy link
Author

SafariMonkey commented Jul 28, 2019

Unfortunately, that was indeed the case. I had some cases which required 10000 to complete, and many that exceeded even that. I looked into it at the time, but couldn't find any resolution.

When everything is fine it compiles pretty well with a more reasonable limit (IIRC I had it set to 1024, but I think 256 was fine.)

I'm gonna look into this again today. I'll also post an example of when it works and fails so someone else can also look into it if they want.

To be honest, after spending many hours fighting with that issue, I've been half avoiding it. I really want to resolve it, though, so I'll look into it again.

@SafariMonkey
Copy link
Author

Here is a minimally redacted version of our code. It compiles fine, but some compiler errors turn into recursion limit errors. For example, change *x to just x, and instead of a compiler error you'll get a recursion limit error. Remove three of the query_field statements and it goes back to being a compiler error.

I'm not sure which recursion limit is being respected here (IIRC I determined that it was the lib.rs). I also really don't know enough about how to diagnose it. I gather that there's some really deep (maybe even infinite) recursion that happens under these circumstances, or the recursion limit is not being set or is being set incorrectly somewhere.

I'm sorry about not passing this info on sooner. If someone could take a look I'd be very grateful.

@SafariMonkey
Copy link
Author

Has anyone had the opportunity to look into this? I'd love to see this feature moved forward, but I don't have the experience to debug the issues mentioned above.

@SafariMonkey
Copy link
Author

Given that Yew has apparently had a native implementation of proc-macro HTML for a while now (in fact, starting not long after this PR was opened: yewstack/yew#500), is there any reason to leave this open? @jstarry since you posted in here before, and you appear to be the largest contributor to Yew recently, would you mind sharing your thoughts on whether typed-html integration would bring anything to the table at this time? (Obviously it was a pioneering project in that space, but I'm wondering if Yew has reached parity by now.)

I made a go at adding the integration, but had weird issues at the time that I didn't (and maybe still don't) have the experience to debug. If there's still a need for this, I can give it another go (or someone else could), but if it's been superceded, I'm also happy to close it.

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.

None yet

3 participants