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

feature request(ng g c): add option to include generated component in module exports list #3778

Closed
rxjs-space opened this issue Dec 29, 2016 · 3 comments · Fixed by #3876
Closed
Assignees
Labels
feature Issue that requests a new feature P5 The team acknowledges the request but does not plan to address it, it remains open for discussion

Comments

@rxjs-space
Copy link

Please consider add following feature option when generating a component:
With a option, say --add-to-exports, we can run ng g c parent/shall-be-exported --add-to-exports, and get shallBeExportedComponent in the exports list of parentModule.

@hansl hansl added P5 The team acknowledges the request but does not plan to address it, it remains open for discussion feature Issue that requests a new feature labels Dec 30, 2016
@baruchvlz
Copy link
Contributor

I tried to give this a go but came across this:

blueprints/component/index.js

// ...

    if(options.export) {
      returns.push(
        astUtils.addExportToModule(this.pathToModule, className, importPath)
          .then(change => change.apply(NodeHost)));
    }

ast-utils.ts

export function addExportToModule(modulePath: string, classifiedName: string,
                                  importPath: string): Promise<Change> {
  return _addSymbolToNgModuleMetadata(modulePath, 'exports', classifiedName, importPath);
}

generates:

import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { FormsModule } from '@angular/forms';
import { HttpModule } from '@angular/http';

import { AppComponent } from './app.component';
import { CompTestComponent } from './comp-test/comp-test.component';

@NgModule({
  declarations: [
    AppComponent
  ],
  imports: [
    BrowserModule,
    FormsModule,
    HttpModule
  ],
  providers: [],
  bootstrap: [AppComponent],
  exports: [CompTestComponent]
})
export class AppModule { }

As you can see CompTestComponent is being added to the exports list, but it's not being declared.

@Brocco
Copy link
Contributor

Brocco commented Dec 31, 2016

@baruchvlz thanks for taking a look, I'm about to start implementing this, I will keep you posted.

Brocco added a commit to Brocco/angular-cli that referenced this issue Jan 6, 2017
Brocco added a commit to Brocco/angular-cli that referenced this issue Jan 6, 2017
Brocco added a commit to Brocco/angular-cli that referenced this issue Jan 12, 2017
MRHarrison pushed a commit to MRHarrison/angular-cli that referenced this issue Feb 9, 2017
@angular-automatic-lock-bot
Copy link

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.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Sep 6, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
feature Issue that requests a new feature P5 The team acknowledges the request but does not plan to address it, it remains open for discussion
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants