Redwood: Routes that aren't defined should fail at build time

Created on 10 Mar 2020  Â·  8Comments  Â·  Source: redwoodjs/redwood

All 8 comments

OP here. Thank you for creating the issue. I'll explain a bit more...

The moment @mojombo said things are all TS happy, the first thing I did was look for something super super basic that wasn't typesafe at all and this came up immediately. For me, having done webdev for 20+ years, it shows a mentality that I hope you guys can correct very early on so that your project is successful. If you want your 'framework' to really stand out... please make it leaps and bounds above everything else out there. Make it 100% typesafe and write a lot of tests please!

Also... separately digging around and seeing you kind of re-invent wrappers around everything, I can see you unfortunately picked the wrong form library. I dug around for a long time myself and eventually stumbled on React Final Form and it changed everything for me.

While RHF is AWESOME (especially compared with formik) ... it has a fundamental issue, which is that every field has to be registered with a ref property, which, as you found, is a little weird... you have to register everything. Yuck

On the other hand, React Final Form is a lot cleaner (IMHO!). I ended up building a library that integrates Material UI and RFF, which is kind of similar to your 'wrapper' library, except it includes all the fun form components already! ;-)

Oh and one other tip... take a look at this router... it will save you a lot of time and energy.

Anyway, keep up the great work... you're obviously on a roll here!

@mojombo looping you in here to take a look at references and links above.

@lookfirst testing as a first-class Redwood citizen is next up on our roadmap. In-progress issue here if you have time to add you thoughts — they’d be very much welcome! #181

@lookfirst - if your comment doesn't relate to typed route config, mind moving it to new issue?

@damassi If you would like to do that, you're more than welcome! This isn't my project, I was just trying to give some constructive help. Cheers.

I've moved the comment regarding RFF to a new issue as suggested. There wasn't much reasoning to go along with the navi router suggestion, so I didn't create a new issue for it, but please feel free to do so.

For type-safe router please see my proposal

Play Framework (Java/Scala) has typesafe routing and fails on routes that aren't defined at build time. It's been a number of years since I've used it, but what I remember is that it worked fairly well on a single module, but where things got a little more complicated was routing across modules. You had to make sure that the routes were compiled in a build step before the other modules referenced them. This meant you had to extract routes out into a separate module once you wanted to share them and compile that module before the others.

I'm not that familiar with routing in React projects, so don't know how applicable this is, but thought it was a learning worth sharing in case there was a better way to do with it via upfront planning.

The other thing I remember that was sometimes frustrating about the Play Framework router was that you would naturally have lots of files that depended on the routes file. At the time, Scala incremental compilation wasn't very advanced and changing this file meant that you had to recompile everything that depended on it, so we were basically always recompiling the world. I'm not sure if this would be an issue with the TypeScript compiler, but more food for thought. It might be worth having one sample project that's a very large project with tons of views, services, etc. to make sure that Redwood is structuring things in a way that will result in acceptable compilation speed.

Was this page helpful?
0 / 5 - 0 ratings