SD Tidbits
Published in

SD Tidbits

Entry Components

Angular

Photo by Pixabay from Pexels

As of Angular 9, entry components are deprecated — but still supported*. This includes the entryComponents array in an NgModule.

Why do we care?

Entry components are the components that an Angular app loads imperatively by type — not referenced in a template. Those referenced in a template are loaded declaratively by type.

Pre-Ivy, these components would be specified by:

  • bootstrapping them in NgModules using the bootstrap property
  • including them in route definitions (if applicable)
  • declaring them explicitly in the entryComponents array in NgModules

Bootstrapped components are loaded into the DOM during the bootstrap process — app initialization.

Route definition components are those included in route definitions. They are also loaded imperatively by type. All route components must be entry components.

Angular automatically added bootstrap components and route definition components as entry components

However, if an app bootstrapped or loaded a component dynamically and imperatively by type, you had to add it to the entryComponents array explicitly. For example, a lazy loaded component that was not being referenced in a template.

Why are entry components so important anyway?

Performance — to attain a smaller Angular app bundle size in production, the compiler would only generate code for the special components that were reachable from the entryComponents array.

*you might still need them for Angular libraries.

--

--

--

Brief writings on some nifty Software Development practices, how-tos, and tools. (Background: Photo by Nothing Ahead from Pexels)

Recommended from Medium

Maximum Subarray Sum in JavaScript

Set up NodeJs Express with Typescript

The Birth of React and Reason to learn

Wrangling Redux and TypeScript FSA: A journey through keeping your files organized and…

Previse-HTB-Writeup

Bridging the Gap — The File Upload saga continues…

Serialize Persistent Object and Reverse

How To work webRTC ?

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
B. Chepkorir

B. Chepkorir

Software Engineer | Software Development Enthusiast

More from Medium

Reactive Forms in Angular

Unit Testing in Angular

How to add unique username or email validator in angular forms?

Lazy Loading in Angular Js