Skip to content

NG generate lazy loaded module #8717

Closed
Closed

Description

@mbeckenbach

Versions

Angular CLI: 1.5.5
Node: 6.9.5
OS: win32 x64
Angular: 5.0.4

Feature request

Usually all of our feature modules are lazy loaded.
So the developer has to run at least two commands to create a new module to get our default file layout.

ng g m Foo -- routing
ng g c Foo --flat

Then the developer has to add a default route to the new modules routing module as well as the lazy loading route definition to the nearest parent module.

As the syntax and relative paths are allways the same, wouldn't it be possible to add some flags to combine those stepts?

maybe like this:
ng g module Foo --routing --component --lazy
or even simpler
ng g feature Foo (--lazy)

image

image

Activity

  1. added
    P5The team acknowledges the request but does not plan to address it, it remains open for discussion
    featureLabel used to distinguish feature request from other issues
    on Dec 1, 2017
  2. tomastrajan commented on Dec 4, 2017

    @tomastrajan
    Contributor

    This can be prototyped with custom schematics eg: ng generate lazy-feature where lazy-feature will be a new schematic which can start as a part 3rd party collection and when stable enough can be included in main @schematics/angular repo?

  3. mbeckenbach commented on Dec 5, 2017

    @mbeckenbach
    Author

    @tomastrajan
    Sound very interesting. Is there any link to a guide on creating custom shcematics?

  4. tomastrajan commented on Dec 5, 2017

    @tomastrajan
    Contributor

    @mbeckenbach check out this talk from Angular Connect 😉

    I am also interested in creating custom schematics but until something is done about this issue and this PR you would have to include original @schematics/angular in your schematics and delegate calls for everything you are not implementing yourself.

    After the feature is merged it will be possible just to add your own schematics on top of default ones provided by Angular CLI just by adding your own collection in angular-cli.json.

    Cheers!

  5. removed
    P5The team acknowledges the request but does not plan to address it, it remains open for discussion
    on Feb 1, 2018
  6. Robbie106gti commented on Nov 16, 2018

    @Robbie106gti

    They have made it fairly easy to do now, you can just do:
    _

    ng g m lazy --routing

    _

    and add the route to your main router file/const

  7. added this to the Backlog milestone on Jan 24, 2019
  8. doggy8088 commented on Aug 7, 2019

    @doggy8088
    Contributor

    I think this feature has been implemented in v8.1.0.

    fdcd1f7

  9. clydin commented on Aug 7, 2019

    @clydin
    Member

    Closing as indicated above.

  10. angular-automatic-lock-bot commented on Sep 9, 2019

    @angular-automatic-lock-bot

    This issue has been automatically locked due to inactivity.
    Please file a new issue if you are encountering a similar or related problem.

    Read more about our automatic conversation locking policy.

    This action has been performed automatically by a bot.

  11. locked and limited conversation to collaborators on Sep 9, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions