angular / router

The Angular 1 Component Router
MIT License
665 stars 135 forks source link

Lazy loading design direction #162

Open brianfeister opened 9 years ago

brianfeister commented 9 years ago

Hey @btford! I tweeted you about this and thought you might like to have it documented here.

In this video you mention newRouter lazy loading. I have this seed project using systemjs. I'm hoping that I'll get to play along with the very early alpha development of Angular 2 + newRouter because I have a release date some time around Jan 2016.

My main question is about the scope of your plans for lazy-loading components with newRouter. Right now, this project uses a routeBundler helper that wires all of the lazy-loaded dependency injection via systemjs. I know this is super early, but will I be able to do this with newRouter? If so, I would probably spend less time on the systemjs workflow automation with the hope of discarding it in favor of newRouter's dependency injection.

PatrickJS commented 9 years ago

that's a nice set up

jeffwhelpley commented 9 years ago

@brianfeister thanks for putting together the seed project. Does it assume you are not packaging your resources (i.e. they remain as individual files on the server)?

If so, I would also want to be able to define packages of modules that can be lazy loaded. For example, somehow you define that x, y and z are packaged as part of foo and then do import {x, y, z} from 'foo'.

brianfeister commented 9 years ago

The project includes an NPM dependency https://github.com/Swimlane/systemjs-route-bundler, which allows you to bundle routes from routes.jons and systemjs does the rest. The project has a bit of weirdness which I'm trying to iron out, feel free to PR any fixes you end up making. It works, but it's not quite "clean" yet.

jeffwhelpley commented 9 years ago

I am still looking through all the router issues and found this one talks about the potential ability to do what I am thinking with 1.5: https://github.com/angular/router/issues/22#issuecomment-73576038

brianfeister commented 9 years ago

This is relevant as well: https://twitter.com/briantford/status/574984205404401664

btford commented 9 years ago

will I be able to do this with newRouter?

Yes, I have similar goals. I plan to keep the routing system static enough that you can figure this information out statically so your code loader knows how to put your app together.

More on this soon!

csbenjamin commented 9 years ago

+1