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

Using Rendr with RequireJS #155

Open
alexindigo opened this issue Oct 23, 2013 · 7 comments
Open

Using Rendr with RequireJS #155

alexindigo opened this issue Oct 23, 2013 · 7 comments

Comments

@alexindigo
Copy link
Member

Hi Spike,

I'm another person on Trulia's team treading Rendr way for our mobile site.

One of the branches of our exploration is to make our app less monolithic,
which brought us to requirejs as server/client conditional-/lazy- loading for the components.

I created proof-of-concept grunt-rendr-requirejs and had to hack rendr a bit to make it actually work. So it does and look very promising.

Although some of the pieces are still tangled together, and this is where we want to have a conversation with you, to better understand your roadmap.

Basically, I had to wrap some of the rendr modules into amd-define and it works pretty well on the server, save for couple extra lines of boilerplate.

But main thing we've bumped into is routing which wants to have all the controllers on init time and compiledTemplates, which again brings all the templates into single file.

I know you already talked to Jon and he is playing with modules-as-separate-apps, but this route brings us a lot of overhead in terms of shared code (will be great deal later down the road).

So, what is your stand on refactoring routes and template part to allow lazy loading/init so it will work with both stitch and requirejs approach?

I'm cleaning up my hack to make it into somewhat more presentable proof-of-concept.
And would like to hear your opinion on early stages of the process, I'm sure sure you had some thoughts on this direction and probably can point to places I need to pay extra attention to. :)

Thank you.

@spikebrehm
Copy link
Member

Thanks for bringing this up. I would like to support RequireJS, and if there are some modifications we need to make to make that easier then let's do it.

We also are very interested in figuring out how to break up the templates/views/controllers to better support lazy-loading. RequireJS/AMD might be one way of accomplishing this, but also I think if we move to Browserify from Stitch, this will be easier. This is something we want to do anyway.

Specifically re: not expecting controllers to be present at app boot time, we can work around that. Feel free to share your sample code I can take it for a spin.

@alexindigo
Copy link
Member Author

Cool. Thanx.

I'm going to have some ready to show later today.

@alexindigo
Copy link
Member Author

This is first chunk of proposed changes
rendrjs/rendr-handlebars#5

Changes for Rendr are still in progress, but you can see the trend there.

@spikebrehm
Copy link
Member

To echo my comment on that PR, it scares me to have to add this boilerplate to every file in the project. Rather, it would be more forward-thinking to just write ES6 modules and transpile to CommonJS & AMD.

For inspiration: handlebars-lang/handlebars.js#628

@alexindigo
Copy link
Member Author

This change allows to load Rendr in pieces using RequireJS.

@alexindigo
Copy link
Member Author

And another one for rendr-handlebars – rendrjs/rendr-handlebars#7

@alexindigo
Copy link
Member Author

Step 2: #177

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