Let's say that in my Angular app I have an NgModule, and I would like to add a bunch of modules to its imports
array. I don't want to import each module individually, but instead gather modules in a group and import the entire group instead. Some of the modules in group are actually useful for that NgModule, other modules are not.
What are possible drawbacks of importing the modules that aren't actually used by that specific modules? Note that each of imported modules is still used somewhere in the application, they just aren't needed in that particular module.
For example, let's consider an index.ts file containing modules for common input components, found at the path @app/common/inputs
:
// whatever imports are necessary
const Modules = [
TextBoxModule,
SelectModule,
DatePickerModule,
// etc.
];
// export individual module types and the Modules array
I have MyWonderfulComponent that uses TextBoxComponent and DatePickerComponent (using TextBoxModule and DatePickerModule, respectively). However, it doesn't use any other input components (including SelectComponent).
Nonetheless, as a lazy software engineer I import all input modules into MyWonderfulModule, because it takes 1 line as opposed to 2 lines importing only TextBoxModule and DatePickerModule:
// some basic imports
import * as Inputs from '@app/common/inputs';
@NgModule({
declarations: [
MyWonderfulComponent
],
imports: [
...Inputs.Modules,
// etc.
],
exports: [
MyWonderfulComponent
]
})
export class MyWonderfulModule {
}
What are the drawbacks of importing unneeded SelectModule (and a bunch of other input modules) alongside the much needed TextBoxModule and DatePickerModule?
Does it have any significant performance or memory hit? Does it result in longer compilation process and/or larger output files? Or maybe the unneeded imports are "just there" and have no significant impact on the app?
(remember - all inputs modules are used somewhere - it's just that MyWonderfulComponent doesn't use anything beside text boxes and date pickers)