[Eg-newdevs] Proposal: new angular components should be standalone

Jane Sandberg sandbergja at gmail.com
Thu Feb 27 09:10:28 EST 2025


Hi Evergreen developers,

I'd like to propose that for any new Angular components we create, we use
the standalone component approach
<https://v17.angular.io/guide/standalone-components>.  In this approach,
you explicitly list the components and angular modules your component
depends on.  This contrasts with the current approach: organizing angular
modules such that each component is within an angular module that supplies
the needed dependencies.  You can see a few standalone component examples
in Open-ILS/src/eg2/src/app/staff/serials
<https://github.com/evergreen-library-system/Evergreen/tree/main/Open-ILS/src/eg2/src/app/staff/serials>
.

Pros:
* I consider the current angular module approach harmful -- you can see the
harm I caused with it in LP2044051
<https://bugs.launchpad.net/evergreen/+bug/2044051>.  There's not a
reliable safety net that will catch you if you don't meticulously trace all
uses of each component and confirm that they are within angular modules
that provide the correct dependencies (either directly, or through the
modules that they depend on, or their dependency's dependencies, and so
on).  You might get a compile-time error, but you might not and -- in
blissful ignorance -- break interfaces completely unrelated to the one that
you were working on.
* Standalone components require less boilerplate code.
* Standalone components are the default in Angular 19, so this could help
us get more prepared for that situation.
* Personally, I have found the explicit list of a component's dependencies
useful, especially when writing component unit tests.

Cons:
* Yet another thing to learn (although tbh, I never totally understood
angular modules anyway hahaha)
* There will be more inconsistency in the different component approaches
within our codebase.
* Listing out dependencies could get repetitive for large, complex
components.
* There may be some legitimate uses for components that are bundled
together in a module (perhaps components that can only ever be used
together?)

FYI: for anybody else who uses the `ng generate component` command, you can
add the `--standalone` flag to create it as a standalone component.

Certainly, if you've already written some new components using angular
modules, I don't want to block you!  But my proposal is that after a
certain date TBD, if you create a new component, please make it standalone.

What do you think?  Very happy to receive questions, counterpoints, etc.!

Thanks!

  -Jane
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://list.evergreen-ils.org/pipermail/eg-newdevs/attachments/20250227/0affb25a/attachment.htm>


More information about the Eg-newdevs mailing list