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

Provide first class support for splitting code base into modules #6026

Closed
patrickhousley opened this issue Jul 4, 2017 · 4 comments
Closed

Comments

@patrickhousley
Copy link

What problem does this feature solve?

Coming from Angular 2 , one of the feature I really miss is the use of modules to divide my code base into logical units. Technically, I can still do this in Vue by providing the below as a router component:

import Vue from 'vue';
import { routes } from './routes';

export const LazyModule: Vue.ComponentOptions<Vue> = {
  render: r => {
    console.log('rendering');
    return r('router-view');
  },
  created: function() {
    this.$router.addRoutes(routes);
  }
};

This does work but I think it would be more intuitive if there was a clear separation between what a Vue Component and Module are. Specifically, a module would not provide a render method.

What does the proposed API look like?

There has been some good work toward this end here. I have also been testing my previous example of "module" here.

Ultimately, I think we could expect some basic support in Vue and then allow Vue Router and Vuex to extend it.

@nickmessing
Copy link
Member

@patrickhousley, Hello, I have no experience with Angular 2, can you please try to describe what exactly is a module and what is example use-case for that?

@jkzing
Copy link
Member

jkzing commented Jul 4, 2017

IMO, in such framework like Vue/React, the idea is trying to think (almost) everything in Component way. So I prefer to composite components rather than with Module.

@patrickhousley
Copy link
Author

@jkzing After looking at this more, I would agree. I think what I am really looking for could be handled here. Honestly, I really just want a way to cleanly split my app into pieces. The router can do this already but only at the component level. The routes still have to be loaded statically making lazy loading large chunks of an app a little problematic.

@nickmessing
Copy link
Member

nickmessing commented Jul 4, 2017

@patrickhousley, you can take a look at:
Vue Async Components
Vue-router Lazy Loading
Vuex async modules (not merged yet)

All that with ssr and pwa results in a very handy mechanism of code splitting and high performance. I know that's a lot but it gets really easy to use if you get some practice.

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

3 participants