RequireJS, Windows 8/WinJS, and Cross Platform
So I have seen a few blog posts talking about RequireJS usage with Windows 8/WinJS, however I had not seen any with working samples or they were "incomplete". I want to take this blog article a step further and provide a fully functioning sample.
Why RequireJS with Windows 8?
Structuring your code for Cross Platform
HTML/CSS - define id's and classes appropriately. You will probably have a unique version of each one per platform
Native Modules - intercepts code as necessary to add in native functionality and wires up handlers to HTML and choses the id's that everything is wired to.
Common Modules - defines the logic that happens when actions are performed during your application. Maybe defines your viewmodels, your business logic, your ajax calls etc.
What about iOS and Android?
Well, I still don't have a perfect answer here yet. I'll have to do some playing around. My first thoughts are create an app that launches a browser to view your web app. At least following the above pattern you can hit windows 8, windows phone, surface, and the web, while allowing access (but not native functionality) to iOS and Android. So not ideal, but maybe one day.
So I hope the sample project is helpful for you. I will continue to develop this code base and put it on all platforms using this basic architecture and idea. I'll post some more stuff as I do so, so please check back to see how it is going. I will field questions and post tips and tricks as I find them and time.