perf(web): take the form-field defaults off the initial path

app.config.ts provided MAT_FORM_FIELD_DEFAULT_OPTIONS at the root, and that
one import put the whole 54 KB chunk of @angular/material/form-field into
the initial bundle, although every form field renders in a lazy route or a
dialog. The bundler places a module in one chunk, so one eager import of any
export carries the module's entire code.

The defaults now travel with the element: AppFormFieldModule
(@iptvnator/ui/components/form-field) exports MatFormFieldModule together
with a directive that matches mat-form-field and provides the options in
its element injector. That also reaches the dialogs that root services
open, which a route-level provider would miss. Every component that renders
a form field imports it, and tools/nx/check-form-field-defaults.mjs (CI)
rejects one that does not.

renderer.initialBytes: 1,596,201 -> 1,534,606 bytes (-61,595) on a local
production build.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
4grayandClaude Fable 5.1 committed 2026-10-13 09:49:55 +02:00
1 parent 8bf92f9d65
commit 73575ff092
26 files changed
+615 -35

No files matched your search

+6
View File
@@ -430,6 +430,12 @@ jobs:
- name: Validate icon-only button names
run: pnpm run a11y:icon-buttons:validate
# The form-field defaults travel with AppFormFieldModule, not a
# root provider: a component that renders <mat-form-field>
# without it silently gets Material's filled look.
- name: Validate form-field defaults
run: pnpm run styles:form-field-defaults:validate
# Nx rejects a non-parallel task with continuous dependencies, and
# the Playwright plugin infers serve dependencies only when CI is
# unset, so this checks both the local and the CI inference.