0

I would like to know is there any way to build specific modules from an application which have multiple modules.

for example, I have module a,b and c in an application but for one of my client required only b and c. I don't want to compile all the modules and remove unwanted chunks looking for a way to compile chunks which only passed as a command or something.

any help highly appreciated.

Sandy Sanap
  • 755
  • 1
  • 5
  • 17
rahul cp
  • 307
  • 1
  • 3
  • 15

2 Answers2

1

You can use the router ability to lazy-load sub-modules in your application.

This will make separate JS chunks of your modules for your application.

Unfortunately, everything will be compiled, because you cannot delete links that easily in imports and such, but your module will not be downloaded nor resolved if your user doesn't go to these modules in your app.

Here is the official documentation link about this :

N.B : In this example, the whole application with the base module is lazy-loaded and this is not a good practice. Only sub-modules that may not be reached are meant to be lazy-loaded.

Alex Beugnet
  • 4,003
  • 4
  • 23
  • 40
  • i am already doing lazy loading so it will download only the desired chunks. but will compile all the modules. i have to remove all unwanted the links and delete the chunk files for different deployment. i want a solution to compile only desired modules – rahul cp May 08 '18 at 10:53
0

Use the following structure.

By using CommonModule instead BrowserModule

import { CommonModule } from '@angular/common';
import { NgModule } from "@angular/core";

import { LastTableComponent } from './last-table.component';

@NgModule({
    imports: [
      CommonModule,          
    ],
    exports:[
      LastTableComponent,
    ],
    declarations: [
      LastTableComponent,
    ],
    providers: [     
    ]

  })
export class LastTableModule { }
Abel Valdez
  • 2,368
  • 1
  • 16
  • 33