Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
673 views
in Technique[技术] by (71.8m points)

npm - Read and List all exports of an angular module

The initial situation is as follows: In the node_moduls folder of my project there is a module called @example with some components I want to use in the application. The amount of components varies therefore it′s necessary to state dynamically which components are included inside the module. The example.module.ts file looks like this:

import { NgModule } from '@angular/core';
import { NgbModule } from '@ng-bootstrap/ng-bootstrap';
import { FirstModule } from 'EXAMPLE_PATH';
import { SecondModule } from 'EXAMPLE_PATH';
import { ThirdModule } from 'EXAMPLE_PATH';
import { FourthModule } from 'EXAMPLE_PATH';


const MODULES = [
  FirstModule,
  SecondModule,
  ThirdModule,
  FourthModule 
];

@NgModule({
  imports: [NgbModule.forRoot(), ...MODULES],
  exports: [NgbModule, ...MODULES],
  providers: [ExampleService]
})
export class ExampleModule {
}

The MODULES array contains all the components which are included. As usually the module gets imported into the app with following app.module.ts

import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { ExampleModule } from '@example/example-module';

import { AppComponent } from './app.component';

@NgModule({
  declarations: [
    AppComponent
  ],
  imports: [
    BrowserModule,
    ExampleModule
  ],
  providers: [],
  bootstrap: [AppComponent]
})
export class AppModule { 
}

Is it possible somehow to determine inside the app which components the exampleModule exports or rather the app imports from this module?
So at the End in this example the app should know that FirstModule, SecondModule, ThirdModule and FourthModule are imported and could be used.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...